Skip to content

fix(tslib): standarised to use private _ over # to prevent: #495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import { sanitizeSiweMessage } from '../siwe/siwe-helper';
import { AuthSig } from '../models';

export class RecapSessionCapabilityObject implements ISessionCapabilityObject {
#inner: Recap;
private _inner: Recap;

constructor(
att: AttenuationsObject = {},
prf: Array<CIDString> | Array<string> = []
) {
this.#inner = new Recap(att, prf);
this._inner = new Recap(att, prf);
}

/**
Expand All @@ -46,19 +46,19 @@ export class RecapSessionCapabilityObject implements ISessionCapabilityObject {
}

get attenuations(): AttenuationsObject {
return this.#inner.attenuations;
return this._inner.attenuations;
}

get proofs(): Array<CIDString> {
return this.#inner.proofs.map((cid: any) => cid.toString());
return this._inner.proofs.map((cid: any) => cid.toString());
}

get statement(): string {
return sanitizeSiweMessage(this.#inner.statement);
return sanitizeSiweMessage(this._inner.statement);
}

addProof(proof: string): void {
return this.#inner.addProof(proof);
return this._inner.addProof(proof);
}

addAttenuation(
Expand All @@ -67,15 +67,15 @@ export class RecapSessionCapabilityObject implements ISessionCapabilityObject {
name: string = '*',
restriction: { [key: string]: PlainJSON } = {}
) {
return this.#inner.addAttenuation(resource, namespace, name, restriction);
return this._inner.addAttenuation(resource, namespace, name, restriction);
}

addToSiweMessage(siwe: SiweMessage): SiweMessage {
return this.#inner.add_to_siwe_message(siwe);
return this._inner.add_to_siwe_message(siwe);
}

encodeAsSiweResource(): string {
return this.#inner.encode();
return this._inner.encode();
}

/** LIT specific methods */
Expand Down Expand Up @@ -129,7 +129,7 @@ export class RecapSessionCapabilityObject implements ISessionCapabilityObject {

// Find an attenuated resource key to match against.
const attenuatedResourceKey =
this.#getResourceKeyToMatchAgainst(litResource);
this._getResourceKeyToMatchAgainst(litResource);

if (!attenuations[attenuatedResourceKey]) {
// No attenuations specified for this resource.
Expand Down Expand Up @@ -171,7 +171,7 @@ export class RecapSessionCapabilityObject implements ISessionCapabilityObject {
*
* Then, if the provided litResource is 'lit-acc://123', the method will return 'lit-acc://*'.
*/
#getResourceKeyToMatchAgainst(litResource: ILitResource): string {
private _getResourceKeyToMatchAgainst(litResource: ILitResource): string {
const attenuatedResourceKeysToMatchAgainst: string[] = [
`${litResource.resourcePrefix}://*`,
litResource.getResourceKey(),
Expand Down
18 changes: 9 additions & 9 deletions packages/core/src/lib/lit-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export class LitCore {
}

// -- set bootstrapUrls to match the network litNetwork unless it's set to custom
this.setCustomBootstrapUrls();
this._setCustomBootstrapUrls();

// -- set global variables
globalThis.litConfig = this.config;
Expand Down Expand Up @@ -442,7 +442,7 @@ export class LitCore {
*
* @returns {Promise<void>} A promise that resolves when the listener is successfully set up.
*/
private _listenForNewEpoch() {
private _listenForNewEpoch(): void {
// Check if we've already set up the listener to avoid duplicates
if (this._stakingContractListener) {
// Already listening, do nothing
Expand Down Expand Up @@ -496,7 +496,7 @@ export class LitCore {
* @returns { void }
*
*/
setCustomBootstrapUrls = (): void => {
private _setCustomBootstrapUrls = (): void => {
// -- validate
if (this.config.litNetwork === 'custom') return;

Expand Down Expand Up @@ -617,7 +617,7 @@ export class LitCore {
}): Promise<JsonHandshakeResponse> {
const challenge = this.getRandomHexString(64);

const handshakeResult = await this.handshakeWithNode(
const handshakeResult = await this._handshakeWithNode(
{ url, challenge },
requestId
);
Expand Down Expand Up @@ -707,7 +707,7 @@ export class LitCore {
coreNodeConfig: CoreNodeConfig;
}> {
// -- handshake with each node
const requestId: string = this.getRequestId();
const requestId: string = this._getRequestId();

// track connectedNodes for the new handshake operation
const connectedNodes = new Set<string>();
Expand Down Expand Up @@ -880,7 +880,7 @@ export class LitCore {
* @returns { string }
*
*/
getRequestId() {
private _getRequestId(): string {
return Math.random().toString(16).slice(2);
}

Expand All @@ -905,7 +905,7 @@ export class LitCore {
* @returns { Promise<NodeCommandServerKeysResponse> }
*
*/
handshakeWithNode = async (
private _handshakeWithNode = async (
params: HandshakeWithNode,
requestId: string
): Promise<NodeCommandServerKeysResponse> => {
Expand All @@ -927,7 +927,7 @@ export class LitCore {
challenge: params.challenge,
};

return await this.sendCommandToNode({
return await this._sendCommandToNode({
url: urlWithPath,
data,
requestId,
Expand Down Expand Up @@ -985,7 +985,7 @@ export class LitCore {
* @returns { Promise<any> }
*
*/
sendCommandToNode = async ({
protected _sendCommandToNode = async ({
url,
data,
requestId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export default class DiscordProvider extends BaseProvider {
* @returns {Promise<string>} - Auth method id
*/
public async getAuthMethodId(authMethod: AuthMethod): Promise<string> {
const userId = await this.#fetchDiscordUser(authMethod.accessToken);
const userId = await this._fetchDiscordUser(authMethod.accessToken);
const authMethodId = ethers.utils.keccak256(
ethers.utils.toUtf8Bytes(`${userId}:${this.clientId}`)
);
Expand Down Expand Up @@ -207,7 +207,7 @@ export default class DiscordProvider extends BaseProvider {
*
* @returns {Promise<string>} - Discord user ID
*/
async #fetchDiscordUser(accessToken: string): Promise<string> {
private async _fetchDiscordUser(accessToken: string): Promise<string> {
const meResponse = await fetch('https://discord.com/api/users/@me', {
method: 'GET',
headers: {
Expand Down
28 changes: 16 additions & 12 deletions packages/lit-node-client-nodejs/src/lib/lit-node-client-nodejs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ import type {
EncryptionSignRequest,
SigningAccessControlConditionRequest,
JsonPKPClaimKeyRequest,
HandshakeWithNode,
NodeCommandServerKeysResponse,
} from '@lit-protocol/types';

import * as blsSdk from '@lit-protocol/bls-sdk';
Expand Down Expand Up @@ -448,7 +450,7 @@ export class LitNodeClientNodeJs
return walletSig!;
};

#authCallbackAndUpdateStorageItem = async ({
private _authCallbackAndUpdateStorageItem = async ({
authCallbackParams,
authCallback,
}: {
Expand Down Expand Up @@ -614,7 +616,7 @@ export class LitNodeClientNodeJs
return finalJwt;
};

#decryptWithSignatureShares = (
private _decryptWithSignatureShares = (
networkPubKey: string,
identityParam: Uint8Array,
ciphertext: string,
Expand Down Expand Up @@ -761,7 +763,7 @@ export class LitNodeClientNodeJs

// this return { url: string, data: JsonRequest }
// const singleNodePromise = this.getJsExecutionShares(url, reqBody, id);
const singleNodePromise = this.sendCommandToNode({
const singleNodePromise = this._sendCommandToNode({
url: url,
data: params,
requestId: id,
Expand Down Expand Up @@ -1150,7 +1152,7 @@ export class LitNodeClientNodeJs
params: any,
requestId: string
): Promise<NodeCommandResponse> => {
return await this.sendCommandToNode({
return await this._sendCommandToNode({
url,
data: params,
requestId,
Expand Down Expand Up @@ -1505,7 +1507,7 @@ export class LitNodeClientNodeJs
);

// ========== Assemble identity parameter ==========
const identityParam = this.#getIdentityParamForEncryption(
const identityParam = this._getIdentityParamForEncryption(
hashOfConditionsStr,
hashOfPrivateDataStr
);
Expand Down Expand Up @@ -1599,7 +1601,7 @@ export class LitNodeClientNodeJs
}

// ========== Assemble identity parameter ==========
const identityParam = this.#getIdentityParamForEncryption(
const identityParam = this._getIdentityParamForEncryption(
hashOfConditionsStr,
dataToEncryptHash
);
Expand Down Expand Up @@ -1675,7 +1677,7 @@ export class LitNodeClientNodeJs
logWithRequestId(requestId, 'signatureShares', signatureShares);

// ========== Result ==========
const decryptedData = this.#decryptWithSignatureShares(
const decryptedData = this._decryptWithSignatureShares(
this.subnetPubKey,
uint8arrayFromString(identityParam, 'utf8'),
ciphertext,
Expand Down Expand Up @@ -1722,7 +1724,7 @@ export class LitNodeClientNodeJs
);
};

#getIdentityParamForEncryption = (
private _getIdentityParamForEncryption = (
hashOfConditionsStr: string,
hashOfPrivateDataStr: string
): string => {
Expand Down Expand Up @@ -1883,7 +1885,7 @@ export class LitNodeClientNodeJs
logWithRequestId(requestId, 'handleNodePromises res:', res);

// -- case: promises rejected
if (!this.#isSuccessNodePromises(res)) {
if (!this._isSuccessNodePromises(res)) {
this._throwNodeError(res as RejectedNodePromises, requestId);
return {} as SignSessionKeyResponse;
}
Expand Down Expand Up @@ -2027,7 +2029,9 @@ export class LitNodeClientNodeJs
return signSessionKeyRes;
};

#isSuccessNodePromises = <T>(res: any): res is SuccessNodePromises<T> => {
private _isSuccessNodePromises = <T>(
res: any
): res is SuccessNodePromises<T> => {
return res.success === true;
};

Expand All @@ -2041,7 +2045,7 @@ export class LitNodeClientNodeJs
url,
endpoint: LIT_ENDPOINT.SIGN_SESSION_KEY,
});
return await this.sendCommandToNode({
return await this._sendCommandToNode({
url: urlWithPath,
data: params.body,
requestId,
Expand Down Expand Up @@ -2139,7 +2143,7 @@ const resourceAbilityRequests = [
// -- (CHECK) if we need to resign the session key
if (needToResignSessionKey) {
log('need to re-sign session key. Signing...');
authSig = await this.#authCallbackAndUpdateStorageItem({
authSig = await this._authCallbackAndUpdateStorageItem({
authCallback: params.authNeededCallback,
authCallbackParams: {
chain: params.chain || 'ethereum',
Expand Down
4 changes: 2 additions & 2 deletions packages/lit-node-client/src/lib/lit-node-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class LitNodeClient extends LitNodeClientNodeJs {
});

// -- override configs
this.overrideConfigsFromLocalStorage();
this._overrideConfigsFromLocalStorage();
}

/**
Expand All @@ -36,7 +36,7 @@ export class LitNodeClient extends LitNodeClientNodeJs {
* @returns { void }
*
*/
overrideConfigsFromLocalStorage = (): void => {
private _overrideConfigsFromLocalStorage = (): void => {
if (isNode()) return;

const storageKey = 'LitNodeClientConfig';
Expand Down
35 changes: 0 additions & 35 deletions packages/types/src/lib/ILitNodeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,6 @@ export interface ILitNodeClient {

// ========== Scoped Class Helpers ==========

/**
*
* Set bootstrapUrls to match the network litNetwork unless it's set to custom
*
* @returns { void }
*
*/
setCustomBootstrapUrls(): void;

/**
*
* we need to send jwt params iat (issued at) and exp (expiration) because the nodes may have different wall clock times, the nodes will verify that these params are withing a grace period
Expand Down Expand Up @@ -144,32 +135,6 @@ export interface ILitNodeClient {
*/
getSignature(shareData: any[], requestId: string): Promise<any>;

// ========== API Calls to Nodes ==========
sendCommandToNode({ url, data, requestId }: SendNodeCommand): Promise<any>;

/**
*
* Get JS Execution Shares from Nodes
*
* @param { JsonExecutionRequest } params
*
* @returns { Promise<any> }
*/

/**
*
* Handshake with SGX
*
* @param { HandshakeWithNode } params
*
* @returns { Promise<NodeCommandServerKeysResponse> }
*
*/
handshakeWithNode(
params: HandshakeWithNode,
requestId: string
): Promise<NodeCommandServerKeysResponse>;

// ========== Scoped Business Logics ==========
/**
*
Expand Down
Loading
Loading