Skip to content

Commit 83316d7

Browse files
committed
chore: consolidate siwe uri prefixes
1 parent eaa14b7 commit 83316d7

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

packages/auth-helpers/src/lib/siwe/create-siwe-message.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { SiweMessage } from 'siwe';
22

3-
import { LIT_ABILITY } from '@lit-protocol/constants';
43
import {
54
BaseSiweMessage,
65
CapacityDelegationFields,

packages/constants/src/lib/constants/constants.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,12 +1217,6 @@ export const AUTH_METHOD_TYPE_IDS = {
12171217
GOOGLE_JWT: 6,
12181218
};
12191219

1220-
// ========== PKP Client ==========
1221-
export const PKP_CLIENT_SUPPORTED_CHAINS = ['eth', 'cosmos'];
1222-
1223-
// ========== RLI Delegation ==========
1224-
export const SIWE_DELEGATION_URI = 'lit:capability:delegation';
1225-
12261220
// ========== Chains ==========
12271221
export const VMTYPE = {
12281222
EVM: 'EVM',
@@ -1391,3 +1385,12 @@ export const FALLBACK_IPFS_GATEWAYS = [
13911385
'https://flk-ipfs.io/ipfs/',
13921386
'https://litprotocol.mypinata.cloud/ipfs/',
13931387
];
1388+
1389+
export const SIWE_URI_PREFIX = {
1390+
SESSION_KEY: 'lit:session:',
1391+
DELEGATION: 'lit:capability:delegation',
1392+
} as const;
1393+
1394+
export type SIWE_URI_PREFIX_TYPE = keyof typeof SIWE_URI_PREFIX;
1395+
export type SIWE_URI_PREFIX_VALUES =
1396+
(typeof SIWE_URI_PREFIX)[keyof typeof SIWE_URI_PREFIX];

packages/lit-node-client-nodejs/src/lib/lit-node-client-nodejs.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
ParamNullError,
3030
ParamsMissingError,
3131
PRODUCT_IDS,
32+
SIWE_URI_PREFIX,
3233
UnknownError,
3334
UnsupportedMethodError,
3435
WalletSignatureNotFoundError,
@@ -196,7 +197,7 @@ export class LitNodeClientNodeJs extends LitCore implements ILitNodeClient {
196197
}
197198

198199
const siweMessage = await createSiweMessageWithCapacityDelegation({
199-
uri: 'lit:capability:delegation',
200+
uri: SIWE_URI_PREFIX.DELEGATION,
200201
litNodeClient: this,
201202
walletAddress: dAppOwnerWalletAddress,
202203
nonce: await this.getLatestBlockhash(),
@@ -224,7 +225,7 @@ export class LitNodeClientNodeJs extends LitCore implements ILitNodeClient {
224225
* if not, generates one.
225226
* @return { SessionKeyPair } session key pair
226227
*/
227-
getSessionKey = (): SessionKeyPair => {
228+
private _getSessionKey = (): SessionKeyPair => {
228229
const storageKey = LOCAL_STORAGE_KEYS.SESSION_KEY;
229230
const storedSessionKeyOrError = getStorageItem(storageKey);
230231

@@ -279,7 +280,6 @@ export class LitNodeClientNodeJs extends LitCore implements ILitNodeClient {
279280
return sessionCapabilityObject;
280281
}
281282

282-
// backward compatibility
283283
async generateSessionCapabilityObjectWithWildcards(
284284
litResources: ILitResource[]
285285
): Promise<ISessionCapabilityObject> {
@@ -1319,8 +1319,8 @@ export class LitNodeClientNodeJs extends LitCore implements ILitNodeClient {
13191319

13201320
// Try to get it from local storage, if not generates one~
13211321
const sessionKey: SessionKeyPair =
1322-
params.sessionKey ?? this.getSessionKey();
1323-
const sessionKeyUri = this.getSessionKeyUri(sessionKey.publicKey);
1322+
params.sessionKey ?? this._getSessionKey();
1323+
const sessionKeyUri = this._getSessionKeyUri(sessionKey.publicKey);
13241324

13251325
log(
13261326
`[signSessionKey] sessionKeyUri is not found in params, generating a new one`,
@@ -1637,9 +1637,9 @@ export class LitNodeClientNodeJs extends LitCore implements ILitNodeClient {
16371637
): Promise<SessionSigsMap> => {
16381638
// -- prepare
16391639
// Try to get it from local storage, if not generates one~
1640-
const sessionKey = params.sessionKey ?? this.getSessionKey();
1640+
const sessionKey = params.sessionKey ?? this._getSessionKey();
16411641

1642-
const sessionKeyUri = this.getSessionKeyUri(sessionKey.publicKey);
1642+
const sessionKeyUri = this._getSessionKeyUri(sessionKey.publicKey);
16431643

16441644
// First get or generate the session capability object for the specified resources.
16451645
const sessionCapabilityObject = params.sessionCapabilityObject
@@ -1917,8 +1917,8 @@ export class LitNodeClientNodeJs extends LitCore implements ILitNodeClient {
19171917
* @param publicKey is the public key of the session key
19181918
* @returns { string } the session key uri
19191919
*/
1920-
getSessionKeyUri = (publicKey: string): string => {
1921-
return 'lit:session:' + publicKey;
1920+
private _getSessionKeyUri = (publicKey: string): string => {
1921+
return SIWE_URI_PREFIX.SESSION_KEY + publicKey;
19221922
};
19231923

19241924
/**

0 commit comments

Comments
 (0)