@metamask/profile-sync-controller 16.0.0 → 17.1.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.
Files changed (126) hide show
  1. package/CHANGELOG.md +24 -1
  2. package/dist/controllers/authentication/AuthenticationController.cjs +60 -24
  3. package/dist/controllers/authentication/AuthenticationController.cjs.map +1 -1
  4. package/dist/controllers/authentication/AuthenticationController.d.cts +6 -4
  5. package/dist/controllers/authentication/AuthenticationController.d.cts.map +1 -1
  6. package/dist/controllers/authentication/AuthenticationController.d.mts +6 -4
  7. package/dist/controllers/authentication/AuthenticationController.d.mts.map +1 -1
  8. package/dist/controllers/authentication/AuthenticationController.mjs +61 -25
  9. package/dist/controllers/authentication/AuthenticationController.mjs.map +1 -1
  10. package/dist/controllers/authentication/auth-snap-requests.cjs +25 -4
  11. package/dist/controllers/authentication/auth-snap-requests.cjs.map +1 -1
  12. package/dist/controllers/authentication/auth-snap-requests.d.cts +12 -2
  13. package/dist/controllers/authentication/auth-snap-requests.d.cts.map +1 -1
  14. package/dist/controllers/authentication/auth-snap-requests.d.mts +12 -2
  15. package/dist/controllers/authentication/auth-snap-requests.d.mts.map +1 -1
  16. package/dist/controllers/authentication/auth-snap-requests.mjs +23 -3
  17. package/dist/controllers/authentication/auth-snap-requests.mjs.map +1 -1
  18. package/dist/controllers/authentication/mocks/mockResponses.cjs +36 -3
  19. package/dist/controllers/authentication/mocks/mockResponses.cjs.map +1 -1
  20. package/dist/controllers/authentication/mocks/mockResponses.d.cts +7 -5
  21. package/dist/controllers/authentication/mocks/mockResponses.d.cts.map +1 -1
  22. package/dist/controllers/authentication/mocks/mockResponses.d.mts +7 -5
  23. package/dist/controllers/authentication/mocks/mockResponses.d.mts.map +1 -1
  24. package/dist/controllers/authentication/mocks/mockResponses.mjs +36 -3
  25. package/dist/controllers/authentication/mocks/mockResponses.mjs.map +1 -1
  26. package/dist/controllers/user-storage/UserStorageController.cjs +79 -27
  27. package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -1
  28. package/dist/controllers/user-storage/UserStorageController.d.cts +26 -10
  29. package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -1
  30. package/dist/controllers/user-storage/UserStorageController.d.mts +26 -10
  31. package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -1
  32. package/dist/controllers/user-storage/UserStorageController.mjs +79 -27
  33. package/dist/controllers/user-storage/UserStorageController.mjs.map +1 -1
  34. package/dist/controllers/user-storage/account-syncing/controller-integration.cjs +22 -26
  35. package/dist/controllers/user-storage/account-syncing/controller-integration.cjs.map +1 -1
  36. package/dist/controllers/user-storage/account-syncing/controller-integration.d.cts +5 -2
  37. package/dist/controllers/user-storage/account-syncing/controller-integration.d.cts.map +1 -1
  38. package/dist/controllers/user-storage/account-syncing/controller-integration.d.mts +5 -2
  39. package/dist/controllers/user-storage/account-syncing/controller-integration.d.mts.map +1 -1
  40. package/dist/controllers/user-storage/account-syncing/controller-integration.mjs +23 -27
  41. package/dist/controllers/user-storage/account-syncing/controller-integration.mjs.map +1 -1
  42. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.cjs +8 -8
  43. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.cjs.map +1 -1
  44. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.cts.map +1 -1
  45. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.d.mts.map +1 -1
  46. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.mjs +8 -8
  47. package/dist/controllers/user-storage/account-syncing/setup-subscriptions.mjs.map +1 -1
  48. package/dist/controllers/user-storage/account-syncing/sync-utils.cjs +16 -7
  49. package/dist/controllers/user-storage/account-syncing/sync-utils.cjs.map +1 -1
  50. package/dist/controllers/user-storage/account-syncing/sync-utils.d.cts +6 -2
  51. package/dist/controllers/user-storage/account-syncing/sync-utils.d.cts.map +1 -1
  52. package/dist/controllers/user-storage/account-syncing/sync-utils.d.mts +6 -2
  53. package/dist/controllers/user-storage/account-syncing/sync-utils.d.mts.map +1 -1
  54. package/dist/controllers/user-storage/account-syncing/sync-utils.mjs +16 -7
  55. package/dist/controllers/user-storage/account-syncing/sync-utils.mjs.map +1 -1
  56. package/dist/controllers/user-storage/account-syncing/utils.cjs +1 -42
  57. package/dist/controllers/user-storage/account-syncing/utils.cjs.map +1 -1
  58. package/dist/controllers/user-storage/account-syncing/utils.d.cts +1 -18
  59. package/dist/controllers/user-storage/account-syncing/utils.d.cts.map +1 -1
  60. package/dist/controllers/user-storage/account-syncing/utils.d.mts +1 -18
  61. package/dist/controllers/user-storage/account-syncing/utils.d.mts.map +1 -1
  62. package/dist/controllers/user-storage/account-syncing/utils.mjs +0 -39
  63. package/dist/controllers/user-storage/account-syncing/utils.mjs.map +1 -1
  64. package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs.map +1 -1
  65. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.cts.map +1 -1
  66. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.mts.map +1 -1
  67. package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs.map +1 -1
  68. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs +22 -22
  69. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs.map +1 -1
  70. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts +4 -4
  71. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts.map +1 -1
  72. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts +4 -4
  73. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts.map +1 -1
  74. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs +22 -22
  75. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs.map +1 -1
  76. package/dist/sdk/authentication-jwt-bearer/services.cjs.map +1 -1
  77. package/dist/sdk/authentication-jwt-bearer/services.d.cts.map +1 -1
  78. package/dist/sdk/authentication-jwt-bearer/services.d.mts.map +1 -1
  79. package/dist/sdk/authentication-jwt-bearer/services.mjs.map +1 -1
  80. package/dist/sdk/authentication-jwt-bearer/types.cjs.map +1 -1
  81. package/dist/sdk/authentication-jwt-bearer/types.d.cts +8 -8
  82. package/dist/sdk/authentication-jwt-bearer/types.d.cts.map +1 -1
  83. package/dist/sdk/authentication-jwt-bearer/types.d.mts +8 -8
  84. package/dist/sdk/authentication-jwt-bearer/types.d.mts.map +1 -1
  85. package/dist/sdk/authentication-jwt-bearer/types.mjs.map +1 -1
  86. package/dist/sdk/authentication.cjs +8 -11
  87. package/dist/sdk/authentication.cjs.map +1 -1
  88. package/dist/sdk/authentication.d.cts +4 -4
  89. package/dist/sdk/authentication.d.cts.map +1 -1
  90. package/dist/sdk/authentication.d.mts +4 -4
  91. package/dist/sdk/authentication.d.mts.map +1 -1
  92. package/dist/sdk/authentication.mjs +8 -11
  93. package/dist/sdk/authentication.mjs.map +1 -1
  94. package/dist/sdk/user-storage.cjs +38 -32
  95. package/dist/sdk/user-storage.cjs.map +1 -1
  96. package/dist/sdk/user-storage.d.cts +4 -3
  97. package/dist/sdk/user-storage.d.cts.map +1 -1
  98. package/dist/sdk/user-storage.d.mts +4 -3
  99. package/dist/sdk/user-storage.d.mts.map +1 -1
  100. package/dist/sdk/user-storage.mjs +38 -32
  101. package/dist/sdk/user-storage.mjs.map +1 -1
  102. package/dist/sdk/utils/messaging-signing-snap-requests.cjs +16 -4
  103. package/dist/sdk/utils/messaging-signing-snap-requests.cjs.map +1 -1
  104. package/dist/sdk/utils/messaging-signing-snap-requests.d.cts +2 -2
  105. package/dist/sdk/utils/messaging-signing-snap-requests.d.cts.map +1 -1
  106. package/dist/sdk/utils/messaging-signing-snap-requests.d.mts +2 -2
  107. package/dist/sdk/utils/messaging-signing-snap-requests.d.mts.map +1 -1
  108. package/dist/sdk/utils/messaging-signing-snap-requests.mjs +16 -4
  109. package/dist/sdk/utils/messaging-signing-snap-requests.mjs.map +1 -1
  110. package/dist/shared/storage-schema.cjs +1 -6
  111. package/dist/shared/storage-schema.cjs.map +1 -1
  112. package/dist/shared/storage-schema.d.cts +0 -1
  113. package/dist/shared/storage-schema.d.cts.map +1 -1
  114. package/dist/shared/storage-schema.d.mts +0 -1
  115. package/dist/shared/storage-schema.d.mts.map +1 -1
  116. package/dist/shared/storage-schema.mjs +0 -4
  117. package/dist/shared/storage-schema.mjs.map +1 -1
  118. package/dist/shared/utils/event-queue.cjs +24 -0
  119. package/dist/shared/utils/event-queue.cjs.map +1 -0
  120. package/dist/shared/utils/event-queue.d.cts +6 -0
  121. package/dist/shared/utils/event-queue.d.cts.map +1 -0
  122. package/dist/shared/utils/event-queue.d.mts +6 -0
  123. package/dist/shared/utils/event-queue.d.mts.map +1 -0
  124. package/dist/shared/utils/event-queue.mjs +20 -0
  125. package/dist/shared/utils/event-queue.mjs.map +1 -0
  126. package/package.json +4 -4
@@ -1,37 +1,58 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createSnapSignMessageRequest = exports.createSnapPublicKeyRequest = void 0;
3
+ exports.createSnapSignMessageRequest = exports.createSnapAllPublicKeysRequest = exports.createSnapPublicKeyRequest = void 0;
4
4
  const snapId = 'npm:@metamask/message-signing-snap';
5
5
  /**
6
6
  * Constructs Request to Message Signing Snap to get Public Key
7
7
  *
8
+ * @param entropySourceId - The source of entropy to use for key generation,
9
+ * when multiple sources are available (Multi-SRP).
8
10
  * @returns Snap Public Key Request
9
11
  */
10
- function createSnapPublicKeyRequest() {
12
+ function createSnapPublicKeyRequest(entropySourceId) {
11
13
  return {
12
14
  snapId,
13
15
  origin: 'metamask',
14
16
  handler: 'onRpcRequest',
15
17
  request: {
16
18
  method: 'getPublicKey',
19
+ ...(entropySourceId ? { params: { entropySourceId } } : {}),
17
20
  },
18
21
  };
19
22
  }
20
23
  exports.createSnapPublicKeyRequest = createSnapPublicKeyRequest;
24
+ /**
25
+ * Constructs Request to Message Signing Snap to get [EntropySourceId, PublicKey][]
26
+ *
27
+ * @returns Snap getAllPublicKeys Request
28
+ */
29
+ function createSnapAllPublicKeysRequest() {
30
+ return {
31
+ snapId,
32
+ origin: 'metamask',
33
+ handler: 'onRpcRequest',
34
+ request: {
35
+ method: 'getAllPublicKeys',
36
+ },
37
+ };
38
+ }
39
+ exports.createSnapAllPublicKeysRequest = createSnapAllPublicKeysRequest;
21
40
  /**
22
41
  * Constructs Request to get Message Signing Snap to sign a message.
23
42
  *
24
43
  * @param message - message to sign
44
+ * @param entropySourceId - The source of entropy to use for key generation,
45
+ * when multiple sources are available (Multi-SRP).
25
46
  * @returns Snap Sign Message Request
26
47
  */
27
- function createSnapSignMessageRequest(message) {
48
+ function createSnapSignMessageRequest(message, entropySourceId) {
28
49
  return {
29
50
  snapId,
30
51
  origin: 'metamask',
31
52
  handler: 'onRpcRequest',
32
53
  request: {
33
54
  method: 'signMessage',
34
- params: { message },
55
+ params: { message, ...(entropySourceId ? { entropySourceId } : {}) },
35
56
  },
36
57
  };
37
58
  }
@@ -1 +1 @@
1
- {"version":3,"file":"auth-snap-requests.cjs","sourceRoot":"","sources":["../../../src/controllers/authentication/auth-snap-requests.ts"],"names":[],"mappings":";;;AAMA,MAAM,MAAM,GAAG,oCAA8C,CAAC;AAE9D;;;;GAIG;AACH,SAAgB,0BAA0B;IACxC,OAAO;QACL,MAAM;QACN,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE,cAAqB;QAC9B,OAAO,EAAE;YACP,MAAM,EAAE,cAAc;SACvB;KACF,CAAC;AACJ,CAAC;AATD,gEASC;AAED;;;;;GAKG;AACH,SAAgB,4BAA4B,CAC1C,OAA6B;IAE7B,OAAO;QACL,MAAM;QACN,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE,cAAqB;QAC9B,OAAO,EAAE;YACP,MAAM,EAAE,aAAa;YACrB,MAAM,EAAE,EAAE,OAAO,EAAE;SACpB;KACF,CAAC;AACJ,CAAC;AAZD,oEAYC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { HandleSnapRequest } from '@metamask/snaps-controllers';\nimport type { SnapId } from '@metamask/snaps-sdk';\n\ntype SnapRPCRequest = Parameters<HandleSnapRequest['handler']>[0];\n\nconst snapId = 'npm:@metamask/message-signing-snap' as SnapId;\n\n/**\n * Constructs Request to Message Signing Snap to get Public Key\n *\n * @returns Snap Public Key Request\n */\nexport function createSnapPublicKeyRequest(): SnapRPCRequest {\n return {\n snapId,\n origin: 'metamask',\n handler: 'onRpcRequest' as any,\n request: {\n method: 'getPublicKey',\n },\n };\n}\n\n/**\n * Constructs Request to get Message Signing Snap to sign a message.\n *\n * @param message - message to sign\n * @returns Snap Sign Message Request\n */\nexport function createSnapSignMessageRequest(\n message: `metamask:${string}`,\n): SnapRPCRequest {\n return {\n snapId,\n origin: 'metamask',\n handler: 'onRpcRequest' as any,\n request: {\n method: 'signMessage',\n params: { message },\n },\n };\n}\n"]}
1
+ {"version":3,"file":"auth-snap-requests.cjs","sourceRoot":"","sources":["../../../src/controllers/authentication/auth-snap-requests.ts"],"names":[],"mappings":";;;AAMA,MAAM,MAAM,GAAG,oCAA8C,CAAC;AAE9D;;;;;;GAMG;AACH,SAAgB,0BAA0B,CACxC,eAAwB;IAExB,OAAO;QACL,MAAM;QACN,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE,cAAqB;QAC9B,OAAO,EAAE;YACP,MAAM,EAAE,cAAc;YACtB,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC5D;KACF,CAAC;AACJ,CAAC;AAZD,gEAYC;AAED;;;;GAIG;AACH,SAAgB,8BAA8B;IAC5C,OAAO;QACL,MAAM;QACN,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE,cAAqB;QAC9B,OAAO,EAAE;YACP,MAAM,EAAE,kBAAkB;SAC3B;KACF,CAAC;AACJ,CAAC;AATD,wEASC;AAED;;;;;;;GAOG;AACH,SAAgB,4BAA4B,CAC1C,OAA6B,EAC7B,eAAwB;IAExB,OAAO;QACL,MAAM;QACN,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE,cAAqB;QAC9B,OAAO,EAAE;YACP,MAAM,EAAE,aAAa;YACrB,MAAM,EAAE,EAAE,OAAO,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE;SACrE;KACF,CAAC;AACJ,CAAC;AAbD,oEAaC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { HandleSnapRequest } from '@metamask/snaps-controllers';\nimport type { SnapId } from '@metamask/snaps-sdk';\n\ntype SnapRPCRequest = Parameters<HandleSnapRequest['handler']>[0];\n\nconst snapId = 'npm:@metamask/message-signing-snap' as SnapId;\n\n/**\n * Constructs Request to Message Signing Snap to get Public Key\n *\n * @param entropySourceId - The source of entropy to use for key generation,\n * when multiple sources are available (Multi-SRP).\n * @returns Snap Public Key Request\n */\nexport function createSnapPublicKeyRequest(\n entropySourceId?: string,\n): SnapRPCRequest {\n return {\n snapId,\n origin: 'metamask',\n handler: 'onRpcRequest' as any,\n request: {\n method: 'getPublicKey',\n ...(entropySourceId ? { params: { entropySourceId } } : {}),\n },\n };\n}\n\n/**\n * Constructs Request to Message Signing Snap to get [EntropySourceId, PublicKey][]\n *\n * @returns Snap getAllPublicKeys Request\n */\nexport function createSnapAllPublicKeysRequest(): SnapRPCRequest {\n return {\n snapId,\n origin: 'metamask',\n handler: 'onRpcRequest' as any,\n request: {\n method: 'getAllPublicKeys',\n },\n };\n}\n\n/**\n * Constructs Request to get Message Signing Snap to sign a message.\n *\n * @param message - message to sign\n * @param entropySourceId - The source of entropy to use for key generation,\n * when multiple sources are available (Multi-SRP).\n * @returns Snap Sign Message Request\n */\nexport function createSnapSignMessageRequest(\n message: `metamask:${string}`,\n entropySourceId?: string,\n): SnapRPCRequest {\n return {\n snapId,\n origin: 'metamask',\n handler: 'onRpcRequest' as any,\n request: {\n method: 'signMessage',\n params: { message, ...(entropySourceId ? { entropySourceId } : {}) },\n },\n };\n}\n"]}
@@ -3,15 +3,25 @@ type SnapRPCRequest = Parameters<HandleSnapRequest['handler']>[0];
3
3
  /**
4
4
  * Constructs Request to Message Signing Snap to get Public Key
5
5
  *
6
+ * @param entropySourceId - The source of entropy to use for key generation,
7
+ * when multiple sources are available (Multi-SRP).
6
8
  * @returns Snap Public Key Request
7
9
  */
8
- export declare function createSnapPublicKeyRequest(): SnapRPCRequest;
10
+ export declare function createSnapPublicKeyRequest(entropySourceId?: string): SnapRPCRequest;
11
+ /**
12
+ * Constructs Request to Message Signing Snap to get [EntropySourceId, PublicKey][]
13
+ *
14
+ * @returns Snap getAllPublicKeys Request
15
+ */
16
+ export declare function createSnapAllPublicKeysRequest(): SnapRPCRequest;
9
17
  /**
10
18
  * Constructs Request to get Message Signing Snap to sign a message.
11
19
  *
12
20
  * @param message - message to sign
21
+ * @param entropySourceId - The source of entropy to use for key generation,
22
+ * when multiple sources are available (Multi-SRP).
13
23
  * @returns Snap Sign Message Request
14
24
  */
15
- export declare function createSnapSignMessageRequest(message: `metamask:${string}`): SnapRPCRequest;
25
+ export declare function createSnapSignMessageRequest(message: `metamask:${string}`, entropySourceId?: string): SnapRPCRequest;
16
26
  export {};
17
27
  //# sourceMappingURL=auth-snap-requests.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth-snap-requests.d.cts","sourceRoot":"","sources":["../../../src/controllers/authentication/auth-snap-requests.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,oCAAoC;AAGrE,KAAK,cAAc,GAAG,UAAU,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAIlE;;;;GAIG;AACH,wBAAgB,0BAA0B,IAAI,cAAc,CAS3D;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,YAAY,MAAM,EAAE,GAC5B,cAAc,CAUhB"}
1
+ {"version":3,"file":"auth-snap-requests.d.cts","sourceRoot":"","sources":["../../../src/controllers/authentication/auth-snap-requests.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,oCAAoC;AAGrE,KAAK,cAAc,GAAG,UAAU,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAIlE;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,eAAe,CAAC,EAAE,MAAM,GACvB,cAAc,CAUhB;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,IAAI,cAAc,CAS/D;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,YAAY,MAAM,EAAE,EAC7B,eAAe,CAAC,EAAE,MAAM,GACvB,cAAc,CAUhB"}
@@ -3,15 +3,25 @@ type SnapRPCRequest = Parameters<HandleSnapRequest['handler']>[0];
3
3
  /**
4
4
  * Constructs Request to Message Signing Snap to get Public Key
5
5
  *
6
+ * @param entropySourceId - The source of entropy to use for key generation,
7
+ * when multiple sources are available (Multi-SRP).
6
8
  * @returns Snap Public Key Request
7
9
  */
8
- export declare function createSnapPublicKeyRequest(): SnapRPCRequest;
10
+ export declare function createSnapPublicKeyRequest(entropySourceId?: string): SnapRPCRequest;
11
+ /**
12
+ * Constructs Request to Message Signing Snap to get [EntropySourceId, PublicKey][]
13
+ *
14
+ * @returns Snap getAllPublicKeys Request
15
+ */
16
+ export declare function createSnapAllPublicKeysRequest(): SnapRPCRequest;
9
17
  /**
10
18
  * Constructs Request to get Message Signing Snap to sign a message.
11
19
  *
12
20
  * @param message - message to sign
21
+ * @param entropySourceId - The source of entropy to use for key generation,
22
+ * when multiple sources are available (Multi-SRP).
13
23
  * @returns Snap Sign Message Request
14
24
  */
15
- export declare function createSnapSignMessageRequest(message: `metamask:${string}`): SnapRPCRequest;
25
+ export declare function createSnapSignMessageRequest(message: `metamask:${string}`, entropySourceId?: string): SnapRPCRequest;
16
26
  export {};
17
27
  //# sourceMappingURL=auth-snap-requests.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth-snap-requests.d.mts","sourceRoot":"","sources":["../../../src/controllers/authentication/auth-snap-requests.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,oCAAoC;AAGrE,KAAK,cAAc,GAAG,UAAU,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAIlE;;;;GAIG;AACH,wBAAgB,0BAA0B,IAAI,cAAc,CAS3D;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,YAAY,MAAM,EAAE,GAC5B,cAAc,CAUhB"}
1
+ {"version":3,"file":"auth-snap-requests.d.mts","sourceRoot":"","sources":["../../../src/controllers/authentication/auth-snap-requests.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,oCAAoC;AAGrE,KAAK,cAAc,GAAG,UAAU,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAIlE;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,eAAe,CAAC,EAAE,MAAM,GACvB,cAAc,CAUhB;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,IAAI,cAAc,CAS/D;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,YAAY,MAAM,EAAE,EAC7B,eAAe,CAAC,EAAE,MAAM,GACvB,cAAc,CAUhB"}
@@ -2,15 +2,33 @@ const snapId = 'npm:@metamask/message-signing-snap';
2
2
  /**
3
3
  * Constructs Request to Message Signing Snap to get Public Key
4
4
  *
5
+ * @param entropySourceId - The source of entropy to use for key generation,
6
+ * when multiple sources are available (Multi-SRP).
5
7
  * @returns Snap Public Key Request
6
8
  */
7
- export function createSnapPublicKeyRequest() {
9
+ export function createSnapPublicKeyRequest(entropySourceId) {
8
10
  return {
9
11
  snapId,
10
12
  origin: 'metamask',
11
13
  handler: 'onRpcRequest',
12
14
  request: {
13
15
  method: 'getPublicKey',
16
+ ...(entropySourceId ? { params: { entropySourceId } } : {}),
17
+ },
18
+ };
19
+ }
20
+ /**
21
+ * Constructs Request to Message Signing Snap to get [EntropySourceId, PublicKey][]
22
+ *
23
+ * @returns Snap getAllPublicKeys Request
24
+ */
25
+ export function createSnapAllPublicKeysRequest() {
26
+ return {
27
+ snapId,
28
+ origin: 'metamask',
29
+ handler: 'onRpcRequest',
30
+ request: {
31
+ method: 'getAllPublicKeys',
14
32
  },
15
33
  };
16
34
  }
@@ -18,16 +36,18 @@ export function createSnapPublicKeyRequest() {
18
36
  * Constructs Request to get Message Signing Snap to sign a message.
19
37
  *
20
38
  * @param message - message to sign
39
+ * @param entropySourceId - The source of entropy to use for key generation,
40
+ * when multiple sources are available (Multi-SRP).
21
41
  * @returns Snap Sign Message Request
22
42
  */
23
- export function createSnapSignMessageRequest(message) {
43
+ export function createSnapSignMessageRequest(message, entropySourceId) {
24
44
  return {
25
45
  snapId,
26
46
  origin: 'metamask',
27
47
  handler: 'onRpcRequest',
28
48
  request: {
29
49
  method: 'signMessage',
30
- params: { message },
50
+ params: { message, ...(entropySourceId ? { entropySourceId } : {}) },
31
51
  },
32
52
  };
33
53
  }
@@ -1 +1 @@
1
- {"version":3,"file":"auth-snap-requests.mjs","sourceRoot":"","sources":["../../../src/controllers/authentication/auth-snap-requests.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,GAAG,oCAA8C,CAAC;AAE9D;;;;GAIG;AACH,MAAM,UAAU,0BAA0B;IACxC,OAAO;QACL,MAAM;QACN,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE,cAAqB;QAC9B,OAAO,EAAE;YACP,MAAM,EAAE,cAAc;SACvB;KACF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAC1C,OAA6B;IAE7B,OAAO;QACL,MAAM;QACN,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE,cAAqB;QAC9B,OAAO,EAAE;YACP,MAAM,EAAE,aAAa;YACrB,MAAM,EAAE,EAAE,OAAO,EAAE;SACpB;KACF,CAAC;AACJ,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { HandleSnapRequest } from '@metamask/snaps-controllers';\nimport type { SnapId } from '@metamask/snaps-sdk';\n\ntype SnapRPCRequest = Parameters<HandleSnapRequest['handler']>[0];\n\nconst snapId = 'npm:@metamask/message-signing-snap' as SnapId;\n\n/**\n * Constructs Request to Message Signing Snap to get Public Key\n *\n * @returns Snap Public Key Request\n */\nexport function createSnapPublicKeyRequest(): SnapRPCRequest {\n return {\n snapId,\n origin: 'metamask',\n handler: 'onRpcRequest' as any,\n request: {\n method: 'getPublicKey',\n },\n };\n}\n\n/**\n * Constructs Request to get Message Signing Snap to sign a message.\n *\n * @param message - message to sign\n * @returns Snap Sign Message Request\n */\nexport function createSnapSignMessageRequest(\n message: `metamask:${string}`,\n): SnapRPCRequest {\n return {\n snapId,\n origin: 'metamask',\n handler: 'onRpcRequest' as any,\n request: {\n method: 'signMessage',\n params: { message },\n },\n };\n}\n"]}
1
+ {"version":3,"file":"auth-snap-requests.mjs","sourceRoot":"","sources":["../../../src/controllers/authentication/auth-snap-requests.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,GAAG,oCAA8C,CAAC;AAE9D;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CACxC,eAAwB;IAExB,OAAO;QACL,MAAM;QACN,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE,cAAqB;QAC9B,OAAO,EAAE;YACP,MAAM,EAAE,cAAc;YACtB,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC5D;KACF,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,8BAA8B;IAC5C,OAAO;QACL,MAAM;QACN,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE,cAAqB;QAC9B,OAAO,EAAE;YACP,MAAM,EAAE,kBAAkB;SAC3B;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,4BAA4B,CAC1C,OAA6B,EAC7B,eAAwB;IAExB,OAAO;QACL,MAAM;QACN,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE,cAAqB;QAC9B,OAAO,EAAE;YACP,MAAM,EAAE,aAAa;YACrB,MAAM,EAAE,EAAE,OAAO,EAAE,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE;SACrE;KACF,CAAC;AACJ,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { HandleSnapRequest } from '@metamask/snaps-controllers';\nimport type { SnapId } from '@metamask/snaps-sdk';\n\ntype SnapRPCRequest = Parameters<HandleSnapRequest['handler']>[0];\n\nconst snapId = 'npm:@metamask/message-signing-snap' as SnapId;\n\n/**\n * Constructs Request to Message Signing Snap to get Public Key\n *\n * @param entropySourceId - The source of entropy to use for key generation,\n * when multiple sources are available (Multi-SRP).\n * @returns Snap Public Key Request\n */\nexport function createSnapPublicKeyRequest(\n entropySourceId?: string,\n): SnapRPCRequest {\n return {\n snapId,\n origin: 'metamask',\n handler: 'onRpcRequest' as any,\n request: {\n method: 'getPublicKey',\n ...(entropySourceId ? { params: { entropySourceId } } : {}),\n },\n };\n}\n\n/**\n * Constructs Request to Message Signing Snap to get [EntropySourceId, PublicKey][]\n *\n * @returns Snap getAllPublicKeys Request\n */\nexport function createSnapAllPublicKeysRequest(): SnapRPCRequest {\n return {\n snapId,\n origin: 'metamask',\n handler: 'onRpcRequest' as any,\n request: {\n method: 'getAllPublicKeys',\n },\n };\n}\n\n/**\n * Constructs Request to get Message Signing Snap to sign a message.\n *\n * @param message - message to sign\n * @param entropySourceId - The source of entropy to use for key generation,\n * when multiple sources are available (Multi-SRP).\n * @returns Snap Sign Message Request\n */\nexport function createSnapSignMessageRequest(\n message: `metamask:${string}`,\n entropySourceId?: string,\n): SnapRPCRequest {\n return {\n snapId,\n origin: 'metamask',\n handler: 'onRpcRequest' as any,\n request: {\n method: 'signMessage',\n params: { message, ...(entropySourceId ? { entropySourceId } : {}) },\n },\n };\n}\n"]}
@@ -9,7 +9,17 @@ const getMockAuthNonceResponse = () => {
9
9
  return {
10
10
  url: auth_1.MOCK_NONCE_URL,
11
11
  requestMethod: 'GET',
12
- response: exports.MOCK_NONCE_RESPONSE,
12
+ response: (_, path, getE2ESrpIdentifierForPublicKey) => {
13
+ // The goal here is to have this identifier bubble all the way up to being the access token
14
+ // That way, we can use it to segregate data in the test environment
15
+ const identifier = path?.split('?identifier=')[1];
16
+ const e2eIdentifier = getE2ESrpIdentifierForPublicKey?.(identifier ?? '');
17
+ return {
18
+ ...exports.MOCK_NONCE_RESPONSE,
19
+ nonce: e2eIdentifier ?? exports.MOCK_NONCE_RESPONSE.nonce,
20
+ identifier: exports.MOCK_NONCE_RESPONSE.identifier,
21
+ };
22
+ },
13
23
  };
14
24
  };
15
25
  exports.getMockAuthNonceResponse = getMockAuthNonceResponse;
@@ -18,7 +28,21 @@ const getMockAuthLoginResponse = () => {
18
28
  return {
19
29
  url: auth_1.MOCK_SRP_LOGIN_URL,
20
30
  requestMethod: 'POST',
21
- response: exports.MOCK_LOGIN_RESPONSE,
31
+ // In case this mock is used in an E2E test, we populate token, profile_id and identifier_id with the e2eIdentifier
32
+ // to make it easier to segregate data in the test environment.
33
+ response: (requestJsonBody) => {
34
+ const splittedRawMessage = requestJsonBody?.raw_message.split(':');
35
+ const e2eIdentifier = splittedRawMessage?.[splittedRawMessage.length - 2];
36
+ return {
37
+ ...exports.MOCK_LOGIN_RESPONSE,
38
+ token: e2eIdentifier ?? exports.MOCK_LOGIN_RESPONSE.token,
39
+ profile: {
40
+ ...exports.MOCK_LOGIN_RESPONSE.profile,
41
+ profile_id: e2eIdentifier ?? exports.MOCK_LOGIN_RESPONSE.profile.profile_id,
42
+ identifier_id: e2eIdentifier ?? exports.MOCK_LOGIN_RESPONSE.profile.identifier_id,
43
+ },
44
+ };
45
+ },
22
46
  };
23
47
  };
24
48
  exports.getMockAuthLoginResponse = getMockAuthLoginResponse;
@@ -27,7 +51,16 @@ const getMockAuthAccessTokenResponse = () => {
27
51
  return {
28
52
  url: auth_1.MOCK_OIDC_TOKEN_URL,
29
53
  requestMethod: 'POST',
30
- response: exports.MOCK_OATH_TOKEN_RESPONSE,
54
+ response: (requestJsonBody) => {
55
+ // We end up setting the access token to the e2eIdentifier in the test environment
56
+ // This is then attached to every request's Authorization header
57
+ // and used to segregate data in the test environment
58
+ const e2eIdentifier = new URLSearchParams(requestJsonBody).get('assertion');
59
+ return {
60
+ ...exports.MOCK_OATH_TOKEN_RESPONSE,
61
+ access_token: e2eIdentifier ?? exports.MOCK_OATH_TOKEN_RESPONSE.access_token,
62
+ };
63
+ },
31
64
  };
32
65
  };
33
66
  exports.getMockAuthAccessTokenResponse = getMockAuthAccessTokenResponse;
@@ -1 +1 @@
1
- {"version":3,"file":"mockResponses.cjs","sourceRoot":"","sources":["../../../../src/controllers/authentication/mocks/mockResponses.ts"],"names":[],"mappings":";;;AAAA,sDAQiC;AAQpB,QAAA,mBAAmB,GAAG,0BAAuB,CAAC;AAC9C,QAAA,UAAU,GAAG,2BAAmB,CAAC,KAAK,CAAC;AACvC,QAAA,QAAQ,GAAG,eAAY,CAAC;AAE9B,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAC3C,OAAO;QACL,GAAG,EAAE,qBAAc;QACnB,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,2BAAmB;KACP,CAAC;AAC3B,CAAC,CAAC;AANW,QAAA,wBAAwB,4BAMnC;AAEW,QAAA,mBAAmB,GAAG,8BAA2B,CAAC;AAExD,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAC3C,OAAO;QACL,GAAG,EAAE,yBAAkB;QACvB,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,2BAAmB;KACP,CAAC;AAC3B,CAAC,CAAC;AANW,QAAA,wBAAwB,4BAMnC;AAEW,QAAA,wBAAwB,GAAG,+BAA4B,CAAC;AAE9D,MAAM,8BAA8B,GAAG,GAAG,EAAE;IACjD,OAAO;QACL,GAAG,EAAE,0BAAmB;QACxB,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,gCAAwB;KACZ,CAAC;AAC3B,CAAC,CAAC;AANW,QAAA,8BAA8B,kCAMzC","sourcesContent":["import {\n MOCK_NONCE_RESPONSE as SDK_MOCK_NONCE_RESPONSE,\n MOCK_JWT as SDK_MOCK_JWT,\n MOCK_SRP_LOGIN_RESPONSE as SDK_MOCK_SRP_LOGIN_RESPONSE,\n MOCK_OIDC_TOKEN_RESPONSE as SDK_MOCK_OIDC_TOKEN_RESPONSE,\n MOCK_NONCE_URL,\n MOCK_SRP_LOGIN_URL,\n MOCK_OIDC_TOKEN_URL,\n} from '../../../sdk/mocks/auth';\n\ntype MockResponse = {\n url: string;\n requestMethod: 'GET' | 'POST' | 'PUT';\n response: unknown;\n};\n\nexport const MOCK_NONCE_RESPONSE = SDK_MOCK_NONCE_RESPONSE;\nexport const MOCK_NONCE = MOCK_NONCE_RESPONSE.nonce;\nexport const MOCK_JWT = SDK_MOCK_JWT;\n\nexport const getMockAuthNonceResponse = () => {\n return {\n url: MOCK_NONCE_URL,\n requestMethod: 'GET',\n response: MOCK_NONCE_RESPONSE,\n } satisfies MockResponse;\n};\n\nexport const MOCK_LOGIN_RESPONSE = SDK_MOCK_SRP_LOGIN_RESPONSE;\n\nexport const getMockAuthLoginResponse = () => {\n return {\n url: MOCK_SRP_LOGIN_URL,\n requestMethod: 'POST',\n response: MOCK_LOGIN_RESPONSE,\n } satisfies MockResponse;\n};\n\nexport const MOCK_OATH_TOKEN_RESPONSE = SDK_MOCK_OIDC_TOKEN_RESPONSE;\n\nexport const getMockAuthAccessTokenResponse = () => {\n return {\n url: MOCK_OIDC_TOKEN_URL,\n requestMethod: 'POST',\n response: MOCK_OATH_TOKEN_RESPONSE,\n } satisfies MockResponse;\n};\n"]}
1
+ {"version":3,"file":"mockResponses.cjs","sourceRoot":"","sources":["../../../../src/controllers/authentication/mocks/mockResponses.ts"],"names":[],"mappings":";;;AAAA,sDAQiC;AAQpB,QAAA,mBAAmB,GAAG,0BAAuB,CAAC;AAC9C,QAAA,UAAU,GAAG,2BAAmB,CAAC,KAAK,CAAC;AACvC,QAAA,QAAQ,GAAG,eAAY,CAAC;AAE9B,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAC3C,OAAO;QACL,GAAG,EAAE,qBAAc;QACnB,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,CACR,CAAW,EACX,IAAa,EACb,+BAA+D,EAC/D,EAAE;YACF,2FAA2F;YAC3F,oEAAoE;YACpE,MAAM,UAAU,GAAG,IAAI,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;YAClD,MAAM,aAAa,GAAG,+BAA+B,EAAE,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;YAE1E,OAAO;gBACL,GAAG,2BAAmB;gBACtB,KAAK,EAAE,aAAa,IAAI,2BAAmB,CAAC,KAAK;gBACjD,UAAU,EAAE,2BAAmB,CAAC,UAAU;aAC3C,CAAC;QACJ,CAAC;KACqB,CAAC;AAC3B,CAAC,CAAC;AArBW,QAAA,wBAAwB,4BAqBnC;AAEW,QAAA,mBAAmB,GAAG,8BAA2B,CAAC;AAExD,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAC3C,OAAO;QACL,GAAG,EAAE,yBAAkB;QACvB,aAAa,EAAE,MAAM;QACrB,mHAAmH;QACnH,+DAA+D;QAC/D,QAAQ,EAAE,CAAC,eAAyC,EAAE,EAAE;YACtD,MAAM,kBAAkB,GAAG,eAAe,EAAE,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnE,MAAM,aAAa,GAAG,kBAAkB,EAAE,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAE1E,OAAO;gBACL,GAAG,2BAAmB;gBACtB,KAAK,EAAE,aAAa,IAAI,2BAAmB,CAAC,KAAK;gBACjD,OAAO,EAAE;oBACP,GAAG,2BAAmB,CAAC,OAAO;oBAC9B,UAAU,EAAE,aAAa,IAAI,2BAAmB,CAAC,OAAO,CAAC,UAAU;oBACnE,aAAa,EACX,aAAa,IAAI,2BAAmB,CAAC,OAAO,CAAC,aAAa;iBAC7D;aACF,CAAC;QACJ,CAAC;KACqB,CAAC;AAC3B,CAAC,CAAC;AAtBW,QAAA,wBAAwB,4BAsBnC;AAEW,QAAA,wBAAwB,GAAG,+BAA4B,CAAC;AAE9D,MAAM,8BAA8B,GAAG,GAAG,EAAE;IACjD,OAAO;QACL,GAAG,EAAE,0BAAmB;QACxB,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,CAAC,eAAwB,EAAE,EAAE;YACrC,kFAAkF;YAClF,gEAAgE;YAChE,qDAAqD;YACrD,MAAM,aAAa,GAAG,IAAI,eAAe,CAAC,eAAe,CAAC,CAAC,GAAG,CAC5D,WAAW,CACZ,CAAC;YAEF,OAAO;gBACL,GAAG,gCAAwB;gBAC3B,YAAY,EAAE,aAAa,IAAI,gCAAwB,CAAC,YAAY;aACrE,CAAC;QACJ,CAAC;KACqB,CAAC;AAC3B,CAAC,CAAC;AAlBW,QAAA,8BAA8B,kCAkBzC","sourcesContent":["import {\n MOCK_NONCE_RESPONSE as SDK_MOCK_NONCE_RESPONSE,\n MOCK_JWT as SDK_MOCK_JWT,\n MOCK_SRP_LOGIN_RESPONSE as SDK_MOCK_SRP_LOGIN_RESPONSE,\n MOCK_OIDC_TOKEN_RESPONSE as SDK_MOCK_OIDC_TOKEN_RESPONSE,\n MOCK_NONCE_URL,\n MOCK_SRP_LOGIN_URL,\n MOCK_OIDC_TOKEN_URL,\n} from '../../../sdk/mocks/auth';\n\ntype MockResponse = {\n url: string;\n requestMethod: 'GET' | 'POST' | 'PUT';\n response: unknown;\n};\n\nexport const MOCK_NONCE_RESPONSE = SDK_MOCK_NONCE_RESPONSE;\nexport const MOCK_NONCE = MOCK_NONCE_RESPONSE.nonce;\nexport const MOCK_JWT = SDK_MOCK_JWT;\n\nexport const getMockAuthNonceResponse = () => {\n return {\n url: MOCK_NONCE_URL,\n requestMethod: 'GET',\n response: (\n _?: unknown,\n path?: string,\n getE2ESrpIdentifierForPublicKey?: (publicKey: string) => string,\n ) => {\n // The goal here is to have this identifier bubble all the way up to being the access token\n // That way, we can use it to segregate data in the test environment\n const identifier = path?.split('?identifier=')[1];\n const e2eIdentifier = getE2ESrpIdentifierForPublicKey?.(identifier ?? '');\n\n return {\n ...MOCK_NONCE_RESPONSE,\n nonce: e2eIdentifier ?? MOCK_NONCE_RESPONSE.nonce,\n identifier: MOCK_NONCE_RESPONSE.identifier,\n };\n },\n } satisfies MockResponse;\n};\n\nexport const MOCK_LOGIN_RESPONSE = SDK_MOCK_SRP_LOGIN_RESPONSE;\n\nexport const getMockAuthLoginResponse = () => {\n return {\n url: MOCK_SRP_LOGIN_URL,\n requestMethod: 'POST',\n // In case this mock is used in an E2E test, we populate token, profile_id and identifier_id with the e2eIdentifier\n // to make it easier to segregate data in the test environment.\n response: (requestJsonBody?: { raw_message: string }) => {\n const splittedRawMessage = requestJsonBody?.raw_message.split(':');\n const e2eIdentifier = splittedRawMessage?.[splittedRawMessage.length - 2];\n\n return {\n ...MOCK_LOGIN_RESPONSE,\n token: e2eIdentifier ?? MOCK_LOGIN_RESPONSE.token,\n profile: {\n ...MOCK_LOGIN_RESPONSE.profile,\n profile_id: e2eIdentifier ?? MOCK_LOGIN_RESPONSE.profile.profile_id,\n identifier_id:\n e2eIdentifier ?? MOCK_LOGIN_RESPONSE.profile.identifier_id,\n },\n };\n },\n } satisfies MockResponse;\n};\n\nexport const MOCK_OATH_TOKEN_RESPONSE = SDK_MOCK_OIDC_TOKEN_RESPONSE;\n\nexport const getMockAuthAccessTokenResponse = () => {\n return {\n url: MOCK_OIDC_TOKEN_URL,\n requestMethod: 'POST',\n response: (requestJsonBody?: string) => {\n // We end up setting the access token to the e2eIdentifier in the test environment\n // This is then attached to every request's Authorization header\n // and used to segregate data in the test environment\n const e2eIdentifier = new URLSearchParams(requestJsonBody).get(\n 'assertion',\n );\n\n return {\n ...MOCK_OATH_TOKEN_RESPONSE,\n access_token: e2eIdentifier ?? MOCK_OATH_TOKEN_RESPONSE.access_token,\n };\n },\n } satisfies MockResponse;\n};\n"]}
@@ -8,7 +8,7 @@ export declare const MOCK_JWT = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImI
8
8
  export declare const getMockAuthNonceResponse: () => {
9
9
  url: string;
10
10
  requestMethod: "GET";
11
- response: {
11
+ response: (_?: unknown, path?: string, getE2ESrpIdentifierForPublicKey?: ((publicKey: string) => string) | undefined) => {
12
12
  nonce: string;
13
13
  identifier: string;
14
14
  expires_in: number;
@@ -28,16 +28,18 @@ export declare const MOCK_LOGIN_RESPONSE: {
28
28
  export declare const getMockAuthLoginResponse: () => {
29
29
  url: string;
30
30
  requestMethod: "POST";
31
- response: {
31
+ response: (requestJsonBody?: {
32
+ raw_message: string;
33
+ }) => {
32
34
  token: string;
33
- expires_in: number;
34
35
  profile: {
35
36
  profile_id: string;
36
- metametrics_id: string;
37
37
  identifier_id: string;
38
+ metametrics_id: string;
38
39
  identifier_type: string;
39
40
  encrypted_storage_key: string;
40
41
  };
42
+ expires_in: number;
41
43
  };
42
44
  };
43
45
  export declare const MOCK_OATH_TOKEN_RESPONSE: {
@@ -47,7 +49,7 @@ export declare const MOCK_OATH_TOKEN_RESPONSE: {
47
49
  export declare const getMockAuthAccessTokenResponse: () => {
48
50
  url: string;
49
51
  requestMethod: "POST";
50
- response: {
52
+ response: (requestJsonBody?: string) => {
51
53
  access_token: string;
52
54
  expires_in: number;
53
55
  };
@@ -1 +1 @@
1
- {"version":3,"file":"mockResponses.d.cts","sourceRoot":"","sources":["../../../../src/controllers/authentication/mocks/mockResponses.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,mBAAmB;;;;CAA0B,CAAC;AAC3D,eAAO,MAAM,UAAU,QAA4B,CAAC;AACpD,eAAO,MAAM,QAAQ,upBAAe,CAAC;AAErC,eAAO,MAAM,wBAAwB;;;;;;;;CAMpC,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;;;;;;;CAA8B,CAAC;AAE/D,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;CAMpC,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;CAA+B,CAAC;AAErE,eAAO,MAAM,8BAA8B;;;;;;;CAM1C,CAAC"}
1
+ {"version":3,"file":"mockResponses.d.cts","sourceRoot":"","sources":["../../../../src/controllers/authentication/mocks/mockResponses.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,mBAAmB;;;;CAA0B,CAAC;AAC3D,eAAO,MAAM,UAAU,QAA4B,CAAC;AACpD,eAAO,MAAM,QAAQ,upBAAe,CAAC;AAErC,eAAO,MAAM,wBAAwB;;;mBAK3B,OAAO,SACJ,MAAM,iDACiC,MAAM,KAAK,MAAM;;;;;CAcpE,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;;;;;;;CAA8B,CAAC;AAE/D,eAAO,MAAM,wBAAwB;;;iCAMJ;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE;;;;;;;;;;;CAgBvD,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;CAA+B,CAAC;AAErE,eAAO,MAAM,8BAA8B;;;iCAIV,MAAM;;;;CActC,CAAC"}
@@ -8,7 +8,7 @@ export declare const MOCK_JWT = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImI
8
8
  export declare const getMockAuthNonceResponse: () => {
9
9
  url: string;
10
10
  requestMethod: "GET";
11
- response: {
11
+ response: (_?: unknown, path?: string, getE2ESrpIdentifierForPublicKey?: ((publicKey: string) => string) | undefined) => {
12
12
  nonce: string;
13
13
  identifier: string;
14
14
  expires_in: number;
@@ -28,16 +28,18 @@ export declare const MOCK_LOGIN_RESPONSE: {
28
28
  export declare const getMockAuthLoginResponse: () => {
29
29
  url: string;
30
30
  requestMethod: "POST";
31
- response: {
31
+ response: (requestJsonBody?: {
32
+ raw_message: string;
33
+ }) => {
32
34
  token: string;
33
- expires_in: number;
34
35
  profile: {
35
36
  profile_id: string;
36
- metametrics_id: string;
37
37
  identifier_id: string;
38
+ metametrics_id: string;
38
39
  identifier_type: string;
39
40
  encrypted_storage_key: string;
40
41
  };
42
+ expires_in: number;
41
43
  };
42
44
  };
43
45
  export declare const MOCK_OATH_TOKEN_RESPONSE: {
@@ -47,7 +49,7 @@ export declare const MOCK_OATH_TOKEN_RESPONSE: {
47
49
  export declare const getMockAuthAccessTokenResponse: () => {
48
50
  url: string;
49
51
  requestMethod: "POST";
50
- response: {
52
+ response: (requestJsonBody?: string) => {
51
53
  access_token: string;
52
54
  expires_in: number;
53
55
  };
@@ -1 +1 @@
1
- {"version":3,"file":"mockResponses.d.mts","sourceRoot":"","sources":["../../../../src/controllers/authentication/mocks/mockResponses.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,mBAAmB;;;;CAA0B,CAAC;AAC3D,eAAO,MAAM,UAAU,QAA4B,CAAC;AACpD,eAAO,MAAM,QAAQ,upBAAe,CAAC;AAErC,eAAO,MAAM,wBAAwB;;;;;;;;CAMpC,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;;;;;;;CAA8B,CAAC;AAE/D,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;CAMpC,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;CAA+B,CAAC;AAErE,eAAO,MAAM,8BAA8B;;;;;;;CAM1C,CAAC"}
1
+ {"version":3,"file":"mockResponses.d.mts","sourceRoot":"","sources":["../../../../src/controllers/authentication/mocks/mockResponses.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,mBAAmB;;;;CAA0B,CAAC;AAC3D,eAAO,MAAM,UAAU,QAA4B,CAAC;AACpD,eAAO,MAAM,QAAQ,upBAAe,CAAC;AAErC,eAAO,MAAM,wBAAwB;;;mBAK3B,OAAO,SACJ,MAAM,iDACiC,MAAM,KAAK,MAAM;;;;;CAcpE,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;;;;;;;CAA8B,CAAC;AAE/D,eAAO,MAAM,wBAAwB;;;iCAMJ;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE;;;;;;;;;;;CAgBvD,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;CAA+B,CAAC;AAErE,eAAO,MAAM,8BAA8B;;;iCAIV,MAAM;;;;CActC,CAAC"}
@@ -6,7 +6,17 @@ export const getMockAuthNonceResponse = () => {
6
6
  return {
7
7
  url: MOCK_NONCE_URL,
8
8
  requestMethod: 'GET',
9
- response: MOCK_NONCE_RESPONSE,
9
+ response: (_, path, getE2ESrpIdentifierForPublicKey) => {
10
+ // The goal here is to have this identifier bubble all the way up to being the access token
11
+ // That way, we can use it to segregate data in the test environment
12
+ const identifier = path?.split('?identifier=')[1];
13
+ const e2eIdentifier = getE2ESrpIdentifierForPublicKey?.(identifier ?? '');
14
+ return {
15
+ ...MOCK_NONCE_RESPONSE,
16
+ nonce: e2eIdentifier ?? MOCK_NONCE_RESPONSE.nonce,
17
+ identifier: MOCK_NONCE_RESPONSE.identifier,
18
+ };
19
+ },
10
20
  };
11
21
  };
12
22
  export const MOCK_LOGIN_RESPONSE = SDK_MOCK_SRP_LOGIN_RESPONSE;
@@ -14,7 +24,21 @@ export const getMockAuthLoginResponse = () => {
14
24
  return {
15
25
  url: MOCK_SRP_LOGIN_URL,
16
26
  requestMethod: 'POST',
17
- response: MOCK_LOGIN_RESPONSE,
27
+ // In case this mock is used in an E2E test, we populate token, profile_id and identifier_id with the e2eIdentifier
28
+ // to make it easier to segregate data in the test environment.
29
+ response: (requestJsonBody) => {
30
+ const splittedRawMessage = requestJsonBody?.raw_message.split(':');
31
+ const e2eIdentifier = splittedRawMessage?.[splittedRawMessage.length - 2];
32
+ return {
33
+ ...MOCK_LOGIN_RESPONSE,
34
+ token: e2eIdentifier ?? MOCK_LOGIN_RESPONSE.token,
35
+ profile: {
36
+ ...MOCK_LOGIN_RESPONSE.profile,
37
+ profile_id: e2eIdentifier ?? MOCK_LOGIN_RESPONSE.profile.profile_id,
38
+ identifier_id: e2eIdentifier ?? MOCK_LOGIN_RESPONSE.profile.identifier_id,
39
+ },
40
+ };
41
+ },
18
42
  };
19
43
  };
20
44
  export const MOCK_OATH_TOKEN_RESPONSE = SDK_MOCK_OIDC_TOKEN_RESPONSE;
@@ -22,7 +46,16 @@ export const getMockAuthAccessTokenResponse = () => {
22
46
  return {
23
47
  url: MOCK_OIDC_TOKEN_URL,
24
48
  requestMethod: 'POST',
25
- response: MOCK_OATH_TOKEN_RESPONSE,
49
+ response: (requestJsonBody) => {
50
+ // We end up setting the access token to the e2eIdentifier in the test environment
51
+ // This is then attached to every request's Authorization header
52
+ // and used to segregate data in the test environment
53
+ const e2eIdentifier = new URLSearchParams(requestJsonBody).get('assertion');
54
+ return {
55
+ ...MOCK_OATH_TOKEN_RESPONSE,
56
+ access_token: e2eIdentifier ?? MOCK_OATH_TOKEN_RESPONSE.access_token,
57
+ };
58
+ },
26
59
  };
27
60
  };
28
61
  //# sourceMappingURL=mockResponses.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"mockResponses.mjs","sourceRoot":"","sources":["../../../../src/controllers/authentication/mocks/mockResponses.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,IAAI,uBAAuB,EAC9C,QAAQ,IAAI,YAAY,EACxB,uBAAuB,IAAI,2BAA2B,EACtD,wBAAwB,IAAI,4BAA4B,EACxD,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACpB,oCAAgC;AAQjC,MAAM,CAAC,MAAM,mBAAmB,GAAG,uBAAuB,CAAC;AAC3D,MAAM,CAAC,MAAM,UAAU,GAAG,mBAAmB,CAAC,KAAK,CAAC;AACpD,MAAM,CAAC,MAAM,QAAQ,GAAG,YAAY,CAAC;AAErC,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAC3C,OAAO;QACL,GAAG,EAAE,cAAc;QACnB,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,mBAAmB;KACP,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,2BAA2B,CAAC;AAE/D,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAC3C,OAAO;QACL,GAAG,EAAE,kBAAkB;QACvB,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,mBAAmB;KACP,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG,4BAA4B,CAAC;AAErE,MAAM,CAAC,MAAM,8BAA8B,GAAG,GAAG,EAAE;IACjD,OAAO;QACL,GAAG,EAAE,mBAAmB;QACxB,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,wBAAwB;KACZ,CAAC;AAC3B,CAAC,CAAC","sourcesContent":["import {\n MOCK_NONCE_RESPONSE as SDK_MOCK_NONCE_RESPONSE,\n MOCK_JWT as SDK_MOCK_JWT,\n MOCK_SRP_LOGIN_RESPONSE as SDK_MOCK_SRP_LOGIN_RESPONSE,\n MOCK_OIDC_TOKEN_RESPONSE as SDK_MOCK_OIDC_TOKEN_RESPONSE,\n MOCK_NONCE_URL,\n MOCK_SRP_LOGIN_URL,\n MOCK_OIDC_TOKEN_URL,\n} from '../../../sdk/mocks/auth';\n\ntype MockResponse = {\n url: string;\n requestMethod: 'GET' | 'POST' | 'PUT';\n response: unknown;\n};\n\nexport const MOCK_NONCE_RESPONSE = SDK_MOCK_NONCE_RESPONSE;\nexport const MOCK_NONCE = MOCK_NONCE_RESPONSE.nonce;\nexport const MOCK_JWT = SDK_MOCK_JWT;\n\nexport const getMockAuthNonceResponse = () => {\n return {\n url: MOCK_NONCE_URL,\n requestMethod: 'GET',\n response: MOCK_NONCE_RESPONSE,\n } satisfies MockResponse;\n};\n\nexport const MOCK_LOGIN_RESPONSE = SDK_MOCK_SRP_LOGIN_RESPONSE;\n\nexport const getMockAuthLoginResponse = () => {\n return {\n url: MOCK_SRP_LOGIN_URL,\n requestMethod: 'POST',\n response: MOCK_LOGIN_RESPONSE,\n } satisfies MockResponse;\n};\n\nexport const MOCK_OATH_TOKEN_RESPONSE = SDK_MOCK_OIDC_TOKEN_RESPONSE;\n\nexport const getMockAuthAccessTokenResponse = () => {\n return {\n url: MOCK_OIDC_TOKEN_URL,\n requestMethod: 'POST',\n response: MOCK_OATH_TOKEN_RESPONSE,\n } satisfies MockResponse;\n};\n"]}
1
+ {"version":3,"file":"mockResponses.mjs","sourceRoot":"","sources":["../../../../src/controllers/authentication/mocks/mockResponses.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,IAAI,uBAAuB,EAC9C,QAAQ,IAAI,YAAY,EACxB,uBAAuB,IAAI,2BAA2B,EACtD,wBAAwB,IAAI,4BAA4B,EACxD,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACpB,oCAAgC;AAQjC,MAAM,CAAC,MAAM,mBAAmB,GAAG,uBAAuB,CAAC;AAC3D,MAAM,CAAC,MAAM,UAAU,GAAG,mBAAmB,CAAC,KAAK,CAAC;AACpD,MAAM,CAAC,MAAM,QAAQ,GAAG,YAAY,CAAC;AAErC,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAC3C,OAAO;QACL,GAAG,EAAE,cAAc;QACnB,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,CACR,CAAW,EACX,IAAa,EACb,+BAA+D,EAC/D,EAAE;YACF,2FAA2F;YAC3F,oEAAoE;YACpE,MAAM,UAAU,GAAG,IAAI,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;YAClD,MAAM,aAAa,GAAG,+BAA+B,EAAE,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;YAE1E,OAAO;gBACL,GAAG,mBAAmB;gBACtB,KAAK,EAAE,aAAa,IAAI,mBAAmB,CAAC,KAAK;gBACjD,UAAU,EAAE,mBAAmB,CAAC,UAAU;aAC3C,CAAC;QACJ,CAAC;KACqB,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,2BAA2B,CAAC;AAE/D,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAC3C,OAAO;QACL,GAAG,EAAE,kBAAkB;QACvB,aAAa,EAAE,MAAM;QACrB,mHAAmH;QACnH,+DAA+D;QAC/D,QAAQ,EAAE,CAAC,eAAyC,EAAE,EAAE;YACtD,MAAM,kBAAkB,GAAG,eAAe,EAAE,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnE,MAAM,aAAa,GAAG,kBAAkB,EAAE,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAE1E,OAAO;gBACL,GAAG,mBAAmB;gBACtB,KAAK,EAAE,aAAa,IAAI,mBAAmB,CAAC,KAAK;gBACjD,OAAO,EAAE;oBACP,GAAG,mBAAmB,CAAC,OAAO;oBAC9B,UAAU,EAAE,aAAa,IAAI,mBAAmB,CAAC,OAAO,CAAC,UAAU;oBACnE,aAAa,EACX,aAAa,IAAI,mBAAmB,CAAC,OAAO,CAAC,aAAa;iBAC7D;aACF,CAAC;QACJ,CAAC;KACqB,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG,4BAA4B,CAAC;AAErE,MAAM,CAAC,MAAM,8BAA8B,GAAG,GAAG,EAAE;IACjD,OAAO;QACL,GAAG,EAAE,mBAAmB;QACxB,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,CAAC,eAAwB,EAAE,EAAE;YACrC,kFAAkF;YAClF,gEAAgE;YAChE,qDAAqD;YACrD,MAAM,aAAa,GAAG,IAAI,eAAe,CAAC,eAAe,CAAC,CAAC,GAAG,CAC5D,WAAW,CACZ,CAAC;YAEF,OAAO;gBACL,GAAG,wBAAwB;gBAC3B,YAAY,EAAE,aAAa,IAAI,wBAAwB,CAAC,YAAY;aACrE,CAAC;QACJ,CAAC;KACqB,CAAC;AAC3B,CAAC,CAAC","sourcesContent":["import {\n MOCK_NONCE_RESPONSE as SDK_MOCK_NONCE_RESPONSE,\n MOCK_JWT as SDK_MOCK_JWT,\n MOCK_SRP_LOGIN_RESPONSE as SDK_MOCK_SRP_LOGIN_RESPONSE,\n MOCK_OIDC_TOKEN_RESPONSE as SDK_MOCK_OIDC_TOKEN_RESPONSE,\n MOCK_NONCE_URL,\n MOCK_SRP_LOGIN_URL,\n MOCK_OIDC_TOKEN_URL,\n} from '../../../sdk/mocks/auth';\n\ntype MockResponse = {\n url: string;\n requestMethod: 'GET' | 'POST' | 'PUT';\n response: unknown;\n};\n\nexport const MOCK_NONCE_RESPONSE = SDK_MOCK_NONCE_RESPONSE;\nexport const MOCK_NONCE = MOCK_NONCE_RESPONSE.nonce;\nexport const MOCK_JWT = SDK_MOCK_JWT;\n\nexport const getMockAuthNonceResponse = () => {\n return {\n url: MOCK_NONCE_URL,\n requestMethod: 'GET',\n response: (\n _?: unknown,\n path?: string,\n getE2ESrpIdentifierForPublicKey?: (publicKey: string) => string,\n ) => {\n // The goal here is to have this identifier bubble all the way up to being the access token\n // That way, we can use it to segregate data in the test environment\n const identifier = path?.split('?identifier=')[1];\n const e2eIdentifier = getE2ESrpIdentifierForPublicKey?.(identifier ?? '');\n\n return {\n ...MOCK_NONCE_RESPONSE,\n nonce: e2eIdentifier ?? MOCK_NONCE_RESPONSE.nonce,\n identifier: MOCK_NONCE_RESPONSE.identifier,\n };\n },\n } satisfies MockResponse;\n};\n\nexport const MOCK_LOGIN_RESPONSE = SDK_MOCK_SRP_LOGIN_RESPONSE;\n\nexport const getMockAuthLoginResponse = () => {\n return {\n url: MOCK_SRP_LOGIN_URL,\n requestMethod: 'POST',\n // In case this mock is used in an E2E test, we populate token, profile_id and identifier_id with the e2eIdentifier\n // to make it easier to segregate data in the test environment.\n response: (requestJsonBody?: { raw_message: string }) => {\n const splittedRawMessage = requestJsonBody?.raw_message.split(':');\n const e2eIdentifier = splittedRawMessage?.[splittedRawMessage.length - 2];\n\n return {\n ...MOCK_LOGIN_RESPONSE,\n token: e2eIdentifier ?? MOCK_LOGIN_RESPONSE.token,\n profile: {\n ...MOCK_LOGIN_RESPONSE.profile,\n profile_id: e2eIdentifier ?? MOCK_LOGIN_RESPONSE.profile.profile_id,\n identifier_id:\n e2eIdentifier ?? MOCK_LOGIN_RESPONSE.profile.identifier_id,\n },\n };\n },\n } satisfies MockResponse;\n};\n\nexport const MOCK_OATH_TOKEN_RESPONSE = SDK_MOCK_OIDC_TOKEN_RESPONSE;\n\nexport const getMockAuthAccessTokenResponse = () => {\n return {\n url: MOCK_OIDC_TOKEN_URL,\n requestMethod: 'POST',\n response: (requestJsonBody?: string) => {\n // We end up setting the access token to the e2eIdentifier in the test environment\n // This is then attached to every request's Authorization header\n // and used to segregate data in the test environment\n const e2eIdentifier = new URLSearchParams(requestJsonBody).get(\n 'assertion',\n );\n\n return {\n ...MOCK_OATH_TOKEN_RESPONSE,\n access_token: e2eIdentifier ?? MOCK_OATH_TOKEN_RESPONSE.access_token,\n };\n },\n } satisfies MockResponse;\n};\n"]}