@metamask/profile-sync-controller 28.3.0 → 30.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -1
- package/LICENSE +1 -0
- package/dist/controllers/authentication/AuthenticationController-method-action-types.cjs.map +1 -1
- package/dist/controllers/authentication/AuthenticationController-method-action-types.d.cts.map +1 -1
- package/dist/controllers/authentication/AuthenticationController-method-action-types.d.mts.map +1 -1
- package/dist/controllers/authentication/AuthenticationController-method-action-types.mjs.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.cjs +236 -75
- package/dist/controllers/authentication/AuthenticationController.cjs.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.d.cts +22 -3
- package/dist/controllers/authentication/AuthenticationController.d.cts.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.d.mts +22 -3
- package/dist/controllers/authentication/AuthenticationController.d.mts.map +1 -1
- package/dist/controllers/authentication/AuthenticationController.mjs +231 -70
- package/dist/controllers/authentication/AuthenticationController.mjs.map +1 -1
- package/dist/controllers/authentication/index.cjs +3 -3
- package/dist/controllers/authentication/index.cjs.map +1 -1
- package/dist/controllers/authentication/index.d.cts.map +1 -1
- package/dist/controllers/authentication/index.d.mts.map +1 -1
- package/dist/controllers/authentication/index.mjs.map +1 -1
- package/dist/controllers/authentication/mocks/index.cjs.map +1 -1
- package/dist/controllers/authentication/mocks/index.d.cts.map +1 -1
- package/dist/controllers/authentication/mocks/index.d.mts.map +1 -1
- package/dist/controllers/authentication/mocks/index.mjs.map +1 -1
- package/dist/controllers/authentication/mocks/mockResponses.cjs +26 -15
- package/dist/controllers/authentication/mocks/mockResponses.cjs.map +1 -1
- package/dist/controllers/authentication/mocks/mockResponses.d.cts +11 -0
- package/dist/controllers/authentication/mocks/mockResponses.d.cts.map +1 -1
- package/dist/controllers/authentication/mocks/mockResponses.d.mts +11 -0
- package/dist/controllers/authentication/mocks/mockResponses.d.mts.map +1 -1
- package/dist/controllers/authentication/mocks/mockResponses.mjs +13 -3
- package/dist/controllers/authentication/mocks/mockResponses.mjs.map +1 -1
- package/dist/controllers/index.cjs.map +1 -1
- package/dist/controllers/index.d.cts.map +1 -1
- package/dist/controllers/index.d.mts.map +1 -1
- package/dist/controllers/index.mjs.map +1 -1
- package/dist/controllers/user-storage/UserStorageController-method-action-types.cjs.map +1 -1
- package/dist/controllers/user-storage/UserStorageController-method-action-types.d.cts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController-method-action-types.d.mts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController-method-action-types.mjs.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.cjs +35 -36
- package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.cts +2 -3
- package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.d.mts +2 -3
- package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -1
- package/dist/controllers/user-storage/UserStorageController.mjs +22 -23
- package/dist/controllers/user-storage/UserStorageController.mjs.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/controller-integration.cjs +23 -23
- package/dist/controllers/user-storage/contact-syncing/controller-integration.cjs.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/controller-integration.d.cts.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/controller-integration.d.mts.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/controller-integration.mjs.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.cjs +9 -9
- package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.cjs.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.cts.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.mts.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.mjs.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/sync-utils.cjs.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/sync-utils.d.cts.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/sync-utils.d.mts.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/sync-utils.mjs.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/types.cjs.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/types.d.cts.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/types.d.mts.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/types.mjs.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/utils.cjs +2 -2
- package/dist/controllers/user-storage/contact-syncing/utils.cjs.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/utils.d.cts.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/utils.d.mts.map +1 -1
- package/dist/controllers/user-storage/contact-syncing/utils.mjs.map +1 -1
- package/dist/controllers/user-storage/index.cjs +3 -3
- package/dist/controllers/user-storage/index.cjs.map +1 -1
- package/dist/controllers/user-storage/index.d.cts.map +1 -1
- package/dist/controllers/user-storage/index.d.mts.map +1 -1
- package/dist/controllers/user-storage/index.mjs.map +1 -1
- package/dist/controllers/user-storage/mocks/index.cjs.map +1 -1
- package/dist/controllers/user-storage/mocks/index.d.cts.map +1 -1
- package/dist/controllers/user-storage/mocks/index.d.mts.map +1 -1
- package/dist/controllers/user-storage/mocks/index.mjs.map +1 -1
- package/dist/controllers/user-storage/mocks/mockResponses.cjs +15 -15
- package/dist/controllers/user-storage/mocks/mockResponses.cjs.map +1 -1
- package/dist/controllers/user-storage/mocks/mockResponses.d.cts.map +1 -1
- package/dist/controllers/user-storage/mocks/mockResponses.d.mts.map +1 -1
- package/dist/controllers/user-storage/mocks/mockResponses.mjs.map +1 -1
- package/dist/controllers/user-storage/mocks/mockStorage.cjs +3 -3
- package/dist/controllers/user-storage/mocks/mockStorage.cjs.map +1 -1
- package/dist/controllers/user-storage/mocks/mockStorage.d.cts.map +1 -1
- package/dist/controllers/user-storage/mocks/mockStorage.d.mts.map +1 -1
- package/dist/controllers/user-storage/mocks/mockStorage.mjs.map +1 -1
- package/dist/controllers/user-storage/types.cjs.map +1 -1
- package/dist/controllers/user-storage/types.d.cts.map +1 -1
- package/dist/controllers/user-storage/types.d.mts.map +1 -1
- package/dist/controllers/user-storage/types.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs +11 -11
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.cts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.mts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs +40 -26
- package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts +12 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts +12 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs +20 -6
- package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.cjs +85 -39
- package/dist/sdk/authentication-jwt-bearer/services.cjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.d.cts +19 -2
- package/dist/sdk/authentication-jwt-bearer/services.d.cts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.d.mts +19 -2
- package/dist/sdk/authentication-jwt-bearer/services.d.mts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/services.mjs +46 -2
- package/dist/sdk/authentication-jwt-bearer/services.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/types.cjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/types.d.cts +36 -0
- package/dist/sdk/authentication-jwt-bearer/types.d.cts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/types.d.mts +36 -0
- package/dist/sdk/authentication-jwt-bearer/types.d.mts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/types.mjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/utils/identifier.cjs +2 -2
- package/dist/sdk/authentication-jwt-bearer/utils/identifier.cjs.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.cts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.mts.map +1 -1
- package/dist/sdk/authentication-jwt-bearer/utils/identifier.mjs.map +1 -1
- package/dist/sdk/authentication.cjs +25 -21
- package/dist/sdk/authentication.cjs.map +1 -1
- package/dist/sdk/authentication.d.cts +2 -1
- package/dist/sdk/authentication.d.cts.map +1 -1
- package/dist/sdk/authentication.d.mts +2 -1
- package/dist/sdk/authentication.d.mts.map +1 -1
- package/dist/sdk/authentication.mjs +4 -0
- package/dist/sdk/authentication.mjs.map +1 -1
- package/dist/sdk/constants.cjs +1 -0
- package/dist/sdk/constants.cjs.map +1 -1
- package/dist/sdk/constants.d.cts +1 -0
- package/dist/sdk/constants.d.cts.map +1 -1
- package/dist/sdk/constants.d.mts +1 -0
- package/dist/sdk/constants.d.mts.map +1 -1
- package/dist/sdk/constants.mjs +1 -0
- package/dist/sdk/constants.mjs.map +1 -1
- package/dist/sdk/errors.cjs +17 -4
- package/dist/sdk/errors.cjs.map +1 -1
- package/dist/sdk/errors.d.cts +9 -0
- package/dist/sdk/errors.d.cts.map +1 -1
- package/dist/sdk/errors.d.mts +9 -0
- package/dist/sdk/errors.d.mts.map +1 -1
- package/dist/sdk/errors.mjs +12 -0
- package/dist/sdk/errors.mjs.map +1 -1
- package/dist/sdk/index.cjs.map +1 -1
- package/dist/sdk/index.d.cts.map +1 -1
- package/dist/sdk/index.d.mts.map +1 -1
- package/dist/sdk/index.mjs.map +1 -1
- package/dist/sdk/mocks/auth.cjs +24 -13
- package/dist/sdk/mocks/auth.cjs.map +1 -1
- package/dist/sdk/mocks/auth.d.cts +11 -0
- package/dist/sdk/mocks/auth.d.cts.map +1 -1
- package/dist/sdk/mocks/auth.d.mts +11 -0
- package/dist/sdk/mocks/auth.d.mts.map +1 -1
- package/dist/sdk/mocks/auth.mjs +12 -1
- package/dist/sdk/mocks/auth.mjs.map +1 -1
- package/dist/sdk/mocks/userstorage.cjs +8 -8
- package/dist/sdk/mocks/userstorage.cjs.map +1 -1
- package/dist/sdk/mocks/userstorage.mjs.map +1 -1
- package/dist/sdk/user-storage.cjs +32 -32
- package/dist/sdk/user-storage.cjs.map +1 -1
- package/dist/sdk/user-storage.d.cts.map +1 -1
- package/dist/sdk/user-storage.d.mts.map +1 -1
- package/dist/sdk/user-storage.mjs +1 -1
- package/dist/sdk/user-storage.mjs.map +1 -1
- package/dist/sdk/utils/validate-login-response.cjs.map +1 -1
- package/dist/sdk/utils/validate-login-response.d.cts.map +1 -1
- package/dist/sdk/utils/validate-login-response.d.mts.map +1 -1
- package/dist/sdk/utils/validate-login-response.mjs.map +1 -1
- package/dist/shared/encryption/cache.cjs +6 -6
- package/dist/shared/encryption/cache.cjs.map +1 -1
- package/dist/shared/encryption/cache.mjs.map +1 -1
- package/dist/shared/encryption/encryption.cjs +26 -26
- package/dist/shared/encryption/encryption.cjs.map +1 -1
- package/dist/shared/encryption/encryption.d.cts.map +1 -1
- package/dist/shared/encryption/encryption.d.mts.map +1 -1
- package/dist/shared/encryption/encryption.mjs.map +1 -1
- package/dist/shared/encryption/index.cjs +3 -3
- package/dist/shared/encryption/index.cjs.map +1 -1
- package/dist/shared/encryption/index.d.cts.map +1 -1
- package/dist/shared/encryption/index.d.mts.map +1 -1
- package/dist/shared/encryption/index.mjs.map +1 -1
- package/dist/shared/storage-schema.cjs +2 -2
- package/dist/shared/storage-schema.cjs.map +1 -1
- package/dist/shared/storage-schema.mjs.map +1 -1
- package/dist/shared/types/services.cjs.map +1 -1
- package/dist/shared/types/services.d.cts.map +1 -1
- package/dist/shared/types/services.d.mts.map +1 -1
- package/dist/shared/types/services.mjs.map +1 -1
- package/dist/shared/utils/entropy-source.cjs +37 -0
- package/dist/shared/utils/entropy-source.cjs.map +1 -0
- package/dist/shared/utils/entropy-source.d.cts +22 -0
- package/dist/shared/utils/entropy-source.d.cts.map +1 -0
- package/dist/shared/utils/entropy-source.d.mts +22 -0
- package/dist/shared/utils/entropy-source.d.mts.map +1 -0
- package/dist/shared/utils/entropy-source.mjs +32 -0
- package/dist/shared/utils/entropy-source.mjs.map +1 -0
- package/dist/shared/utils/hd-keyring-seed.cjs +49 -0
- package/dist/shared/utils/hd-keyring-seed.cjs.map +1 -0
- package/dist/shared/utils/hd-keyring-seed.d.cts +27 -0
- package/dist/shared/utils/hd-keyring-seed.d.cts.map +1 -0
- package/dist/shared/utils/hd-keyring-seed.d.mts +27 -0
- package/dist/shared/utils/hd-keyring-seed.d.mts.map +1 -0
- package/dist/shared/utils/hd-keyring-seed.mjs +45 -0
- package/dist/shared/utils/hd-keyring-seed.mjs.map +1 -0
- package/dist/shared/utils/message-signing.cjs +147 -0
- package/dist/shared/utils/message-signing.cjs.map +1 -0
- package/dist/shared/utils/message-signing.d.cts +73 -0
- package/dist/shared/utils/message-signing.d.cts.map +1 -0
- package/dist/shared/utils/message-signing.d.mts +73 -0
- package/dist/shared/utils/message-signing.d.mts.map +1 -0
- package/dist/shared/utils/message-signing.mjs +140 -0
- package/dist/shared/utils/message-signing.mjs.map +1 -0
- package/package.json +17 -14
- package/dist/controllers/authentication/auth-snap-requests.cjs +0 -60
- package/dist/controllers/authentication/auth-snap-requests.cjs.map +0 -1
- package/dist/controllers/authentication/auth-snap-requests.d.cts +0 -27
- package/dist/controllers/authentication/auth-snap-requests.d.cts.map +0 -1
- package/dist/controllers/authentication/auth-snap-requests.d.mts +0 -27
- package/dist/controllers/authentication/auth-snap-requests.d.mts.map +0 -1
- package/dist/controllers/authentication/auth-snap-requests.mjs +0 -54
- package/dist/controllers/authentication/auth-snap-requests.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockResponses.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/mocks/mockResponses.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"mockResponses.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/mocks/mockResponses.ts"],"names":[],"mappings":";;;AAAA,qDAAwD;AAKxD,0EAG2C;AAK3C,sDAI0B;AAQnB,MAAM,0BAA0B,GAAG,CACxC,IAEyC,EACzC,EAAE;IACF,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjC,OAAO,GAAG,IAAA,qBAAU,EAAC,cAAG,CAAC,GAAG,CAAC,CAAC,iBAAiB,uBAAuB,IAAI,EAAE,CAAC;IAC/E,CAAC;IAED,OAAO,GAAG,IAAA,qBAAU,EAAC,cAAG,CAAC,GAAG,CAAC,CAAC,iBAAiB,uBAAuB,IAAA,mCAAe,EACnF,IAA+C,EAC/C,iCAAgB,CACjB,EAAE,CAAC;AACN,CAAC,CAAC;AAbW,QAAA,0BAA0B,8BAarC;AAEF;;;;;GAKG;AACI,KAAK,UAAU,4BAA4B,CAChD,IAAa;IAEb,OAAO;QACL,SAAS,EAAE,YAAY;QACvB,IAAI,EAAE,MAAM,IAAA,4CAA2B,EAAC,IAAI,CAAC;KAC9C,CAAC;AACJ,CAAC;AAPD,oEAOC;AAED;;;;;GAKG;AACI,KAAK,UAAU,mCAAmC,CACvD,UAAoB,CAAC,kCAAiB,CAAC;IAEvC,MAAM,aAAa,GAAG,EAAE,CAAC;IAEzB,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;QAC3B,aAAa,CAAC,IAAI,CAAC;YACjB,SAAS,EAAE,YAAY;YAC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L,GAAG,EAAE,IAAA,kCAA0B,EAAC,IAAI,CAAC;QACrC,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC;AARW,QAAA,qCAAqC,yCAQhD;AAEK,MAAM,6BAA6B,GAAG,CAC3C,OAAgD,GAAG,8CAA0B,CAAC,aAAa,wBAAwB,EACnH,EAAE;IACF,OAAO;QACL,GAAG,EAAE,IAAA,kCAA0B,EAAC,IAAI,CAAC;QACrC,aAAa,EAAE,QAAQ;QACvB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC;AARW,QAAA,6BAA6B,iCAQxC;AAEK,MAAM,8CAA8C,GAAG,CAC5D,OAA8C,8CAA0B,CAAC,aAAa,EACtF,EAAE;IACF,OAAO;QACL,GAAG,EAAE,IAAA,kCAA0B,EAAC,IAAI,CAAC;QACrC,aAAa,EAAE,QAAQ;QACvB,QAAQ,EAAE,IAAI;KACQ,CAAC;AAC3B,CAAC,CAAC;AARW,QAAA,8CAA8C,kDAQzD","sourcesContent":["import { Env, getEnvUrls } from '../../../sdk/index.js';\nimport type {\n UserStorageGenericPathWithFeatureAndKey,\n UserStorageGenericPathWithFeatureOnly,\n} from '../../../shared/storage-schema.js';\nimport {\n createEntryPath,\n USER_STORAGE_FEATURE_NAMES,\n} from '../../../shared/storage-schema.js';\nimport type {\n GetUserStorageAllFeatureEntriesResponse,\n GetUserStorageResponse,\n} from '../types.js';\nimport {\n MOCK_ENCRYPTED_STORAGE_DATA,\n MOCK_STORAGE_DATA,\n MOCK_STORAGE_KEY,\n} from './mockStorage.js';\n\ntype MockResponse = {\n url: string;\n requestMethod: 'GET' | 'POST' | 'PUT' | 'DELETE';\n response: unknown;\n};\n\nexport const getMockUserStorageEndpoint = (\n path:\n | UserStorageGenericPathWithFeatureAndKey\n | UserStorageGenericPathWithFeatureOnly,\n) => {\n if (path.split('.').length === 1) {\n return `${getEnvUrls(Env.PRD).userStorageApiUrl}/api/v1/userstorage/${path}`;\n }\n\n return `${getEnvUrls(Env.PRD).userStorageApiUrl}/api/v1/userstorage/${createEntryPath(\n path as UserStorageGenericPathWithFeatureAndKey,\n MOCK_STORAGE_KEY,\n )}`;\n};\n\n/**\n * Creates a mock GET user-storage response\n *\n * @param data - data to encrypt\n * @returns a realistic GET Response Body\n */\nexport async function createMockGetStorageResponse(\n data?: string,\n): Promise<GetUserStorageResponse> {\n return {\n HashedKey: 'HASHED_KEY',\n Data: await MOCK_ENCRYPTED_STORAGE_DATA(data),\n };\n}\n\n/**\n * Creates a mock GET ALL user-storage response\n *\n * @param dataArr - array of data to encrypt\n * @returns a realistic GET ALL Response Body\n */\nexport async function createMockAllFeatureEntriesResponse(\n dataArr: string[] = [MOCK_STORAGE_DATA],\n): Promise<GetUserStorageAllFeatureEntriesResponse> {\n const decryptedData = [];\n\n for (const data of dataArr) {\n decryptedData.push({\n HashedKey: 'HASHED_KEY',\n Data: await MOCK_ENCRYPTED_STORAGE_DATA(data),\n });\n }\n\n return decryptedData;\n}\n\n/**\n * Creates a mock user-storage api GET request\n *\n * @param path - path of the GET Url\n * @returns mock GET API request. Can be used by e2e or unit mock servers\n */\nexport async function getMockUserStorageGetResponse(\n path: UserStorageGenericPathWithFeatureAndKey = `${USER_STORAGE_FEATURE_NAMES.notifications}.notification_settings`,\n) {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'GET',\n response: await createMockGetStorageResponse(),\n } satisfies MockResponse;\n}\n\n/**\n * Creates a mock user-storage api GET ALL request\n *\n * @param path - path of the GET url\n * @param dataArr - data to encrypt\n * @returns mock GET ALL API request. Can be used by e2e or unit mock servers\n */\nexport async function getMockUserStorageAllFeatureEntriesResponse(\n path: UserStorageGenericPathWithFeatureOnly = USER_STORAGE_FEATURE_NAMES.notifications,\n dataArr?: string[],\n) {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'GET',\n response: await createMockAllFeatureEntriesResponse(dataArr),\n } satisfies MockResponse;\n}\n\nexport const getMockUserStoragePutResponse = (\n path: UserStorageGenericPathWithFeatureAndKey = `${USER_STORAGE_FEATURE_NAMES.notifications}.notification_settings`,\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'PUT',\n response: null,\n } satisfies MockResponse;\n};\n\nexport const getMockUserStorageBatchPutResponse = (\n path: UserStorageGenericPathWithFeatureOnly = USER_STORAGE_FEATURE_NAMES.notifications,\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'PUT',\n response: null,\n } satisfies MockResponse;\n};\n\nexport const getMockUserStorageBatchDeleteResponse = (\n path: UserStorageGenericPathWithFeatureOnly = USER_STORAGE_FEATURE_NAMES.notifications,\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'PUT',\n response: null,\n } satisfies MockResponse;\n};\n\nexport const deleteMockUserStorageResponse = (\n path: UserStorageGenericPathWithFeatureAndKey = `${USER_STORAGE_FEATURE_NAMES.notifications}.notification_settings`,\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'DELETE',\n response: null,\n } satisfies MockResponse;\n};\n\nexport const deleteMockUserStorageAllFeatureEntriesResponse = (\n path: UserStorageGenericPathWithFeatureOnly = USER_STORAGE_FEATURE_NAMES.notifications,\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'DELETE',\n response: null,\n } satisfies MockResponse;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockResponses.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/mocks/mockResponses.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,uCAAuC,EACvC,qCAAqC,EACtC,
|
|
1
|
+
{"version":3,"file":"mockResponses.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/mocks/mockResponses.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,uCAAuC,EACvC,qCAAqC,EACtC,2CAA0C;AAK3C,OAAO,KAAK,EACV,uCAAuC,EACvC,sBAAsB,EACvB,qBAAoB;AAarB,eAAO,MAAM,0BAA0B,SAEjC,uCAAuC,GACvC,qCAAqC,WAU1C,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,4BAA4B,CAChD,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,sBAAsB,CAAC,CAKjC;AAED;;;;;GAKG;AACH,wBAAsB,mCAAmC,CACvD,OAAO,GAAE,MAAM,EAAwB,GACtC,OAAO,CAAC,uCAAuC,CAAC,CAWlD;AAED;;;;;GAKG;AACH,wBAAsB,6BAA6B,CACjD,IAAI,GAAE,uCAA6G;;;;GAOpH;AAED;;;;;;GAMG;AACH,wBAAsB,2CAA2C,CAC/D,IAAI,GAAE,qCAAgF,EACtF,OAAO,CAAC,EAAE,MAAM,EAAE;;;;GAOnB;AAED,eAAO,MAAM,6BAA6B,UAClC,uCAAuC;;;;CAO9C,CAAC;AAEF,eAAO,MAAM,kCAAkC,UACvC,qCAAqC;;;;CAO5C,CAAC;AAEF,eAAO,MAAM,qCAAqC,UAC1C,qCAAqC;;;;CAO5C,CAAC;AAEF,eAAO,MAAM,6BAA6B,UAClC,uCAAuC;;;;CAO9C,CAAC;AAEF,eAAO,MAAM,8CAA8C,UACnD,qCAAqC;;;;CAO5C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockResponses.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/mocks/mockResponses.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,uCAAuC,EACvC,qCAAqC,EACtC,
|
|
1
|
+
{"version":3,"file":"mockResponses.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/mocks/mockResponses.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,uCAAuC,EACvC,qCAAqC,EACtC,2CAA0C;AAK3C,OAAO,KAAK,EACV,uCAAuC,EACvC,sBAAsB,EACvB,qBAAoB;AAarB,eAAO,MAAM,0BAA0B,SAEjC,uCAAuC,GACvC,qCAAqC,WAU1C,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,4BAA4B,CAChD,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,sBAAsB,CAAC,CAKjC;AAED;;;;;GAKG;AACH,wBAAsB,mCAAmC,CACvD,OAAO,GAAE,MAAM,EAAwB,GACtC,OAAO,CAAC,uCAAuC,CAAC,CAWlD;AAED;;;;;GAKG;AACH,wBAAsB,6BAA6B,CACjD,IAAI,GAAE,uCAA6G;;;;GAOpH;AAED;;;;;;GAMG;AACH,wBAAsB,2CAA2C,CAC/D,IAAI,GAAE,qCAAgF,EACtF,OAAO,CAAC,EAAE,MAAM,EAAE;;;;GAOnB;AAED,eAAO,MAAM,6BAA6B,UAClC,uCAAuC;;;;CAO9C,CAAC;AAEF,eAAO,MAAM,kCAAkC,UACvC,qCAAqC;;;;CAO5C,CAAC;AAEF,eAAO,MAAM,qCAAqC,UAC1C,qCAAqC;;;;CAO5C,CAAC;AAEF,eAAO,MAAM,6BAA6B,UAClC,uCAAuC;;;;CAO9C,CAAC;AAEF,eAAO,MAAM,8CAA8C,UACnD,qCAAqC;;;;CAO5C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockResponses.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/mocks/mockResponses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,+
|
|
1
|
+
{"version":3,"file":"mockResponses.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/mocks/mockResponses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,+BAA8B;AAKxD,OAAO,EACL,eAAe,EACf,0BAA0B,EAC3B,2CAA0C;AAK3C,OAAO,EACL,2BAA2B,EAC3B,iBAAiB,EACjB,gBAAgB,EACjB,0BAAyB;AAQ1B,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,IAEyC,EACzC,EAAE;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,CAAC;AAC3B,CAAC,CAAC","sourcesContent":["import { Env, getEnvUrls } from '../../../sdk/index.js';\nimport type {\n UserStorageGenericPathWithFeatureAndKey,\n UserStorageGenericPathWithFeatureOnly,\n} from '../../../shared/storage-schema.js';\nimport {\n createEntryPath,\n USER_STORAGE_FEATURE_NAMES,\n} from '../../../shared/storage-schema.js';\nimport type {\n GetUserStorageAllFeatureEntriesResponse,\n GetUserStorageResponse,\n} from '../types.js';\nimport {\n MOCK_ENCRYPTED_STORAGE_DATA,\n MOCK_STORAGE_DATA,\n MOCK_STORAGE_KEY,\n} from './mockStorage.js';\n\ntype MockResponse = {\n url: string;\n requestMethod: 'GET' | 'POST' | 'PUT' | 'DELETE';\n response: unknown;\n};\n\nexport const getMockUserStorageEndpoint = (\n path:\n | UserStorageGenericPathWithFeatureAndKey\n | UserStorageGenericPathWithFeatureOnly,\n) => {\n if (path.split('.').length === 1) {\n return `${getEnvUrls(Env.PRD).userStorageApiUrl}/api/v1/userstorage/${path}`;\n }\n\n return `${getEnvUrls(Env.PRD).userStorageApiUrl}/api/v1/userstorage/${createEntryPath(\n path as UserStorageGenericPathWithFeatureAndKey,\n MOCK_STORAGE_KEY,\n )}`;\n};\n\n/**\n * Creates a mock GET user-storage response\n *\n * @param data - data to encrypt\n * @returns a realistic GET Response Body\n */\nexport async function createMockGetStorageResponse(\n data?: string,\n): Promise<GetUserStorageResponse> {\n return {\n HashedKey: 'HASHED_KEY',\n Data: await MOCK_ENCRYPTED_STORAGE_DATA(data),\n };\n}\n\n/**\n * Creates a mock GET ALL user-storage response\n *\n * @param dataArr - array of data to encrypt\n * @returns a realistic GET ALL Response Body\n */\nexport async function createMockAllFeatureEntriesResponse(\n dataArr: string[] = [MOCK_STORAGE_DATA],\n): Promise<GetUserStorageAllFeatureEntriesResponse> {\n const decryptedData = [];\n\n for (const data of dataArr) {\n decryptedData.push({\n HashedKey: 'HASHED_KEY',\n Data: await MOCK_ENCRYPTED_STORAGE_DATA(data),\n });\n }\n\n return decryptedData;\n}\n\n/**\n * Creates a mock user-storage api GET request\n *\n * @param path - path of the GET Url\n * @returns mock GET API request. Can be used by e2e or unit mock servers\n */\nexport async function getMockUserStorageGetResponse(\n path: UserStorageGenericPathWithFeatureAndKey = `${USER_STORAGE_FEATURE_NAMES.notifications}.notification_settings`,\n) {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'GET',\n response: await createMockGetStorageResponse(),\n } satisfies MockResponse;\n}\n\n/**\n * Creates a mock user-storage api GET ALL request\n *\n * @param path - path of the GET url\n * @param dataArr - data to encrypt\n * @returns mock GET ALL API request. Can be used by e2e or unit mock servers\n */\nexport async function getMockUserStorageAllFeatureEntriesResponse(\n path: UserStorageGenericPathWithFeatureOnly = USER_STORAGE_FEATURE_NAMES.notifications,\n dataArr?: string[],\n) {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'GET',\n response: await createMockAllFeatureEntriesResponse(dataArr),\n } satisfies MockResponse;\n}\n\nexport const getMockUserStoragePutResponse = (\n path: UserStorageGenericPathWithFeatureAndKey = `${USER_STORAGE_FEATURE_NAMES.notifications}.notification_settings`,\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'PUT',\n response: null,\n } satisfies MockResponse;\n};\n\nexport const getMockUserStorageBatchPutResponse = (\n path: UserStorageGenericPathWithFeatureOnly = USER_STORAGE_FEATURE_NAMES.notifications,\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'PUT',\n response: null,\n } satisfies MockResponse;\n};\n\nexport const getMockUserStorageBatchDeleteResponse = (\n path: UserStorageGenericPathWithFeatureOnly = USER_STORAGE_FEATURE_NAMES.notifications,\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'PUT',\n response: null,\n } satisfies MockResponse;\n};\n\nexport const deleteMockUserStorageResponse = (\n path: UserStorageGenericPathWithFeatureAndKey = `${USER_STORAGE_FEATURE_NAMES.notifications}.notification_settings`,\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'DELETE',\n response: null,\n } satisfies MockResponse;\n};\n\nexport const deleteMockUserStorageAllFeatureEntriesResponse = (\n path: UserStorageGenericPathWithFeatureOnly = USER_STORAGE_FEATURE_NAMES.notifications,\n) => {\n return {\n url: getMockUserStorageEndpoint(path),\n requestMethod: 'DELETE',\n response: null,\n } satisfies MockResponse;\n};\n"]}
|
|
@@ -24,13 +24,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.MOCK_ENCRYPTED_STORAGE_DATA = exports.MOCK_STORAGE_DATA = exports.MOCK_STORAGE_KEY = exports.MOCK_STORAGE_KEY_SIGNATURE = void 0;
|
|
27
|
-
const
|
|
27
|
+
const index_js_1 = __importStar(require("../../../shared/encryption/index.cjs"));
|
|
28
28
|
exports.MOCK_STORAGE_KEY_SIGNATURE = 'mockStorageKey';
|
|
29
|
-
exports.MOCK_STORAGE_KEY = (0,
|
|
29
|
+
exports.MOCK_STORAGE_KEY = (0, index_js_1.createSHA256Hash)(exports.MOCK_STORAGE_KEY_SIGNATURE);
|
|
30
30
|
exports.MOCK_STORAGE_DATA = JSON.stringify({ hello: 'world' });
|
|
31
31
|
// NOTE - using encryption.encryptString directly in fixtures causes issues on mobile.
|
|
32
32
|
// This is because this fixture is getting added in at run time. Will be improved once we support multiple exports
|
|
33
33
|
let cachedMockEncryptedData;
|
|
34
|
-
const MOCK_ENCRYPTED_STORAGE_DATA = async (data) => (cachedMockEncryptedData ?? (cachedMockEncryptedData = await
|
|
34
|
+
const MOCK_ENCRYPTED_STORAGE_DATA = async (data) => (cachedMockEncryptedData ?? (cachedMockEncryptedData = await index_js_1.default.encryptString(data ?? exports.MOCK_STORAGE_DATA, exports.MOCK_STORAGE_KEY)));
|
|
35
35
|
exports.MOCK_ENCRYPTED_STORAGE_DATA = MOCK_ENCRYPTED_STORAGE_DATA;
|
|
36
36
|
//# sourceMappingURL=mockStorage.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockStorage.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/mocks/mockStorage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"mockStorage.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/mocks/mockStorage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iFAE6C;AAEhC,QAAA,0BAA0B,GAAG,gBAAgB,CAAC;AAC9C,QAAA,gBAAgB,GAAG,IAAA,2BAAgB,EAAC,kCAA0B,CAAC,CAAC;AAChE,QAAA,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;AAEpE,sFAAsF;AACtF,kHAAkH;AAClH,IAAI,uBAA+B,CAAC;AAC7B,MAAM,2BAA2B,GAAG,KAAK,EAAE,IAAa,EAAE,EAAE,CACjE,CAAC,uBAAuB,KAAvB,uBAAuB,GAAK,MAAM,kBAAU,CAAC,aAAa,CACzD,IAAI,IAAI,yBAAiB,EACzB,wBAAgB,CACjB,EAAC,CAAC;AAJQ,QAAA,2BAA2B,+BAInC","sourcesContent":["import encryption, {\n createSHA256Hash,\n} from '../../../shared/encryption/index.js';\n\nexport const MOCK_STORAGE_KEY_SIGNATURE = 'mockStorageKey';\nexport const MOCK_STORAGE_KEY = createSHA256Hash(MOCK_STORAGE_KEY_SIGNATURE);\nexport const MOCK_STORAGE_DATA = JSON.stringify({ hello: 'world' });\n\n// NOTE - using encryption.encryptString directly in fixtures causes issues on mobile.\n// This is because this fixture is getting added in at run time. Will be improved once we support multiple exports\nlet cachedMockEncryptedData: string;\nexport const MOCK_ENCRYPTED_STORAGE_DATA = async (data?: string) =>\n (cachedMockEncryptedData ??= await encryption.encryptString(\n data ?? MOCK_STORAGE_DATA,\n MOCK_STORAGE_KEY,\n ));\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockStorage.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/mocks/mockStorage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mockStorage.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/mocks/mockStorage.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,0BAA0B,mBAAmB,CAAC;AAC3D,eAAO,MAAM,gBAAgB,QAA+C,CAAC;AAC7E,eAAO,MAAM,iBAAiB,QAAqC,CAAC;AAKpE,eAAO,MAAM,2BAA2B,UAAiB,MAAM,oBAI3D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockStorage.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/mocks/mockStorage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mockStorage.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/mocks/mockStorage.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,0BAA0B,mBAAmB,CAAC;AAC3D,eAAO,MAAM,gBAAgB,QAA+C,CAAC;AAC7E,eAAO,MAAM,iBAAiB,QAAqC,CAAC;AAKpE,eAAO,MAAM,2BAA2B,UAAiB,MAAM,oBAI3D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockStorage.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/mocks/mockStorage.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"mockStorage.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/mocks/mockStorage.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,EAAE,EACjB,gBAAgB,EACjB,6CAA4C;AAE7C,MAAM,CAAC,MAAM,0BAA0B,GAAG,gBAAgB,CAAC;AAC3D,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,0BAA0B,CAAC,CAAC;AAC7E,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;AAEpE,sFAAsF;AACtF,kHAAkH;AAClH,IAAI,uBAA+B,CAAC;AACpC,MAAM,CAAC,MAAM,2BAA2B,GAAG,KAAK,EAAE,IAAa,EAAE,EAAE,CACjE,CAAC,uBAAuB,KAAvB,uBAAuB,GAAK,MAAM,UAAU,CAAC,aAAa,CACzD,IAAI,IAAI,iBAAiB,EACzB,gBAAgB,CACjB,EAAC,CAAC","sourcesContent":["import encryption, {\n createSHA256Hash,\n} from '../../../shared/encryption/index.js';\n\nexport const MOCK_STORAGE_KEY_SIGNATURE = 'mockStorageKey';\nexport const MOCK_STORAGE_KEY = createSHA256Hash(MOCK_STORAGE_KEY_SIGNATURE);\nexport const MOCK_STORAGE_DATA = JSON.stringify({ hello: 'world' });\n\n// NOTE - using encryption.encryptString directly in fixtures causes issues on mobile.\n// This is because this fixture is getting added in at run time. Will be improved once we support multiple exports\nlet cachedMockEncryptedData: string;\nexport const MOCK_ENCRYPTED_STORAGE_DATA = async (data?: string) =>\n (cachedMockEncryptedData ??= await encryption.encryptString(\n data ?? MOCK_STORAGE_DATA,\n MOCK_STORAGE_KEY,\n ));\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../../src/controllers/user-storage/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n UserStorageGenericPathWithFeatureAndKey,\n UserStorageGenericPathWithFeatureOnly,\n} from '../../shared/storage-schema';\nimport type { NativeScrypt } from '../../shared/types/encryption';\n\nexport type UserStorageBaseOptions = {\n bearerToken: string;\n storageKey: string;\n nativeScryptCrypto?: NativeScrypt;\n};\n\nexport type UserStorageOptions = UserStorageBaseOptions & {\n path: UserStorageGenericPathWithFeatureAndKey;\n};\n\nexport type UserStorageAllFeatureEntriesOptions = UserStorageBaseOptions & {\n path: UserStorageGenericPathWithFeatureOnly;\n};\n\nexport type UserStorageBatchUpsertOptions = UserStorageAllFeatureEntriesOptions;\n\nexport type GetUserStorageResponse = {\n HashedKey: string;\n Data: string;\n};\n\nexport type GetUserStorageAllFeatureEntriesResponse = {\n HashedKey: string;\n Data: string;\n}[];\n"]}
|
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../../src/controllers/user-storage/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n UserStorageGenericPathWithFeatureAndKey,\n UserStorageGenericPathWithFeatureOnly,\n} from '../../shared/storage-schema.js';\nimport type { NativeScrypt } from '../../shared/types/encryption.js';\n\nexport type UserStorageBaseOptions = {\n bearerToken: string;\n storageKey: string;\n nativeScryptCrypto?: NativeScrypt;\n};\n\nexport type UserStorageOptions = UserStorageBaseOptions & {\n path: UserStorageGenericPathWithFeatureAndKey;\n};\n\nexport type UserStorageAllFeatureEntriesOptions = UserStorageBaseOptions & {\n path: UserStorageGenericPathWithFeatureOnly;\n};\n\nexport type UserStorageBatchUpsertOptions = UserStorageAllFeatureEntriesOptions;\n\nexport type GetUserStorageResponse = {\n HashedKey: string;\n Data: string;\n};\n\nexport type GetUserStorageAllFeatureEntriesResponse = {\n HashedKey: string;\n Data: string;\n}[];\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../../src/controllers/user-storage/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uCAAuC,EACvC,qCAAqC,EACtC,
|
|
1
|
+
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../../src/controllers/user-storage/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uCAAuC,EACvC,qCAAqC,EACtC,wCAAuC;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,0CAAyC;AAErE,MAAM,MAAM,sBAAsB,GAAG;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,YAAY,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,GAAG;IACxD,IAAI,EAAE,uCAAuC,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAAG,sBAAsB,GAAG;IACzE,IAAI,EAAE,qCAAqC,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG,mCAAmC,CAAC;AAEhF,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,uCAAuC,GAAG;IACpD,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../../src/controllers/user-storage/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uCAAuC,EACvC,qCAAqC,EACtC,
|
|
1
|
+
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../../src/controllers/user-storage/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uCAAuC,EACvC,qCAAqC,EACtC,wCAAuC;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,0CAAyC;AAErE,MAAM,MAAM,sBAAsB,GAAG;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,YAAY,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,GAAG;IACxD,IAAI,EAAE,uCAAuC,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAAG,sBAAsB,GAAG;IACzE,IAAI,EAAE,qCAAqC,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG,mCAAmC,CAAC;AAEhF,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,uCAAuC,GAAG;IACpD,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../src/controllers/user-storage/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n UserStorageGenericPathWithFeatureAndKey,\n UserStorageGenericPathWithFeatureOnly,\n} from '../../shared/storage-schema';\nimport type { NativeScrypt } from '../../shared/types/encryption';\n\nexport type UserStorageBaseOptions = {\n bearerToken: string;\n storageKey: string;\n nativeScryptCrypto?: NativeScrypt;\n};\n\nexport type UserStorageOptions = UserStorageBaseOptions & {\n path: UserStorageGenericPathWithFeatureAndKey;\n};\n\nexport type UserStorageAllFeatureEntriesOptions = UserStorageBaseOptions & {\n path: UserStorageGenericPathWithFeatureOnly;\n};\n\nexport type UserStorageBatchUpsertOptions = UserStorageAllFeatureEntriesOptions;\n\nexport type GetUserStorageResponse = {\n HashedKey: string;\n Data: string;\n};\n\nexport type GetUserStorageAllFeatureEntriesResponse = {\n HashedKey: string;\n Data: string;\n}[];\n"]}
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../src/controllers/user-storage/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n UserStorageGenericPathWithFeatureAndKey,\n UserStorageGenericPathWithFeatureOnly,\n} from '../../shared/storage-schema.js';\nimport type { NativeScrypt } from '../../shared/types/encryption.js';\n\nexport type UserStorageBaseOptions = {\n bearerToken: string;\n storageKey: string;\n nativeScryptCrypto?: NativeScrypt;\n};\n\nexport type UserStorageOptions = UserStorageBaseOptions & {\n path: UserStorageGenericPathWithFeatureAndKey;\n};\n\nexport type UserStorageAllFeatureEntriesOptions = UserStorageBaseOptions & {\n path: UserStorageGenericPathWithFeatureOnly;\n};\n\nexport type UserStorageBatchUpsertOptions = UserStorageAllFeatureEntriesOptions;\n\nexport type GetUserStorageResponse = {\n HashedKey: string;\n Data: string;\n};\n\nexport type GetUserStorageAllFeatureEntriesResponse = {\n HashedKey: string;\n Data: string;\n}[];\n"]}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAAsC;AACtC,mGAAkF;AAClF,8FAA6E","sourcesContent":["export * as SDK from './sdk/index.js';\nexport * as AuthenticationController from './controllers/authentication/index.js';\nexport * as UserStorageController from './controllers/user-storage/index.js';\n"]}
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,wBAAuB;AACtC,OAAO,KAAK,wBAAwB,+CAA8C;AAClF,OAAO,KAAK,qBAAqB,6CAA4C"}
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,wBAAuB;AACtC,OAAO,KAAK,wBAAwB,+CAA8C;AAClF,OAAO,KAAK,qBAAqB,6CAA4C"}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,wBAAuB;AACtC,OAAO,KAAK,wBAAwB,+CAA8C;AAClF,OAAO,KAAK,qBAAqB,6CAA4C","sourcesContent":["export * as SDK from './sdk/index.js';\nexport * as AuthenticationController from './controllers/authentication/index.js';\nexport * as UserStorageController from './controllers/user-storage/index.js';\n"]}
|
|
@@ -14,9 +14,9 @@ var _SIWEJwtBearerAuth_instances, _SIWEJwtBearerAuth_config, _SIWEJwtBearerAuth_
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.SIWEJwtBearerAuth = void 0;
|
|
16
16
|
const siwe_1 = require("siwe");
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
17
|
+
const errors_js_1 = require("../errors.cjs");
|
|
18
|
+
const validate_login_response_js_1 = require("../utils/validate-login-response.cjs");
|
|
19
|
+
const services_js_1 = require("./services.cjs");
|
|
20
20
|
class SIWEJwtBearerAuth {
|
|
21
21
|
constructor(config, options) {
|
|
22
22
|
_SIWEJwtBearerAuth_instances.add(this);
|
|
@@ -48,11 +48,11 @@ class SIWEJwtBearerAuth {
|
|
|
48
48
|
}
|
|
49
49
|
async getUserProfileLineage() {
|
|
50
50
|
const accessToken = await this.getAccessToken();
|
|
51
|
-
return await (0,
|
|
51
|
+
return await (0, services_js_1.getUserProfileLineage)(__classPrivateFieldGet(this, _SIWEJwtBearerAuth_config, "f").env, accessToken);
|
|
52
52
|
}
|
|
53
53
|
async getCustomerServiceToken() {
|
|
54
54
|
const accessToken = await this.getAccessToken();
|
|
55
|
-
return await (0,
|
|
55
|
+
return await (0, services_js_1.getCustomerServiceToken)(__classPrivateFieldGet(this, _SIWEJwtBearerAuth_config, "f").env, accessToken);
|
|
56
56
|
}
|
|
57
57
|
async signMessage(message) {
|
|
58
58
|
__classPrivateFieldGet(this, _SIWEJwtBearerAuth_instances, "m", _SIWEJwtBearerAuth_assertSigner).call(this, __classPrivateFieldGet(this, _SIWEJwtBearerAuth_signer, "f"));
|
|
@@ -67,7 +67,7 @@ _SIWEJwtBearerAuth_config = new WeakMap(), _SIWEJwtBearerAuth_options = new Weak
|
|
|
67
67
|
// convert expiresIn from seconds to milliseconds and use 90% of expiresIn
|
|
68
68
|
async function _SIWEJwtBearerAuth_getAuthSession() {
|
|
69
69
|
const auth = await __classPrivateFieldGet(this, _SIWEJwtBearerAuth_options, "f").storage.getLoginResponse();
|
|
70
|
-
if (!(0,
|
|
70
|
+
if (!(0, validate_login_response_js_1.validateLoginResponse)(auth)) {
|
|
71
71
|
return null;
|
|
72
72
|
}
|
|
73
73
|
const currentTime = Date.now();
|
|
@@ -81,13 +81,13 @@ async function _SIWEJwtBearerAuth_getAuthSession() {
|
|
|
81
81
|
__classPrivateFieldGet(this, _SIWEJwtBearerAuth_instances, "m", _SIWEJwtBearerAuth_assertSigner).call(this, __classPrivateFieldGet(this, _SIWEJwtBearerAuth_signer, "f"));
|
|
82
82
|
// Nonce
|
|
83
83
|
const address = await this.getIdentifier();
|
|
84
|
-
const nonceRes = await (0,
|
|
84
|
+
const nonceRes = await (0, services_js_1.getNonce)(address, __classPrivateFieldGet(this, _SIWEJwtBearerAuth_config, "f").env);
|
|
85
85
|
const rawMessage = __classPrivateFieldGet(this, _SIWEJwtBearerAuth_instances, "m", _SIWEJwtBearerAuth_createSiWELoginRawMessage).call(this, nonceRes.nonce);
|
|
86
86
|
const signature = await this.signMessage(rawMessage);
|
|
87
87
|
// Authenticate
|
|
88
|
-
const authResponse = await (0,
|
|
88
|
+
const authResponse = await (0, services_js_1.authenticate)(rawMessage, signature, __classPrivateFieldGet(this, _SIWEJwtBearerAuth_config, "f").type, __classPrivateFieldGet(this, _SIWEJwtBearerAuth_config, "f").env);
|
|
89
89
|
// Authorize
|
|
90
|
-
const tokenResponse = await (0,
|
|
90
|
+
const tokenResponse = await (0, services_js_1.authorizeOIDC)(authResponse.token, __classPrivateFieldGet(this, _SIWEJwtBearerAuth_config, "f").env, __classPrivateFieldGet(this, _SIWEJwtBearerAuth_config, "f").platform);
|
|
91
91
|
// Save
|
|
92
92
|
const result = {
|
|
93
93
|
profile: authResponse.profile,
|
|
@@ -100,7 +100,7 @@ async function _SIWEJwtBearerAuth_getAuthSession() {
|
|
|
100
100
|
return new siwe_1.SiweMessage({
|
|
101
101
|
domain: __classPrivateFieldGet(this, _SIWEJwtBearerAuth_signer, "f")?.domain,
|
|
102
102
|
address: __classPrivateFieldGet(this, _SIWEJwtBearerAuth_signer, "f")?.address,
|
|
103
|
-
uri: (0,
|
|
103
|
+
uri: (0, services_js_1.SIWE_LOGIN_URL)(__classPrivateFieldGet(this, _SIWEJwtBearerAuth_config, "f").env),
|
|
104
104
|
version: '1',
|
|
105
105
|
chainId: __classPrivateFieldGet(this, _SIWEJwtBearerAuth_signer, "f")?.chainId,
|
|
106
106
|
nonce,
|
|
@@ -108,7 +108,7 @@ async function _SIWEJwtBearerAuth_getAuthSession() {
|
|
|
108
108
|
}).prepareMessage();
|
|
109
109
|
}, _SIWEJwtBearerAuth_assertSigner = function _SIWEJwtBearerAuth_assertSigner(signer) {
|
|
110
110
|
if (!signer) {
|
|
111
|
-
throw new
|
|
111
|
+
throw new errors_js_1.ValidationError(`you must call 'prepare()' before logging in`);
|
|
112
112
|
}
|
|
113
113
|
};
|
|
114
114
|
//# sourceMappingURL=flow-siwe.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-siwe.cjs","sourceRoot":"","sources":["../../../src/sdk/authentication-jwt-bearer/flow-siwe.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAAmC;AAEnC,
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BAAc,EAAC,uBAAA,IAAI,iCAAQ,CAAC,GAAG,CAAC;QACrC,OAAO,EAAE,GAAG;QACZ,OAAO,EAAE,uBAAA,IAAI,iCAAQ,EAAE,OAAO;QAC9B,KAAK;QACL,QAAQ,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACnC,CAAC,CAAC,cAAc,EAAE,CAAC;AACtB,CAAC,6EAGC,MAAkC;IAElC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,2BAAe,CAAC,6CAA6C,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC","sourcesContent":["import { SiweMessage } from 'siwe';\n\nimport { ValidationError } from '../errors.js';\nimport { validateLoginResponse } from '../utils/validate-login-response.js';\nimport {\n SIWE_LOGIN_URL,\n authenticate,\n authorizeOIDC,\n getCustomerServiceToken,\n getNonce,\n getUserProfileLineage,\n} from './services.js';\nimport type {\n AuthConfig,\n AuthStorageOptions,\n AuthType,\n IBaseAuth,\n LoginResponse,\n UserProfile,\n UserProfileLineage,\n} from './types.js';\n\ntype JwtBearerAuth_SIWE_Options = {\n storage: AuthStorageOptions;\n};\n\ntype JwtBearerAuth_SIWE_Signer = {\n address: string;\n chainId: number;\n signMessage: (message: string) => Promise<string>;\n domain: string;\n};\n\nexport class SIWEJwtBearerAuth implements IBaseAuth {\n readonly #config: AuthConfig;\n\n readonly #options: JwtBearerAuth_SIWE_Options;\n\n #signer: JwtBearerAuth_SIWE_Signer | undefined;\n\n constructor(\n config: AuthConfig & { type: AuthType.SiWE },\n options: JwtBearerAuth_SIWE_Options,\n ) {\n this.#config = config;\n this.#options = options;\n }\n\n async getAccessToken(): Promise<string> {\n const session = await this.#getAuthSession();\n if (session) {\n return session.token.accessToken;\n }\n\n const loginResponse = await this.#login();\n return loginResponse.token.accessToken;\n }\n\n async getUserProfile(): Promise<UserProfile> {\n const session = await this.#getAuthSession();\n if (session) {\n return session.profile;\n }\n\n const loginResponse = await this.#login();\n return loginResponse.profile;\n }\n\n async getIdentifier(): Promise<string> {\n this.#assertSigner(this.#signer);\n return this.#signer.address;\n }\n\n async getUserProfileLineage(): Promise<UserProfileLineage> {\n const accessToken = await this.getAccessToken();\n return await getUserProfileLineage(this.#config.env, accessToken);\n }\n\n async getCustomerServiceToken(): Promise<string> {\n const accessToken = await this.getAccessToken();\n return await getCustomerServiceToken(this.#config.env, accessToken);\n }\n\n async signMessage(message: string): Promise<string> {\n this.#assertSigner(this.#signer);\n return await this.#signer.signMessage(message);\n }\n\n prepare(signer: JwtBearerAuth_SIWE_Signer) {\n this.#signer = signer;\n }\n\n // convert expiresIn from seconds to milliseconds and use 90% of expiresIn\n async #getAuthSession(): Promise<LoginResponse | null> {\n const auth = await this.#options.storage.getLoginResponse();\n if (!validateLoginResponse(auth)) {\n return null;\n }\n\n const currentTime = Date.now();\n const sessionAge = currentTime - auth.token.obtainedAt;\n const refreshThreshold = auth.token.expiresIn * 1000 * 0.9;\n\n if (sessionAge < refreshThreshold) {\n return auth;\n }\n return null;\n }\n\n async #login(): Promise<LoginResponse> {\n this.#assertSigner(this.#signer);\n\n // Nonce\n const address = await this.getIdentifier();\n const nonceRes = await getNonce(address, this.#config.env);\n const rawMessage = this.#createSiWELoginRawMessage(nonceRes.nonce);\n const signature = await this.signMessage(rawMessage);\n\n // Authenticate\n const authResponse = await authenticate(\n rawMessage,\n signature,\n this.#config.type,\n this.#config.env,\n );\n\n // Authorize\n const tokenResponse = await authorizeOIDC(\n authResponse.token,\n this.#config.env,\n this.#config.platform,\n );\n\n // Save\n const result: LoginResponse = {\n profile: authResponse.profile,\n token: tokenResponse,\n };\n\n await this.#options.storage.setLoginResponse(result);\n\n return result;\n }\n\n #createSiWELoginRawMessage(nonce: string): string {\n this.#assertSigner(this.#signer);\n\n return new SiweMessage({\n domain: this.#signer?.domain,\n address: this.#signer?.address,\n uri: SIWE_LOGIN_URL(this.#config.env),\n version: '1',\n chainId: this.#signer?.chainId,\n nonce,\n issuedAt: new Date().toISOString(),\n }).prepareMessage();\n }\n\n #assertSigner(\n signer?: JwtBearerAuth_SIWE_Signer,\n ): asserts signer is JwtBearerAuth_SIWE_Signer {\n if (!signer) {\n throw new ValidationError(`you must call 'prepare()' before logging in`);\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-siwe.d.cts","sourceRoot":"","sources":["../../../src/sdk/authentication-jwt-bearer/flow-siwe.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,UAAU,EACV,kBAAkB,EAClB,QAAQ,EACR,SAAS,EAET,WAAW,EACX,kBAAkB,EACnB,
|
|
1
|
+
{"version":3,"file":"flow-siwe.d.cts","sourceRoot":"","sources":["../../../src/sdk/authentication-jwt-bearer/flow-siwe.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,UAAU,EACV,kBAAkB,EAClB,QAAQ,EACR,SAAS,EAET,WAAW,EACX,kBAAkB,EACnB,oBAAmB;AAEpB,KAAK,0BAA0B,GAAG;IAChC,OAAO,EAAE,kBAAkB,CAAC;CAC7B,CAAC;AAEF,KAAK,yBAAyB,GAAG;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAClD,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,qBAAa,iBAAkB,YAAW,SAAS;;gBAQ/C,MAAM,EAAE,UAAU,GAAG;QAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAA;KAAE,EAC5C,OAAO,EAAE,0BAA0B;IAM/B,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;IAUjC,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC;IAUtC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAKhC,qBAAqB,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAKpD,uBAAuB,IAAI,OAAO,CAAC,MAAM,CAAC;IAK1C,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAKnD,OAAO,CAAC,MAAM,EAAE,yBAAyB;CA6E1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-siwe.d.mts","sourceRoot":"","sources":["../../../src/sdk/authentication-jwt-bearer/flow-siwe.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,UAAU,EACV,kBAAkB,EAClB,QAAQ,EACR,SAAS,EAET,WAAW,EACX,kBAAkB,EACnB,
|
|
1
|
+
{"version":3,"file":"flow-siwe.d.mts","sourceRoot":"","sources":["../../../src/sdk/authentication-jwt-bearer/flow-siwe.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,UAAU,EACV,kBAAkB,EAClB,QAAQ,EACR,SAAS,EAET,WAAW,EACX,kBAAkB,EACnB,oBAAmB;AAEpB,KAAK,0BAA0B,GAAG;IAChC,OAAO,EAAE,kBAAkB,CAAC;CAC7B,CAAC;AAEF,KAAK,yBAAyB,GAAG;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAClD,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,qBAAa,iBAAkB,YAAW,SAAS;;gBAQ/C,MAAM,EAAE,UAAU,GAAG;QAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAA;KAAE,EAC5C,OAAO,EAAE,0BAA0B;IAM/B,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;IAUjC,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC;IAUtC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAKhC,qBAAqB,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAKpD,uBAAuB,IAAI,OAAO,CAAC,MAAM,CAAC;IAK1C,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAKnD,OAAO,CAAC,MAAM,EAAE,yBAAyB;CA6E1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-siwe.mjs","sourceRoot":"","sources":["../../../src/sdk/authentication-jwt-bearer/flow-siwe.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,aAAa;AAEnC,OAAO,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"flow-siwe.mjs","sourceRoot":"","sources":["../../../src/sdk/authentication-jwt-bearer/flow-siwe.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,aAAa;AAEnC,OAAO,EAAE,eAAe,EAAE,sBAAqB;AAC/C,OAAO,EAAE,qBAAqB,EAAE,6CAA4C;AAC5E,OAAO,EACL,cAAc,EACd,YAAY,EACZ,aAAa,EACb,uBAAuB,EACvB,QAAQ,EACR,qBAAqB,EACtB,uBAAsB;AAsBvB,MAAM,OAAO,iBAAiB;IAO5B,YACE,MAA4C,EAC5C,OAAmC;;QAR5B,4CAAoB;QAEpB,6CAAqC;QAE9C,4CAA+C;QAM7C,uBAAA,IAAI,6BAAW,MAAM,MAAA,CAAC;QACtB,uBAAA,IAAI,8BAAY,OAAO,MAAA,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,cAAc;QAClB,MAAM,OAAO,GAAG,MAAM,uBAAA,IAAI,uEAAgB,MAApB,IAAI,CAAkB,CAAC;QAC7C,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC;QACnC,CAAC;QAED,MAAM,aAAa,GAAG,MAAM,uBAAA,IAAI,8DAAO,MAAX,IAAI,CAAS,CAAC;QAC1C,OAAO,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,cAAc;QAClB,MAAM,OAAO,GAAG,MAA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C7B,KAAK,EAAE,aAAa;KACrB,CAAC;IAEF,MAAM,uBAAA,IAAI,kCAAS,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAErD,OAAO,MAAM,CAAC;AAChB,CAAC,uGAE0B,KAAa;IACtC,uBAAA,IAAI,qEAAc,MAAlB,IAAI,EAAe,uBAAA,IAAI,iCAAQ,CAAC,CAAC;IAEjC,OAAO,IAAI,WAAW,CAAC;QACrB,MAAM,EAAE,uBAAA,IAAI,iCAAQ,EAAE,MAAM;QAC5B,OAAO,EAAE,uBAAA,IAAI,iCAAQ,EAAE,OAAO;QAC9B,GAAG,EAAE,cAAc,CAAC,uBAAA,IAAI,iCAAQ,CAAC,GAAG,CAAC;QACrC,OAAO,EAAE,GAAG;QACZ,OAAO,EAAE,uBAAA,IAAI,iCAAQ,EAAE,OAAO;QAC9B,KAAK;QACL,QAAQ,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACnC,CAAC,CAAC,cAAc,EAAE,CAAC;AACtB,CAAC,6EAGC,MAAkC;IAElC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,eAAe,CAAC,6CAA6C,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC","sourcesContent":["import { SiweMessage } from 'siwe';\n\nimport { ValidationError } from '../errors.js';\nimport { validateLoginResponse } from '../utils/validate-login-response.js';\nimport {\n SIWE_LOGIN_URL,\n authenticate,\n authorizeOIDC,\n getCustomerServiceToken,\n getNonce,\n getUserProfileLineage,\n} from './services.js';\nimport type {\n AuthConfig,\n AuthStorageOptions,\n AuthType,\n IBaseAuth,\n LoginResponse,\n UserProfile,\n UserProfileLineage,\n} from './types.js';\n\ntype JwtBearerAuth_SIWE_Options = {\n storage: AuthStorageOptions;\n};\n\ntype JwtBearerAuth_SIWE_Signer = {\n address: string;\n chainId: number;\n signMessage: (message: string) => Promise<string>;\n domain: string;\n};\n\nexport class SIWEJwtBearerAuth implements IBaseAuth {\n readonly #config: AuthConfig;\n\n readonly #options: JwtBearerAuth_SIWE_Options;\n\n #signer: JwtBearerAuth_SIWE_Signer | undefined;\n\n constructor(\n config: AuthConfig & { type: AuthType.SiWE },\n options: JwtBearerAuth_SIWE_Options,\n ) {\n this.#config = config;\n this.#options = options;\n }\n\n async getAccessToken(): Promise<string> {\n const session = await this.#getAuthSession();\n if (session) {\n return session.token.accessToken;\n }\n\n const loginResponse = await this.#login();\n return loginResponse.token.accessToken;\n }\n\n async getUserProfile(): Promise<UserProfile> {\n const session = await this.#getAuthSession();\n if (session) {\n return session.profile;\n }\n\n const loginResponse = await this.#login();\n return loginResponse.profile;\n }\n\n async getIdentifier(): Promise<string> {\n this.#assertSigner(this.#signer);\n return this.#signer.address;\n }\n\n async getUserProfileLineage(): Promise<UserProfileLineage> {\n const accessToken = await this.getAccessToken();\n return await getUserProfileLineage(this.#config.env, accessToken);\n }\n\n async getCustomerServiceToken(): Promise<string> {\n const accessToken = await this.getAccessToken();\n return await getCustomerServiceToken(this.#config.env, accessToken);\n }\n\n async signMessage(message: string): Promise<string> {\n this.#assertSigner(this.#signer);\n return await this.#signer.signMessage(message);\n }\n\n prepare(signer: JwtBearerAuth_SIWE_Signer) {\n this.#signer = signer;\n }\n\n // convert expiresIn from seconds to milliseconds and use 90% of expiresIn\n async #getAuthSession(): Promise<LoginResponse | null> {\n const auth = await this.#options.storage.getLoginResponse();\n if (!validateLoginResponse(auth)) {\n return null;\n }\n\n const currentTime = Date.now();\n const sessionAge = currentTime - auth.token.obtainedAt;\n const refreshThreshold = auth.token.expiresIn * 1000 * 0.9;\n\n if (sessionAge < refreshThreshold) {\n return auth;\n }\n return null;\n }\n\n async #login(): Promise<LoginResponse> {\n this.#assertSigner(this.#signer);\n\n // Nonce\n const address = await this.getIdentifier();\n const nonceRes = await getNonce(address, this.#config.env);\n const rawMessage = this.#createSiWELoginRawMessage(nonceRes.nonce);\n const signature = await this.signMessage(rawMessage);\n\n // Authenticate\n const authResponse = await authenticate(\n rawMessage,\n signature,\n this.#config.type,\n this.#config.env,\n );\n\n // Authorize\n const tokenResponse = await authorizeOIDC(\n authResponse.token,\n this.#config.env,\n this.#config.platform,\n );\n\n // Save\n const result: LoginResponse = {\n profile: authResponse.profile,\n token: tokenResponse,\n };\n\n await this.#options.storage.setLoginResponse(result);\n\n return result;\n }\n\n #createSiWELoginRawMessage(nonce: string): string {\n this.#assertSigner(this.#signer);\n\n return new SiweMessage({\n domain: this.#signer?.domain,\n address: this.#signer?.address,\n uri: SIWE_LOGIN_URL(this.#config.env),\n version: '1',\n chainId: this.#signer?.chainId,\n nonce,\n issuedAt: new Date().toISOString(),\n }).prepareMessage();\n }\n\n #assertSigner(\n signer?: JwtBearerAuth_SIWE_Signer,\n ): asserts signer is JwtBearerAuth_SIWE_Signer {\n if (!signer) {\n throw new ValidationError(`you must call 'prepare()' before logging in`);\n }\n }\n}\n"]}
|
|
@@ -33,35 +33,35 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
33
33
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
34
34
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
35
35
|
};
|
|
36
|
-
var _SRPJwtBearerAuth_instances, _SRPJwtBearerAuth_config, _SRPJwtBearerAuth_options, _SRPJwtBearerAuth_metametrics, _SRPJwtBearerAuth_ongoingLogins, _SRPJwtBearerAuth_ongoingPairings, _SRPJwtBearerAuth_cooldownDefaultMs, _SRPJwtBearerAuth_maxLoginRetries, _SRPJwtBearerAuth_customProvider, _SRPJwtBearerAuth_getAuthSession, _SRPJwtBearerAuth_login, _SRPJwtBearerAuth_performLogin, _SRPJwtBearerAuth_deferredLogin, _SRPJwtBearerAuth_loginWithRetry, _SRPJwtBearerAuth_createSrpLoginRawMessage;
|
|
36
|
+
var _SRPJwtBearerAuth_instances, _SRPJwtBearerAuth_config, _SRPJwtBearerAuth_options, _SRPJwtBearerAuth_metametrics, _SRPJwtBearerAuth_ongoingLogins, _SRPJwtBearerAuth_ongoingPairings, _SRPJwtBearerAuth_cooldownDefaultMs, _SRPJwtBearerAuth_maxLoginRetries, _SRPJwtBearerAuth_getLoginTag, _SRPJwtBearerAuth_getLoginIdentifierType, _SRPJwtBearerAuth_customProvider, _SRPJwtBearerAuth_getAuthSession, _SRPJwtBearerAuth_login, _SRPJwtBearerAuth_performLogin, _SRPJwtBearerAuth_deferredLogin, _SRPJwtBearerAuth_loginWithRetry, _SRPJwtBearerAuth_createSrpLoginRawMessage;
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.SRPJwtBearerAuth = exports.PAIR_DEDUPE_TTL_MS = void 0;
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const
|
|
39
|
+
const errors_js_1 = require("../errors.cjs");
|
|
40
|
+
const eip_6963_metamask_provider_js_1 = require("../utils/eip-6963-metamask-provider.cjs");
|
|
41
|
+
const messaging_signing_snap_requests_js_1 = require("../utils/messaging-signing-snap-requests.cjs");
|
|
42
|
+
const validate_login_response_js_1 = require("../utils/validate-login-response.cjs");
|
|
43
|
+
const services_js_1 = require("./services.cjs");
|
|
44
|
+
const identifier_js_1 = require("./utils/identifier.cjs");
|
|
45
45
|
const timeUtils = __importStar(require("./utils/time.cjs"));
|
|
46
46
|
// How long a successful pairing result stays cached so identical payloads
|
|
47
47
|
// (concurrent or sequential retries) reuse it instead of re-hitting the endpoint.
|
|
48
48
|
exports.PAIR_DEDUPE_TTL_MS = 30000;
|
|
49
49
|
const getDefaultEIP6963Provider = async () => {
|
|
50
|
-
const provider = await (0,
|
|
50
|
+
const provider = await (0, eip_6963_metamask_provider_js_1.getMetaMaskProviderEIP6963)();
|
|
51
51
|
if (!provider) {
|
|
52
|
-
throw new
|
|
52
|
+
throw new errors_js_1.ValidationError('No MetaMask wallet connected');
|
|
53
53
|
}
|
|
54
54
|
return provider;
|
|
55
55
|
};
|
|
56
56
|
const getDefaultEIP6963SigningOptions = (customProvider) => ({
|
|
57
57
|
getIdentifier: async (entropySourceId) => {
|
|
58
58
|
const provider = customProvider ?? (await getDefaultEIP6963Provider());
|
|
59
|
-
return await
|
|
59
|
+
return await messaging_signing_snap_requests_js_1.MESSAGE_SIGNING_SNAP.getPublicKey(provider, entropySourceId);
|
|
60
60
|
},
|
|
61
61
|
signMessage: async (message, entropySourceId) => {
|
|
62
62
|
const provider = customProvider ?? (await getDefaultEIP6963Provider());
|
|
63
|
-
(0,
|
|
64
|
-
return await
|
|
63
|
+
(0, messaging_signing_snap_requests_js_1.assertMessageStartsWithMetamask)(message);
|
|
64
|
+
return await messaging_signing_snap_requests_js_1.MESSAGE_SIGNING_SNAP.signMessage(provider, message, entropySourceId);
|
|
65
65
|
},
|
|
66
66
|
});
|
|
67
67
|
class SRPJwtBearerAuth {
|
|
@@ -80,9 +80,13 @@ class SRPJwtBearerAuth {
|
|
|
80
80
|
_SRPJwtBearerAuth_cooldownDefaultMs.set(this, void 0);
|
|
81
81
|
// Maximum number of login retries on rate limit errors
|
|
82
82
|
_SRPJwtBearerAuth_maxLoginRetries.set(this, void 0);
|
|
83
|
+
_SRPJwtBearerAuth_getLoginTag.set(this, void 0);
|
|
84
|
+
_SRPJwtBearerAuth_getLoginIdentifierType.set(this, void 0);
|
|
83
85
|
_SRPJwtBearerAuth_customProvider.set(this, void 0);
|
|
84
86
|
__classPrivateFieldSet(this, _SRPJwtBearerAuth_config, config, "f");
|
|
85
87
|
__classPrivateFieldSet(this, _SRPJwtBearerAuth_customProvider, options.customProvider, "f");
|
|
88
|
+
__classPrivateFieldSet(this, _SRPJwtBearerAuth_getLoginTag, options.getLoginTag, "f");
|
|
89
|
+
__classPrivateFieldSet(this, _SRPJwtBearerAuth_getLoginIdentifierType, options.getLoginIdentifierType, "f");
|
|
86
90
|
__classPrivateFieldSet(this, _SRPJwtBearerAuth_options, {
|
|
87
91
|
storage: options.storage,
|
|
88
92
|
signing: options.signing ??
|
|
@@ -119,11 +123,14 @@ class SRPJwtBearerAuth {
|
|
|
119
123
|
}
|
|
120
124
|
async getUserProfileLineage(entropySourceId) {
|
|
121
125
|
const accessToken = await this.getAccessToken(entropySourceId);
|
|
122
|
-
return await (0,
|
|
126
|
+
return await (0, services_js_1.getUserProfileLineage)(__classPrivateFieldGet(this, _SRPJwtBearerAuth_config, "f").env, accessToken);
|
|
123
127
|
}
|
|
124
128
|
async getCustomerServiceToken(entropySourceId) {
|
|
125
129
|
const accessToken = await this.getAccessToken(entropySourceId);
|
|
126
|
-
return await (0,
|
|
130
|
+
return await (0, services_js_1.getCustomerServiceToken)(__classPrivateFieldGet(this, _SRPJwtBearerAuth_config, "f").env, accessToken);
|
|
131
|
+
}
|
|
132
|
+
async pairSocialIdentifier(params, authAccessToken) {
|
|
133
|
+
await (0, services_js_1.pairSocialIdentifier)(params, authAccessToken, __classPrivateFieldGet(this, _SRPJwtBearerAuth_config, "f").env);
|
|
127
134
|
}
|
|
128
135
|
async pairSrpProfiles(accessTokens, authAccessToken) {
|
|
129
136
|
// Order-insensitive key: the same token set in any order maps to the same
|
|
@@ -133,7 +140,7 @@ class SRPJwtBearerAuth {
|
|
|
133
140
|
if (cached && cached.expiresAt > Date.now()) {
|
|
134
141
|
return await cached.promise;
|
|
135
142
|
}
|
|
136
|
-
const promise = (0,
|
|
143
|
+
const promise = (0, services_js_1.pairProfiles)(accessTokens, authAccessToken, __classPrivateFieldGet(this, _SRPJwtBearerAuth_config, "f").env);
|
|
137
144
|
// Store the in-flight promise immediately so concurrent callers coalesce
|
|
138
145
|
// regardless of how long the request takes.
|
|
139
146
|
__classPrivateFieldGet(this, _SRPJwtBearerAuth_ongoingPairings, "f").set(key, {
|
|
@@ -165,21 +172,21 @@ class SRPJwtBearerAuth {
|
|
|
165
172
|
if (!provider) {
|
|
166
173
|
return false;
|
|
167
174
|
}
|
|
168
|
-
const isConnected = await (0,
|
|
175
|
+
const isConnected = await (0, messaging_signing_snap_requests_js_1.isSnapConnected)(provider);
|
|
169
176
|
return isConnected;
|
|
170
177
|
}
|
|
171
178
|
async connectSnap() {
|
|
172
179
|
const provider = __classPrivateFieldGet(this, _SRPJwtBearerAuth_customProvider, "f") ?? (await getDefaultEIP6963Provider());
|
|
173
|
-
const res = await (0,
|
|
180
|
+
const res = await (0, messaging_signing_snap_requests_js_1.connectSnap)(provider);
|
|
174
181
|
return res;
|
|
175
182
|
}
|
|
176
183
|
}
|
|
177
184
|
exports.SRPJwtBearerAuth = SRPJwtBearerAuth;
|
|
178
|
-
_SRPJwtBearerAuth_config = new WeakMap(), _SRPJwtBearerAuth_options = new WeakMap(), _SRPJwtBearerAuth_metametrics = new WeakMap(), _SRPJwtBearerAuth_ongoingLogins = new WeakMap(), _SRPJwtBearerAuth_ongoingPairings = new WeakMap(), _SRPJwtBearerAuth_cooldownDefaultMs = new WeakMap(), _SRPJwtBearerAuth_maxLoginRetries = new WeakMap(), _SRPJwtBearerAuth_customProvider = new WeakMap(), _SRPJwtBearerAuth_instances = new WeakSet(), _SRPJwtBearerAuth_getAuthSession =
|
|
185
|
+
_SRPJwtBearerAuth_config = new WeakMap(), _SRPJwtBearerAuth_options = new WeakMap(), _SRPJwtBearerAuth_metametrics = new WeakMap(), _SRPJwtBearerAuth_ongoingLogins = new WeakMap(), _SRPJwtBearerAuth_ongoingPairings = new WeakMap(), _SRPJwtBearerAuth_cooldownDefaultMs = new WeakMap(), _SRPJwtBearerAuth_maxLoginRetries = new WeakMap(), _SRPJwtBearerAuth_getLoginTag = new WeakMap(), _SRPJwtBearerAuth_getLoginIdentifierType = new WeakMap(), _SRPJwtBearerAuth_customProvider = new WeakMap(), _SRPJwtBearerAuth_instances = new WeakSet(), _SRPJwtBearerAuth_getAuthSession =
|
|
179
186
|
// convert expiresIn from seconds to milliseconds and use 90% of expiresIn
|
|
180
187
|
async function _SRPJwtBearerAuth_getAuthSession(entropySourceId) {
|
|
181
188
|
const auth = await __classPrivateFieldGet(this, _SRPJwtBearerAuth_options, "f").storage.getLoginResponse(entropySourceId);
|
|
182
|
-
if (!(0,
|
|
189
|
+
if (!(0, validate_login_response_js_1.validateLoginResponse)(auth)) {
|
|
183
190
|
return null;
|
|
184
191
|
}
|
|
185
192
|
// get canonical profile id from server if not present in the cached session
|
|
@@ -199,18 +206,22 @@ async function _SRPJwtBearerAuth_getAuthSession(entropySourceId) {
|
|
|
199
206
|
}, _SRPJwtBearerAuth_performLogin = async function _SRPJwtBearerAuth_performLogin(entropySourceId) {
|
|
200
207
|
// Nonce
|
|
201
208
|
const publicKey = await this.getIdentifier(entropySourceId);
|
|
202
|
-
const nonceRes = await (0,
|
|
203
|
-
|
|
209
|
+
const nonceRes = await (0, services_js_1.getNonce)(publicKey, __classPrivateFieldGet(this, _SRPJwtBearerAuth_config, "f").env);
|
|
210
|
+
// Tag only when the wallet supplies getLoginTag. SDK callers keep the
|
|
211
|
+
// legacy 3-part message rather than guessing `primary`.
|
|
212
|
+
const tag = await __classPrivateFieldGet(this, _SRPJwtBearerAuth_getLoginTag, "f")?.call(this, entropySourceId);
|
|
213
|
+
const identifierType = (await __classPrivateFieldGet(this, _SRPJwtBearerAuth_getLoginIdentifierType, "f")?.call(this, entropySourceId)) ?? 'SRP';
|
|
214
|
+
const rawMessage = __classPrivateFieldGet(this, _SRPJwtBearerAuth_instances, "m", _SRPJwtBearerAuth_createSrpLoginRawMessage).call(this, nonceRes.nonce, publicKey, tag);
|
|
204
215
|
const signature = await this.signMessage(rawMessage, entropySourceId);
|
|
205
216
|
// Authenticate
|
|
206
|
-
const authResponse = await (0,
|
|
217
|
+
const authResponse = await (0, services_js_1.authenticate)(rawMessage, signature, __classPrivateFieldGet(this, _SRPJwtBearerAuth_config, "f").type, __classPrivateFieldGet(this, _SRPJwtBearerAuth_config, "f").env, __classPrivateFieldGet(this, _SRPJwtBearerAuth_metametrics, "f"), identifierType);
|
|
207
218
|
// Resolve original profileId from aliases.
|
|
208
219
|
// This is done mainly to preserve the original profileId for storage key derivation
|
|
209
220
|
// until we migrate to the canonical profileId storage system.
|
|
210
221
|
const canonicalProfileId = authResponse.profile.profileId;
|
|
211
222
|
const profile = { ...authResponse.profile };
|
|
212
223
|
if (authResponse.profileAliases?.length > 0) {
|
|
213
|
-
const targetIdentifierId = (0,
|
|
224
|
+
const targetIdentifierId = (0, identifier_js_1.computeIdentifierId)(publicKey, __classPrivateFieldGet(this, _SRPJwtBearerAuth_config, "f").env);
|
|
214
225
|
const matchingAliases = authResponse.profileAliases.filter((alias) => alias.identifierIds.some((id) => id.id === targetIdentifierId));
|
|
215
226
|
// Prefer the leaf alias (single identifier) — it's the original profile
|
|
216
227
|
// created for this SRP. Multi-identifier aliases are former canonicals
|
|
@@ -224,7 +235,7 @@ async function _SRPJwtBearerAuth_getAuthSession(entropySourceId) {
|
|
|
224
235
|
}
|
|
225
236
|
profile.canonicalProfileId = canonicalProfileId;
|
|
226
237
|
// Authorize
|
|
227
|
-
const tokenResponse = await (0,
|
|
238
|
+
const tokenResponse = await (0, services_js_1.authorizeOIDC)(authResponse.token, __classPrivateFieldGet(this, _SRPJwtBearerAuth_config, "f").env, __classPrivateFieldGet(this, _SRPJwtBearerAuth_config, "f").platform);
|
|
228
239
|
// Save
|
|
229
240
|
const result = {
|
|
230
241
|
profile,
|
|
@@ -258,7 +269,7 @@ async function _SRPJwtBearerAuth_getAuthSession(entropySourceId) {
|
|
|
258
269
|
}
|
|
259
270
|
catch (e) {
|
|
260
271
|
// Only retry on rate-limit (429) errors
|
|
261
|
-
if (!
|
|
272
|
+
if (!errors_js_1.RateLimitedError.isRateLimitError(e)) {
|
|
262
273
|
throw e;
|
|
263
274
|
}
|
|
264
275
|
// If we've exhausted attempts, rethrow
|
|
@@ -273,7 +284,10 @@ async function _SRPJwtBearerAuth_getAuthSession(entropySourceId) {
|
|
|
273
284
|
}
|
|
274
285
|
// Should never reach here due to loop logic, but TypeScript needs a return
|
|
275
286
|
throw new Error('Unexpected: login loop exhausted without result');
|
|
276
|
-
}, _SRPJwtBearerAuth_createSrpLoginRawMessage = function _SRPJwtBearerAuth_createSrpLoginRawMessage(nonce, publicKey) {
|
|
287
|
+
}, _SRPJwtBearerAuth_createSrpLoginRawMessage = function _SRPJwtBearerAuth_createSrpLoginRawMessage(nonce, publicKey, tag) {
|
|
288
|
+
if (tag) {
|
|
289
|
+
return `metamask:${nonce}:${publicKey}:${tag}`;
|
|
290
|
+
}
|
|
277
291
|
return `metamask:${nonce}:${publicKey}`;
|
|
278
292
|
};
|
|
279
293
|
//# sourceMappingURL=flow-srp.cjs.map
|