@metamask/profile-sync-controller 28.3.0 → 30.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/CHANGELOG.md +30 -1
  2. package/LICENSE +1 -0
  3. package/dist/controllers/authentication/AuthenticationController-method-action-types.cjs.map +1 -1
  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.map +1 -1
  6. package/dist/controllers/authentication/AuthenticationController-method-action-types.mjs.map +1 -1
  7. package/dist/controllers/authentication/AuthenticationController.cjs +236 -75
  8. package/dist/controllers/authentication/AuthenticationController.cjs.map +1 -1
  9. package/dist/controllers/authentication/AuthenticationController.d.cts +22 -3
  10. package/dist/controllers/authentication/AuthenticationController.d.cts.map +1 -1
  11. package/dist/controllers/authentication/AuthenticationController.d.mts +22 -3
  12. package/dist/controllers/authentication/AuthenticationController.d.mts.map +1 -1
  13. package/dist/controllers/authentication/AuthenticationController.mjs +231 -70
  14. package/dist/controllers/authentication/AuthenticationController.mjs.map +1 -1
  15. package/dist/controllers/authentication/index.cjs +3 -3
  16. package/dist/controllers/authentication/index.cjs.map +1 -1
  17. package/dist/controllers/authentication/index.d.cts.map +1 -1
  18. package/dist/controllers/authentication/index.d.mts.map +1 -1
  19. package/dist/controllers/authentication/index.mjs.map +1 -1
  20. package/dist/controllers/authentication/mocks/index.cjs.map +1 -1
  21. package/dist/controllers/authentication/mocks/index.d.cts.map +1 -1
  22. package/dist/controllers/authentication/mocks/index.d.mts.map +1 -1
  23. package/dist/controllers/authentication/mocks/index.mjs.map +1 -1
  24. package/dist/controllers/authentication/mocks/mockResponses.cjs +26 -15
  25. package/dist/controllers/authentication/mocks/mockResponses.cjs.map +1 -1
  26. package/dist/controllers/authentication/mocks/mockResponses.d.cts +11 -0
  27. package/dist/controllers/authentication/mocks/mockResponses.d.cts.map +1 -1
  28. package/dist/controllers/authentication/mocks/mockResponses.d.mts +11 -0
  29. package/dist/controllers/authentication/mocks/mockResponses.d.mts.map +1 -1
  30. package/dist/controllers/authentication/mocks/mockResponses.mjs +13 -3
  31. package/dist/controllers/authentication/mocks/mockResponses.mjs.map +1 -1
  32. package/dist/controllers/index.cjs.map +1 -1
  33. package/dist/controllers/index.d.cts.map +1 -1
  34. package/dist/controllers/index.d.mts.map +1 -1
  35. package/dist/controllers/index.mjs.map +1 -1
  36. package/dist/controllers/user-storage/UserStorageController-method-action-types.cjs.map +1 -1
  37. package/dist/controllers/user-storage/UserStorageController-method-action-types.d.cts.map +1 -1
  38. package/dist/controllers/user-storage/UserStorageController-method-action-types.d.mts.map +1 -1
  39. package/dist/controllers/user-storage/UserStorageController-method-action-types.mjs.map +1 -1
  40. package/dist/controllers/user-storage/UserStorageController.cjs +35 -36
  41. package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -1
  42. package/dist/controllers/user-storage/UserStorageController.d.cts +2 -3
  43. package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -1
  44. package/dist/controllers/user-storage/UserStorageController.d.mts +2 -3
  45. package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -1
  46. package/dist/controllers/user-storage/UserStorageController.mjs +22 -23
  47. package/dist/controllers/user-storage/UserStorageController.mjs.map +1 -1
  48. package/dist/controllers/user-storage/contact-syncing/controller-integration.cjs +23 -23
  49. package/dist/controllers/user-storage/contact-syncing/controller-integration.cjs.map +1 -1
  50. package/dist/controllers/user-storage/contact-syncing/controller-integration.d.cts.map +1 -1
  51. package/dist/controllers/user-storage/contact-syncing/controller-integration.d.mts.map +1 -1
  52. package/dist/controllers/user-storage/contact-syncing/controller-integration.mjs.map +1 -1
  53. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.cjs +9 -9
  54. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.cjs.map +1 -1
  55. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.cts.map +1 -1
  56. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.mts.map +1 -1
  57. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.mjs.map +1 -1
  58. package/dist/controllers/user-storage/contact-syncing/sync-utils.cjs.map +1 -1
  59. package/dist/controllers/user-storage/contact-syncing/sync-utils.d.cts.map +1 -1
  60. package/dist/controllers/user-storage/contact-syncing/sync-utils.d.mts.map +1 -1
  61. package/dist/controllers/user-storage/contact-syncing/sync-utils.mjs.map +1 -1
  62. package/dist/controllers/user-storage/contact-syncing/types.cjs.map +1 -1
  63. package/dist/controllers/user-storage/contact-syncing/types.d.cts.map +1 -1
  64. package/dist/controllers/user-storage/contact-syncing/types.d.mts.map +1 -1
  65. package/dist/controllers/user-storage/contact-syncing/types.mjs.map +1 -1
  66. package/dist/controllers/user-storage/contact-syncing/utils.cjs +2 -2
  67. package/dist/controllers/user-storage/contact-syncing/utils.cjs.map +1 -1
  68. package/dist/controllers/user-storage/contact-syncing/utils.d.cts.map +1 -1
  69. package/dist/controllers/user-storage/contact-syncing/utils.d.mts.map +1 -1
  70. package/dist/controllers/user-storage/contact-syncing/utils.mjs.map +1 -1
  71. package/dist/controllers/user-storage/index.cjs +3 -3
  72. package/dist/controllers/user-storage/index.cjs.map +1 -1
  73. package/dist/controllers/user-storage/index.d.cts.map +1 -1
  74. package/dist/controllers/user-storage/index.d.mts.map +1 -1
  75. package/dist/controllers/user-storage/index.mjs.map +1 -1
  76. package/dist/controllers/user-storage/mocks/index.cjs.map +1 -1
  77. package/dist/controllers/user-storage/mocks/index.d.cts.map +1 -1
  78. package/dist/controllers/user-storage/mocks/index.d.mts.map +1 -1
  79. package/dist/controllers/user-storage/mocks/index.mjs.map +1 -1
  80. package/dist/controllers/user-storage/mocks/mockResponses.cjs +15 -15
  81. package/dist/controllers/user-storage/mocks/mockResponses.cjs.map +1 -1
  82. package/dist/controllers/user-storage/mocks/mockResponses.d.cts.map +1 -1
  83. package/dist/controllers/user-storage/mocks/mockResponses.d.mts.map +1 -1
  84. package/dist/controllers/user-storage/mocks/mockResponses.mjs.map +1 -1
  85. package/dist/controllers/user-storage/mocks/mockStorage.cjs +3 -3
  86. package/dist/controllers/user-storage/mocks/mockStorage.cjs.map +1 -1
  87. package/dist/controllers/user-storage/mocks/mockStorage.d.cts.map +1 -1
  88. package/dist/controllers/user-storage/mocks/mockStorage.d.mts.map +1 -1
  89. package/dist/controllers/user-storage/mocks/mockStorage.mjs.map +1 -1
  90. package/dist/controllers/user-storage/types.cjs.map +1 -1
  91. package/dist/controllers/user-storage/types.d.cts.map +1 -1
  92. package/dist/controllers/user-storage/types.d.mts.map +1 -1
  93. package/dist/controllers/user-storage/types.mjs.map +1 -1
  94. package/dist/index.cjs.map +1 -1
  95. package/dist/index.d.cts.map +1 -1
  96. package/dist/index.d.mts.map +1 -1
  97. package/dist/index.mjs.map +1 -1
  98. package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs +11 -11
  99. package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs.map +1 -1
  100. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.cts.map +1 -1
  101. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.mts.map +1 -1
  102. package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs.map +1 -1
  103. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs +40 -26
  104. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs.map +1 -1
  105. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts +12 -1
  106. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts.map +1 -1
  107. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts +12 -1
  108. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts.map +1 -1
  109. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs +20 -6
  110. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs.map +1 -1
  111. package/dist/sdk/authentication-jwt-bearer/services.cjs +85 -39
  112. package/dist/sdk/authentication-jwt-bearer/services.cjs.map +1 -1
  113. package/dist/sdk/authentication-jwt-bearer/services.d.cts +19 -2
  114. package/dist/sdk/authentication-jwt-bearer/services.d.cts.map +1 -1
  115. package/dist/sdk/authentication-jwt-bearer/services.d.mts +19 -2
  116. package/dist/sdk/authentication-jwt-bearer/services.d.mts.map +1 -1
  117. package/dist/sdk/authentication-jwt-bearer/services.mjs +46 -2
  118. package/dist/sdk/authentication-jwt-bearer/services.mjs.map +1 -1
  119. package/dist/sdk/authentication-jwt-bearer/types.cjs.map +1 -1
  120. package/dist/sdk/authentication-jwt-bearer/types.d.cts +36 -0
  121. package/dist/sdk/authentication-jwt-bearer/types.d.cts.map +1 -1
  122. package/dist/sdk/authentication-jwt-bearer/types.d.mts +36 -0
  123. package/dist/sdk/authentication-jwt-bearer/types.d.mts.map +1 -1
  124. package/dist/sdk/authentication-jwt-bearer/types.mjs.map +1 -1
  125. package/dist/sdk/authentication-jwt-bearer/utils/identifier.cjs +2 -2
  126. package/dist/sdk/authentication-jwt-bearer/utils/identifier.cjs.map +1 -1
  127. package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.cts.map +1 -1
  128. package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.mts.map +1 -1
  129. package/dist/sdk/authentication-jwt-bearer/utils/identifier.mjs.map +1 -1
  130. package/dist/sdk/authentication.cjs +25 -21
  131. package/dist/sdk/authentication.cjs.map +1 -1
  132. package/dist/sdk/authentication.d.cts +2 -1
  133. package/dist/sdk/authentication.d.cts.map +1 -1
  134. package/dist/sdk/authentication.d.mts +2 -1
  135. package/dist/sdk/authentication.d.mts.map +1 -1
  136. package/dist/sdk/authentication.mjs +4 -0
  137. package/dist/sdk/authentication.mjs.map +1 -1
  138. package/dist/sdk/constants.cjs +1 -0
  139. package/dist/sdk/constants.cjs.map +1 -1
  140. package/dist/sdk/constants.d.cts +1 -0
  141. package/dist/sdk/constants.d.cts.map +1 -1
  142. package/dist/sdk/constants.d.mts +1 -0
  143. package/dist/sdk/constants.d.mts.map +1 -1
  144. package/dist/sdk/constants.mjs +1 -0
  145. package/dist/sdk/constants.mjs.map +1 -1
  146. package/dist/sdk/errors.cjs +17 -4
  147. package/dist/sdk/errors.cjs.map +1 -1
  148. package/dist/sdk/errors.d.cts +9 -0
  149. package/dist/sdk/errors.d.cts.map +1 -1
  150. package/dist/sdk/errors.d.mts +9 -0
  151. package/dist/sdk/errors.d.mts.map +1 -1
  152. package/dist/sdk/errors.mjs +12 -0
  153. package/dist/sdk/errors.mjs.map +1 -1
  154. package/dist/sdk/index.cjs.map +1 -1
  155. package/dist/sdk/index.d.cts.map +1 -1
  156. package/dist/sdk/index.d.mts.map +1 -1
  157. package/dist/sdk/index.mjs.map +1 -1
  158. package/dist/sdk/mocks/auth.cjs +24 -13
  159. package/dist/sdk/mocks/auth.cjs.map +1 -1
  160. package/dist/sdk/mocks/auth.d.cts +11 -0
  161. package/dist/sdk/mocks/auth.d.cts.map +1 -1
  162. package/dist/sdk/mocks/auth.d.mts +11 -0
  163. package/dist/sdk/mocks/auth.d.mts.map +1 -1
  164. package/dist/sdk/mocks/auth.mjs +12 -1
  165. package/dist/sdk/mocks/auth.mjs.map +1 -1
  166. package/dist/sdk/mocks/userstorage.cjs +8 -8
  167. package/dist/sdk/mocks/userstorage.cjs.map +1 -1
  168. package/dist/sdk/mocks/userstorage.mjs.map +1 -1
  169. package/dist/sdk/user-storage.cjs +32 -32
  170. package/dist/sdk/user-storage.cjs.map +1 -1
  171. package/dist/sdk/user-storage.d.cts.map +1 -1
  172. package/dist/sdk/user-storage.d.mts.map +1 -1
  173. package/dist/sdk/user-storage.mjs +1 -1
  174. package/dist/sdk/user-storage.mjs.map +1 -1
  175. package/dist/sdk/utils/validate-login-response.cjs.map +1 -1
  176. package/dist/sdk/utils/validate-login-response.d.cts.map +1 -1
  177. package/dist/sdk/utils/validate-login-response.d.mts.map +1 -1
  178. package/dist/sdk/utils/validate-login-response.mjs.map +1 -1
  179. package/dist/shared/encryption/cache.cjs +6 -6
  180. package/dist/shared/encryption/cache.cjs.map +1 -1
  181. package/dist/shared/encryption/cache.mjs.map +1 -1
  182. package/dist/shared/encryption/encryption.cjs +26 -26
  183. package/dist/shared/encryption/encryption.cjs.map +1 -1
  184. package/dist/shared/encryption/encryption.d.cts.map +1 -1
  185. package/dist/shared/encryption/encryption.d.mts.map +1 -1
  186. package/dist/shared/encryption/encryption.mjs.map +1 -1
  187. package/dist/shared/encryption/index.cjs +3 -3
  188. package/dist/shared/encryption/index.cjs.map +1 -1
  189. package/dist/shared/encryption/index.d.cts.map +1 -1
  190. package/dist/shared/encryption/index.d.mts.map +1 -1
  191. package/dist/shared/encryption/index.mjs.map +1 -1
  192. package/dist/shared/storage-schema.cjs +2 -2
  193. package/dist/shared/storage-schema.cjs.map +1 -1
  194. package/dist/shared/storage-schema.mjs.map +1 -1
  195. package/dist/shared/types/services.cjs.map +1 -1
  196. package/dist/shared/types/services.d.cts.map +1 -1
  197. package/dist/shared/types/services.d.mts.map +1 -1
  198. package/dist/shared/types/services.mjs.map +1 -1
  199. package/dist/shared/utils/entropy-source.cjs +37 -0
  200. package/dist/shared/utils/entropy-source.cjs.map +1 -0
  201. package/dist/shared/utils/entropy-source.d.cts +22 -0
  202. package/dist/shared/utils/entropy-source.d.cts.map +1 -0
  203. package/dist/shared/utils/entropy-source.d.mts +22 -0
  204. package/dist/shared/utils/entropy-source.d.mts.map +1 -0
  205. package/dist/shared/utils/entropy-source.mjs +32 -0
  206. package/dist/shared/utils/entropy-source.mjs.map +1 -0
  207. package/dist/shared/utils/hd-keyring-seed.cjs +49 -0
  208. package/dist/shared/utils/hd-keyring-seed.cjs.map +1 -0
  209. package/dist/shared/utils/hd-keyring-seed.d.cts +27 -0
  210. package/dist/shared/utils/hd-keyring-seed.d.cts.map +1 -0
  211. package/dist/shared/utils/hd-keyring-seed.d.mts +27 -0
  212. package/dist/shared/utils/hd-keyring-seed.d.mts.map +1 -0
  213. package/dist/shared/utils/hd-keyring-seed.mjs +45 -0
  214. package/dist/shared/utils/hd-keyring-seed.mjs.map +1 -0
  215. package/dist/shared/utils/message-signing.cjs +147 -0
  216. package/dist/shared/utils/message-signing.cjs.map +1 -0
  217. package/dist/shared/utils/message-signing.d.cts +73 -0
  218. package/dist/shared/utils/message-signing.d.cts.map +1 -0
  219. package/dist/shared/utils/message-signing.d.mts +73 -0
  220. package/dist/shared/utils/message-signing.d.mts.map +1 -0
  221. package/dist/shared/utils/message-signing.mjs +140 -0
  222. package/dist/shared/utils/message-signing.mjs.map +1 -0
  223. package/package.json +17 -14
  224. package/dist/controllers/authentication/auth-snap-requests.cjs +0 -60
  225. package/dist/controllers/authentication/auth-snap-requests.cjs.map +0 -1
  226. package/dist/controllers/authentication/auth-snap-requests.d.cts +0 -27
  227. package/dist/controllers/authentication/auth-snap-requests.d.cts.map +0 -1
  228. package/dist/controllers/authentication/auth-snap-requests.d.mts +0 -27
  229. package/dist/controllers/authentication/auth-snap-requests.d.mts.map +0 -1
  230. package/dist/controllers/authentication/auth-snap-requests.mjs +0 -54
  231. package/dist/controllers/authentication/auth-snap-requests.mjs.map +0 -1
@@ -9,14 +9,17 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10
10
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
11
  };
12
- var _AuthenticationController_instances, _AuthenticationController_metametrics, _AuthenticationController_auth, _AuthenticationController_config, _AuthenticationController_isUnlocked, _AuthenticationController_cachedPrimaryEntropySourceId, _AuthenticationController_profilePairingRequestEpoch, _AuthenticationController_keyringController, _AuthenticationController_getLoginResponseFromState, _AuthenticationController_setLoginResponseToState, _AuthenticationController_assertIsUnlocked, _AuthenticationController_getPrimaryEntropySourceId, _AuthenticationController_tryClearNeedsProfilePairing, _AuthenticationController_doPair, _AuthenticationController_pairSrpProfiles, _AuthenticationController_propagateCanonical, _AuthenticationController_getCanonicalProfileId, _AuthenticationController_invalidateSrpSession, _AuthenticationController_snapGetPublicKey, _AuthenticationController_snapGetAllPublicKeys, _AuthenticationController__snapSignMessageCache, _AuthenticationController_snapSignMessage;
12
+ var _AuthenticationController_instances, _AuthenticationController_metametrics, _AuthenticationController_auth, _AuthenticationController_config, _AuthenticationController_isUnlocked, _AuthenticationController_profilePairingRequestEpoch, _AuthenticationController_keyringController, _AuthenticationController_getLoginResponseFromState, _AuthenticationController_setLoginResponseToState, _AuthenticationController_assertIsUnlocked, _AuthenticationController_getHdKeyringEntropySourceIds, _AuthenticationController_getPrimaryEntropySourceId, _AuthenticationController_getLoginTag, _AuthenticationController_getLoginIdentifierType, _AuthenticationController_resolveSocialIdentifierType, _AuthenticationController_identifierTypeFromSeedlessState, _AuthenticationController_trySocialPairing, _AuthenticationController_clearNeedsSocialPairing, _AuthenticationController_tryClearNeedsProfilePairing, _AuthenticationController_doPair, _AuthenticationController_pairSrpProfiles, _AuthenticationController_propagateCanonical, _AuthenticationController_getCanonicalProfileId, _AuthenticationController_invalidateSrpSession, _AuthenticationController_getHdKeyringSeed, _AuthenticationController_getPublicKey, _AuthenticationController__signMessageCache, _AuthenticationController_scopedCacheKey, _AuthenticationController_signMessage;
13
13
  import { BaseController } from "@metamask/base-controller";
14
- import { assertMessageStartsWithMetamask, AuthType, Env, JwtBearerAuth } from "../../sdk/index.mjs";
15
- import { createSnapPublicKeyRequest, createSnapAllPublicKeysRequest, createSnapSignMessageRequest } from "./auth-snap-requests.mjs";
14
+ import { assertMessageStartsWithMetamask, AuthType, Env, JwtBearerAuth, PairConflictError } from "../../sdk/index.mjs";
15
+ import { getHdKeyringEntropySourceIds, getPrimaryHdKeyringEntropySourceId } from "../../shared/utils/entropy-source.mjs";
16
+ import { getHdKeyringSeed } from "../../shared/utils/hd-keyring-seed.mjs";
17
+ import { getMessageSigningPublicKey, signMessageWithMessageSigningKey } from "../../shared/utils/message-signing.mjs";
16
18
  const controllerName = 'AuthenticationController';
17
19
  export const defaultState = {
18
20
  isSignedIn: false,
19
21
  needsProfilePairing: true,
22
+ needsSocialPairing: true,
20
23
  };
21
24
  const metadata = {
22
25
  isSignedIn: {
@@ -31,6 +34,12 @@ const metadata = {
31
34
  includeInDebugSnapshot: true,
32
35
  usedInUi: true,
33
36
  },
37
+ needsSocialPairing: {
38
+ includeInStateLogs: true,
39
+ persist: true,
40
+ includeInDebugSnapshot: true,
41
+ usedInUi: true,
42
+ },
34
43
  srpSessionData: {
35
44
  // Remove access token from state logs
36
45
  includeInStateLogs: (srpSessionData) => {
@@ -84,9 +93,9 @@ export class AuthenticationController extends BaseController {
84
93
  _AuthenticationController_auth.set(this, void 0);
85
94
  _AuthenticationController_config.set(this, {
86
95
  env: Env.PRD,
96
+ isSocialPairingEnabled: () => false,
87
97
  });
88
98
  _AuthenticationController_isUnlocked.set(this, false);
89
- _AuthenticationController_cachedPrimaryEntropySourceId.set(this, void 0);
90
99
  // Bumped by `requestProfilePairing`. `performSignIn` snapshots this
91
100
  // before its first await; if it changes mid-flight we must NOT clear
92
101
  // `needsProfilePairing` (the rearm signal wins).
@@ -103,13 +112,14 @@ export class AuthenticationController extends BaseController {
103
112
  });
104
113
  },
105
114
  });
106
- _AuthenticationController__snapSignMessageCache.set(this, {});
115
+ _AuthenticationController__signMessageCache.set(this, {});
107
116
  if (!metametrics) {
108
117
  throw new Error('`metametrics` field is required');
109
118
  }
110
119
  __classPrivateFieldSet(this, _AuthenticationController_config, {
111
120
  ...__classPrivateFieldGet(this, _AuthenticationController_config, "f"),
112
121
  ...config,
122
+ isSocialPairingEnabled: config?.isSocialPairingEnabled ?? __classPrivateFieldGet(this, _AuthenticationController_config, "f").isSocialPairingEnabled,
113
123
  }, "f");
114
124
  __classPrivateFieldSet(this, _AuthenticationController_metametrics, metametrics, "f");
115
125
  __classPrivateFieldSet(this, _AuthenticationController_auth, new JwtBearerAuth({
@@ -122,9 +132,11 @@ export class AuthenticationController extends BaseController {
122
132
  setLoginResponse: __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_setLoginResponseToState).bind(this),
123
133
  },
124
134
  signing: {
125
- getIdentifier: __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_snapGetPublicKey).bind(this),
126
- signMessage: __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_snapSignMessage).bind(this),
135
+ getIdentifier: __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPublicKey).bind(this),
136
+ signMessage: __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_signMessage).bind(this),
127
137
  },
138
+ getLoginTag: __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getLoginTag).bind(this),
139
+ getLoginIdentifierType: __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getLoginIdentifierType).bind(this),
128
140
  metametrics: __classPrivateFieldGet(this, _AuthenticationController_metametrics, "f"),
129
141
  }), "f");
130
142
  __classPrivateFieldGet(this, _AuthenticationController_keyringController, "f").setupLockedStateSubscriptions();
@@ -133,15 +145,15 @@ export class AuthenticationController extends BaseController {
133
145
  async performSignIn() {
134
146
  __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, 'performSignIn');
135
147
  const epochAtStart = __classPrivateFieldGet(this, _AuthenticationController_profilePairingRequestEpoch, "f");
136
- const allPublicKeys = await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_snapGetAllPublicKeys).call(this);
148
+ const entropySourceIds = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getHdKeyringEntropySourceIds).call(this);
137
149
  const accessTokens = [];
138
150
  // We iterate sequentially in order to be sure that the first entry
139
151
  // is the primary SRP LoginResponse.
140
- for (const [entropySourceId] of allPublicKeys) {
152
+ for (const entropySourceId of entropySourceIds) {
141
153
  const accessToken = await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").getAccessToken(entropySourceId);
142
154
  accessTokens.push(accessToken);
143
155
  }
144
- if (allPublicKeys.length < 2) {
156
+ if (entropySourceIds.length < 2) {
145
157
  // Single-SRP wallet: nothing to pair.
146
158
  __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_tryClearNeedsProfilePairing).call(this, epochAtStart);
147
159
  }
@@ -154,6 +166,12 @@ export class AuthenticationController extends BaseController {
154
166
  // noop
155
167
  }
156
168
  }
169
+ try {
170
+ await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_trySocialPairing).call(this, accessTokens[0]);
171
+ }
172
+ catch {
173
+ // noop
174
+ }
157
175
  return accessTokens;
158
176
  }
159
177
  /**
@@ -170,7 +188,6 @@ export class AuthenticationController extends BaseController {
170
188
  }
171
189
  }
172
190
  performSignOut() {
173
- __classPrivateFieldSet(this, _AuthenticationController_cachedPrimaryEntropySourceId, undefined, "f");
174
191
  this.update((state) => {
175
192
  state.isSignedIn = false;
176
193
  state.srpSessionData = undefined;
@@ -189,7 +206,7 @@ export class AuthenticationController extends BaseController {
189
206
  */
190
207
  async getBearerToken(entropySourceId) {
191
208
  __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, 'getBearerToken');
192
- const resolvedId = entropySourceId ?? (await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this));
209
+ const resolvedId = entropySourceId ?? __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
193
210
  return await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").getAccessToken(resolvedId);
194
211
  }
195
212
  /**
@@ -207,7 +224,7 @@ export class AuthenticationController extends BaseController {
207
224
  */
208
225
  async getSessionProfile(entropySourceId) {
209
226
  __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, 'getSessionProfile');
210
- const resolvedId = entropySourceId ?? (await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this));
227
+ const resolvedId = entropySourceId ?? __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
211
228
  return await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").getUserProfile(resolvedId);
212
229
  }
213
230
  /**
@@ -228,10 +245,10 @@ export class AuthenticationController extends BaseController {
228
245
  */
229
246
  async refreshCanonicalProfileId() {
230
247
  __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, 'refreshCanonicalProfileId');
231
- const primaryEntropySourceId = await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
248
+ const primaryEntropySourceId = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
232
249
  __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_invalidateSrpSession).call(this, primaryEntropySourceId);
233
250
  await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").getAccessToken(primaryEntropySourceId);
234
- const canonical = await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getCanonicalProfileId).call(this);
251
+ const canonical = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getCanonicalProfileId).call(this);
235
252
  if (!canonical) {
236
253
  throw new Error('refreshCanonicalProfileId - Unable to resolve canonical profile ID');
237
254
  }
@@ -240,7 +257,7 @@ export class AuthenticationController extends BaseController {
240
257
  }
241
258
  async getUserProfileLineage(entropySourceId) {
242
259
  __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, 'getUserProfileLineage');
243
- const resolvedId = entropySourceId ?? (await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this));
260
+ const resolvedId = entropySourceId ?? __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
244
261
  return await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").getUserProfileLineage(resolvedId);
245
262
  }
246
263
  /**
@@ -256,21 +273,21 @@ export class AuthenticationController extends BaseController {
256
273
  */
257
274
  async getCustomerServiceToken(entropySourceId) {
258
275
  __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, 'getCustomerServiceToken');
259
- const resolvedId = entropySourceId ?? (await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this));
276
+ const resolvedId = entropySourceId ?? __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
260
277
  return await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").getCustomerServiceToken(resolvedId);
261
278
  }
262
279
  isSignedIn() {
263
280
  return this.state.isSignedIn;
264
281
  }
265
282
  }
266
- _AuthenticationController_metametrics = new WeakMap(), _AuthenticationController_auth = new WeakMap(), _AuthenticationController_config = new WeakMap(), _AuthenticationController_isUnlocked = new WeakMap(), _AuthenticationController_cachedPrimaryEntropySourceId = new WeakMap(), _AuthenticationController_profilePairingRequestEpoch = new WeakMap(), _AuthenticationController_keyringController = new WeakMap(), _AuthenticationController__snapSignMessageCache = new WeakMap(), _AuthenticationController_instances = new WeakSet(), _AuthenticationController_getLoginResponseFromState = async function _AuthenticationController_getLoginResponseFromState(entropySourceId) {
267
- const resolvedId = entropySourceId ?? (await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this));
283
+ _AuthenticationController_metametrics = new WeakMap(), _AuthenticationController_auth = new WeakMap(), _AuthenticationController_config = new WeakMap(), _AuthenticationController_isUnlocked = new WeakMap(), _AuthenticationController_profilePairingRequestEpoch = new WeakMap(), _AuthenticationController_keyringController = new WeakMap(), _AuthenticationController__signMessageCache = new WeakMap(), _AuthenticationController_instances = new WeakSet(), _AuthenticationController_getLoginResponseFromState = async function _AuthenticationController_getLoginResponseFromState(entropySourceId) {
284
+ const resolvedId = entropySourceId ?? __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
268
285
  if (!this.state.srpSessionData?.[resolvedId]) {
269
286
  return null;
270
287
  }
271
288
  return this.state.srpSessionData[resolvedId];
272
289
  }, _AuthenticationController_setLoginResponseToState = async function _AuthenticationController_setLoginResponseToState(loginResponse, entropySourceId) {
273
- const resolvedId = entropySourceId ?? (await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this));
290
+ const resolvedId = entropySourceId ?? __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
274
291
  const metaMetricsId = await __classPrivateFieldGet(this, _AuthenticationController_metametrics, "f").getMetaMetricsId();
275
292
  this.update((state) => {
276
293
  state.isSignedIn = true;
@@ -289,20 +306,168 @@ _AuthenticationController_metametrics = new WeakMap(), _AuthenticationController
289
306
  if (!__classPrivateFieldGet(this, _AuthenticationController_isUnlocked, "f")) {
290
307
  throw new Error(`${methodName} - unable to proceed, wallet is locked`);
291
308
  }
292
- }, _AuthenticationController_getPrimaryEntropySourceId = async function _AuthenticationController_getPrimaryEntropySourceId() {
293
- if (__classPrivateFieldGet(this, _AuthenticationController_cachedPrimaryEntropySourceId, "f")) {
294
- return __classPrivateFieldGet(this, _AuthenticationController_cachedPrimaryEntropySourceId, "f");
309
+ }, _AuthenticationController_getHdKeyringEntropySourceIds = function _AuthenticationController_getHdKeyringEntropySourceIds() {
310
+ const { keyrings } = this.messenger.call('KeyringController:getState');
311
+ return getHdKeyringEntropySourceIds(keyrings);
312
+ }, _AuthenticationController_getPrimaryEntropySourceId = function _AuthenticationController_getPrimaryEntropySourceId() {
313
+ const { keyrings } = this.messenger.call('KeyringController:getState');
314
+ return getPrimaryHdKeyringEntropySourceId(keyrings);
315
+ }, _AuthenticationController_getLoginTag =
316
+ /**
317
+ * Resolves the SRP login tag for `raw_message`.
318
+ *
319
+ * - `primary` for the first HD entropy source
320
+ * - `secondary` for any other entropy source
321
+ *
322
+ * @param entropySourceId - Entropy source for this login attempt.
323
+ * @returns The login tag to append to the signed message.
324
+ */
325
+ async function _AuthenticationController_getLoginTag(entropySourceId) {
326
+ const primaryEntropySourceId = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
327
+ const resolvedId = entropySourceId ?? primaryEntropySourceId;
328
+ return resolvedId === primaryEntropySourceId ? 'primary' : 'secondary';
329
+ }, _AuthenticationController_getLoginIdentifierType =
330
+ /**
331
+ * Resolves metametrics `identifier_type` for `/srp/login`
332
+ * (`SRP` | `GOOGLE` | `APPLE` | `TELEGRAM`).
333
+ *
334
+ * This is the auth method for the entropy source, independent of
335
+ * {@link SrpLoginTag} (`primary` / `secondary`).
336
+ *
337
+ * SeedlessOnboarding currently exposes a single vault-level
338
+ * `authConnection`, which always backs the primary entropy source. Non-
339
+ * primary sources therefore return `SRP`. If social identities become
340
+ * per-entropy later, resolve from that metadata instead of assuming
341
+ * primary === social.
342
+ *
343
+ * Soft-fails to `SRP` when SeedlessOnboarding is not registered.
344
+ *
345
+ * @param entropySourceId - Entropy source for this login attempt.
346
+ * @returns The login identifier type.
347
+ */
348
+ async function _AuthenticationController_getLoginIdentifierType(entropySourceId) {
349
+ const primaryEntropySourceId = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
350
+ const resolvedId = entropySourceId ?? primaryEntropySourceId;
351
+ // Social vault authConnection is only associated with the primary source.
352
+ if (resolvedId !== primaryEntropySourceId) {
353
+ return 'SRP';
354
+ }
355
+ return __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_resolveSocialIdentifierType).call(this);
356
+ }, _AuthenticationController_resolveSocialIdentifierType = function _AuthenticationController_resolveSocialIdentifierType() {
357
+ try {
358
+ return __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_identifierTypeFromSeedlessState).call(this, this.messenger.call('SeedlessOnboardingController:getState'));
359
+ }
360
+ catch {
361
+ return 'SRP';
362
+ }
363
+ }, _AuthenticationController_identifierTypeFromSeedlessState = function _AuthenticationController_identifierTypeFromSeedlessState(state) {
364
+ if (state.vault === null || state.vault === undefined) {
365
+ return 'SRP';
366
+ }
367
+ // Match provider strings from SeedlessOnboarding state rather than
368
+ // importing AuthConnection — a value import would load that package
369
+ // (and its heavy deps) whenever this controller is imported.
370
+ switch (state.authConnection) {
371
+ case 'google':
372
+ return 'GOOGLE';
373
+ case 'apple':
374
+ return 'APPLE';
375
+ case 'telegram':
376
+ return 'TELEGRAM';
377
+ default:
378
+ return 'SRP';
379
+ }
380
+ }, _AuthenticationController_trySocialPairing =
381
+ /**
382
+ * Attaches a Google/Apple/Telegram social identifier to the primary SRP
383
+ * profile via `POST /api/v2/profile/pair/identifier`.
384
+ *
385
+ * Runs only when `isSocialPairingEnabled()` is true and
386
+ * `needsSocialPairing` is not `false` (`undefined` is treated as true).
387
+ * No social provider (`authConnection` unset) → clear the flag (nothing
388
+ * to pair). Social provider set but vault missing → skip (onboarding
389
+ * still in flight). Google without email → skip (API requires it).
390
+ * Telegram never sends `email` (the field holds a display name, not an
391
+ * address). Missing social JWT → skip. 409 Conflict → clear the flag
392
+ * (identifier already owned; retry is pointless). Other errors
393
+ * propagate so the caller can swallow them and leave the flag set for
394
+ * retry.
395
+ *
396
+ * @param primaryAccessToken - Primary SRP OIDC access token used as the
397
+ * Bearer credential. The profile associated with this JWT becomes the
398
+ * canonical owner of the social identifier.
399
+ */
400
+ async function _AuthenticationController_trySocialPairing(primaryAccessToken) {
401
+ if (!__classPrivateFieldGet(this, _AuthenticationController_config, "f").isSocialPairingEnabled() ||
402
+ this.state.needsSocialPairing === false ||
403
+ !primaryAccessToken) {
404
+ return;
405
+ }
406
+ let seedlessState;
407
+ try {
408
+ seedlessState = this.messenger.call('SeedlessOnboardingController:getState');
409
+ }
410
+ catch {
411
+ // Controller missing or getState failed — retry next performSignIn.
412
+ return;
413
+ }
414
+ // `SRP` here does not describe the vault: it is the mapping's "no social
415
+ // identity" result, returned when there is no seedless vault or the
416
+ // provider is unrecognised. In both cases there is nothing to pair.
417
+ const identifierType = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_identifierTypeFromSeedlessState).call(this, seedlessState);
418
+ if (identifierType === 'SRP') {
419
+ const { vault, authConnection } = seedlessState;
420
+ // Vault not written yet but a social provider is already known —
421
+ // onboarding is still in flight. Do not clear; retry next sign-in.
422
+ if ((vault === null || vault === undefined) && Boolean(authConnection)) {
423
+ return;
424
+ }
425
+ __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_clearNeedsSocialPairing).call(this);
426
+ return;
427
+ }
428
+ // Email policy follows the API contract: GOOGLE requires `email` (400
429
+ // without it), APPLE accepts it optionally, TELEGRAM must not send it
430
+ // (clients store a display name in `socialLoginEmail` for Telegram).
431
+ // Clients request the `email` scope for Google, so a missing value is a
432
+ // defensive case rather than an expected one; returning here leaves
433
+ // `needsSocialPairing` set so the next sign-in retries instead of
434
+ // sending a request that would fail.
435
+ const { socialLoginEmail } = seedlessState;
436
+ let email;
437
+ if (identifierType === 'GOOGLE') {
438
+ if (!socialLoginEmail) {
439
+ return;
440
+ }
441
+ email = socialLoginEmail;
442
+ }
443
+ else if (identifierType === 'APPLE') {
444
+ email = socialLoginEmail;
445
+ }
446
+ const socialJwt = await this.messenger.call('SeedlessOnboardingController:getAccessToken');
447
+ if (socialJwt === undefined || socialJwt === '') {
448
+ return;
449
+ }
450
+ try {
451
+ await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").pairSocialIdentifier({
452
+ identifierType,
453
+ socialJwt,
454
+ ...(email ? { email } : {}),
455
+ }, primaryAccessToken);
456
+ __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_clearNeedsSocialPairing).call(this);
295
457
  }
296
- const allPublicKeys = await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_snapGetAllPublicKeys).call(this);
297
- if (allPublicKeys.length === 0) {
298
- throw new Error('#getPrimaryEntropySourceId - No entropy sources found from snap');
458
+ catch (error) {
459
+ if (error instanceof PairConflictError) {
460
+ __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_clearNeedsSocialPairing).call(this);
461
+ return;
462
+ }
463
+ throw error;
299
464
  }
300
- const primaryId = allPublicKeys[0][0];
301
- if (!primaryId) {
302
- throw new Error('#getPrimaryEntropySourceId - Primary entropy source ID is undefined');
465
+ }, _AuthenticationController_clearNeedsSocialPairing = function _AuthenticationController_clearNeedsSocialPairing() {
466
+ if (this.state.needsSocialPairing !== false) {
467
+ this.update((state) => {
468
+ state.needsSocialPairing = false;
469
+ });
303
470
  }
304
- __classPrivateFieldSet(this, _AuthenticationController_cachedPrimaryEntropySourceId, primaryId, "f");
305
- return __classPrivateFieldGet(this, _AuthenticationController_cachedPrimaryEntropySourceId, "f");
306
471
  }, _AuthenticationController_tryClearNeedsProfilePairing = function _AuthenticationController_tryClearNeedsProfilePairing(epochAtStart) {
307
472
  if (__classPrivateFieldGet(this, _AuthenticationController_profilePairingRequestEpoch, "f") !== epochAtStart) {
308
473
  return;
@@ -325,9 +490,9 @@ _AuthenticationController_metametrics = new WeakMap(), _AuthenticationController
325
490
  * pair API call was in-flight.
326
491
  */
327
492
  async function _AuthenticationController_doPair(accessTokens, epochAtStart) {
328
- const previousCanonical = await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getCanonicalProfileId).call(this);
493
+ const previousCanonical = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getCanonicalProfileId).call(this);
329
494
  const profileAliases = await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_pairSrpProfiles).call(this, accessTokens);
330
- const newCanonical = await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getCanonicalProfileId).call(this);
495
+ const newCanonical = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getCanonicalProfileId).call(this);
331
496
  // If somehow we cannot compute the new canonical profile ID after pairing,
332
497
  // we just return now and do not update the `needsProfilePairing` flag.
333
498
  if (!newCanonical) {
@@ -363,18 +528,8 @@ async function _AuthenticationController_doPair(accessTokens, epochAtStart) {
363
528
  }
364
529
  }
365
530
  });
366
- }, _AuthenticationController_getCanonicalProfileId =
367
- /**
368
- * Returns the canonical profile id from the primary SRP's cached session.
369
- * Returns `null` when no session exists yet for the primary SRP.
370
- *
371
- * Always reads from the primary SRP because the canonical is shared across
372
- * all paired SRPs after `#propagateCanonical`.
373
- *
374
- * @returns The canonical profile id, or `null` if unavailable.
375
- */
376
- async function _AuthenticationController_getCanonicalProfileId() {
377
- const primaryEntropySourceId = await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
531
+ }, _AuthenticationController_getCanonicalProfileId = function _AuthenticationController_getCanonicalProfileId() {
532
+ const primaryEntropySourceId = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
378
533
  return (this.state.srpSessionData?.[primaryEntropySourceId]?.profile
379
534
  ?.canonicalProfileId ?? null);
380
535
  }, _AuthenticationController_invalidateSrpSession = function _AuthenticationController_invalidateSrpSession(entropySourceId) {
@@ -387,45 +542,51 @@ async function _AuthenticationController_getCanonicalProfileId() {
387
542
  entry.profile.canonicalProfileId = '';
388
543
  }
389
544
  });
390
- }, _AuthenticationController_snapGetPublicKey =
545
+ }, _AuthenticationController_getHdKeyringSeed =
391
546
  /**
392
- * Returns the auth snap public key.
547
+ * Reads the BIP-39 seed for an HD entropy source from KeyringController.
393
548
  *
394
- * @param entropySourceId - The entropy source ID used to derive the key,
395
- * when multiple sources are available (Multi-SRP).
396
- * @returns The snap public key.
549
+ * @param entropySourceId - Entropy source ID. Defaults to the primary HD
550
+ * keyring.
551
+ * @returns The HD keyring seed.
397
552
  */
398
- async function _AuthenticationController_snapGetPublicKey(entropySourceId) {
399
- __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, '#snapGetPublicKey');
400
- const result = (await this.messenger.call('SnapController:handleRequest', createSnapPublicKeyRequest(entropySourceId)));
401
- return result;
402
- }, _AuthenticationController_snapGetAllPublicKeys =
553
+ async function _AuthenticationController_getHdKeyringSeed(entropySourceId) {
554
+ const resolvedId = entropySourceId ?? __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
555
+ return getHdKeyringSeed(this.messenger, resolvedId);
556
+ }, _AuthenticationController_getPublicKey =
403
557
  /**
404
- * Returns a mapping of entropy source IDs to auth snap public keys.
558
+ * Returns the message-signing public key via native SIP-6 derivation
559
+ * (same key as `@metamask/message-signing-snap` with empty salt).
405
560
  *
406
- * @returns A mapping of entropy source IDs to public keys.
561
+ * @param entropySourceId - The entropy source ID used to derive the key,
562
+ * when multiple sources are available (Multi-SRP).
563
+ * @returns The public key hex.
407
564
  */
408
- async function _AuthenticationController_snapGetAllPublicKeys() {
409
- __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, '#snapGetAllPublicKeys');
410
- const result = (await this.messenger.call('SnapController:handleRequest', createSnapAllPublicKeysRequest()));
411
- return result;
412
- }, _AuthenticationController_snapSignMessage =
565
+ async function _AuthenticationController_getPublicKey(entropySourceId) {
566
+ __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, '#getPublicKey');
567
+ const seed = await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getHdKeyringSeed).call(this, entropySourceId);
568
+ return getMessageSigningPublicKey(seed);
569
+ }, _AuthenticationController_scopedCacheKey = function _AuthenticationController_scopedCacheKey(message, entropySourceId) {
570
+ return `${entropySourceId ?? __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this)}:${message}`;
571
+ }, _AuthenticationController_signMessage =
413
572
  /**
414
- * Signs a specific message using an underlying auth snap.
573
+ * Signs a `metamask:…` message with the native SIP-6 message-signing key.
415
574
  *
416
575
  * @param message - A specific tagged message to sign.
417
576
  * @param entropySourceId - The entropy source ID used to derive the key,
418
577
  * when multiple sources are available (Multi-SRP).
419
- * @returns A Signature created by the snap.
578
+ * @returns Compact secp256k1 signature hex.
420
579
  */
421
- async function _AuthenticationController_snapSignMessage(message, entropySourceId) {
580
+ async function _AuthenticationController_signMessage(message, entropySourceId) {
422
581
  assertMessageStartsWithMetamask(message);
423
- if (__classPrivateFieldGet(this, _AuthenticationController__snapSignMessageCache, "f")[message]) {
424
- return __classPrivateFieldGet(this, _AuthenticationController__snapSignMessageCache, "f")[message];
582
+ __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, '#signMessage');
583
+ const cacheKey = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_scopedCacheKey).call(this, message, entropySourceId);
584
+ if (__classPrivateFieldGet(this, _AuthenticationController__signMessageCache, "f")[cacheKey]) {
585
+ return __classPrivateFieldGet(this, _AuthenticationController__signMessageCache, "f")[cacheKey];
425
586
  }
426
- __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, '#snapSignMessage');
427
- const result = (await this.messenger.call('SnapController:handleRequest', createSnapSignMessageRequest(message, entropySourceId)));
428
- __classPrivateFieldGet(this, _AuthenticationController__snapSignMessageCache, "f")[message] = result;
587
+ const seed = await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getHdKeyringSeed).call(this, entropySourceId);
588
+ const result = await signMessageWithMessageSigningKey(message, seed);
589
+ __classPrivateFieldGet(this, _AuthenticationController__signMessageCache, "f")[cacheKey] = result;
429
590
  return result;
430
591
  };
431
592
  //# sourceMappingURL=AuthenticationController.mjs.map