@metamask-previews/profile-sync-controller 28.0.2-preview-eb7b1aa4b → 28.0.2-preview-938fc5d87

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.
Files changed (84) hide show
  1. package/CHANGELOG.md +0 -14
  2. package/dist/controllers/authentication/AuthenticationController-method-action-types.cjs.map +1 -1
  3. package/dist/controllers/authentication/AuthenticationController-method-action-types.d.cts +6 -36
  4. package/dist/controllers/authentication/AuthenticationController-method-action-types.d.cts.map +1 -1
  5. package/dist/controllers/authentication/AuthenticationController-method-action-types.d.mts +6 -36
  6. package/dist/controllers/authentication/AuthenticationController-method-action-types.d.mts.map +1 -1
  7. package/dist/controllers/authentication/AuthenticationController-method-action-types.mjs.map +1 -1
  8. package/dist/controllers/authentication/AuthenticationController.cjs +6 -101
  9. package/dist/controllers/authentication/AuthenticationController.cjs.map +1 -1
  10. package/dist/controllers/authentication/AuthenticationController.d.cts +7 -43
  11. package/dist/controllers/authentication/AuthenticationController.d.cts.map +1 -1
  12. package/dist/controllers/authentication/AuthenticationController.d.mts +7 -43
  13. package/dist/controllers/authentication/AuthenticationController.d.mts.map +1 -1
  14. package/dist/controllers/authentication/AuthenticationController.mjs +6 -101
  15. package/dist/controllers/authentication/AuthenticationController.mjs.map +1 -1
  16. package/dist/controllers/authentication/index.cjs.map +1 -1
  17. package/dist/controllers/authentication/index.d.cts +1 -1
  18. package/dist/controllers/authentication/index.d.cts.map +1 -1
  19. package/dist/controllers/authentication/index.d.mts +1 -1
  20. package/dist/controllers/authentication/index.d.mts.map +1 -1
  21. package/dist/controllers/authentication/index.mjs.map +1 -1
  22. package/dist/controllers/authentication/mocks/mockResponses.cjs +1 -10
  23. package/dist/controllers/authentication/mocks/mockResponses.cjs.map +1 -1
  24. package/dist/controllers/authentication/mocks/mockResponses.d.cts +0 -22
  25. package/dist/controllers/authentication/mocks/mockResponses.d.cts.map +1 -1
  26. package/dist/controllers/authentication/mocks/mockResponses.d.mts +0 -22
  27. package/dist/controllers/authentication/mocks/mockResponses.d.mts.map +1 -1
  28. package/dist/controllers/authentication/mocks/mockResponses.mjs +1 -9
  29. package/dist/controllers/authentication/mocks/mockResponses.mjs.map +1 -1
  30. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs +1 -28
  31. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs.map +1 -1
  32. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts +0 -2
  33. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts.map +1 -1
  34. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts +0 -2
  35. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts.map +1 -1
  36. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs +2 -29
  37. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs.map +1 -1
  38. package/dist/sdk/authentication-jwt-bearer/services.cjs +1 -56
  39. package/dist/sdk/authentication-jwt-bearer/services.cjs.map +1 -1
  40. package/dist/sdk/authentication-jwt-bearer/services.d.cts +1 -17
  41. package/dist/sdk/authentication-jwt-bearer/services.d.cts.map +1 -1
  42. package/dist/sdk/authentication-jwt-bearer/services.d.mts +1 -17
  43. package/dist/sdk/authentication-jwt-bearer/services.d.mts.map +1 -1
  44. package/dist/sdk/authentication-jwt-bearer/services.mjs +0 -53
  45. package/dist/sdk/authentication-jwt-bearer/services.mjs.map +1 -1
  46. package/dist/sdk/authentication-jwt-bearer/types.cjs.map +1 -1
  47. package/dist/sdk/authentication-jwt-bearer/types.d.cts +1 -20
  48. package/dist/sdk/authentication-jwt-bearer/types.d.cts.map +1 -1
  49. package/dist/sdk/authentication-jwt-bearer/types.d.mts +1 -20
  50. package/dist/sdk/authentication-jwt-bearer/types.d.mts.map +1 -1
  51. package/dist/sdk/authentication-jwt-bearer/types.mjs.map +1 -1
  52. package/dist/sdk/authentication.cjs +0 -4
  53. package/dist/sdk/authentication.cjs.map +1 -1
  54. package/dist/sdk/authentication.d.cts +0 -2
  55. package/dist/sdk/authentication.d.cts.map +1 -1
  56. package/dist/sdk/authentication.d.mts +0 -2
  57. package/dist/sdk/authentication.d.mts.map +1 -1
  58. package/dist/sdk/authentication.mjs +0 -4
  59. package/dist/sdk/authentication.mjs.map +1 -1
  60. package/dist/sdk/mocks/auth.cjs +1 -11
  61. package/dist/sdk/mocks/auth.cjs.map +1 -1
  62. package/dist/sdk/mocks/auth.d.cts +0 -10
  63. package/dist/sdk/mocks/auth.d.cts.map +1 -1
  64. package/dist/sdk/mocks/auth.d.mts +0 -10
  65. package/dist/sdk/mocks/auth.d.mts.map +1 -1
  66. package/dist/sdk/mocks/auth.mjs +1 -11
  67. package/dist/sdk/mocks/auth.mjs.map +1 -1
  68. package/dist/sdk/user-storage.cjs +3 -22
  69. package/dist/sdk/user-storage.cjs.map +1 -1
  70. package/dist/sdk/user-storage.d.cts +0 -7
  71. package/dist/sdk/user-storage.d.cts.map +1 -1
  72. package/dist/sdk/user-storage.d.mts +0 -7
  73. package/dist/sdk/user-storage.d.mts.map +1 -1
  74. package/dist/sdk/user-storage.mjs +3 -22
  75. package/dist/sdk/user-storage.mjs.map +1 -1
  76. package/package.json +1 -1
  77. package/dist/sdk/authentication-jwt-bearer/utils/identifier.cjs +0 -27
  78. package/dist/sdk/authentication-jwt-bearer/utils/identifier.cjs.map +0 -1
  79. package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.cts +0 -13
  80. package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.cts.map +0 -1
  81. package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.mts +0 -13
  82. package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.mts.map +0 -1
  83. package/dist/sdk/authentication-jwt-bearer/utils/identifier.mjs +0 -23
  84. package/dist/sdk/authentication-jwt-bearer/utils/identifier.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"authentication.mjs","sourceRoot":"","sources":["../../src/sdk/authentication.ts"],"names":[],"mappings":";;;;;;;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BAAA,IAAI,2BAAM,EAAE,uBAAA,IAAI,0BAAK,CAAC,CAAC;QACxC,uBAAA,IAAI,0BAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;CA2BF;sNAxBG,IAAc,EACd,IAA0C;IAE1C,IAAI,IAAI,KAAK,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC3B,OAAO;IACT,CAAC;IAED,MAAM,IAAI,wBAAwB,CAChC,kDAAkD,CACnD,CAAC;AACJ,CAAC,+DAGC,IAAc,EACd,IAA0C;IAE1C,IAAI,IAAI,KAAK,QAAQ,CAAC,GAAG,EAAE,CAAC;QAC1B,OAAO;IACT,CAAC;IAED,MAAM,IAAI,wBAAwB,CAChC,iDAAiD,CAClD,CAAC;AACJ,CAAC;AAGH,OAAO,EAAE,iBAAiB,EAAE,kDAA8C;AAC1E,OAAO,EAAE,gBAAgB,EAAE,iDAA6C;AACxE,sDAAkD","sourcesContent":["import type { Eip1193Provider } from 'ethers';\n\nimport type { Env } from '../shared/env';\nimport { SIWEJwtBearerAuth } from './authentication-jwt-bearer/flow-siwe';\nimport { SRPJwtBearerAuth } from './authentication-jwt-bearer/flow-srp';\nimport {\n getNonce,\n pairIdentifiers,\n} from './authentication-jwt-bearer/services';\nimport type { PairProfilesResponse } from './authentication-jwt-bearer/services';\nimport type {\n UserProfile,\n Pair,\n UserProfileLineage,\n} from './authentication-jwt-bearer/types';\nimport { AuthType } from './authentication-jwt-bearer/types';\nimport { PairError, UnsupportedAuthTypeError } from './errors';\n\n// Computing the Classes, so we only get back the public methods for the interface.\n\ntype Compute<T> = T extends infer U ? { [K in keyof U]: U[K] } : never;\ntype SIWEInterface = Compute<SIWEJwtBearerAuth>;\nexport type SRPInterface = Compute<SRPJwtBearerAuth>;\n\ntype SiweParams = ConstructorParameters<typeof SIWEJwtBearerAuth>;\ntype SRPParams = ConstructorParameters<typeof SRPJwtBearerAuth>;\ntype JwtBearerAuthParams = SiweParams | SRPParams;\n\nexport class JwtBearerAuth implements SIWEInterface, SRPInterface {\n readonly #type: AuthType;\n\n readonly #env: Env;\n\n readonly #sdk: SIWEJwtBearerAuth | SRPJwtBearerAuth;\n\n constructor(...args: JwtBearerAuthParams) {\n this.#type = args[0].type;\n this.#env = args[0].env;\n\n if (args[0].type === AuthType.SRP) {\n this.#sdk = new SRPJwtBearerAuth(args[0], args[1]);\n return;\n }\n\n if (args[0].type === AuthType.SiWE) {\n this.#sdk = new SIWEJwtBearerAuth(args[0], args[1]);\n return;\n }\n\n throw new UnsupportedAuthTypeError('unsupported auth type');\n }\n\n setCustomProvider(provider: Eip1193Provider) {\n this.#assertSRP(this.#type, this.#sdk);\n this.#sdk.setCustomProvider(provider);\n }\n\n async getAccessToken(entropySourceId?: string): Promise<string> {\n return await this.#sdk.getAccessToken(entropySourceId);\n }\n\n async connectSnap(): Promise<string> {\n this.#assertSRP(this.#type, this.#sdk);\n return this.#sdk.connectSnap();\n }\n\n async isSnapConnected(): Promise<boolean> {\n this.#assertSRP(this.#type, this.#sdk);\n return this.#sdk.isSnapConnected();\n }\n\n async getUserProfile(entropySourceId?: string): Promise<UserProfile> {\n return await this.#sdk.getUserProfile(entropySourceId);\n }\n\n async getIdentifier(entropySourceId?: string): Promise<string> {\n return await this.#sdk.getIdentifier(entropySourceId);\n }\n\n async getUserProfileLineage(\n entropySourceId?: string,\n ): Promise<UserProfileLineage> {\n return await this.#sdk.getUserProfileLineage(entropySourceId);\n }\n\n async pairSrpProfiles(\n accessTokens: string[],\n authAccessToken: string,\n ): Promise<PairProfilesResponse> {\n this.#assertSRP(this.#type, this.#sdk);\n return await this.#sdk.pairSrpProfiles(accessTokens, authAccessToken);\n }\n\n async signMessage(\n message: string,\n entropySourceId?: string,\n ): Promise<string> {\n return await this.#sdk.signMessage(message, entropySourceId);\n }\n\n async pairIdentifiers(pairing: Pair[]): Promise<void> {\n const profile = await this.getUserProfile();\n const n = await getNonce(profile.profileId, this.#env);\n\n const logins = await Promise.all(\n pairing.map(async (p) => {\n try {\n const raw = `metamask:${n.nonce}:${p.identifier}`;\n const sig = await p.signMessage(raw);\n return {\n signature: sig,\n raw_message: raw,\n encrypted_storage_key: p.encryptedStorageKey,\n identifier_type: p.identifierType,\n };\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n throw new PairError(\n `failed to sign pairing message: ${errorMessage}`,\n );\n }\n }),\n );\n\n const accessToken = await this.getAccessToken();\n await pairIdentifiers(n.nonce, logins, accessToken, this.#env);\n }\n\n prepare(signer: {\n address: string;\n chainId: number;\n signMessage: (message: string) => Promise<string>;\n domain: string;\n }): void {\n this.#assertSIWE(this.#type, this.#sdk);\n this.#sdk.prepare(signer);\n }\n\n #assertSIWE(\n type: AuthType,\n _sdk: SIWEJwtBearerAuth | SRPJwtBearerAuth,\n ): asserts _sdk is SIWEJwtBearerAuth {\n if (type === AuthType.SiWE) {\n return;\n }\n\n throw new UnsupportedAuthTypeError(\n 'This method is only available via SIWE auth type',\n );\n }\n\n #assertSRP(\n type: AuthType,\n _sdk: SIWEJwtBearerAuth | SRPJwtBearerAuth,\n ): asserts _sdk is SRPJwtBearerAuth {\n if (type === AuthType.SRP) {\n return;\n }\n\n throw new UnsupportedAuthTypeError(\n 'This method is only available via SRP auth type',\n );\n }\n}\n\nexport { SIWEJwtBearerAuth } from './authentication-jwt-bearer/flow-siwe';\nexport { SRPJwtBearerAuth } from './authentication-jwt-bearer/flow-srp';\nexport * from './authentication-jwt-bearer/types';\n"]}
1
+ {"version":3,"file":"authentication.mjs","sourceRoot":"","sources":["../../src/sdk/authentication.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,OAAO,EAAE,iBAAiB,EAAE,kDAA8C;AAC1E,OAAO,EAAE,gBAAgB,EAAE,iDAA6C;AACxE,OAAO,EACL,QAAQ,EACR,eAAe,EAChB,iDAA6C;AAM9C,OAAO,EAAE,QAAQ,EAAE,8CAA0C;AAC7D,OAAO,EAAE,SAAS,EAAE,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CAAC;AACJ,CAAC;AAGH,OAAO,EAAE,iBAAiB,EAAE,kDAA8C;AAC1E,OAAO,EAAE,gBAAgB,EAAE,iDAA6C;AACxE,sDAAkD","sourcesContent":["import type { Eip1193Provider } from 'ethers';\n\nimport type { Env } from '../shared/env';\nimport { SIWEJwtBearerAuth } from './authentication-jwt-bearer/flow-siwe';\nimport { SRPJwtBearerAuth } from './authentication-jwt-bearer/flow-srp';\nimport {\n getNonce,\n pairIdentifiers,\n} from './authentication-jwt-bearer/services';\nimport type {\n UserProfile,\n Pair,\n UserProfileLineage,\n} from './authentication-jwt-bearer/types';\nimport { AuthType } from './authentication-jwt-bearer/types';\nimport { PairError, UnsupportedAuthTypeError } from './errors';\n\n// Computing the Classes, so we only get back the public methods for the interface.\n\ntype Compute<T> = T extends infer U ? { [K in keyof U]: U[K] } : never;\ntype SIWEInterface = Compute<SIWEJwtBearerAuth>;\nexport type SRPInterface = Compute<SRPJwtBearerAuth>;\n\ntype SiweParams = ConstructorParameters<typeof SIWEJwtBearerAuth>;\ntype SRPParams = ConstructorParameters<typeof SRPJwtBearerAuth>;\ntype JwtBearerAuthParams = SiweParams | SRPParams;\n\nexport class JwtBearerAuth implements SIWEInterface, SRPInterface {\n readonly #type: AuthType;\n\n readonly #env: Env;\n\n readonly #sdk: SIWEJwtBearerAuth | SRPJwtBearerAuth;\n\n constructor(...args: JwtBearerAuthParams) {\n this.#type = args[0].type;\n this.#env = args[0].env;\n\n if (args[0].type === AuthType.SRP) {\n this.#sdk = new SRPJwtBearerAuth(args[0], args[1]);\n return;\n }\n\n if (args[0].type === AuthType.SiWE) {\n this.#sdk = new SIWEJwtBearerAuth(args[0], args[1]);\n return;\n }\n\n throw new UnsupportedAuthTypeError('unsupported auth type');\n }\n\n setCustomProvider(provider: Eip1193Provider) {\n this.#assertSRP(this.#type, this.#sdk);\n this.#sdk.setCustomProvider(provider);\n }\n\n async getAccessToken(entropySourceId?: string): Promise<string> {\n return await this.#sdk.getAccessToken(entropySourceId);\n }\n\n async connectSnap(): Promise<string> {\n this.#assertSRP(this.#type, this.#sdk);\n return this.#sdk.connectSnap();\n }\n\n async isSnapConnected(): Promise<boolean> {\n this.#assertSRP(this.#type, this.#sdk);\n return this.#sdk.isSnapConnected();\n }\n\n async getUserProfile(entropySourceId?: string): Promise<UserProfile> {\n return await this.#sdk.getUserProfile(entropySourceId);\n }\n\n async getIdentifier(entropySourceId?: string): Promise<string> {\n return await this.#sdk.getIdentifier(entropySourceId);\n }\n\n async getUserProfileLineage(\n entropySourceId?: string,\n ): Promise<UserProfileLineage> {\n return await this.#sdk.getUserProfileLineage(entropySourceId);\n }\n\n async signMessage(\n message: string,\n entropySourceId?: string,\n ): Promise<string> {\n return await this.#sdk.signMessage(message, entropySourceId);\n }\n\n async pairIdentifiers(pairing: Pair[]): Promise<void> {\n const profile = await this.getUserProfile();\n const n = await getNonce(profile.profileId, this.#env);\n\n const logins = await Promise.all(\n pairing.map(async (p) => {\n try {\n const raw = `metamask:${n.nonce}:${p.identifier}`;\n const sig = await p.signMessage(raw);\n return {\n signature: sig,\n raw_message: raw,\n encrypted_storage_key: p.encryptedStorageKey,\n identifier_type: p.identifierType,\n };\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n throw new PairError(\n `failed to sign pairing message: ${errorMessage}`,\n );\n }\n }),\n );\n\n const accessToken = await this.getAccessToken();\n await pairIdentifiers(n.nonce, logins, accessToken, this.#env);\n }\n\n prepare(signer: {\n address: string;\n chainId: number;\n signMessage: (message: string) => Promise<string>;\n domain: string;\n }): void {\n this.#assertSIWE(this.#type, this.#sdk);\n this.#sdk.prepare(signer);\n }\n\n #assertSIWE(\n type: AuthType,\n _sdk: SIWEJwtBearerAuth | SRPJwtBearerAuth,\n ): asserts _sdk is SIWEJwtBearerAuth {\n if (type === AuthType.SiWE) {\n return;\n }\n\n throw new UnsupportedAuthTypeError(\n 'This method is only available via SIWE auth type',\n );\n }\n\n #assertSRP(\n type: AuthType,\n _sdk: SIWEJwtBearerAuth | SRPJwtBearerAuth,\n ): asserts _sdk is SRPJwtBearerAuth {\n if (type === AuthType.SRP) {\n return;\n }\n\n throw new UnsupportedAuthTypeError(\n 'This method is only available via SRP auth type',\n );\n }\n}\n\nexport { SIWEJwtBearerAuth } from './authentication-jwt-bearer/flow-siwe';\nexport { SRPJwtBearerAuth } from './authentication-jwt-bearer/flow-srp';\nexport * from './authentication-jwt-bearer/types';\n"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MOCK_USER_PROFILE_LINEAGE_RESPONSE = exports.MOCK_PAIR_PROFILES_RESPONSE = exports.MOCK_OIDC_TOKEN_RESPONSE = exports.MOCK_SRP_LOGIN_RESPONSE = exports.MOCK_SIWE_LOGIN_RESPONSE = exports.MOCK_NONCE_RESPONSE = exports.MOCK_ACCESS_JWT = exports.MOCK_JWT = exports.MOCK_PROFILE_LINEAGE_URL = exports.MOCK_PAIR_PROFILES_URL = exports.MOCK_PAIR_IDENTIFIERS_URL = exports.MOCK_SIWE_LOGIN_URL = exports.MOCK_OIDC_TOKEN_URL = exports.MOCK_SRP_LOGIN_URL = exports.MOCK_NONCE_URL = void 0;
3
+ exports.MOCK_USER_PROFILE_LINEAGE_RESPONSE = exports.MOCK_OIDC_TOKEN_RESPONSE = exports.MOCK_SRP_LOGIN_RESPONSE = exports.MOCK_SIWE_LOGIN_RESPONSE = exports.MOCK_NONCE_RESPONSE = exports.MOCK_ACCESS_JWT = exports.MOCK_JWT = exports.MOCK_PROFILE_LINEAGE_URL = exports.MOCK_PAIR_IDENTIFIERS_URL = exports.MOCK_SIWE_LOGIN_URL = exports.MOCK_OIDC_TOKEN_URL = exports.MOCK_SRP_LOGIN_URL = exports.MOCK_NONCE_URL = void 0;
4
4
  const env_1 = require("../../shared/env.cjs");
5
5
  const services_1 = require("../authentication-jwt-bearer/services.cjs");
6
6
  exports.MOCK_NONCE_URL = (0, services_1.NONCE_URL)(env_1.Env.PRD);
@@ -8,7 +8,6 @@ exports.MOCK_SRP_LOGIN_URL = (0, services_1.SRP_LOGIN_URL)(env_1.Env.PRD);
8
8
  exports.MOCK_OIDC_TOKEN_URL = (0, services_1.OIDC_TOKEN_URL)(env_1.Env.PRD);
9
9
  exports.MOCK_SIWE_LOGIN_URL = (0, services_1.SIWE_LOGIN_URL)(env_1.Env.PRD);
10
10
  exports.MOCK_PAIR_IDENTIFIERS_URL = (0, services_1.PAIR_IDENTIFIERS)(env_1.Env.PRD);
11
- exports.MOCK_PAIR_PROFILES_URL = (0, services_1.PAIR_PROFILES_URL)(env_1.Env.PRD);
12
11
  exports.MOCK_PROFILE_LINEAGE_URL = (0, services_1.PROFILE_LINEAGE_URL)(env_1.Env.PRD);
13
12
  exports.MOCK_JWT = 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImIwNzE2N2U2LWJjNWUtNDgyZC1hNjRhLWU1MjQ0MjY2MGU3NyJ9.eyJzdWIiOiI1MzE0ODc5YWM2NDU1OGI3OTQ5ZmI4NWIzMjg2ZjZjNjUwODAzYmFiMTY0Y2QyOWNmMmM3YzdmMjMzMWMwZTRlIiwiaWF0IjoxNzA2MTEzMDYyLCJleHAiOjE3NjkxODUwNjMsImlzcyI6ImF1dGgubWV0YW1hc2suaW8iLCJhdWQiOiJwb3J0Zm9saW8ubWV0YW1hc2suaW8ifQ.E5UL6oABNweS8t5a6IBTqTf7NLOJbrhJSmEcsr7kwLp4bGvcENJzACwnsHDkA6PlzfDV09ZhAGU_F3hlS0j-erbY0k0AFR-GAtyS7E9N02D8RgUDz5oDR65CKmzM8JilgFA8UvruJ6OJGogroaOSOqzRES_s8MjHpP47RJ9lXrUesajsbOudXbuksXWg5QmWip6LLvjwr8UUzcJzNQilyIhiEpo4WdzWM4R3VtTwr4rHnWEvtYnYCov1jmI2w3YQ48y0M-3Y9IOO0ov_vlITRrOnR7Y7fRUGLUFmU5msD8mNWRywjQFLHfJJ1yNP5aJ8TkuCK3sC6kcUH335IVvukQ';
14
13
  exports.MOCK_ACCESS_JWT = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjQxMDI0NDQ4MDB9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';
@@ -38,20 +37,11 @@ exports.MOCK_SRP_LOGIN_RESPONSE = {
38
37
  identifier_type: 'SRP',
39
38
  encrypted_storage_key: 'd2ddd8af8af905306f3e1456fb',
40
39
  },
41
- profile_aliases: [],
42
40
  };
43
41
  exports.MOCK_OIDC_TOKEN_RESPONSE = {
44
42
  access_token: exports.MOCK_ACCESS_JWT,
45
43
  expires_in: 3600,
46
44
  };
47
- exports.MOCK_PAIR_PROFILES_RESPONSE = {
48
- profile: {
49
- identifier_id: exports.MOCK_SRP_LOGIN_RESPONSE.profile.identifier_id,
50
- metametrics_id: exports.MOCK_SRP_LOGIN_RESPONSE.profile.metametrics_id,
51
- profile_id: exports.MOCK_SRP_LOGIN_RESPONSE.profile.profile_id,
52
- },
53
- profile_aliases: [],
54
- };
55
45
  exports.MOCK_USER_PROFILE_LINEAGE_RESPONSE = {
56
46
  profile_id: 'f88227bd-b615-41a3-b0be-467dd781a4ad',
57
47
  created_at: '2025-10-01T12:00:00Z',
@@ -1 +1 @@
1
- {"version":3,"file":"auth.cjs","sourceRoot":"","sources":["../../../src/sdk/mocks/auth.ts"],"names":[],"mappings":";;;AAAA,8CAAiD;AACjD,wEAQ+C;AAElC,QAAA,cAAc,GAAG,IAAA,oBAAS,EAAC,SAAG,CAAC,GAAG,CAAC,CAAC;AACpC,QAAA,kBAAkB,GAAG,IAAA,wBAAa,EAAC,SAAG,CAAC,GAAG,CAAC,CAAC;AAC5C,QAAA,mBAAmB,GAAG,IAAA,yBAAc,EAAC,SAAG,CAAC,G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+BAAuB,CAAC,OAAO,CAAC,cAAc;QAC9D,UAAU,EAAE,+BAAuB,CAAC,OAAO,CAAC,UAAU;KACvD;IACD,eAAe,EAAE,EAAE;CACpB,CAAC;AAEW,QAAA,kCAAkC,GAAG;IAChD,UAAU,EAAE,sCAAsC;IAClD,UAAU,EAAE,sBAAsB;IAClC,OAAO,EAAE;QACP;YACE,cAAc,EAAE,sCAAsC;YACtD,KAAK,EAAE,cAAQ,CAAC,MAAM;YACtB,UAAU,EAAE,sBAAsB;YAClC,UAAU,EAAE,sBAAsB;YAClC,OAAO,EAAE,CAAC;SACX;QACD;YACE,cAAc,EAAE,sCAAsC;YACtD,KAAK,EAAE,cAAQ,CAAC,SAAS;YACzB,UAAU,EAAE,sBAAsB;YAClC,UAAU,EAAE,sBAAsB;YAClC,OAAO,EAAE,CAAC;SACX;KACF;CACF,CAAC","sourcesContent":["import { Env, Platform } from '../../shared/env';\nimport {\n NONCE_URL,\n SIWE_LOGIN_URL,\n SRP_LOGIN_URL,\n OIDC_TOKEN_URL,\n PAIR_IDENTIFIERS,\n PAIR_PROFILES_URL,\n PROFILE_LINEAGE_URL,\n} from '../authentication-jwt-bearer/services';\n\nexport const MOCK_NONCE_URL = NONCE_URL(Env.PRD);\nexport const MOCK_SRP_LOGIN_URL = SRP_LOGIN_URL(Env.PRD);\nexport const MOCK_OIDC_TOKEN_URL = OIDC_TOKEN_URL(Env.PRD);\nexport const MOCK_SIWE_LOGIN_URL = SIWE_LOGIN_URL(Env.PRD);\nexport const MOCK_PAIR_IDENTIFIERS_URL = PAIR_IDENTIFIERS(Env.PRD);\nexport const MOCK_PAIR_PROFILES_URL = PAIR_PROFILES_URL(Env.PRD);\nexport const MOCK_PROFILE_LINEAGE_URL = PROFILE_LINEAGE_URL(Env.PRD);\n\nexport const MOCK_JWT =\n 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImIwNzE2N2U2LWJjNWUtNDgyZC1hNjRhLWU1MjQ0MjY2MGU3NyJ9.eyJzdWIiOiI1MzE0ODc5YWM2NDU1OGI3OTQ5ZmI4NWIzMjg2ZjZjNjUwODAzYmFiMTY0Y2QyOWNmMmM3YzdmMjMzMWMwZTRlIiwiaWF0IjoxNzA2MTEzMDYyLCJleHAiOjE3NjkxODUwNjMsImlzcyI6ImF1dGgubWV0YW1hc2suaW8iLCJhdWQiOiJwb3J0Zm9saW8ubWV0YW1hc2suaW8ifQ.E5UL6oABNweS8t5a6IBTqTf7NLOJbrhJSmEcsr7kwLp4bGvcENJzACwnsHDkA6PlzfDV09ZhAGU_F3hlS0j-erbY0k0AFR-GAtyS7E9N02D8RgUDz5oDR65CKmzM8JilgFA8UvruJ6OJGogroaOSOqzRES_s8MjHpP47RJ9lXrUesajsbOudXbuksXWg5QmWip6LLvjwr8UUzcJzNQilyIhiEpo4WdzWM4R3VtTwr4rHnWEvtYnYCov1jmI2w3YQ48y0M-3Y9IOO0ov_vlITRrOnR7Y7fRUGLUFmU5msD8mNWRywjQFLHfJJ1yNP5aJ8TkuCK3sC6kcUH335IVvukQ';\n\nexport const MOCK_ACCESS_JWT =\n 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjQxMDI0NDQ4MDB9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';\n\nexport const MOCK_NONCE_RESPONSE = {\n nonce: 'xGMm9SoihEKeAEfV',\n identifier: '0xd8641601Cb79a94FD872fE42d5b4a067A44a7e88',\n expires_in: 300,\n};\n\nexport const MOCK_SIWE_LOGIN_RESPONSE = {\n token: MOCK_JWT,\n expires_in: 3600,\n profile: {\n profile_id: 'fa2bbf82-bd9a-4e6b-aabc-9ca0d0319b6e',\n metametrics_id: 'de742679-4960-4977-a415-4718b5f8e86c',\n identifier_id:\n 'ec9a4e9906836497efad2fd4d4290b34d2c6a2c0d93eb174aa3cd88a133adbaf',\n identifier_type: 'SIWE',\n encrypted_storage_key: '2c6a2c0d93eb174aa3cd88a133adbaf',\n },\n};\n\nexport const MOCK_SRP_LOGIN_RESPONSE = {\n token: MOCK_JWT,\n expires_in: 3600,\n profile: {\n profile_id: 'f88227bd-b615-41a3-b0be-467dd781a4ad',\n metametrics_id: '561ec651-a844-4b36-a451-04d6eac35740',\n identifier_id:\n 'da9a9fc7b09edde9cc23cec9b7e11a71fb0ab4d2ddd8af8af905306f3e1456fb',\n identifier_type: 'SRP',\n encrypted_storage_key: 'd2ddd8af8af905306f3e1456fb',\n },\n profile_aliases: [],\n};\n\nexport const MOCK_OIDC_TOKEN_RESPONSE = {\n access_token: MOCK_ACCESS_JWT,\n expires_in: 3600,\n};\n\nexport const MOCK_PAIR_PROFILES_RESPONSE = {\n profile: {\n identifier_id: MOCK_SRP_LOGIN_RESPONSE.profile.identifier_id,\n metametrics_id: MOCK_SRP_LOGIN_RESPONSE.profile.metametrics_id,\n profile_id: MOCK_SRP_LOGIN_RESPONSE.profile.profile_id,\n },\n profile_aliases: [],\n};\n\nexport const MOCK_USER_PROFILE_LINEAGE_RESPONSE = {\n profile_id: 'f88227bd-b615-41a3-b0be-467dd781a4ad',\n created_at: '2025-10-01T12:00:00Z',\n lineage: [\n {\n metametrics_id: '561ec651-a844-4b36-a451-04d6eac35740',\n agent: Platform.MOBILE,\n created_at: '2025-10-01T12:00:00Z',\n updated_at: '2025-10-01T12:00:00Z',\n counter: 1,\n },\n {\n metametrics_id: 'de742679-4960-4977-a415-4718b5f8e86c',\n agent: Platform.EXTENSION,\n created_at: '2025-10-01T12:00:00Z',\n updated_at: '2025-10-01T12:00:00Z',\n counter: 2,\n },\n ],\n};\n"]}
1
+ {"version":3,"file":"auth.cjs","sourceRoot":"","sources":["../../../src/sdk/mocks/auth.ts"],"names":[],"mappings":";;;AAAA,8CAAiD;AACjD,wEAO+C;AAElC,QAAA,cAAc,GAAG,IAAA,oBAAS,EAAC,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AsC;IAClD,UAAU,EAAE,sBAAsB;IAClC,OAAO,EAAE;QACP;YACE,cAAc,EAAE,sCAAsC;YACtD,KAAK,EAAE,cAAQ,CAAC,MAAM;YACtB,UAAU,EAAE,sBAAsB;YAClC,UAAU,EAAE,sBAAsB;YAClC,OAAO,EAAE,CAAC;SACX;QACD;YACE,cAAc,EAAE,sCAAsC;YACtD,KAAK,EAAE,cAAQ,CAAC,SAAS;YACzB,UAAU,EAAE,sBAAsB;YAClC,UAAU,EAAE,sBAAsB;YAClC,OAAO,EAAE,CAAC;SACX;KACF;CACF,CAAC","sourcesContent":["import { Env, Platform } from '../../shared/env';\nimport {\n NONCE_URL,\n SIWE_LOGIN_URL,\n SRP_LOGIN_URL,\n OIDC_TOKEN_URL,\n PAIR_IDENTIFIERS,\n PROFILE_LINEAGE_URL,\n} from '../authentication-jwt-bearer/services';\n\nexport const MOCK_NONCE_URL = NONCE_URL(Env.PRD);\nexport const MOCK_SRP_LOGIN_URL = SRP_LOGIN_URL(Env.PRD);\nexport const MOCK_OIDC_TOKEN_URL = OIDC_TOKEN_URL(Env.PRD);\nexport const MOCK_SIWE_LOGIN_URL = SIWE_LOGIN_URL(Env.PRD);\nexport const MOCK_PAIR_IDENTIFIERS_URL = PAIR_IDENTIFIERS(Env.PRD);\nexport const MOCK_PROFILE_LINEAGE_URL = PROFILE_LINEAGE_URL(Env.PRD);\n\nexport const MOCK_JWT =\n 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImIwNzE2N2U2LWJjNWUtNDgyZC1hNjRhLWU1MjQ0MjY2MGU3NyJ9.eyJzdWIiOiI1MzE0ODc5YWM2NDU1OGI3OTQ5ZmI4NWIzMjg2ZjZjNjUwODAzYmFiMTY0Y2QyOWNmMmM3YzdmMjMzMWMwZTRlIiwiaWF0IjoxNzA2MTEzMDYyLCJleHAiOjE3NjkxODUwNjMsImlzcyI6ImF1dGgubWV0YW1hc2suaW8iLCJhdWQiOiJwb3J0Zm9saW8ubWV0YW1hc2suaW8ifQ.E5UL6oABNweS8t5a6IBTqTf7NLOJbrhJSmEcsr7kwLp4bGvcENJzACwnsHDkA6PlzfDV09ZhAGU_F3hlS0j-erbY0k0AFR-GAtyS7E9N02D8RgUDz5oDR65CKmzM8JilgFA8UvruJ6OJGogroaOSOqzRES_s8MjHpP47RJ9lXrUesajsbOudXbuksXWg5QmWip6LLvjwr8UUzcJzNQilyIhiEpo4WdzWM4R3VtTwr4rHnWEvtYnYCov1jmI2w3YQ48y0M-3Y9IOO0ov_vlITRrOnR7Y7fRUGLUFmU5msD8mNWRywjQFLHfJJ1yNP5aJ8TkuCK3sC6kcUH335IVvukQ';\n\nexport const MOCK_ACCESS_JWT =\n 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjQxMDI0NDQ4MDB9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';\n\nexport const MOCK_NONCE_RESPONSE = {\n nonce: 'xGMm9SoihEKeAEfV',\n identifier: '0xd8641601Cb79a94FD872fE42d5b4a067A44a7e88',\n expires_in: 300,\n};\n\nexport const MOCK_SIWE_LOGIN_RESPONSE = {\n token: MOCK_JWT,\n expires_in: 3600,\n profile: {\n profile_id: 'fa2bbf82-bd9a-4e6b-aabc-9ca0d0319b6e',\n metametrics_id: 'de742679-4960-4977-a415-4718b5f8e86c',\n identifier_id:\n 'ec9a4e9906836497efad2fd4d4290b34d2c6a2c0d93eb174aa3cd88a133adbaf',\n identifier_type: 'SIWE',\n encrypted_storage_key: '2c6a2c0d93eb174aa3cd88a133adbaf',\n },\n};\n\nexport const MOCK_SRP_LOGIN_RESPONSE = {\n token: MOCK_JWT,\n expires_in: 3600,\n profile: {\n profile_id: 'f88227bd-b615-41a3-b0be-467dd781a4ad',\n metametrics_id: '561ec651-a844-4b36-a451-04d6eac35740',\n identifier_id:\n 'da9a9fc7b09edde9cc23cec9b7e11a71fb0ab4d2ddd8af8af905306f3e1456fb',\n identifier_type: 'SRP',\n encrypted_storage_key: 'd2ddd8af8af905306f3e1456fb',\n },\n};\n\nexport const MOCK_OIDC_TOKEN_RESPONSE = {\n access_token: MOCK_ACCESS_JWT,\n expires_in: 3600,\n};\n\nexport const MOCK_USER_PROFILE_LINEAGE_RESPONSE = {\n profile_id: 'f88227bd-b615-41a3-b0be-467dd781a4ad',\n created_at: '2025-10-01T12:00:00Z',\n lineage: [\n {\n metametrics_id: '561ec651-a844-4b36-a451-04d6eac35740',\n agent: Platform.MOBILE,\n created_at: '2025-10-01T12:00:00Z',\n updated_at: '2025-10-01T12:00:00Z',\n counter: 1,\n },\n {\n metametrics_id: 'de742679-4960-4977-a415-4718b5f8e86c',\n agent: Platform.EXTENSION,\n created_at: '2025-10-01T12:00:00Z',\n updated_at: '2025-10-01T12:00:00Z',\n counter: 2,\n },\n ],\n};\n"]}
@@ -4,7 +4,6 @@ export declare const MOCK_SRP_LOGIN_URL: string;
4
4
  export declare const MOCK_OIDC_TOKEN_URL: string;
5
5
  export declare const MOCK_SIWE_LOGIN_URL: string;
6
6
  export declare const MOCK_PAIR_IDENTIFIERS_URL: string;
7
- export declare const MOCK_PAIR_PROFILES_URL: string;
8
7
  export declare const MOCK_PROFILE_LINEAGE_URL: string;
9
8
  export declare const MOCK_JWT = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImIwNzE2N2U2LWJjNWUtNDgyZC1hNjRhLWU1MjQ0MjY2MGU3NyJ9.eyJzdWIiOiI1MzE0ODc5YWM2NDU1OGI3OTQ5ZmI4NWIzMjg2ZjZjNjUwODAzYmFiMTY0Y2QyOWNmMmM3YzdmMjMzMWMwZTRlIiwiaWF0IjoxNzA2MTEzMDYyLCJleHAiOjE3NjkxODUwNjMsImlzcyI6ImF1dGgubWV0YW1hc2suaW8iLCJhdWQiOiJwb3J0Zm9saW8ubWV0YW1hc2suaW8ifQ.E5UL6oABNweS8t5a6IBTqTf7NLOJbrhJSmEcsr7kwLp4bGvcENJzACwnsHDkA6PlzfDV09ZhAGU_F3hlS0j-erbY0k0AFR-GAtyS7E9N02D8RgUDz5oDR65CKmzM8JilgFA8UvruJ6OJGogroaOSOqzRES_s8MjHpP47RJ9lXrUesajsbOudXbuksXWg5QmWip6LLvjwr8UUzcJzNQilyIhiEpo4WdzWM4R3VtTwr4rHnWEvtYnYCov1jmI2w3YQ48y0M-3Y9IOO0ov_vlITRrOnR7Y7fRUGLUFmU5msD8mNWRywjQFLHfJJ1yNP5aJ8TkuCK3sC6kcUH335IVvukQ";
10
9
  export declare const MOCK_ACCESS_JWT = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjQxMDI0NDQ4MDB9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c";
@@ -34,20 +33,11 @@ export declare const MOCK_SRP_LOGIN_RESPONSE: {
34
33
  identifier_type: string;
35
34
  encrypted_storage_key: string;
36
35
  };
37
- profile_aliases: never[];
38
36
  };
39
37
  export declare const MOCK_OIDC_TOKEN_RESPONSE: {
40
38
  access_token: string;
41
39
  expires_in: number;
42
40
  };
43
- export declare const MOCK_PAIR_PROFILES_RESPONSE: {
44
- profile: {
45
- identifier_id: string;
46
- metametrics_id: string;
47
- profile_id: string;
48
- };
49
- profile_aliases: never[];
50
- };
51
41
  export declare const MOCK_USER_PROFILE_LINEAGE_RESPONSE: {
52
42
  profile_id: string;
53
43
  created_at: string;
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.cts","sourceRoot":"","sources":["../../../src/sdk/mocks/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,QAAQ,EAAE,6BAAyB;AAWjD,eAAO,MAAM,cAAc,QAAqB,CAAC;AACjD,eAA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eAAO,MAAM,kCAAkC;;;;;;;;;;CAmB9C,CAAC"}
@@ -4,7 +4,6 @@ export declare const MOCK_SRP_LOGIN_URL: string;
4
4
  export declare const MOCK_OIDC_TOKEN_URL: string;
5
5
  export declare const MOCK_SIWE_LOGIN_URL: string;
6
6
  export declare const MOCK_PAIR_IDENTIFIERS_URL: string;
7
- export declare const MOCK_PAIR_PROFILES_URL: string;
8
7
  export declare const MOCK_PROFILE_LINEAGE_URL: string;
9
8
  export declare const MOCK_JWT = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImIwNzE2N2U2LWJjNWUtNDgyZC1hNjRhLWU1MjQ0MjY2MGU3NyJ9.eyJzdWIiOiI1MzE0ODc5YWM2NDU1OGI3OTQ5ZmI4NWIzMjg2ZjZjNjUwODAzYmFiMTY0Y2QyOWNmMmM3YzdmMjMzMWMwZTRlIiwiaWF0IjoxNzA2MTEzMDYyLCJleHAiOjE3NjkxODUwNjMsImlzcyI6ImF1dGgubWV0YW1hc2suaW8iLCJhdWQiOiJwb3J0Zm9saW8ubWV0YW1hc2suaW8ifQ.E5UL6oABNweS8t5a6IBTqTf7NLOJbrhJSmEcsr7kwLp4bGvcENJzACwnsHDkA6PlzfDV09ZhAGU_F3hlS0j-erbY0k0AFR-GAtyS7E9N02D8RgUDz5oDR65CKmzM8JilgFA8UvruJ6OJGogroaOSOqzRES_s8MjHpP47RJ9lXrUesajsbOudXbuksXWg5QmWip6LLvjwr8UUzcJzNQilyIhiEpo4WdzWM4R3VtTwr4rHnWEvtYnYCov1jmI2w3YQ48y0M-3Y9IOO0ov_vlITRrOnR7Y7fRUGLUFmU5msD8mNWRywjQFLHfJJ1yNP5aJ8TkuCK3sC6kcUH335IVvukQ";
10
9
  export declare const MOCK_ACCESS_JWT = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjQxMDI0NDQ4MDB9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c";
@@ -34,20 +33,11 @@ export declare const MOCK_SRP_LOGIN_RESPONSE: {
34
33
  identifier_type: string;
35
34
  encrypted_storage_key: string;
36
35
  };
37
- profile_aliases: never[];
38
36
  };
39
37
  export declare const MOCK_OIDC_TOKEN_RESPONSE: {
40
38
  access_token: string;
41
39
  expires_in: number;
42
40
  };
43
- export declare const MOCK_PAIR_PROFILES_RESPONSE: {
44
- profile: {
45
- identifier_id: string;
46
- metametrics_id: string;
47
- profile_id: string;
48
- };
49
- profile_aliases: never[];
50
- };
51
41
  export declare const MOCK_USER_PROFILE_LINEAGE_RESPONSE: {
52
42
  profile_id: string;
53
43
  created_at: string;
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.mts","sourceRoot":"","sources":["../../../src/sdk/mocks/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,QAAQ,EAAE,6BAAyB;AAWjD,eAAO,MAAM,cAAc,QAAqB,CAAC;AACjD,eAAO,MAAM,kBAAkB,QAAyB,CAAC;AACzD,eAAO,MAAM,mBAAmB,QAA0B,CAAC;AAC3D,eAAO,MAAM,mBAAmB,QAA0B,CAAC;AAC3D,eAAO,MAAM,yBAAyB,QAA4B,CAAC;AACnE,eAAO,MAAM,sBAAsB,QAA6B,CAAC;AACjE,eAAO,MAAM,wBAAwB,QAA+B,CAAC;AAErE,eAAO,MAAM,QAAQ,upBACioB,CAAC;AAEvpB,eAAO,MAAM,eAAe,sLACyJ,CAAC;AAEtL,eAAO,MAAM,mBAAmB;;;;CAI/B,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;;;;;;;;CAWpC,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;;;;;;;;;CAYnC,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;CAGpC,CAAC;AAEF,eAAO,MAAM,2BAA2B;;;;;;;CAOvC,CAAC;AAEF,eAAO,MAAM,kCAAkC;;;;;;;;;;CAmB9C,CAAC"}
1
+ {"version":3,"file":"auth.d.mts","sourceRoot":"","sources":["../../../src/sdk/mocks/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,QAAQ,EAAE,6BAAyB;AAUjD,eAAO,MAAM,cAAc,QAAqB,CAAC;AACjD,eAAO,MAAM,kBAAkB,QAAyB,CAAC;AACzD,eAAO,MAAM,mBAAmB,QAA0B,CAAC;AAC3D,eAAO,MAAM,mBAAmB,QAA0B,CAAC;AAC3D,eAAO,MAAM,yBAAyB,QAA4B,CAAC;AACnE,eAAO,MAAM,wBAAwB,QAA+B,CAAC;AAErE,eAAO,MAAM,QAAQ,upBACioB,CAAC;AAEvpB,eAAO,MAAM,eAAe,sLACyJ,CAAC;AAEtL,eAAO,MAAM,mBAAmB;;;;CAI/B,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;;;;;;;;CAWpC,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;;;;;;;;CAWnC,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;CAGpC,CAAC;AAEF,eAAO,MAAM,kCAAkC;;;;;;;;;;CAmB9C,CAAC"}
@@ -1,11 +1,10 @@
1
1
  import { Env, Platform } from "../../shared/env.mjs";
2
- import { NONCE_URL, SIWE_LOGIN_URL, SRP_LOGIN_URL, OIDC_TOKEN_URL, PAIR_IDENTIFIERS, PAIR_PROFILES_URL, PROFILE_LINEAGE_URL } from "../authentication-jwt-bearer/services.mjs";
2
+ import { NONCE_URL, SIWE_LOGIN_URL, SRP_LOGIN_URL, OIDC_TOKEN_URL, PAIR_IDENTIFIERS, PROFILE_LINEAGE_URL } from "../authentication-jwt-bearer/services.mjs";
3
3
  export const MOCK_NONCE_URL = NONCE_URL(Env.PRD);
4
4
  export const MOCK_SRP_LOGIN_URL = SRP_LOGIN_URL(Env.PRD);
5
5
  export const MOCK_OIDC_TOKEN_URL = OIDC_TOKEN_URL(Env.PRD);
6
6
  export const MOCK_SIWE_LOGIN_URL = SIWE_LOGIN_URL(Env.PRD);
7
7
  export const MOCK_PAIR_IDENTIFIERS_URL = PAIR_IDENTIFIERS(Env.PRD);
8
- export const MOCK_PAIR_PROFILES_URL = PAIR_PROFILES_URL(Env.PRD);
9
8
  export const MOCK_PROFILE_LINEAGE_URL = PROFILE_LINEAGE_URL(Env.PRD);
10
9
  export const MOCK_JWT = 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImIwNzE2N2U2LWJjNWUtNDgyZC1hNjRhLWU1MjQ0MjY2MGU3NyJ9.eyJzdWIiOiI1MzE0ODc5YWM2NDU1OGI3OTQ5ZmI4NWIzMjg2ZjZjNjUwODAzYmFiMTY0Y2QyOWNmMmM3YzdmMjMzMWMwZTRlIiwiaWF0IjoxNzA2MTEzMDYyLCJleHAiOjE3NjkxODUwNjMsImlzcyI6ImF1dGgubWV0YW1hc2suaW8iLCJhdWQiOiJwb3J0Zm9saW8ubWV0YW1hc2suaW8ifQ.E5UL6oABNweS8t5a6IBTqTf7NLOJbrhJSmEcsr7kwLp4bGvcENJzACwnsHDkA6PlzfDV09ZhAGU_F3hlS0j-erbY0k0AFR-GAtyS7E9N02D8RgUDz5oDR65CKmzM8JilgFA8UvruJ6OJGogroaOSOqzRES_s8MjHpP47RJ9lXrUesajsbOudXbuksXWg5QmWip6LLvjwr8UUzcJzNQilyIhiEpo4WdzWM4R3VtTwr4rHnWEvtYnYCov1jmI2w3YQ48y0M-3Y9IOO0ov_vlITRrOnR7Y7fRUGLUFmU5msD8mNWRywjQFLHfJJ1yNP5aJ8TkuCK3sC6kcUH335IVvukQ';
11
10
  export const MOCK_ACCESS_JWT = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjQxMDI0NDQ4MDB9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';
@@ -35,20 +34,11 @@ export const MOCK_SRP_LOGIN_RESPONSE = {
35
34
  identifier_type: 'SRP',
36
35
  encrypted_storage_key: 'd2ddd8af8af905306f3e1456fb',
37
36
  },
38
- profile_aliases: [],
39
37
  };
40
38
  export const MOCK_OIDC_TOKEN_RESPONSE = {
41
39
  access_token: MOCK_ACCESS_JWT,
42
40
  expires_in: 3600,
43
41
  };
44
- export const MOCK_PAIR_PROFILES_RESPONSE = {
45
- profile: {
46
- identifier_id: MOCK_SRP_LOGIN_RESPONSE.profile.identifier_id,
47
- metametrics_id: MOCK_SRP_LOGIN_RESPONSE.profile.metametrics_id,
48
- profile_id: MOCK_SRP_LOGIN_RESPONSE.profile.profile_id,
49
- },
50
- profile_aliases: [],
51
- };
52
42
  export const MOCK_USER_PROFILE_LINEAGE_RESPONSE = {
53
43
  profile_id: 'f88227bd-b615-41a3-b0be-467dd781a4ad',
54
44
  created_at: '2025-10-01T12:00:00Z',
@@ -1 +1 @@
1
- {"version":3,"file":"auth.mjs","sourceRoot":"","sources":["../../../src/sdk/mocks/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,6BAAyB;AACjD,OAAO,EACL,SAAS,EACT,cAAc,EACd,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACpB,kDAA8C;AAE/C,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACjD,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACzD,MAAM,CAAC,MAAM,mBAAmB,GAAG,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC3D,MAAM,CAAC,MAAM,mBAAmB,GAAG,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC3D,MAAM,CAAC,MAAM,yBAAyB,GAAG,gBAAgB,CAAC,GAAG,CAAC,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AAC,OAAO,CAAC,UAAU;KACvD;IACD,eAAe,EAAE,EAAE;CACpB,CAAC;AAEF,MAAM,CAAC,MAAM,kCAAkC,GAAG;IAChD,UAAU,EAAE,sCAAsC;IAClD,UAAU,EAAE,sBAAsB;IAClC,OAAO,EAAE;QACP;YACE,cAAc,EAAE,sCAAsC;YACtD,KAAK,EAAE,QAAQ,CAAC,MAAM;YACtB,UAAU,EAAE,sBAAsB;YAClC,UAAU,EAAE,sBAAsB;YAClC,OAAO,EAAE,CAAC;SACX;QACD;YACE,cAAc,EAAE,sCAAsC;YACtD,KAAK,EAAE,QAAQ,CAAC,SAAS;YACzB,UAAU,EAAE,sBAAsB;YAClC,UAAU,EAAE,sBAAsB;YAClC,OAAO,EAAE,CAAC;SACX;KACF;CACF,CAAC","sourcesContent":["import { Env, Platform } from '../../shared/env';\nimport {\n NONCE_URL,\n SIWE_LOGIN_URL,\n SRP_LOGIN_URL,\n OIDC_TOKEN_URL,\n PAIR_IDENTIFIERS,\n PAIR_PROFILES_URL,\n PROFILE_LINEAGE_URL,\n} from '../authentication-jwt-bearer/services';\n\nexport const MOCK_NONCE_URL = NONCE_URL(Env.PRD);\nexport const MOCK_SRP_LOGIN_URL = SRP_LOGIN_URL(Env.PRD);\nexport const MOCK_OIDC_TOKEN_URL = OIDC_TOKEN_URL(Env.PRD);\nexport const MOCK_SIWE_LOGIN_URL = SIWE_LOGIN_URL(Env.PRD);\nexport const MOCK_PAIR_IDENTIFIERS_URL = PAIR_IDENTIFIERS(Env.PRD);\nexport const MOCK_PAIR_PROFILES_URL = PAIR_PROFILES_URL(Env.PRD);\nexport const MOCK_PROFILE_LINEAGE_URL = PROFILE_LINEAGE_URL(Env.PRD);\n\nexport const MOCK_JWT =\n 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImIwNzE2N2U2LWJjNWUtNDgyZC1hNjRhLWU1MjQ0MjY2MGU3NyJ9.eyJzdWIiOiI1MzE0ODc5YWM2NDU1OGI3OTQ5ZmI4NWIzMjg2ZjZjNjUwODAzYmFiMTY0Y2QyOWNmMmM3YzdmMjMzMWMwZTRlIiwiaWF0IjoxNzA2MTEzMDYyLCJleHAiOjE3NjkxODUwNjMsImlzcyI6ImF1dGgubWV0YW1hc2suaW8iLCJhdWQiOiJwb3J0Zm9saW8ubWV0YW1hc2suaW8ifQ.E5UL6oABNweS8t5a6IBTqTf7NLOJbrhJSmEcsr7kwLp4bGvcENJzACwnsHDkA6PlzfDV09ZhAGU_F3hlS0j-erbY0k0AFR-GAtyS7E9N02D8RgUDz5oDR65CKmzM8JilgFA8UvruJ6OJGogroaOSOqzRES_s8MjHpP47RJ9lXrUesajsbOudXbuksXWg5QmWip6LLvjwr8UUzcJzNQilyIhiEpo4WdzWM4R3VtTwr4rHnWEvtYnYCov1jmI2w3YQ48y0M-3Y9IOO0ov_vlITRrOnR7Y7fRUGLUFmU5msD8mNWRywjQFLHfJJ1yNP5aJ8TkuCK3sC6kcUH335IVvukQ';\n\nexport const MOCK_ACCESS_JWT =\n 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjQxMDI0NDQ4MDB9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';\n\nexport const MOCK_NONCE_RESPONSE = {\n nonce: 'xGMm9SoihEKeAEfV',\n identifier: '0xd8641601Cb79a94FD872fE42d5b4a067A44a7e88',\n expires_in: 300,\n};\n\nexport const MOCK_SIWE_LOGIN_RESPONSE = {\n token: MOCK_JWT,\n expires_in: 3600,\n profile: {\n profile_id: 'fa2bbf82-bd9a-4e6b-aabc-9ca0d0319b6e',\n metametrics_id: 'de742679-4960-4977-a415-4718b5f8e86c',\n identifier_id:\n 'ec9a4e9906836497efad2fd4d4290b34d2c6a2c0d93eb174aa3cd88a133adbaf',\n identifier_type: 'SIWE',\n encrypted_storage_key: '2c6a2c0d93eb174aa3cd88a133adbaf',\n },\n};\n\nexport const MOCK_SRP_LOGIN_RESPONSE = {\n token: MOCK_JWT,\n expires_in: 3600,\n profile: {\n profile_id: 'f88227bd-b615-41a3-b0be-467dd781a4ad',\n metametrics_id: '561ec651-a844-4b36-a451-04d6eac35740',\n identifier_id:\n 'da9a9fc7b09edde9cc23cec9b7e11a71fb0ab4d2ddd8af8af905306f3e1456fb',\n identifier_type: 'SRP',\n encrypted_storage_key: 'd2ddd8af8af905306f3e1456fb',\n },\n profile_aliases: [],\n};\n\nexport const MOCK_OIDC_TOKEN_RESPONSE = {\n access_token: MOCK_ACCESS_JWT,\n expires_in: 3600,\n};\n\nexport const MOCK_PAIR_PROFILES_RESPONSE = {\n profile: {\n identifier_id: MOCK_SRP_LOGIN_RESPONSE.profile.identifier_id,\n metametrics_id: MOCK_SRP_LOGIN_RESPONSE.profile.metametrics_id,\n profile_id: MOCK_SRP_LOGIN_RESPONSE.profile.profile_id,\n },\n profile_aliases: [],\n};\n\nexport const MOCK_USER_PROFILE_LINEAGE_RESPONSE = {\n profile_id: 'f88227bd-b615-41a3-b0be-467dd781a4ad',\n created_at: '2025-10-01T12:00:00Z',\n lineage: [\n {\n metametrics_id: '561ec651-a844-4b36-a451-04d6eac35740',\n agent: Platform.MOBILE,\n created_at: '2025-10-01T12:00:00Z',\n updated_at: '2025-10-01T12:00:00Z',\n counter: 1,\n },\n {\n metametrics_id: 'de742679-4960-4977-a415-4718b5f8e86c',\n agent: Platform.EXTENSION,\n created_at: '2025-10-01T12:00:00Z',\n updated_at: '2025-10-01T12:00:00Z',\n counter: 2,\n },\n ],\n};\n"]}
1
+ {"version":3,"file":"auth.mjs","sourceRoot":"","sources":["../../../src/sdk/mocks/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,6BAAyB;AACjD,OAAO,EACL,SAAS,EACT,cAAc,EACd,aAAa,EACb,cAAc,EACd,gBAAgB,EACh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4B;KACpD;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,YAAY,EAAE,eAAe;IAC7B,UAAU,EAAE,IAAI;CACjB,CAAC;AAEF,MAAM,CAAC,MAAM,kCAAkC,GAAG;IAChD,UAAU,EAAE,sCAAsC;IAClD,UAAU,EAAE,sBAAsB;IAClC,OAAO,EAAE;QACP;YACE,cAAc,EAAE,sCAAsC;YACtD,KAAK,EAAE,QAAQ,CAAC,MAAM;YACtB,UAAU,EAAE,sBAAsB;YAClC,UAAU,EAAE,sBAAsB;YAClC,OAAO,EAAE,CAAC;SACX;QACD;YACE,cAAc,EAAE,sCAAsC;YACtD,KAAK,EAAE,QAAQ,CAAC,SAAS;YACzB,UAAU,EAAE,sBAAsB;YAClC,UAAU,EAAE,sBAAsB;YAClC,OAAO,EAAE,CAAC;SACX;KACF;CACF,CAAC","sourcesContent":["import { Env, Platform } from '../../shared/env';\nimport {\n NONCE_URL,\n SIWE_LOGIN_URL,\n SRP_LOGIN_URL,\n OIDC_TOKEN_URL,\n PAIR_IDENTIFIERS,\n PROFILE_LINEAGE_URL,\n} from '../authentication-jwt-bearer/services';\n\nexport const MOCK_NONCE_URL = NONCE_URL(Env.PRD);\nexport const MOCK_SRP_LOGIN_URL = SRP_LOGIN_URL(Env.PRD);\nexport const MOCK_OIDC_TOKEN_URL = OIDC_TOKEN_URL(Env.PRD);\nexport const MOCK_SIWE_LOGIN_URL = SIWE_LOGIN_URL(Env.PRD);\nexport const MOCK_PAIR_IDENTIFIERS_URL = PAIR_IDENTIFIERS(Env.PRD);\nexport const MOCK_PROFILE_LINEAGE_URL = PROFILE_LINEAGE_URL(Env.PRD);\n\nexport const MOCK_JWT =\n 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImIwNzE2N2U2LWJjNWUtNDgyZC1hNjRhLWU1MjQ0MjY2MGU3NyJ9.eyJzdWIiOiI1MzE0ODc5YWM2NDU1OGI3OTQ5ZmI4NWIzMjg2ZjZjNjUwODAzYmFiMTY0Y2QyOWNmMmM3YzdmMjMzMWMwZTRlIiwiaWF0IjoxNzA2MTEzMDYyLCJleHAiOjE3NjkxODUwNjMsImlzcyI6ImF1dGgubWV0YW1hc2suaW8iLCJhdWQiOiJwb3J0Zm9saW8ubWV0YW1hc2suaW8ifQ.E5UL6oABNweS8t5a6IBTqTf7NLOJbrhJSmEcsr7kwLp4bGvcENJzACwnsHDkA6PlzfDV09ZhAGU_F3hlS0j-erbY0k0AFR-GAtyS7E9N02D8RgUDz5oDR65CKmzM8JilgFA8UvruJ6OJGogroaOSOqzRES_s8MjHpP47RJ9lXrUesajsbOudXbuksXWg5QmWip6LLvjwr8UUzcJzNQilyIhiEpo4WdzWM4R3VtTwr4rHnWEvtYnYCov1jmI2w3YQ48y0M-3Y9IOO0ov_vlITRrOnR7Y7fRUGLUFmU5msD8mNWRywjQFLHfJJ1yNP5aJ8TkuCK3sC6kcUH335IVvukQ';\n\nexport const MOCK_ACCESS_JWT =\n 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyLCJleHAiOjQxMDI0NDQ4MDB9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';\n\nexport const MOCK_NONCE_RESPONSE = {\n nonce: 'xGMm9SoihEKeAEfV',\n identifier: '0xd8641601Cb79a94FD872fE42d5b4a067A44a7e88',\n expires_in: 300,\n};\n\nexport const MOCK_SIWE_LOGIN_RESPONSE = {\n token: MOCK_JWT,\n expires_in: 3600,\n profile: {\n profile_id: 'fa2bbf82-bd9a-4e6b-aabc-9ca0d0319b6e',\n metametrics_id: 'de742679-4960-4977-a415-4718b5f8e86c',\n identifier_id:\n 'ec9a4e9906836497efad2fd4d4290b34d2c6a2c0d93eb174aa3cd88a133adbaf',\n identifier_type: 'SIWE',\n encrypted_storage_key: '2c6a2c0d93eb174aa3cd88a133adbaf',\n },\n};\n\nexport const MOCK_SRP_LOGIN_RESPONSE = {\n token: MOCK_JWT,\n expires_in: 3600,\n profile: {\n profile_id: 'f88227bd-b615-41a3-b0be-467dd781a4ad',\n metametrics_id: '561ec651-a844-4b36-a451-04d6eac35740',\n identifier_id:\n 'da9a9fc7b09edde9cc23cec9b7e11a71fb0ab4d2ddd8af8af905306f3e1456fb',\n identifier_type: 'SRP',\n encrypted_storage_key: 'd2ddd8af8af905306f3e1456fb',\n },\n};\n\nexport const MOCK_OIDC_TOKEN_RESPONSE = {\n access_token: MOCK_ACCESS_JWT,\n expires_in: 3600,\n};\n\nexport const MOCK_USER_PROFILE_LINEAGE_RESPONSE = {\n profile_id: 'f88227bd-b615-41a3-b0be-467dd781a4ad',\n created_at: '2025-10-01T12:00:00Z',\n lineage: [\n {\n metametrics_id: '561ec651-a844-4b36-a451-04d6eac35740',\n agent: Platform.MOBILE,\n created_at: '2025-10-01T12:00:00Z',\n updated_at: '2025-10-01T12:00:00Z',\n counter: 1,\n },\n {\n metametrics_id: 'de742679-4960-4977-a415-4718b5f8e86c',\n agent: Platform.EXTENSION,\n created_at: '2025-10-01T12:00:00Z',\n updated_at: '2025-10-01T12:00:00Z',\n counter: 2,\n },\n ],\n};\n"]}
@@ -27,7 +27,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
27
27
  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");
28
28
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
29
29
  };
30
- var _UserStorage_instances, _UserStorage_upsertUserStorage, _UserStorage_batchUpsertUserStorage, _UserStorage_batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries, _UserStorage_getUserStorage, _UserStorage_getUserStorageAllFeatureEntries, _UserStorage_deleteUserStorage, _UserStorage_deleteUserStorageAllFeatureEntries, _UserStorage_batchDeleteUserStorage, _UserStorage_createEntryKey, _UserStorage_getAuthorizationHeader, _UserStorage_getProfileScopeHeader;
30
+ var _UserStorage_instances, _UserStorage_upsertUserStorage, _UserStorage_batchUpsertUserStorage, _UserStorage_batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries, _UserStorage_getUserStorage, _UserStorage_getUserStorageAllFeatureEntries, _UserStorage_deleteUserStorage, _UserStorage_deleteUserStorageAllFeatureEntries, _UserStorage_batchDeleteUserStorage, _UserStorage_createEntryKey, _UserStorage_getAuthorizationHeader;
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
32
  exports.UserStorage = exports.STORAGE_URL = void 0;
33
33
  const encryption_1 = __importStar(require("../shared/encryption/index.cjs"));
@@ -83,7 +83,6 @@ _UserStorage_instances = new WeakSet(), _UserStorage_upsertUserStorage = async f
83
83
  const entropySourceId = options?.entropySourceId;
84
84
  try {
85
85
  const headers = await __classPrivateFieldGet(this, _UserStorage_instances, "m", _UserStorage_getAuthorizationHeader).call(this, entropySourceId);
86
- const profileScopeHeader = await __classPrivateFieldGet(this, _UserStorage_instances, "m", _UserStorage_getProfileScopeHeader).call(this, entropySourceId, options?.useCanonicalScope);
87
86
  const storageKey = await this.getStorageKey(entropySourceId);
88
87
  const encryptedData = await encryption_1.default.encryptString(data, storageKey, options?.nativeScryptCrypto);
89
88
  const encryptedPath = (0, storage_schema_1.createEntryPath)(path, storageKey);
@@ -93,7 +92,6 @@ _UserStorage_instances = new WeakSet(), _UserStorage_upsertUserStorage = async f
93
92
  headers: {
94
93
  'Content-Type': 'application/json',
95
94
  ...headers,
96
- ...profileScopeHeader,
97
95
  },
98
96
  body: JSON.stringify({ data: encryptedData }),
99
97
  });
@@ -117,7 +115,6 @@ _UserStorage_instances = new WeakSet(), _UserStorage_upsertUserStorage = async f
117
115
  return;
118
116
  }
119
117
  const headers = await __classPrivateFieldGet(this, _UserStorage_instances, "m", _UserStorage_getAuthorizationHeader).call(this, entropySourceId);
120
- const profileScopeHeader = await __classPrivateFieldGet(this, _UserStorage_instances, "m", _UserStorage_getProfileScopeHeader).call(this, entropySourceId, options?.useCanonicalScope);
121
118
  const storageKey = await this.getStorageKey(entropySourceId);
122
119
  const encryptedData = await Promise.all(data.map(async (d) => {
123
120
  return [
@@ -131,7 +128,6 @@ _UserStorage_instances = new WeakSet(), _UserStorage_upsertUserStorage = async f
131
128
  headers: {
132
129
  'Content-Type': 'application/json',
133
130
  ...headers,
134
- ...profileScopeHeader,
135
131
  },
136
132
  body: JSON.stringify({ data: Object.fromEntries(encryptedData) }),
137
133
  });
@@ -148,17 +144,15 @@ _UserStorage_instances = new WeakSet(), _UserStorage_upsertUserStorage = async f
148
144
  const errorMessage = e instanceof Error ? e.message : JSON.stringify(e ?? '');
149
145
  throw new errors_1.UserStorageError(`failed to batch upsert user storage for path '${path}'. ${errorMessage}`);
150
146
  }
151
- }, _UserStorage_batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries = async function _UserStorage_batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries(path, encryptedData, entropySourceId, useCanonicalScope) {
147
+ }, _UserStorage_batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries = async function _UserStorage_batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries(path, encryptedData, entropySourceId) {
152
148
  try {
153
149
  const headers = await __classPrivateFieldGet(this, _UserStorage_instances, "m", _UserStorage_getAuthorizationHeader).call(this, entropySourceId);
154
- const profileScopeHeader = await __classPrivateFieldGet(this, _UserStorage_instances, "m", _UserStorage_getProfileScopeHeader).call(this, entropySourceId, useCanonicalScope);
155
150
  const url = new URL((0, exports.STORAGE_URL)(this.env, path));
156
151
  const response = await fetch(url.toString(), {
157
152
  method: 'PUT',
158
153
  headers: {
159
154
  'Content-Type': 'application/json',
160
155
  ...headers,
161
- ...profileScopeHeader,
162
156
  },
163
157
  body: JSON.stringify({ data: Object.fromEntries(encryptedData) }),
164
158
  });
@@ -219,14 +213,12 @@ _UserStorage_instances = new WeakSet(), _UserStorage_upsertUserStorage = async f
219
213
  const entropySourceId = options?.entropySourceId;
220
214
  try {
221
215
  const headers = await __classPrivateFieldGet(this, _UserStorage_instances, "m", _UserStorage_getAuthorizationHeader).call(this, entropySourceId);
222
- const profileScopeHeader = await __classPrivateFieldGet(this, _UserStorage_instances, "m", _UserStorage_getProfileScopeHeader).call(this, entropySourceId, options?.useCanonicalScope);
223
216
  const storageKey = await this.getStorageKey(entropySourceId);
224
217
  const url = new URL((0, exports.STORAGE_URL)(this.env, path));
225
218
  const response = await fetch(url.toString(), {
226
219
  headers: {
227
220
  'Content-Type': 'application/json',
228
221
  ...headers,
229
- ...profileScopeHeader,
230
222
  },
231
223
  });
232
224
  if (response.status === 404) {
@@ -264,7 +256,7 @@ _UserStorage_instances = new WeakSet(), _UserStorage_upsertUserStorage = async f
264
256
  }
265
257
  // Re-upload the re-encrypted entries
266
258
  if (reEncryptedEntries.length) {
267
- await __classPrivateFieldGet(this, _UserStorage_instances, "m", _UserStorage_batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries).call(this, path, reEncryptedEntries, entropySourceId, options?.useCanonicalScope);
259
+ await __classPrivateFieldGet(this, _UserStorage_instances, "m", _UserStorage_batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries).call(this, path, reEncryptedEntries, entropySourceId);
268
260
  }
269
261
  return decryptedData;
270
262
  }
@@ -307,14 +299,12 @@ _UserStorage_instances = new WeakSet(), _UserStorage_upsertUserStorage = async f
307
299
  try {
308
300
  const entropySourceId = options?.entropySourceId;
309
301
  const headers = await __classPrivateFieldGet(this, _UserStorage_instances, "m", _UserStorage_getAuthorizationHeader).call(this, entropySourceId);
310
- const profileScopeHeader = await __classPrivateFieldGet(this, _UserStorage_instances, "m", _UserStorage_getProfileScopeHeader).call(this, entropySourceId, options?.useCanonicalScope);
311
302
  const url = new URL((0, exports.STORAGE_URL)(this.env, path));
312
303
  const response = await fetch(url.toString(), {
313
304
  method: 'DELETE',
314
305
  headers: {
315
306
  'Content-Type': 'application/json',
316
307
  ...headers,
317
- ...profileScopeHeader,
318
308
  },
319
309
  });
320
310
  if (response.status === 404) {
@@ -369,14 +359,5 @@ _UserStorage_instances = new WeakSet(), _UserStorage_upsertUserStorage = async f
369
359
  }, _UserStorage_getAuthorizationHeader = async function _UserStorage_getAuthorizationHeader(entropySourceId) {
370
360
  const accessToken = await this.config.auth.getAccessToken(entropySourceId);
371
361
  return { Authorization: `Bearer ${accessToken}` };
372
- }, _UserStorage_getProfileScopeHeader = async function _UserStorage_getProfileScopeHeader(entropySourceId, useCanonicalScope) {
373
- if (useCanonicalScope) {
374
- return {};
375
- }
376
- const profile = await this.config.auth.getUserProfile(entropySourceId);
377
- if (profile.profileId !== profile.canonicalProfileId) {
378
- return { 'x-profile-id': profile.profileId };
379
- }
380
- return {};
381
362
  };
382
363
  //# sourceMappingURL=user-storage.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"user-storage.cjs","sourceRoot":"","sources":["../../src/sdk/user-storage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6EAAoE;AACpE,kEAA6D;AAE7D,2CAA2C;AAO3C,iEAA2D;AAG3D,yCAA2D;AAEpD,MAAM,WAAW,GAAG,CAAC,GAAQ,EAAE,aAAqB,EAAE,EAAE,CAC7D,GAAG,IAAA,gBAAU,EAAC,GAAG,CAAC,CAAC,iBAAiB,uBAAuB,aAAa,EAAE,CAAC;AADhE,QAAA,WAAW,eACqD;AAuC7E,MAAa,WAAW;IAOtB,YAAY,MAAyB,EAAE,OAA2B;;QAChE,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,OAAO,CACX,IAA6C,EAC7C,KAAa,EACb,OAAkC;QAElC,MAAM,uBAAA,IAAI,8DAAmB,MAAvB,IAAI,EAAoB,IAAI,EAAE,KAAK,E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AK,CACb,uBAAuB,YAAY,CAAC,OAAO,YAAY,YAAY,CAAC,KAAK,EAAE,CAC5E,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,0BAA0B;QAC1B,MAAM,YAAY,GAChB,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QAC3D,MAAM,IAAI,yBAAgB,CACxB,iDAAiD,IAAI,MAAM,YAAY,EAAE,CAC1E,CAAC;IACJ,CAAC;AACH,CAAC,qEAEe,GAAW,EAAE,UAAkB;IAC7C,OAAO,IAAA,6BAAgB,EAAC,GAAG,GAAG,UAAU,CAAC,CAAC;AAC5C,CAAC,wCAED,KAAK,8CACH,eAAwB;IAExB,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;IAC3E,OAAO,EAAE,aAAa,EAAE,UAAU,WAAW,EAAE,EAAE,CAAC;AACpD,CAAC,uCAED,KAAK,6CACH,eAAwB,EACxB,iBAA2B;IAE3B,IAAI,iBAAiB,EAAE,CAAC;QACtB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;IACvE,IAAI,OAAO,CAAC,SAAS,KAAK,OAAO,CAAC,kBAAkB,EAAE,CAAC;QACrD,OAAO,EAAE,cAAc,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;IAC/C,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["import encryption, { createSHA256Hash } from '../shared/encryption';\nimport { SHARED_SALT } from '../shared/encryption/constants';\nimport type { Env } from '../shared/env';\nimport { getEnvUrls } from '../shared/env';\nimport type {\n UserStorageGenericFeatureKey,\n UserStorageGenericFeatureName,\n UserStorageGenericPathWithFeatureAndKey,\n UserStorageGenericPathWithFeatureOnly,\n} from '../shared/storage-schema';\nimport { createEntryPath } from '../shared/storage-schema';\nimport type { NativeScrypt } from '../shared/types/encryption';\nimport type { IBaseAuth } from './authentication-jwt-bearer/types';\nimport { NotFoundError, UserStorageError } from './errors';\n\nexport const STORAGE_URL = (env: Env, encryptedPath: string) =>\n `${getEnvUrls(env).userStorageApiUrl}/api/v1/userstorage/${encryptedPath}`;\n\nexport type UserStorageConfig = {\n env: Env;\n auth: Pick<IBaseAuth, 'getAccessToken' | 'getUserProfile' | 'signMessage'>;\n};\n\nexport type StorageOptions = {\n getStorageKey: (message: `metamask:${string}`) => Promise<string | null>;\n setStorageKey: (message: `metamask:${string}`, val: string) => Promise<void>;\n};\n\nexport type UserStorageOptions = {\n storage?: StorageOptions;\n};\n\nexport type GetUserStorageAllFeatureEntriesResponse = {\n HashedKey: string;\n\n Data: string;\n}[];\n\nexport type UserStorageMethodOptions = {\n nativeScryptCrypto?: NativeScrypt;\n entropySourceId?: string;\n /**\n * When true, skip the `x-profile-id` header on feature-scoped requests,\n * letting the server default to the JWT `sub` (canonical profile ID).\n * Useful during canonical storage migration (ADR 0005) to read/verify\n * data stored under the canonical key.\n */\n useCanonicalScope?: boolean;\n};\n\ntype ErrorMessage = {\n message: string;\n error: string;\n};\n\nexport class UserStorage {\n protected config: UserStorageConfig;\n\n public options: UserStorageOptions;\n\n protected env: Env;\n\n constructor(config: UserStorageConfig, options: UserStorageOptions) {\n this.env = config.env;\n this.config = config;\n this.options = options;\n }\n\n async setItem(\n path: UserStorageGenericPathWithFeatureAndKey,\n value: string,\n options?: UserStorageMethodOptions,\n ): Promise<void> {\n await this.#upsertUserStorage(path, value, options);\n }\n\n async batchSetItems(\n path: UserStorageGenericFeatureName,\n values: [UserStorageGenericFeatureKey, string][],\n options?: UserStorageMethodOptions,\n ) {\n await this.#batchUpsertUserStorage(path, values, options);\n }\n\n async getItem(\n path: UserStorageGenericPathWithFeatureAndKey,\n options?: UserStorageMethodOptions,\n ): Promise<string | null> {\n return this.#getUserStorage(path, options);\n }\n\n async getAllFeatureItems(\n path: UserStorageGenericFeatureName,\n options?: UserStorageMethodOptions,\n ): Promise<string[] | null> {\n return this.#getUserStorageAllFeatureEntries(path, options);\n }\n\n async deleteItem(\n path: UserStorageGenericPathWithFeatureAndKey,\n options?: UserStorageMethodOptions,\n ): Promise<void> {\n return this.#deleteUserStorage(path, options);\n }\n\n async deleteAllFeatureItems(\n path: UserStorageGenericFeatureName,\n options?: UserStorageMethodOptions,\n ): Promise<void> {\n return this.#deleteUserStorageAllFeatureEntries(path, options);\n }\n\n async batchDeleteItems(\n path: UserStorageGenericFeatureName,\n values: UserStorageGenericFeatureKey[],\n options?: UserStorageMethodOptions,\n ) {\n return this.#batchDeleteUserStorage(path, values, options);\n }\n\n async getStorageKey(entropySourceId?: string): Promise<string> {\n const userProfile = await this.config.auth.getUserProfile(entropySourceId);\n const message = `metamask:${userProfile.profileId}` as const;\n\n const storageKey = await this.options.storage?.getStorageKey(message);\n if (storageKey) {\n return storageKey;\n }\n\n const storageKeySignature = await this.config.auth.signMessage(\n message,\n entropySourceId,\n );\n const hashedStorageKeySignature = createSHA256Hash(storageKeySignature);\n await this.options.storage?.setStorageKey(\n message,\n hashedStorageKeySignature,\n );\n return hashedStorageKeySignature;\n }\n\n async #upsertUserStorage(\n path: UserStorageGenericPathWithFeatureAndKey,\n data: string,\n options?: UserStorageMethodOptions,\n ): Promise<void> {\n const entropySourceId = options?.entropySourceId;\n try {\n const headers = await this.#getAuthorizationHeader(entropySourceId);\n const profileScopeHeader = await this.#getProfileScopeHeader(\n entropySourceId,\n options?.useCanonicalScope,\n );\n const storageKey = await this.getStorageKey(entropySourceId);\n const encryptedData = await encryption.encryptString(\n data,\n storageKey,\n options?.nativeScryptCrypto,\n );\n const encryptedPath = createEntryPath(path, storageKey);\n\n const url = new URL(STORAGE_URL(this.env, encryptedPath));\n\n const response = await fetch(url.toString(), {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n ...profileScopeHeader,\n },\n body: JSON.stringify({ data: encryptedData }),\n });\n\n if (!response.ok) {\n const responseBody: ErrorMessage = await response.json().catch(() => ({\n message: 'unknown',\n error: 'unknown',\n }));\n throw new Error(\n `HTTP error message: ${responseBody.message}, error: ${responseBody.error}`,\n );\n }\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n throw new UserStorageError(\n `failed to upsert user storage for path '${path}'. ${errorMessage}`,\n );\n }\n }\n\n async #batchUpsertUserStorage(\n path: UserStorageGenericPathWithFeatureOnly,\n data: [string, string][],\n options?: UserStorageMethodOptions,\n ): Promise<void> {\n const entropySourceId = options?.entropySourceId;\n try {\n if (!data.length) {\n return;\n }\n\n const headers = await this.#getAuthorizationHeader(entropySourceId);\n const profileScopeHeader = await this.#getProfileScopeHeader(\n entropySourceId,\n options?.useCanonicalScope,\n );\n const storageKey = await this.getStorageKey(entropySourceId);\n\n const encryptedData = await Promise.all(\n data.map(async (d) => {\n return [\n this.#createEntryKey(d[0], storageKey),\n await encryption.encryptString(\n d[1],\n storageKey,\n options?.nativeScryptCrypto,\n ),\n ];\n }),\n );\n\n const url = new URL(STORAGE_URL(this.env, path));\n\n const response = await fetch(url.toString(), {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n ...profileScopeHeader,\n },\n body: JSON.stringify({ data: Object.fromEntries(encryptedData) }),\n });\n\n if (!response.ok) {\n const responseBody: ErrorMessage = await response.json().catch(() => ({\n message: 'unknown',\n error: 'unknown',\n }));\n throw new Error(\n `HTTP error message: ${responseBody.message}, error: ${responseBody.error}`,\n );\n }\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n throw new UserStorageError(\n `failed to batch upsert user storage for path '${path}'. ${errorMessage}`,\n );\n }\n }\n\n async #batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries(\n path: UserStorageGenericPathWithFeatureOnly,\n encryptedData: [string, string][],\n entropySourceId?: string,\n useCanonicalScope?: boolean,\n ): Promise<void> {\n try {\n const headers = await this.#getAuthorizationHeader(entropySourceId);\n const profileScopeHeader = await this.#getProfileScopeHeader(\n entropySourceId,\n useCanonicalScope,\n );\n\n const url = new URL(STORAGE_URL(this.env, path));\n\n const response = await fetch(url.toString(), {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n ...profileScopeHeader,\n },\n body: JSON.stringify({ data: Object.fromEntries(encryptedData) }),\n });\n\n // istanbul ignore next\n if (!response.ok) {\n const responseBody: ErrorMessage = await response.json().catch(() => ({\n message: 'unknown',\n error: 'unknown',\n }));\n throw new Error(\n `HTTP error message: ${responseBody.message}, error: ${responseBody.error}`,\n );\n }\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n // istanbul ignore next\n throw new UserStorageError(\n `failed to batch upsert user storage for path '${path}'. ${errorMessage}`,\n );\n }\n }\n\n async #getUserStorage(\n path: UserStorageGenericPathWithFeatureAndKey,\n options?: UserStorageMethodOptions,\n ): Promise<string | null> {\n const entropySourceId = options?.entropySourceId;\n try {\n const headers = await this.#getAuthorizationHeader(entropySourceId);\n const storageKey = await this.getStorageKey(entropySourceId);\n const encryptedPath = createEntryPath(path, storageKey);\n\n const url = new URL(STORAGE_URL(this.env, encryptedPath));\n\n const response = await fetch(url.toString(), {\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n },\n });\n\n if (response.status === 404) {\n return null;\n }\n\n if (!response.ok) {\n const responseBody = (await response.json()) as ErrorMessage;\n throw new Error(\n `HTTP error message: ${responseBody.message}, error: ${responseBody.error}`,\n );\n }\n\n const userStorage = await response.json();\n const encryptedData = userStorage?.Data ?? null;\n\n if (!encryptedData) {\n return null;\n }\n\n const decryptedData = await encryption.decryptString(\n encryptedData,\n storageKey,\n options?.nativeScryptCrypto,\n );\n\n // Re-encrypt the entry if it was encrypted with a random salt\n const salt = encryption.getSalt(encryptedData);\n if (salt.toString() !== SHARED_SALT.toString()) {\n await this.#upsertUserStorage(path, decryptedData, options);\n }\n\n return decryptedData;\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n\n throw new UserStorageError(\n `failed to get user storage for path '${path}'. ${errorMessage}`,\n );\n }\n }\n\n async #getUserStorageAllFeatureEntries(\n path: UserStorageGenericPathWithFeatureOnly,\n options?: UserStorageMethodOptions,\n ): Promise<string[] | null> {\n const entropySourceId = options?.entropySourceId;\n try {\n const headers = await this.#getAuthorizationHeader(entropySourceId);\n const profileScopeHeader = await this.#getProfileScopeHeader(\n entropySourceId,\n options?.useCanonicalScope,\n );\n const storageKey = await this.getStorageKey(entropySourceId);\n\n const url = new URL(STORAGE_URL(this.env, path));\n\n const response = await fetch(url.toString(), {\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n ...profileScopeHeader,\n },\n });\n\n if (response.status === 404) {\n return null;\n }\n\n if (!response.ok) {\n const responseBody = (await response.json()) as ErrorMessage;\n throw new Error(\n `HTTP error message: ${responseBody.message}, error: ${responseBody.error}`,\n );\n }\n\n const userStorage: GetUserStorageAllFeatureEntriesResponse | null =\n await response.json();\n\n if (!Array.isArray(userStorage)) {\n return null;\n }\n\n const decryptedData: string[] = [];\n const reEncryptedEntries: [string, string][] = [];\n\n for (const entry of userStorage) {\n if (!entry.Data) {\n continue;\n }\n\n try {\n const data = await encryption.decryptString(\n entry.Data,\n storageKey,\n options?.nativeScryptCrypto,\n );\n decryptedData.push(data);\n\n // Re-encrypt the entry was encrypted with a random salt\n const salt = encryption.getSalt(entry.Data);\n if (salt.toString() !== SHARED_SALT.toString()) {\n reEncryptedEntries.push([\n entry.HashedKey,\n await encryption.encryptString(\n data,\n storageKey,\n options?.nativeScryptCrypto,\n ),\n ]);\n }\n } catch {\n // do nothing\n }\n }\n\n // Re-upload the re-encrypted entries\n if (reEncryptedEntries.length) {\n await this.#batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries(\n path,\n reEncryptedEntries,\n entropySourceId,\n options?.useCanonicalScope,\n );\n }\n\n return decryptedData;\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n\n throw new UserStorageError(\n `failed to get user storage for path '${path}'. ${errorMessage}`,\n );\n }\n }\n\n async #deleteUserStorage(\n path: UserStorageGenericPathWithFeatureAndKey,\n options?: UserStorageMethodOptions,\n ): Promise<void> {\n const entropySourceId = options?.entropySourceId;\n try {\n const headers = await this.#getAuthorizationHeader(entropySourceId);\n const storageKey = await this.getStorageKey(entropySourceId);\n const encryptedPath = createEntryPath(path, storageKey);\n\n const url = new URL(STORAGE_URL(this.env, encryptedPath));\n\n const response = await fetch(url.toString(), {\n method: 'DELETE',\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n },\n });\n\n if (response.status === 404) {\n throw new NotFoundError(\n `feature/key set not found for path '${path}'.`,\n );\n }\n\n if (!response.ok) {\n const responseBody = (await response.json()) as ErrorMessage;\n throw new Error(\n `HTTP error message: ${responseBody.message}, error: ${responseBody.error}`,\n );\n }\n } catch (e) {\n if (e instanceof NotFoundError) {\n throw e;\n }\n\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n\n throw new UserStorageError(\n `failed to delete user storage for path '${path}'. ${errorMessage}`,\n );\n }\n }\n\n async #deleteUserStorageAllFeatureEntries(\n path: UserStorageGenericPathWithFeatureOnly,\n options?: UserStorageMethodOptions,\n ): Promise<void> {\n try {\n const entropySourceId = options?.entropySourceId;\n const headers = await this.#getAuthorizationHeader(entropySourceId);\n const profileScopeHeader = await this.#getProfileScopeHeader(\n entropySourceId,\n options?.useCanonicalScope,\n );\n\n const url = new URL(STORAGE_URL(this.env, path));\n\n const response = await fetch(url.toString(), {\n method: 'DELETE',\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n ...profileScopeHeader,\n },\n });\n\n if (response.status === 404) {\n throw new NotFoundError(`feature not found for path '${path}'.`);\n }\n\n if (!response.ok) {\n const responseBody = (await response.json()) as ErrorMessage;\n throw new Error(\n `HTTP error message: ${responseBody.message}, error: ${responseBody.error}`,\n );\n }\n } catch (e) {\n if (e instanceof NotFoundError) {\n throw e;\n }\n\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n\n throw new UserStorageError(\n `failed to delete user storage for path '${path}'. ${errorMessage}`,\n );\n }\n }\n\n async #batchDeleteUserStorage(\n path: UserStorageGenericPathWithFeatureOnly,\n keysToDelete: string[],\n options?: UserStorageMethodOptions,\n ): Promise<void> {\n try {\n if (!keysToDelete.length) {\n return;\n }\n\n const entropySourceId = options?.entropySourceId;\n const headers = await this.#getAuthorizationHeader(entropySourceId);\n const storageKey = await this.getStorageKey(entropySourceId);\n\n const rawEntryKeys = keysToDelete.map((d) =>\n this.#createEntryKey(d, storageKey),\n );\n\n const url = new URL(STORAGE_URL(this.env, path));\n\n const response = await fetch(url.toString(), {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n },\n\n body: JSON.stringify({ batch_delete: rawEntryKeys }),\n });\n\n if (!response.ok) {\n const responseBody: ErrorMessage = await response.json().catch(() => ({\n message: 'unknown',\n error: 'unknown',\n }));\n throw new Error(\n `HTTP error message: ${responseBody.message}, error: ${responseBody.error}`,\n );\n }\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n throw new UserStorageError(\n `failed to batch delete user storage for path '${path}'. ${errorMessage}`,\n );\n }\n }\n\n #createEntryKey(key: string, storageKey: string): string {\n return createSHA256Hash(key + storageKey);\n }\n\n async #getAuthorizationHeader(\n entropySourceId?: string,\n ): Promise<{ Authorization: string }> {\n const accessToken = await this.config.auth.getAccessToken(entropySourceId);\n return { Authorization: `Bearer ${accessToken}` };\n }\n\n async #getProfileScopeHeader(\n entropySourceId?: string,\n useCanonicalScope?: boolean,\n ): Promise<Record<string, string>> {\n if (useCanonicalScope) {\n return {};\n }\n const profile = await this.config.auth.getUserProfile(entropySourceId);\n if (profile.profileId !== profile.canonicalProfileId) {\n return { 'x-profile-id': profile.profileId };\n }\n return {};\n }\n}\n"]}
1
+ {"version":3,"file":"user-storage.cjs","sourceRoot":"","sources":["../../src/sdk/user-storage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6EAAoE;AACpE,kEAA6D;AAE7D,2CAA2C;AAO3C,iEAA2D;AAG3D,yCAA2D;AAEpD,MAAM,WAAW,GAAG,CAAC,GAAQ,EAAE,aAAqB,EAAE,EAAE,CAC7D,GAAG,IAAA,gBAAU,EAAC,GAAG,CAAC,CAAC,iBAAiB,uBAAuB,aAAa,EAAE,CAAC;AADhE,QAAA,WAAW,eACqD;AAgC7E,MAAa,WAAW;IAOtB,YAAY,MAAyB,EAAE,OAA2B;;QAChE,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,OAAO,CACX,IAA6C,EAC7C,KAAa,EACb,OAAkC;QAElC,MAAM,uBAAA,IAAI,8DAAmB,MAAvB,IAAI,EAAoB,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,aAAa,CACjB,IAAmC,EACnC,MAAgD,EAChD,OAAkC;QAElC,MAAM,uBAAA,IAAI,mEAAwB,MAA5B,IAAI,EAAyB,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,OAAO,CACX,IAA6C,EAC7C,OAAkC;QAElC,OAAO,uBAAA,IAAI,2DAAgB,MAApB,I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AC,EAAE,EAAE,CAAC;YACjB,MAAM,YAAY,GAAiB,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;gBACpE,OAAO,EAAE,SAAS;gBAClB,KAAK,EAAE,SAAS;aACjB,CAAC,CAAC,CAAC;YACJ,MAAM,IAAI,KAAK,CACb,uBAAuB,YAAY,CAAC,OAAO,YAAY,YAAY,CAAC,KAAK,EAAE,CAC5E,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,0BAA0B;QAC1B,MAAM,YAAY,GAChB,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QAC3D,MAAM,IAAI,yBAAgB,CACxB,iDAAiD,IAAI,MAAM,YAAY,EAAE,CAC1E,CAAC;IACJ,CAAC;AACH,CAAC,qEAEe,GAAW,EAAE,UAAkB;IAC7C,OAAO,IAAA,6BAAgB,EAAC,GAAG,GAAG,UAAU,CAAC,CAAC;AAC5C,CAAC,wCAED,KAAK,8CACH,eAAwB;IAExB,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;IAC3E,OAAO,EAAE,aAAa,EAAE,UAAU,WAAW,EAAE,EAAE,CAAC;AACpD,CAAC","sourcesContent":["import encryption, { createSHA256Hash } from '../shared/encryption';\nimport { SHARED_SALT } from '../shared/encryption/constants';\nimport type { Env } from '../shared/env';\nimport { getEnvUrls } from '../shared/env';\nimport type {\n UserStorageGenericFeatureKey,\n UserStorageGenericFeatureName,\n UserStorageGenericPathWithFeatureAndKey,\n UserStorageGenericPathWithFeatureOnly,\n} from '../shared/storage-schema';\nimport { createEntryPath } from '../shared/storage-schema';\nimport type { NativeScrypt } from '../shared/types/encryption';\nimport type { IBaseAuth } from './authentication-jwt-bearer/types';\nimport { NotFoundError, UserStorageError } from './errors';\n\nexport const STORAGE_URL = (env: Env, encryptedPath: string) =>\n `${getEnvUrls(env).userStorageApiUrl}/api/v1/userstorage/${encryptedPath}`;\n\nexport type UserStorageConfig = {\n env: Env;\n auth: Pick<IBaseAuth, 'getAccessToken' | 'getUserProfile' | 'signMessage'>;\n};\n\nexport type StorageOptions = {\n getStorageKey: (message: `metamask:${string}`) => Promise<string | null>;\n setStorageKey: (message: `metamask:${string}`, val: string) => Promise<void>;\n};\n\nexport type UserStorageOptions = {\n storage?: StorageOptions;\n};\n\nexport type GetUserStorageAllFeatureEntriesResponse = {\n HashedKey: string;\n\n Data: string;\n}[];\n\nexport type UserStorageMethodOptions = {\n nativeScryptCrypto?: NativeScrypt;\n entropySourceId?: string;\n};\n\ntype ErrorMessage = {\n message: string;\n error: string;\n};\n\nexport class UserStorage {\n protected config: UserStorageConfig;\n\n public options: UserStorageOptions;\n\n protected env: Env;\n\n constructor(config: UserStorageConfig, options: UserStorageOptions) {\n this.env = config.env;\n this.config = config;\n this.options = options;\n }\n\n async setItem(\n path: UserStorageGenericPathWithFeatureAndKey,\n value: string,\n options?: UserStorageMethodOptions,\n ): Promise<void> {\n await this.#upsertUserStorage(path, value, options);\n }\n\n async batchSetItems(\n path: UserStorageGenericFeatureName,\n values: [UserStorageGenericFeatureKey, string][],\n options?: UserStorageMethodOptions,\n ) {\n await this.#batchUpsertUserStorage(path, values, options);\n }\n\n async getItem(\n path: UserStorageGenericPathWithFeatureAndKey,\n options?: UserStorageMethodOptions,\n ): Promise<string | null> {\n return this.#getUserStorage(path, options);\n }\n\n async getAllFeatureItems(\n path: UserStorageGenericFeatureName,\n options?: UserStorageMethodOptions,\n ): Promise<string[] | null> {\n return this.#getUserStorageAllFeatureEntries(path, options);\n }\n\n async deleteItem(\n path: UserStorageGenericPathWithFeatureAndKey,\n options?: UserStorageMethodOptions,\n ): Promise<void> {\n return this.#deleteUserStorage(path, options);\n }\n\n async deleteAllFeatureItems(\n path: UserStorageGenericFeatureName,\n options?: UserStorageMethodOptions,\n ): Promise<void> {\n return this.#deleteUserStorageAllFeatureEntries(path, options);\n }\n\n async batchDeleteItems(\n path: UserStorageGenericFeatureName,\n values: UserStorageGenericFeatureKey[],\n options?: UserStorageMethodOptions,\n ) {\n return this.#batchDeleteUserStorage(path, values, options);\n }\n\n async getStorageKey(entropySourceId?: string): Promise<string> {\n const userProfile = await this.config.auth.getUserProfile(entropySourceId);\n const message = `metamask:${userProfile.profileId}` as const;\n\n const storageKey = await this.options.storage?.getStorageKey(message);\n if (storageKey) {\n return storageKey;\n }\n\n const storageKeySignature = await this.config.auth.signMessage(\n message,\n entropySourceId,\n );\n const hashedStorageKeySignature = createSHA256Hash(storageKeySignature);\n await this.options.storage?.setStorageKey(\n message,\n hashedStorageKeySignature,\n );\n return hashedStorageKeySignature;\n }\n\n async #upsertUserStorage(\n path: UserStorageGenericPathWithFeatureAndKey,\n data: string,\n options?: UserStorageMethodOptions,\n ): Promise<void> {\n const entropySourceId = options?.entropySourceId;\n try {\n const headers = await this.#getAuthorizationHeader(entropySourceId);\n const storageKey = await this.getStorageKey(entropySourceId);\n const encryptedData = await encryption.encryptString(\n data,\n storageKey,\n options?.nativeScryptCrypto,\n );\n const encryptedPath = createEntryPath(path, storageKey);\n\n const url = new URL(STORAGE_URL(this.env, encryptedPath));\n\n const response = await fetch(url.toString(), {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n },\n body: JSON.stringify({ data: encryptedData }),\n });\n\n if (!response.ok) {\n const responseBody: ErrorMessage = await response.json().catch(() => ({\n message: 'unknown',\n error: 'unknown',\n }));\n throw new Error(\n `HTTP error message: ${responseBody.message}, error: ${responseBody.error}`,\n );\n }\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n throw new UserStorageError(\n `failed to upsert user storage for path '${path}'. ${errorMessage}`,\n );\n }\n }\n\n async #batchUpsertUserStorage(\n path: UserStorageGenericPathWithFeatureOnly,\n data: [string, string][],\n options?: UserStorageMethodOptions,\n ): Promise<void> {\n const entropySourceId = options?.entropySourceId;\n try {\n if (!data.length) {\n return;\n }\n\n const headers = await this.#getAuthorizationHeader(entropySourceId);\n const storageKey = await this.getStorageKey(entropySourceId);\n\n const encryptedData = await Promise.all(\n data.map(async (d) => {\n return [\n this.#createEntryKey(d[0], storageKey),\n await encryption.encryptString(\n d[1],\n storageKey,\n options?.nativeScryptCrypto,\n ),\n ];\n }),\n );\n\n const url = new URL(STORAGE_URL(this.env, path));\n\n const response = await fetch(url.toString(), {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n },\n body: JSON.stringify({ data: Object.fromEntries(encryptedData) }),\n });\n\n if (!response.ok) {\n const responseBody: ErrorMessage = await response.json().catch(() => ({\n message: 'unknown',\n error: 'unknown',\n }));\n throw new Error(\n `HTTP error message: ${responseBody.message}, error: ${responseBody.error}`,\n );\n }\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n throw new UserStorageError(\n `failed to batch upsert user storage for path '${path}'. ${errorMessage}`,\n );\n }\n }\n\n async #batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries(\n path: UserStorageGenericPathWithFeatureOnly,\n encryptedData: [string, string][],\n entropySourceId?: string,\n ): Promise<void> {\n try {\n const headers = await this.#getAuthorizationHeader(entropySourceId);\n\n const url = new URL(STORAGE_URL(this.env, path));\n\n const response = await fetch(url.toString(), {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n },\n body: JSON.stringify({ data: Object.fromEntries(encryptedData) }),\n });\n\n // istanbul ignore next\n if (!response.ok) {\n const responseBody: ErrorMessage = await response.json().catch(() => ({\n message: 'unknown',\n error: 'unknown',\n }));\n throw new Error(\n `HTTP error message: ${responseBody.message}, error: ${responseBody.error}`,\n );\n }\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n // istanbul ignore next\n throw new UserStorageError(\n `failed to batch upsert user storage for path '${path}'. ${errorMessage}`,\n );\n }\n }\n\n async #getUserStorage(\n path: UserStorageGenericPathWithFeatureAndKey,\n options?: UserStorageMethodOptions,\n ): Promise<string | null> {\n const entropySourceId = options?.entropySourceId;\n try {\n const headers = await this.#getAuthorizationHeader(entropySourceId);\n const storageKey = await this.getStorageKey(entropySourceId);\n const encryptedPath = createEntryPath(path, storageKey);\n\n const url = new URL(STORAGE_URL(this.env, encryptedPath));\n\n const response = await fetch(url.toString(), {\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n },\n });\n\n if (response.status === 404) {\n return null;\n }\n\n if (!response.ok) {\n const responseBody = (await response.json()) as ErrorMessage;\n throw new Error(\n `HTTP error message: ${responseBody.message}, error: ${responseBody.error}`,\n );\n }\n\n const userStorage = await response.json();\n const encryptedData = userStorage?.Data ?? null;\n\n if (!encryptedData) {\n return null;\n }\n\n const decryptedData = await encryption.decryptString(\n encryptedData,\n storageKey,\n options?.nativeScryptCrypto,\n );\n\n // Re-encrypt the entry if it was encrypted with a random salt\n const salt = encryption.getSalt(encryptedData);\n if (salt.toString() !== SHARED_SALT.toString()) {\n await this.#upsertUserStorage(path, decryptedData, options);\n }\n\n return decryptedData;\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n\n throw new UserStorageError(\n `failed to get user storage for path '${path}'. ${errorMessage}`,\n );\n }\n }\n\n async #getUserStorageAllFeatureEntries(\n path: UserStorageGenericPathWithFeatureOnly,\n options?: UserStorageMethodOptions,\n ): Promise<string[] | null> {\n const entropySourceId = options?.entropySourceId;\n try {\n const headers = await this.#getAuthorizationHeader(entropySourceId);\n const storageKey = await this.getStorageKey(entropySourceId);\n\n const url = new URL(STORAGE_URL(this.env, path));\n\n const response = await fetch(url.toString(), {\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n },\n });\n\n if (response.status === 404) {\n return null;\n }\n\n if (!response.ok) {\n const responseBody = (await response.json()) as ErrorMessage;\n throw new Error(\n `HTTP error message: ${responseBody.message}, error: ${responseBody.error}`,\n );\n }\n\n const userStorage: GetUserStorageAllFeatureEntriesResponse | null =\n await response.json();\n\n if (!Array.isArray(userStorage)) {\n return null;\n }\n\n const decryptedData: string[] = [];\n const reEncryptedEntries: [string, string][] = [];\n\n for (const entry of userStorage) {\n if (!entry.Data) {\n continue;\n }\n\n try {\n const data = await encryption.decryptString(\n entry.Data,\n storageKey,\n options?.nativeScryptCrypto,\n );\n decryptedData.push(data);\n\n // Re-encrypt the entry was encrypted with a random salt\n const salt = encryption.getSalt(entry.Data);\n if (salt.toString() !== SHARED_SALT.toString()) {\n reEncryptedEntries.push([\n entry.HashedKey,\n await encryption.encryptString(\n data,\n storageKey,\n options?.nativeScryptCrypto,\n ),\n ]);\n }\n } catch {\n // do nothing\n }\n }\n\n // Re-upload the re-encrypted entries\n if (reEncryptedEntries.length) {\n await this.#batchUpsertUserStorageWithAlreadyHashedAndEncryptedEntries(\n path,\n reEncryptedEntries,\n entropySourceId,\n );\n }\n\n return decryptedData;\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n\n throw new UserStorageError(\n `failed to get user storage for path '${path}'. ${errorMessage}`,\n );\n }\n }\n\n async #deleteUserStorage(\n path: UserStorageGenericPathWithFeatureAndKey,\n options?: UserStorageMethodOptions,\n ): Promise<void> {\n const entropySourceId = options?.entropySourceId;\n try {\n const headers = await this.#getAuthorizationHeader(entropySourceId);\n const storageKey = await this.getStorageKey(entropySourceId);\n const encryptedPath = createEntryPath(path, storageKey);\n\n const url = new URL(STORAGE_URL(this.env, encryptedPath));\n\n const response = await fetch(url.toString(), {\n method: 'DELETE',\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n },\n });\n\n if (response.status === 404) {\n throw new NotFoundError(\n `feature/key set not found for path '${path}'.`,\n );\n }\n\n if (!response.ok) {\n const responseBody = (await response.json()) as ErrorMessage;\n throw new Error(\n `HTTP error message: ${responseBody.message}, error: ${responseBody.error}`,\n );\n }\n } catch (e) {\n if (e instanceof NotFoundError) {\n throw e;\n }\n\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n\n throw new UserStorageError(\n `failed to delete user storage for path '${path}'. ${errorMessage}`,\n );\n }\n }\n\n async #deleteUserStorageAllFeatureEntries(\n path: UserStorageGenericPathWithFeatureOnly,\n options?: UserStorageMethodOptions,\n ): Promise<void> {\n try {\n const entropySourceId = options?.entropySourceId;\n const headers = await this.#getAuthorizationHeader(entropySourceId);\n\n const url = new URL(STORAGE_URL(this.env, path));\n\n const response = await fetch(url.toString(), {\n method: 'DELETE',\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n },\n });\n\n if (response.status === 404) {\n throw new NotFoundError(`feature not found for path '${path}'.`);\n }\n\n if (!response.ok) {\n const responseBody = (await response.json()) as ErrorMessage;\n throw new Error(\n `HTTP error message: ${responseBody.message}, error: ${responseBody.error}`,\n );\n }\n } catch (e) {\n if (e instanceof NotFoundError) {\n throw e;\n }\n\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n\n throw new UserStorageError(\n `failed to delete user storage for path '${path}'. ${errorMessage}`,\n );\n }\n }\n\n async #batchDeleteUserStorage(\n path: UserStorageGenericPathWithFeatureOnly,\n keysToDelete: string[],\n options?: UserStorageMethodOptions,\n ): Promise<void> {\n try {\n if (!keysToDelete.length) {\n return;\n }\n\n const entropySourceId = options?.entropySourceId;\n const headers = await this.#getAuthorizationHeader(entropySourceId);\n const storageKey = await this.getStorageKey(entropySourceId);\n\n const rawEntryKeys = keysToDelete.map((d) =>\n this.#createEntryKey(d, storageKey),\n );\n\n const url = new URL(STORAGE_URL(this.env, path));\n\n const response = await fetch(url.toString(), {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n },\n\n body: JSON.stringify({ batch_delete: rawEntryKeys }),\n });\n\n if (!response.ok) {\n const responseBody: ErrorMessage = await response.json().catch(() => ({\n message: 'unknown',\n error: 'unknown',\n }));\n throw new Error(\n `HTTP error message: ${responseBody.message}, error: ${responseBody.error}`,\n );\n }\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n throw new UserStorageError(\n `failed to batch delete user storage for path '${path}'. ${errorMessage}`,\n );\n }\n }\n\n #createEntryKey(key: string, storageKey: string): string {\n return createSHA256Hash(key + storageKey);\n }\n\n async #getAuthorizationHeader(\n entropySourceId?: string,\n ): Promise<{ Authorization: string }> {\n const accessToken = await this.config.auth.getAccessToken(entropySourceId);\n return { Authorization: `Bearer ${accessToken}` };\n }\n}\n"]}
@@ -21,13 +21,6 @@ export type GetUserStorageAllFeatureEntriesResponse = {
21
21
  export type UserStorageMethodOptions = {
22
22
  nativeScryptCrypto?: NativeScrypt;
23
23
  entropySourceId?: string;
24
- /**
25
- * When true, skip the `x-profile-id` header on feature-scoped requests,
26
- * letting the server default to the JWT `sub` (canonical profile ID).
27
- * Useful during canonical storage migration (ADR 0005) to read/verify
28
- * data stored under the canonical key.
29
- */
30
- useCanonicalScope?: boolean;
31
24
  };
32
25
  export declare class UserStorage {
33
26
  #private;
@@ -1 +1 @@
1
- {"version":3,"file":"user-storage.d.cts","sourceRoot":"","sources":["../../src/sdk/user-storage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,0BAAsB;AAEzC,OAAO,KAAK,EACV,4BAA4B,EAC5B,6BAA6B,EAC7B,uCAAuC,EAExC,qCAAiC;AAElC,OAAO,KAAK,EAAE,YAAY,EAAE,uCAAmC;AAC/D,OAAO,KAAK,EAAE,SAAS,EAAE,8CAA0C;AAGnE,eAAO,MAAM,WAAW,QAAS,GAAG,iBAAiB,MAAM,WACiB,CAAC;AAE7E,MAAM,MAA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,EAAE,wBAAwB,GACjC,OAAO,CAAC,IAAI,CAAC;IAIV,qBAAqB,CACzB,IAAI,EAAE,6BAA6B,EACnC,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,IAAI,CAAC;IAIV,gBAAgB,CACpB,IAAI,EAAE,6BAA6B,EACnC,MAAM,EAAE,4BAA4B,EAAE,EACtC,OAAO,CAAC,EAAE,wBAAwB;IAK9B,aAAa,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAgd/D"}
@@ -21,13 +21,6 @@ export type GetUserStorageAllFeatureEntriesResponse = {
21
21
  export type UserStorageMethodOptions = {
22
22
  nativeScryptCrypto?: NativeScrypt;
23
23
  entropySourceId?: string;
24
- /**
25
- * When true, skip the `x-profile-id` header on feature-scoped requests,
26
- * letting the server default to the JWT `sub` (canonical profile ID).
27
- * Useful during canonical storage migration (ADR 0005) to read/verify
28
- * data stored under the canonical key.
29
- */
30
- useCanonicalScope?: boolean;
31
24
  };
32
25
  export declare class UserStorage {
33
26
  #private;
@@ -1 +1 @@
1
- {"version":3,"file":"user-storage.d.mts","sourceRoot":"","sources":["../../src/sdk/user-storage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,0BAAsB;AAEzC,OAAO,KAAK,EACV,4BAA4B,EAC5B,6BAA6B,EAC7B,uCAAuC,EAExC,qCAAiC;AAElC,OAAO,KAAK,EAAE,YAAY,EAAE,uCAAmC;AAC/D,OAAO,KAAK,EAAE,SAAS,EAAE,8CAA0C;AAGnE,eAAO,MAAM,WAAW,QAAS,GAAG,iBAAiB,MAAM,WACiB,CAAC;AAE7E,MAAM,MAAM,iBAAiB,GAAG;IAC9B,GAAG,EAAE,GAAG,CAAC;IACT,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,gBAAgB,GAAG,gBAAgB,GAAG,aAAa,CAAC,CAAC;CAC5E,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,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