Skip to content

Commit

Permalink
Merge pull request #526 from LIT-Protocol/feature/lit-3139-identify-p…
Browse files Browse the repository at this point in the history
…rivate-methods-in-litnodeclient-fix-tslib-3

fix(tslib): standarised to use private _ over # to prevent:
  • Loading branch information
Ansonhkg committed Jul 10, 2024
2 parents 5042d1a + 7ef841f commit f67160c
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 33 deletions.
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
10 changes: 5 additions & 5 deletions packages/core/src/lib/lit-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ export class LitCore {

this._epochUpdateTimeout = setTimeout(async () => {
try {
this.currentEpochNumber = await this.fetchCurrentEpochNumber();
this.currentEpochNumber = await this._fetchCurrentEpochNumber();
} catch (e) {
// Don't let errors here bubble up to be unhandle rejections in the runtime!
logError('Error while attempting to fetch current epoch number');
Expand Down Expand Up @@ -534,7 +534,7 @@ export class LitCore {
// Already scheduled update for current epoch number (due to a recent epoch change)
// Skip setting it right now, because we haven't waited long enough for nodes to propagate the new epoch
if (!this._epochUpdateTimeout) {
this.currentEpochNumber = await this.fetchCurrentEpochNumber();
this.currentEpochNumber = await this._fetchCurrentEpochNumber();
}

// -- handshake with each node. Note that if we've previously initialized successfully, but this call fails,
Expand Down Expand Up @@ -566,7 +566,7 @@ export class LitCore {
}
}

private async handshakeAndVerifyNodeAttestation({
private async _handshakeAndVerifyNodeAttestation({
url,
requestId,
}: {
Expand Down Expand Up @@ -701,7 +701,7 @@ export class LitCore {
}),
Promise.all(
this.config.bootstrapUrls.map(async (url) => {
serverKeys[url] = await this.handshakeAndVerifyNodeAttestation({
serverKeys[url] = await this._handshakeAndVerifyNodeAttestation({
url,
requestId,
});
Expand Down Expand Up @@ -888,7 +888,7 @@ export class LitCore {
});
};

private async fetchCurrentEpochNumber() {
private async _fetchCurrentEpochNumber() {
if (!this._stakingContract) {
return throwError({
message:
Expand Down
4 changes: 2 additions & 2 deletions packages/lit-auth-client/src/lib/providers/DiscordProvider.ts
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
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ export class LitNodeClientNodeJs
return walletSig!;
};

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

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

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

// ========== Assemble identity parameter ==========
const identityParam = this.#getIdentityParamForEncryption(
const identityParam = this._getIdentityParamForEncryption(
hashOfConditionsStr,
dataToEncryptHash
);
Expand Down Expand Up @@ -1613,7 +1613,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 @@ -1660,7 +1660,7 @@ export class LitNodeClientNodeJs
);
};

#getIdentityParamForEncryption = (
private _getIdentityParamForEncryption = (
hashOfConditionsStr: string,
hashOfPrivateDataStr: string
): string => {
Expand Down Expand Up @@ -1804,7 +1804,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 @@ -1947,7 +1947,7 @@ export class LitNodeClientNodeJs
return signSessionKeyRes;
};

#isSuccessNodePromises = <T>(
private _isSuccessNodePromises = <T>(
res: SuccessNodePromises<T> | RejectedNodePromises
): res is SuccessNodePromises<T> => {
return res.success;
Expand Down Expand Up @@ -2061,7 +2061,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
13 changes: 9 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
# yarn lockfile v1


"@aashutoshrathi/word-wrap@^1.2.3":
version "1.2.6"
resolved "https://registry.yarnpkg.com/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz#bd9154aec9983f77b3a034ecaa015c2e4201f6cf"
integrity sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==

"@ampproject/remapping@^2.2.0":
version "2.3.0"
resolved "https://registry.yarnpkg.com/@ampproject/remapping/-/remapping-2.3.0.tgz#ed441b6fa600072520ce18b43d2c8cc8caecc7f4"
Expand Down Expand Up @@ -3153,7 +3158,7 @@
hey-listen "^1.0.8"
tslib "^2.3.1"

"@motionone/easing@^10.18.0":
"@motionone/easing@^10.17.0", "@motionone/easing@^10.18.0":
version "10.18.0"
resolved "https://registry.yarnpkg.com/@motionone/easing/-/easing-10.18.0.tgz#7b82f6010dfee3a1bb0ee83abfbaff6edae0c708"
integrity sha512-VcjByo7XpdLS4o9T8t99JtgxkdMcNWD3yHU/n6CLEz3bkmKDRZyYQ/wmSf6daum8ZXqfUAgFeCZSpJZIMxaCzg==
Expand All @@ -3178,12 +3183,12 @@
"@motionone/dom" "^10.16.4"
tslib "^2.3.1"

"@motionone/types@^10.15.1", "@motionone/types@^10.17.1":
"@motionone/types@^10.15.1", "@motionone/types@^10.17.0", "@motionone/types@^10.17.1":
version "10.17.1"
resolved "https://registry.yarnpkg.com/@motionone/types/-/types-10.17.1.tgz#cf487badbbdc9da0c2cb86ffc1e5d11147c6e6fb"
integrity sha512-KaC4kgiODDz8hswCrS0btrVrzyU2CSQKO7Ps90ibBVSQmjkrt2teqta6/sOG59v7+dPnKMAg13jyqtMKV2yJ7A==

"@motionone/utils@^10.15.1", "@motionone/utils@^10.18.0":
"@motionone/utils@^10.15.1", "@motionone/utils@^10.17.0", "@motionone/utils@^10.18.0":
version "10.18.0"
resolved "https://registry.yarnpkg.com/@motionone/utils/-/utils-10.18.0.tgz#a59ff8932ed9009624bca07c56b28ef2bb2f885e"
integrity sha512-3XVF7sgyTSI2KWvTf6uLlBJ5iAgRgmvp3bpuOiQJvInd4nZ19ET8lX5unn30SlmRH7hXbBbH+Gxd0m0klJ3Xtw==
Expand Down Expand Up @@ -8023,7 +8028,7 @@ braces@^2.3.1, braces@^2.3.2:
split-string "^3.0.2"
to-regex "^3.0.1"

braces@^3.0.3, braces@~3.0.2:
braces@^3.0.2, braces@^3.0.3, braces@~3.0.2:
version "3.0.3"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789"
integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==
Expand Down

0 comments on commit f67160c

Please sign in to comment.