@metamask-previews/profile-sync-controller 29.0.0-preview-5b293ee50 → 29.0.0-preview-3866c0ff1

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 (548) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/dist/controllers/authentication/{AuthenticationController-method-action-types.d.mts → AuthenticationController-method-action-types.d.ts} +2 -2
  3. package/dist/controllers/authentication/AuthenticationController-method-action-types.d.ts.map +1 -0
  4. package/dist/controllers/authentication/{AuthenticationController-method-action-types.mjs → AuthenticationController-method-action-types.js} +1 -1
  5. package/dist/controllers/authentication/AuthenticationController-method-action-types.js.map +1 -0
  6. package/dist/controllers/authentication/{AuthenticationController.d.mts → AuthenticationController.d.ts} +10 -10
  7. package/dist/controllers/authentication/AuthenticationController.d.ts.map +1 -0
  8. package/dist/controllers/authentication/AuthenticationController.js +536 -0
  9. package/dist/controllers/authentication/AuthenticationController.js.map +1 -0
  10. package/dist/controllers/authentication/{index.d.cts → index.d.ts} +5 -5
  11. package/dist/controllers/authentication/index.d.ts.map +1 -0
  12. package/dist/controllers/authentication/index.js +6 -0
  13. package/dist/controllers/authentication/index.js.map +1 -0
  14. package/dist/controllers/authentication/mocks/index.d.ts +2 -0
  15. package/dist/controllers/authentication/mocks/index.d.ts.map +1 -0
  16. package/dist/controllers/authentication/mocks/index.js +2 -0
  17. package/dist/controllers/authentication/mocks/index.js.map +1 -0
  18. package/dist/controllers/authentication/mocks/{mockResponses.d.mts → mockResponses.d.ts} +1 -1
  19. package/dist/controllers/authentication/mocks/mockResponses.d.ts.map +1 -0
  20. package/dist/controllers/authentication/mocks/{mockResponses.mjs → mockResponses.js} +2 -2
  21. package/dist/controllers/authentication/mocks/mockResponses.js.map +1 -0
  22. package/dist/controllers/index.d.ts +3 -0
  23. package/dist/controllers/index.d.ts.map +1 -0
  24. package/dist/controllers/index.js +3 -0
  25. package/dist/controllers/index.js.map +1 -0
  26. package/dist/controllers/user-storage/{UserStorageController-method-action-types.d.mts → UserStorageController-method-action-types.d.ts} +2 -2
  27. package/dist/controllers/user-storage/UserStorageController-method-action-types.d.ts.map +1 -0
  28. package/dist/controllers/user-storage/{UserStorageController-method-action-types.mjs → UserStorageController-method-action-types.js} +1 -1
  29. package/dist/controllers/user-storage/UserStorageController-method-action-types.js.map +1 -0
  30. package/dist/controllers/user-storage/{UserStorageController.d.cts → UserStorageController.d.ts} +14 -14
  31. package/dist/controllers/user-storage/UserStorageController.d.ts.map +1 -0
  32. package/dist/controllers/user-storage/UserStorageController.js +429 -0
  33. package/dist/controllers/user-storage/UserStorageController.js.map +1 -0
  34. package/dist/controllers/user-storage/constants.d.ts +15 -0
  35. package/dist/controllers/user-storage/constants.d.ts.map +1 -0
  36. package/dist/controllers/user-storage/{constants.mjs → constants.js} +1 -1
  37. package/dist/controllers/user-storage/constants.js.map +1 -0
  38. package/dist/controllers/user-storage/contact-syncing/{constants.d.cts → constants.d.ts} +1 -1
  39. package/dist/controllers/user-storage/contact-syncing/constants.d.ts.map +1 -0
  40. package/dist/controllers/user-storage/contact-syncing/{constants.mjs → constants.js} +1 -1
  41. package/dist/controllers/user-storage/contact-syncing/constants.js.map +1 -0
  42. package/dist/controllers/user-storage/contact-syncing/{controller-integration.d.cts → controller-integration.d.ts} +3 -3
  43. package/dist/controllers/user-storage/contact-syncing/controller-integration.d.ts.map +1 -0
  44. package/dist/controllers/user-storage/contact-syncing/{controller-integration.mjs → controller-integration.js} +6 -6
  45. package/dist/controllers/user-storage/contact-syncing/controller-integration.js.map +1 -0
  46. package/dist/controllers/user-storage/contact-syncing/{setup-subscriptions.d.cts → setup-subscriptions.d.ts} +2 -2
  47. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.ts.map +1 -0
  48. package/dist/controllers/user-storage/contact-syncing/{setup-subscriptions.mjs → setup-subscriptions.js} +4 -4
  49. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.js.map +1 -0
  50. package/dist/controllers/user-storage/contact-syncing/{sync-utils.d.cts → sync-utils.d.ts} +2 -2
  51. package/dist/controllers/user-storage/contact-syncing/sync-utils.d.ts.map +1 -0
  52. package/dist/controllers/user-storage/contact-syncing/{sync-utils.mjs → sync-utils.js} +1 -1
  53. package/dist/controllers/user-storage/contact-syncing/sync-utils.js.map +1 -0
  54. package/dist/controllers/user-storage/contact-syncing/{types.d.cts → types.d.ts} +6 -6
  55. package/dist/controllers/user-storage/contact-syncing/types.d.ts.map +1 -0
  56. package/dist/controllers/user-storage/contact-syncing/types.js +2 -0
  57. package/dist/controllers/user-storage/contact-syncing/types.js.map +1 -0
  58. package/dist/controllers/user-storage/contact-syncing/{utils.d.mts → utils.d.ts} +3 -3
  59. package/dist/controllers/user-storage/contact-syncing/utils.d.ts.map +1 -0
  60. package/dist/controllers/user-storage/contact-syncing/{utils.mjs → utils.js} +2 -2
  61. package/dist/controllers/user-storage/contact-syncing/utils.js.map +1 -0
  62. package/dist/controllers/user-storage/{index.d.cts → index.d.ts} +8 -8
  63. package/dist/controllers/user-storage/index.d.ts.map +1 -0
  64. package/dist/controllers/user-storage/index.js +9 -0
  65. package/dist/controllers/user-storage/index.js.map +1 -0
  66. package/dist/controllers/user-storage/mocks/index.d.ts +3 -0
  67. package/dist/controllers/user-storage/mocks/index.d.ts.map +1 -0
  68. package/dist/controllers/user-storage/mocks/index.js +3 -0
  69. package/dist/controllers/user-storage/mocks/index.js.map +1 -0
  70. package/dist/controllers/user-storage/mocks/{mockResponses.d.mts → mockResponses.d.ts} +3 -3
  71. package/dist/controllers/user-storage/mocks/mockResponses.d.ts.map +1 -0
  72. package/dist/controllers/user-storage/mocks/{mockResponses.mjs → mockResponses.js} +4 -4
  73. package/dist/controllers/user-storage/mocks/mockResponses.js.map +1 -0
  74. package/dist/controllers/user-storage/mocks/{mockStorage.d.cts → mockStorage.d.ts} +1 -1
  75. package/dist/controllers/user-storage/mocks/mockStorage.d.ts.map +1 -0
  76. package/dist/controllers/user-storage/mocks/{mockStorage.mjs → mockStorage.js} +3 -3
  77. package/dist/controllers/user-storage/mocks/mockStorage.js.map +1 -0
  78. package/dist/controllers/user-storage/{types.d.cts → types.d.ts} +3 -3
  79. package/dist/controllers/user-storage/types.d.ts.map +1 -0
  80. package/dist/controllers/user-storage/types.js +2 -0
  81. package/dist/controllers/user-storage/types.js.map +1 -0
  82. package/dist/controllers/user-storage/{utils.d.cts → utils.d.ts} +1 -1
  83. package/dist/controllers/user-storage/utils.d.ts.map +1 -0
  84. package/dist/controllers/user-storage/{utils.mjs → utils.js} +1 -1
  85. package/dist/controllers/user-storage/utils.js.map +1 -0
  86. package/dist/index.d.ts +4 -0
  87. package/dist/index.d.ts.map +1 -0
  88. package/dist/index.js +4 -0
  89. package/dist/index.js.map +1 -0
  90. package/dist/sdk/authentication-jwt-bearer/{flow-siwe.d.cts → flow-siwe.d.ts} +2 -2
  91. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.ts.map +1 -0
  92. package/dist/sdk/authentication-jwt-bearer/flow-siwe.js +99 -0
  93. package/dist/sdk/authentication-jwt-bearer/flow-siwe.js.map +1 -0
  94. package/dist/sdk/authentication-jwt-bearer/{flow-srp.d.cts → flow-srp.d.ts} +5 -5
  95. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.ts.map +1 -0
  96. package/dist/sdk/authentication-jwt-bearer/flow-srp.js +255 -0
  97. package/dist/sdk/authentication-jwt-bearer/flow-srp.js.map +1 -0
  98. package/dist/sdk/authentication-jwt-bearer/{services.d.cts → services.d.ts} +5 -5
  99. package/dist/sdk/authentication-jwt-bearer/services.d.ts.map +1 -0
  100. package/dist/sdk/authentication-jwt-bearer/{services.mjs → services.js} +6 -6
  101. package/dist/sdk/authentication-jwt-bearer/services.js.map +1 -0
  102. package/dist/sdk/authentication-jwt-bearer/{types.d.cts → types.d.ts} +2 -2
  103. package/dist/sdk/authentication-jwt-bearer/types.d.ts.map +1 -0
  104. package/dist/sdk/authentication-jwt-bearer/{types.mjs → types.js} +1 -1
  105. package/dist/sdk/authentication-jwt-bearer/types.js.map +1 -0
  106. package/dist/sdk/authentication-jwt-bearer/utils/{identifier.d.cts → identifier.d.ts} +2 -2
  107. package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.ts.map +1 -0
  108. package/dist/sdk/authentication-jwt-bearer/utils/{identifier.mjs → identifier.js} +2 -2
  109. package/dist/sdk/authentication-jwt-bearer/utils/identifier.js.map +1 -0
  110. package/dist/sdk/authentication-jwt-bearer/utils/{time.d.cts → time.d.ts} +1 -1
  111. package/dist/sdk/authentication-jwt-bearer/utils/time.d.ts.map +1 -0
  112. package/dist/sdk/authentication-jwt-bearer/utils/{time.mjs → time.js} +1 -1
  113. package/dist/sdk/authentication-jwt-bearer/utils/time.js.map +1 -0
  114. package/dist/sdk/{authentication.d.cts → authentication.d.ts} +9 -9
  115. package/dist/sdk/authentication.d.ts.map +1 -0
  116. package/dist/sdk/authentication.js +100 -0
  117. package/dist/sdk/authentication.js.map +1 -0
  118. package/dist/sdk/{constants.d.cts → constants.d.ts} +1 -1
  119. package/dist/sdk/constants.d.ts.map +1 -0
  120. package/dist/sdk/{constants.mjs → constants.js} +1 -1
  121. package/dist/sdk/constants.js.map +1 -0
  122. package/dist/sdk/{errors.d.cts → errors.d.ts} +1 -1
  123. package/dist/sdk/errors.d.ts.map +1 -0
  124. package/dist/sdk/{errors.mjs → errors.js} +4 -3
  125. package/dist/sdk/errors.js.map +1 -0
  126. package/dist/sdk/index.d.ts +8 -0
  127. package/dist/sdk/index.d.ts.map +1 -0
  128. package/dist/sdk/index.js +8 -0
  129. package/dist/sdk/index.js.map +1 -0
  130. package/dist/sdk/mocks/{auth.d.cts → auth.d.ts} +2 -2
  131. package/dist/sdk/mocks/auth.d.ts.map +1 -0
  132. package/dist/sdk/mocks/{auth.mjs → auth.js} +3 -3
  133. package/dist/sdk/mocks/auth.js.map +1 -0
  134. package/dist/sdk/mocks/{userstorage.d.cts → userstorage.d.ts} +1 -1
  135. package/dist/sdk/mocks/userstorage.d.ts.map +1 -0
  136. package/dist/sdk/mocks/{userstorage.mjs → userstorage.js} +5 -5
  137. package/dist/sdk/mocks/userstorage.js.map +1 -0
  138. package/dist/sdk/{user-storage.d.mts → user-storage.d.ts} +5 -5
  139. package/dist/sdk/user-storage.d.ts.map +1 -0
  140. package/dist/sdk/user-storage.js +364 -0
  141. package/dist/sdk/user-storage.js.map +1 -0
  142. package/dist/sdk/utils/{eip-6963-metamask-provider.d.cts → eip-6963-metamask-provider.d.ts} +2 -2
  143. package/dist/sdk/utils/eip-6963-metamask-provider.d.ts.map +1 -0
  144. package/dist/sdk/utils/{eip-6963-metamask-provider.mjs → eip-6963-metamask-provider.js} +1 -1
  145. package/dist/sdk/utils/eip-6963-metamask-provider.js.map +1 -0
  146. package/dist/sdk/utils/{messaging-signing-snap-requests.d.cts → messaging-signing-snap-requests.d.ts} +2 -2
  147. package/dist/sdk/utils/messaging-signing-snap-requests.d.ts.map +1 -0
  148. package/dist/sdk/utils/{messaging-signing-snap-requests.mjs → messaging-signing-snap-requests.js} +1 -1
  149. package/dist/sdk/utils/messaging-signing-snap-requests.js.map +1 -0
  150. package/dist/sdk/utils/{validate-login-response.d.mts → validate-login-response.d.ts} +2 -2
  151. package/dist/sdk/utils/validate-login-response.d.ts.map +1 -0
  152. package/dist/sdk/utils/{validate-login-response.mjs → validate-login-response.js} +1 -1
  153. package/dist/sdk/utils/validate-login-response.js.map +1 -0
  154. package/dist/sdk/utils/{validate-pair-response.d.cts → validate-pair-response.d.ts} +1 -1
  155. package/dist/sdk/utils/validate-pair-response.d.ts.map +1 -0
  156. package/dist/sdk/utils/{validate-pair-response.mjs → validate-pair-response.js} +1 -1
  157. package/dist/sdk/utils/validate-pair-response.js.map +1 -0
  158. package/dist/shared/encryption/{cache.d.cts → cache.d.ts} +1 -1
  159. package/dist/shared/encryption/cache.d.ts.map +1 -0
  160. package/dist/shared/encryption/{cache.mjs → cache.js} +4 -4
  161. package/dist/shared/encryption/cache.js.map +1 -0
  162. package/dist/shared/encryption/{constants.d.cts → constants.d.ts} +2 -2
  163. package/dist/shared/encryption/constants.d.ts.map +1 -0
  164. package/dist/shared/encryption/{constants.mjs → constants.js} +1 -1
  165. package/dist/shared/encryption/constants.js.map +1 -0
  166. package/dist/shared/encryption/{encryption.d.cts → encryption.d.ts} +3 -3
  167. package/dist/shared/encryption/encryption.d.ts.map +1 -0
  168. package/dist/shared/encryption/encryption.js +202 -0
  169. package/dist/shared/encryption/encryption.js.map +1 -0
  170. package/dist/shared/encryption/index.d.ts +5 -0
  171. package/dist/shared/encryption/index.d.ts.map +1 -0
  172. package/dist/shared/encryption/index.js +5 -0
  173. package/dist/shared/encryption/index.js.map +1 -0
  174. package/dist/shared/encryption/{utils.d.cts → utils.d.ts} +3 -3
  175. package/dist/shared/encryption/utils.d.ts.map +1 -0
  176. package/dist/shared/encryption/{utils.mjs → utils.js} +1 -1
  177. package/dist/shared/encryption/utils.js.map +1 -0
  178. package/dist/shared/{env.d.cts → env.d.ts} +1 -1
  179. package/dist/shared/env.d.ts.map +1 -0
  180. package/dist/shared/{env.mjs → env.js} +1 -1
  181. package/dist/shared/env.js.map +1 -0
  182. package/dist/shared/{storage-schema.d.mts → storage-schema.d.ts} +1 -1
  183. package/dist/shared/storage-schema.d.ts.map +1 -0
  184. package/dist/shared/{storage-schema.mjs → storage-schema.js} +2 -2
  185. package/dist/shared/storage-schema.js.map +1 -0
  186. package/dist/shared/types/{encryption.d.cts → encryption.d.ts} +1 -1
  187. package/dist/shared/types/encryption.d.ts.map +1 -0
  188. package/dist/shared/types/encryption.js +2 -0
  189. package/dist/shared/types/encryption.js.map +1 -0
  190. package/dist/shared/types/{services.d.cts → services.d.ts} +2 -2
  191. package/dist/shared/types/services.d.ts.map +1 -0
  192. package/dist/shared/types/services.js +2 -0
  193. package/dist/shared/types/services.js.map +1 -0
  194. package/dist/shared/utils/{entropy-source.d.cts → entropy-source.d.ts} +2 -2
  195. package/dist/shared/utils/entropy-source.d.ts.map +1 -0
  196. package/dist/shared/utils/{entropy-source.mjs → entropy-source.js} +2 -2
  197. package/dist/shared/utils/entropy-source.js.map +1 -0
  198. package/dist/shared/utils/{event-queue.d.cts → event-queue.d.ts} +1 -1
  199. package/dist/shared/utils/event-queue.d.ts.map +1 -0
  200. package/dist/shared/utils/{event-queue.mjs → event-queue.js} +2 -4
  201. package/dist/shared/utils/event-queue.js.map +1 -0
  202. package/dist/shared/utils/{hd-keyring-seed.d.mts → hd-keyring-seed.d.ts} +3 -3
  203. package/dist/shared/utils/hd-keyring-seed.d.ts.map +1 -0
  204. package/dist/shared/utils/{hd-keyring-seed.mjs → hd-keyring-seed.js} +1 -1
  205. package/dist/shared/utils/hd-keyring-seed.js.map +1 -0
  206. package/dist/shared/utils/{message-signing.d.mts → message-signing.d.ts} +1 -1
  207. package/dist/shared/utils/message-signing.d.ts.map +1 -0
  208. package/dist/shared/utils/{message-signing.mjs → message-signing.js} +7 -7
  209. package/dist/shared/utils/message-signing.js.map +1 -0
  210. package/package.json +22 -56
  211. package/dist/controllers/authentication/AuthenticationController-method-action-types.cjs +0 -7
  212. package/dist/controllers/authentication/AuthenticationController-method-action-types.cjs.map +0 -1
  213. package/dist/controllers/authentication/AuthenticationController-method-action-types.d.cts +0 -102
  214. package/dist/controllers/authentication/AuthenticationController-method-action-types.d.cts.map +0 -1
  215. package/dist/controllers/authentication/AuthenticationController-method-action-types.d.mts.map +0 -1
  216. package/dist/controllers/authentication/AuthenticationController-method-action-types.mjs.map +0 -1
  217. package/dist/controllers/authentication/AuthenticationController.cjs +0 -489
  218. package/dist/controllers/authentication/AuthenticationController.cjs.map +0 -1
  219. package/dist/controllers/authentication/AuthenticationController.d.cts +0 -130
  220. package/dist/controllers/authentication/AuthenticationController.d.cts.map +0 -1
  221. package/dist/controllers/authentication/AuthenticationController.d.mts.map +0 -1
  222. package/dist/controllers/authentication/AuthenticationController.mjs +0 -485
  223. package/dist/controllers/authentication/AuthenticationController.mjs.map +0 -1
  224. package/dist/controllers/authentication/index.cjs +0 -35
  225. package/dist/controllers/authentication/index.cjs.map +0 -1
  226. package/dist/controllers/authentication/index.d.cts.map +0 -1
  227. package/dist/controllers/authentication/index.d.mts +0 -7
  228. package/dist/controllers/authentication/index.d.mts.map +0 -1
  229. package/dist/controllers/authentication/index.mjs +0 -6
  230. package/dist/controllers/authentication/index.mjs.map +0 -1
  231. package/dist/controllers/authentication/mocks/index.cjs +0 -18
  232. package/dist/controllers/authentication/mocks/index.cjs.map +0 -1
  233. package/dist/controllers/authentication/mocks/index.d.cts +0 -2
  234. package/dist/controllers/authentication/mocks/index.d.cts.map +0 -1
  235. package/dist/controllers/authentication/mocks/index.d.mts +0 -2
  236. package/dist/controllers/authentication/mocks/index.d.mts.map +0 -1
  237. package/dist/controllers/authentication/mocks/index.mjs +0 -2
  238. package/dist/controllers/authentication/mocks/index.mjs.map +0 -1
  239. package/dist/controllers/authentication/mocks/mockResponses.cjs +0 -126
  240. package/dist/controllers/authentication/mocks/mockResponses.cjs.map +0 -1
  241. package/dist/controllers/authentication/mocks/mockResponses.d.cts +0 -58
  242. package/dist/controllers/authentication/mocks/mockResponses.d.cts.map +0 -1
  243. package/dist/controllers/authentication/mocks/mockResponses.d.mts.map +0 -1
  244. package/dist/controllers/authentication/mocks/mockResponses.mjs.map +0 -1
  245. package/dist/controllers/index.cjs +0 -29
  246. package/dist/controllers/index.cjs.map +0 -1
  247. package/dist/controllers/index.d.cts +0 -3
  248. package/dist/controllers/index.d.cts.map +0 -1
  249. package/dist/controllers/index.d.mts +0 -3
  250. package/dist/controllers/index.d.mts.map +0 -1
  251. package/dist/controllers/index.mjs +0 -3
  252. package/dist/controllers/index.mjs.map +0 -1
  253. package/dist/controllers/user-storage/UserStorageController-method-action-types.cjs +0 -7
  254. package/dist/controllers/user-storage/UserStorageController-method-action-types.cjs.map +0 -1
  255. package/dist/controllers/user-storage/UserStorageController-method-action-types.d.cts +0 -137
  256. package/dist/controllers/user-storage/UserStorageController-method-action-types.d.cts.map +0 -1
  257. package/dist/controllers/user-storage/UserStorageController-method-action-types.d.mts.map +0 -1
  258. package/dist/controllers/user-storage/UserStorageController-method-action-types.mjs.map +0 -1
  259. package/dist/controllers/user-storage/UserStorageController.cjs +0 -412
  260. package/dist/controllers/user-storage/UserStorageController.cjs.map +0 -1
  261. package/dist/controllers/user-storage/UserStorageController.d.cts.map +0 -1
  262. package/dist/controllers/user-storage/UserStorageController.d.mts +0 -182
  263. package/dist/controllers/user-storage/UserStorageController.d.mts.map +0 -1
  264. package/dist/controllers/user-storage/UserStorageController.mjs +0 -408
  265. package/dist/controllers/user-storage/UserStorageController.mjs.map +0 -1
  266. package/dist/controllers/user-storage/constants.cjs +0 -19
  267. package/dist/controllers/user-storage/constants.cjs.map +0 -1
  268. package/dist/controllers/user-storage/constants.d.cts +0 -15
  269. package/dist/controllers/user-storage/constants.d.cts.map +0 -1
  270. package/dist/controllers/user-storage/constants.d.mts +0 -15
  271. package/dist/controllers/user-storage/constants.d.mts.map +0 -1
  272. package/dist/controllers/user-storage/constants.mjs.map +0 -1
  273. package/dist/controllers/user-storage/contact-syncing/constants.cjs +0 -12
  274. package/dist/controllers/user-storage/contact-syncing/constants.cjs.map +0 -1
  275. package/dist/controllers/user-storage/contact-syncing/constants.d.cts.map +0 -1
  276. package/dist/controllers/user-storage/contact-syncing/constants.d.mts +0 -9
  277. package/dist/controllers/user-storage/contact-syncing/constants.d.mts.map +0 -1
  278. package/dist/controllers/user-storage/contact-syncing/constants.mjs.map +0 -1
  279. package/dist/controllers/user-storage/contact-syncing/controller-integration.cjs +0 -346
  280. package/dist/controllers/user-storage/contact-syncing/controller-integration.cjs.map +0 -1
  281. package/dist/controllers/user-storage/contact-syncing/controller-integration.d.cts.map +0 -1
  282. package/dist/controllers/user-storage/contact-syncing/controller-integration.d.mts +0 -47
  283. package/dist/controllers/user-storage/contact-syncing/controller-integration.d.mts.map +0 -1
  284. package/dist/controllers/user-storage/contact-syncing/controller-integration.mjs.map +0 -1
  285. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.cjs +0 -50
  286. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.cjs.map +0 -1
  287. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.cts.map +0 -1
  288. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.mts +0 -8
  289. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.mts.map +0 -1
  290. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.mjs.map +0 -1
  291. package/dist/controllers/user-storage/contact-syncing/sync-utils.cjs +0 -23
  292. package/dist/controllers/user-storage/contact-syncing/sync-utils.cjs.map +0 -1
  293. package/dist/controllers/user-storage/contact-syncing/sync-utils.d.cts.map +0 -1
  294. package/dist/controllers/user-storage/contact-syncing/sync-utils.d.mts +0 -9
  295. package/dist/controllers/user-storage/contact-syncing/sync-utils.d.mts.map +0 -1
  296. package/dist/controllers/user-storage/contact-syncing/sync-utils.mjs.map +0 -1
  297. package/dist/controllers/user-storage/contact-syncing/types.cjs +0 -3
  298. package/dist/controllers/user-storage/contact-syncing/types.cjs.map +0 -1
  299. package/dist/controllers/user-storage/contact-syncing/types.d.cts.map +0 -1
  300. package/dist/controllers/user-storage/contact-syncing/types.d.mts +0 -37
  301. package/dist/controllers/user-storage/contact-syncing/types.d.mts.map +0 -1
  302. package/dist/controllers/user-storage/contact-syncing/types.mjs +0 -2
  303. package/dist/controllers/user-storage/contact-syncing/types.mjs.map +0 -1
  304. package/dist/controllers/user-storage/contact-syncing/utils.cjs +0 -64
  305. package/dist/controllers/user-storage/contact-syncing/utils.cjs.map +0 -1
  306. package/dist/controllers/user-storage/contact-syncing/utils.d.cts +0 -36
  307. package/dist/controllers/user-storage/contact-syncing/utils.d.cts.map +0 -1
  308. package/dist/controllers/user-storage/contact-syncing/utils.d.mts.map +0 -1
  309. package/dist/controllers/user-storage/contact-syncing/utils.mjs.map +0 -1
  310. package/dist/controllers/user-storage/index.cjs +0 -38
  311. package/dist/controllers/user-storage/index.cjs.map +0 -1
  312. package/dist/controllers/user-storage/index.d.cts.map +0 -1
  313. package/dist/controllers/user-storage/index.d.mts +0 -10
  314. package/dist/controllers/user-storage/index.d.mts.map +0 -1
  315. package/dist/controllers/user-storage/index.mjs +0 -9
  316. package/dist/controllers/user-storage/index.mjs.map +0 -1
  317. package/dist/controllers/user-storage/mocks/index.cjs +0 -19
  318. package/dist/controllers/user-storage/mocks/index.cjs.map +0 -1
  319. package/dist/controllers/user-storage/mocks/index.d.cts +0 -3
  320. package/dist/controllers/user-storage/mocks/index.d.cts.map +0 -1
  321. package/dist/controllers/user-storage/mocks/index.d.mts +0 -3
  322. package/dist/controllers/user-storage/mocks/index.d.mts.map +0 -1
  323. package/dist/controllers/user-storage/mocks/index.mjs +0 -3
  324. package/dist/controllers/user-storage/mocks/index.mjs.map +0 -1
  325. package/dist/controllers/user-storage/mocks/mockResponses.cjs +0 -113
  326. package/dist/controllers/user-storage/mocks/mockResponses.cjs.map +0 -1
  327. package/dist/controllers/user-storage/mocks/mockResponses.d.cts +0 -66
  328. package/dist/controllers/user-storage/mocks/mockResponses.d.cts.map +0 -1
  329. package/dist/controllers/user-storage/mocks/mockResponses.d.mts.map +0 -1
  330. package/dist/controllers/user-storage/mocks/mockResponses.mjs.map +0 -1
  331. package/dist/controllers/user-storage/mocks/mockStorage.cjs +0 -36
  332. package/dist/controllers/user-storage/mocks/mockStorage.cjs.map +0 -1
  333. package/dist/controllers/user-storage/mocks/mockStorage.d.cts.map +0 -1
  334. package/dist/controllers/user-storage/mocks/mockStorage.d.mts +0 -5
  335. package/dist/controllers/user-storage/mocks/mockStorage.d.mts.map +0 -1
  336. package/dist/controllers/user-storage/mocks/mockStorage.mjs.map +0 -1
  337. package/dist/controllers/user-storage/types.cjs +0 -3
  338. package/dist/controllers/user-storage/types.cjs.map +0 -1
  339. package/dist/controllers/user-storage/types.d.cts.map +0 -1
  340. package/dist/controllers/user-storage/types.d.mts +0 -23
  341. package/dist/controllers/user-storage/types.d.mts.map +0 -1
  342. package/dist/controllers/user-storage/types.mjs +0 -2
  343. package/dist/controllers/user-storage/types.mjs.map +0 -1
  344. package/dist/controllers/user-storage/utils.cjs +0 -32
  345. package/dist/controllers/user-storage/utils.cjs.map +0 -1
  346. package/dist/controllers/user-storage/utils.d.cts.map +0 -1
  347. package/dist/controllers/user-storage/utils.d.mts +0 -19
  348. package/dist/controllers/user-storage/utils.d.mts.map +0 -1
  349. package/dist/controllers/user-storage/utils.mjs.map +0 -1
  350. package/dist/index.cjs +0 -30
  351. package/dist/index.cjs.map +0 -1
  352. package/dist/index.d.cts +0 -4
  353. package/dist/index.d.cts.map +0 -1
  354. package/dist/index.d.mts +0 -4
  355. package/dist/index.d.mts.map +0 -1
  356. package/dist/index.mjs +0 -4
  357. package/dist/index.mjs.map +0 -1
  358. package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs +0 -114
  359. package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs.map +0 -1
  360. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.cts.map +0 -1
  361. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.mts +0 -25
  362. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.mts.map +0 -1
  363. package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs +0 -110
  364. package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs.map +0 -1
  365. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs +0 -290
  366. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs.map +0 -1
  367. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts.map +0 -1
  368. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts +0 -44
  369. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts.map +0 -1
  370. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs +0 -263
  371. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs.map +0 -1
  372. package/dist/sdk/authentication-jwt-bearer/services.cjs +0 -400
  373. package/dist/sdk/authentication-jwt-bearer/services.cjs.map +0 -1
  374. package/dist/sdk/authentication-jwt-bearer/services.d.cts.map +0 -1
  375. package/dist/sdk/authentication-jwt-bearer/services.d.mts +0 -105
  376. package/dist/sdk/authentication-jwt-bearer/services.d.mts.map +0 -1
  377. package/dist/sdk/authentication-jwt-bearer/services.mjs.map +0 -1
  378. package/dist/sdk/authentication-jwt-bearer/types.cjs +0 -12
  379. package/dist/sdk/authentication-jwt-bearer/types.cjs.map +0 -1
  380. package/dist/sdk/authentication-jwt-bearer/types.d.cts.map +0 -1
  381. package/dist/sdk/authentication-jwt-bearer/types.d.mts +0 -114
  382. package/dist/sdk/authentication-jwt-bearer/types.d.mts.map +0 -1
  383. package/dist/sdk/authentication-jwt-bearer/types.mjs.map +0 -1
  384. package/dist/sdk/authentication-jwt-bearer/utils/identifier.cjs +0 -27
  385. package/dist/sdk/authentication-jwt-bearer/utils/identifier.cjs.map +0 -1
  386. package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.cts.map +0 -1
  387. package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.mts +0 -13
  388. package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.mts.map +0 -1
  389. package/dist/sdk/authentication-jwt-bearer/utils/identifier.mjs.map +0 -1
  390. package/dist/sdk/authentication-jwt-bearer/utils/time.cjs +0 -17
  391. package/dist/sdk/authentication-jwt-bearer/utils/time.cjs.map +0 -1
  392. package/dist/sdk/authentication-jwt-bearer/utils/time.d.cts.map +0 -1
  393. package/dist/sdk/authentication-jwt-bearer/utils/time.d.mts +0 -8
  394. package/dist/sdk/authentication-jwt-bearer/utils/time.d.mts.map +0 -1
  395. package/dist/sdk/authentication-jwt-bearer/utils/time.mjs.map +0 -1
  396. package/dist/sdk/authentication.cjs +0 -132
  397. package/dist/sdk/authentication.cjs.map +0 -1
  398. package/dist/sdk/authentication.d.cts.map +0 -1
  399. package/dist/sdk/authentication.d.mts +0 -38
  400. package/dist/sdk/authentication.d.mts.map +0 -1
  401. package/dist/sdk/authentication.mjs +0 -112
  402. package/dist/sdk/authentication.mjs.map +0 -1
  403. package/dist/sdk/constants.cjs +0 -7
  404. package/dist/sdk/constants.cjs.map +0 -1
  405. package/dist/sdk/constants.d.cts.map +0 -1
  406. package/dist/sdk/constants.d.mts +0 -4
  407. package/dist/sdk/constants.d.mts.map +0 -1
  408. package/dist/sdk/constants.mjs.map +0 -1
  409. package/dist/sdk/errors.cjs +0 -76
  410. package/dist/sdk/errors.cjs.map +0 -1
  411. package/dist/sdk/errors.d.cts.map +0 -1
  412. package/dist/sdk/errors.d.mts +0 -34
  413. package/dist/sdk/errors.d.mts.map +0 -1
  414. package/dist/sdk/errors.mjs.map +0 -1
  415. package/dist/sdk/index.cjs +0 -24
  416. package/dist/sdk/index.cjs.map +0 -1
  417. package/dist/sdk/index.d.cts +0 -8
  418. package/dist/sdk/index.d.cts.map +0 -1
  419. package/dist/sdk/index.d.mts +0 -8
  420. package/dist/sdk/index.d.mts.map +0 -1
  421. package/dist/sdk/index.mjs +0 -8
  422. package/dist/sdk/index.mjs.map +0 -1
  423. package/dist/sdk/mocks/auth.cjs +0 -82
  424. package/dist/sdk/mocks/auth.cjs.map +0 -1
  425. package/dist/sdk/mocks/auth.d.cts.map +0 -1
  426. package/dist/sdk/mocks/auth.d.mts +0 -69
  427. package/dist/sdk/mocks/auth.d.mts.map +0 -1
  428. package/dist/sdk/mocks/auth.mjs.map +0 -1
  429. package/dist/sdk/mocks/userstorage.cjs +0 -43
  430. package/dist/sdk/mocks/userstorage.cjs.map +0 -1
  431. package/dist/sdk/mocks/userstorage.d.cts.map +0 -1
  432. package/dist/sdk/mocks/userstorage.d.mts +0 -10
  433. package/dist/sdk/mocks/userstorage.d.mts.map +0 -1
  434. package/dist/sdk/mocks/userstorage.mjs.map +0 -1
  435. package/dist/sdk/user-storage.cjs +0 -386
  436. package/dist/sdk/user-storage.cjs.map +0 -1
  437. package/dist/sdk/user-storage.d.cts +0 -47
  438. package/dist/sdk/user-storage.d.cts.map +0 -1
  439. package/dist/sdk/user-storage.d.mts.map +0 -1
  440. package/dist/sdk/user-storage.mjs +0 -358
  441. package/dist/sdk/user-storage.mjs.map +0 -1
  442. package/dist/sdk/utils/eip-6963-metamask-provider.cjs +0 -70
  443. package/dist/sdk/utils/eip-6963-metamask-provider.cjs.map +0 -1
  444. package/dist/sdk/utils/eip-6963-metamask-provider.d.cts.map +0 -1
  445. package/dist/sdk/utils/eip-6963-metamask-provider.d.mts +0 -25
  446. package/dist/sdk/utils/eip-6963-metamask-provider.d.mts.map +0 -1
  447. package/dist/sdk/utils/eip-6963-metamask-provider.mjs.map +0 -1
  448. package/dist/sdk/utils/messaging-signing-snap-requests.cjs +0 -96
  449. package/dist/sdk/utils/messaging-signing-snap-requests.cjs.map +0 -1
  450. package/dist/sdk/utils/messaging-signing-snap-requests.d.cts.map +0 -1
  451. package/dist/sdk/utils/messaging-signing-snap-requests.d.mts +0 -41
  452. package/dist/sdk/utils/messaging-signing-snap-requests.d.mts.map +0 -1
  453. package/dist/sdk/utils/messaging-signing-snap-requests.mjs.map +0 -1
  454. package/dist/sdk/utils/validate-login-response.cjs +0 -49
  455. package/dist/sdk/utils/validate-login-response.cjs.map +0 -1
  456. package/dist/sdk/utils/validate-login-response.d.cts +0 -14
  457. package/dist/sdk/utils/validate-login-response.d.cts.map +0 -1
  458. package/dist/sdk/utils/validate-login-response.d.mts.map +0 -1
  459. package/dist/sdk/utils/validate-login-response.mjs.map +0 -1
  460. package/dist/sdk/utils/validate-pair-response.cjs +0 -29
  461. package/dist/sdk/utils/validate-pair-response.cjs.map +0 -1
  462. package/dist/sdk/utils/validate-pair-response.d.cts.map +0 -1
  463. package/dist/sdk/utils/validate-pair-response.d.mts +0 -26
  464. package/dist/sdk/utils/validate-pair-response.d.mts.map +0 -1
  465. package/dist/sdk/utils/validate-pair-response.mjs.map +0 -1
  466. package/dist/shared/encryption/cache.cjs +0 -77
  467. package/dist/shared/encryption/cache.cjs.map +0 -1
  468. package/dist/shared/encryption/cache.d.cts.map +0 -1
  469. package/dist/shared/encryption/cache.d.mts +0 -32
  470. package/dist/shared/encryption/cache.d.mts.map +0 -1
  471. package/dist/shared/encryption/cache.mjs.map +0 -1
  472. package/dist/shared/encryption/constants.cjs +0 -17
  473. package/dist/shared/encryption/constants.cjs.map +0 -1
  474. package/dist/shared/encryption/constants.d.cts.map +0 -1
  475. package/dist/shared/encryption/constants.d.mts +0 -9
  476. package/dist/shared/encryption/constants.d.mts.map +0 -1
  477. package/dist/shared/encryption/constants.mjs.map +0 -1
  478. package/dist/shared/encryption/encryption.cjs +0 -209
  479. package/dist/shared/encryption/encryption.cjs.map +0 -1
  480. package/dist/shared/encryption/encryption.d.cts.map +0 -1
  481. package/dist/shared/encryption/encryption.d.mts +0 -30
  482. package/dist/shared/encryption/encryption.d.mts.map +0 -1
  483. package/dist/shared/encryption/encryption.mjs +0 -205
  484. package/dist/shared/encryption/encryption.mjs.map +0 -1
  485. package/dist/shared/encryption/index.cjs +0 -25
  486. package/dist/shared/encryption/index.cjs.map +0 -1
  487. package/dist/shared/encryption/index.d.cts +0 -5
  488. package/dist/shared/encryption/index.d.cts.map +0 -1
  489. package/dist/shared/encryption/index.d.mts +0 -5
  490. package/dist/shared/encryption/index.d.mts.map +0 -1
  491. package/dist/shared/encryption/index.mjs +0 -5
  492. package/dist/shared/encryption/index.mjs.map +0 -1
  493. package/dist/shared/encryption/utils.cjs +0 -21
  494. package/dist/shared/encryption/utils.cjs.map +0 -1
  495. package/dist/shared/encryption/utils.d.cts.map +0 -1
  496. package/dist/shared/encryption/utils.d.mts +0 -5
  497. package/dist/shared/encryption/utils.d.mts.map +0 -1
  498. package/dist/shared/encryption/utils.mjs.map +0 -1
  499. package/dist/shared/env.cjs +0 -85
  500. package/dist/shared/env.cjs.map +0 -1
  501. package/dist/shared/env.d.cts.map +0 -1
  502. package/dist/shared/env.d.mts +0 -34
  503. package/dist/shared/env.d.mts.map +0 -1
  504. package/dist/shared/env.mjs.map +0 -1
  505. package/dist/shared/storage-schema.cjs +0 -42
  506. package/dist/shared/storage-schema.cjs.map +0 -1
  507. package/dist/shared/storage-schema.d.cts +0 -34
  508. package/dist/shared/storage-schema.d.cts.map +0 -1
  509. package/dist/shared/storage-schema.d.mts.map +0 -1
  510. package/dist/shared/storage-schema.mjs.map +0 -1
  511. package/dist/shared/types/encryption.cjs +0 -3
  512. package/dist/shared/types/encryption.cjs.map +0 -1
  513. package/dist/shared/types/encryption.d.cts.map +0 -1
  514. package/dist/shared/types/encryption.d.mts +0 -2
  515. package/dist/shared/types/encryption.d.mts.map +0 -1
  516. package/dist/shared/types/encryption.mjs +0 -2
  517. package/dist/shared/types/encryption.mjs.map +0 -1
  518. package/dist/shared/types/services.cjs +0 -3
  519. package/dist/shared/types/services.cjs.map +0 -1
  520. package/dist/shared/types/services.d.cts.map +0 -1
  521. package/dist/shared/types/services.d.mts +0 -17
  522. package/dist/shared/types/services.d.mts.map +0 -1
  523. package/dist/shared/types/services.mjs +0 -2
  524. package/dist/shared/types/services.mjs.map +0 -1
  525. package/dist/shared/utils/entropy-source.cjs +0 -37
  526. package/dist/shared/utils/entropy-source.cjs.map +0 -1
  527. package/dist/shared/utils/entropy-source.d.cts.map +0 -1
  528. package/dist/shared/utils/entropy-source.d.mts +0 -22
  529. package/dist/shared/utils/entropy-source.d.mts.map +0 -1
  530. package/dist/shared/utils/entropy-source.mjs.map +0 -1
  531. package/dist/shared/utils/event-queue.cjs +0 -24
  532. package/dist/shared/utils/event-queue.cjs.map +0 -1
  533. package/dist/shared/utils/event-queue.d.cts.map +0 -1
  534. package/dist/shared/utils/event-queue.d.mts +0 -6
  535. package/dist/shared/utils/event-queue.d.mts.map +0 -1
  536. package/dist/shared/utils/event-queue.mjs.map +0 -1
  537. package/dist/shared/utils/hd-keyring-seed.cjs +0 -49
  538. package/dist/shared/utils/hd-keyring-seed.cjs.map +0 -1
  539. package/dist/shared/utils/hd-keyring-seed.d.cts +0 -27
  540. package/dist/shared/utils/hd-keyring-seed.d.cts.map +0 -1
  541. package/dist/shared/utils/hd-keyring-seed.d.mts.map +0 -1
  542. package/dist/shared/utils/hd-keyring-seed.mjs.map +0 -1
  543. package/dist/shared/utils/message-signing.cjs +0 -147
  544. package/dist/shared/utils/message-signing.cjs.map +0 -1
  545. package/dist/shared/utils/message-signing.d.cts +0 -73
  546. package/dist/shared/utils/message-signing.d.cts.map +0 -1
  547. package/dist/shared/utils/message-signing.d.mts.map +0 -1
  548. package/dist/shared/utils/message-signing.mjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
 
10
10
  ### Changed
11
11
 
12
+ - **BREAKING:** Bump minimum Node.js version to 22 ([#9168](https://github.com/MetaMask/core/pull/9168))
12
13
  - **BREAKING:** Derive auth and user-storage message-signing keys natively via SIP-6 from HD keyring seeds instead of calling `@metamask/message-signing-snap` through `SnapController`. `AuthenticationController` and `UserStorageController` now require `KeyringController:withKeyringV2Unsafe` and no longer call `SnapController:handleRequest`. The message-signing snap remains for Portfolio / external origins ([#9824](https://github.com/MetaMask/core/pull/9824))
13
14
  - Derive native SIP-6 keys with `@noble/hashes` HMAC-SHA-512 instead of Web Crypto, so auth works on React Native, whose SubtleCrypto cannot HMAC.
14
15
  - Resolve HD entropy source IDs from `KeyringController` instead of the message-signing snap (`getBearerToken` primary ID, `performSignIn` SRP enumeration) ([#9794](https://github.com/MetaMask/core/pull/9794))
@@ -2,7 +2,7 @@
2
2
  * This file is auto generated.
3
3
  * Do not edit manually.
4
4
  */
5
- import type { AuthenticationController } from "./AuthenticationController.mjs";
5
+ import type { AuthenticationController } from './AuthenticationController.js';
6
6
  export type AuthenticationControllerPerformSignInAction = {
7
7
  type: `AuthenticationController:performSignIn`;
8
8
  handler: AuthenticationController['performSignIn'];
@@ -99,4 +99,4 @@ export type AuthenticationControllerIsSignedInAction = {
99
99
  * Union of all AuthenticationController action types.
100
100
  */
101
101
  export type AuthenticationControllerMethodActions = AuthenticationControllerPerformSignInAction | AuthenticationControllerRequestProfilePairingAction | AuthenticationControllerPerformSignOutAction | AuthenticationControllerGetBearerTokenAction | AuthenticationControllerGetSessionProfileAction | AuthenticationControllerRefreshCanonicalProfileIdAction | AuthenticationControllerGetUserProfileLineageAction | AuthenticationControllerGetCustomerServiceTokenAction | AuthenticationControllerIsSignedInAction;
102
- //# sourceMappingURL=AuthenticationController-method-action-types.d.mts.map
102
+ //# sourceMappingURL=AuthenticationController-method-action-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthenticationController-method-action-types.d.ts","sourceRoot":"","sources":["../../../src/controllers/authentication/AuthenticationController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAE9E,MAAM,MAAM,2CAA2C,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,wBAAwB,CAAC,eAAe,CAAC,CAAC;CACpD,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,mDAAmD,GAAG;IAChE,IAAI,EAAE,gDAAgD,CAAC;IACvD,OAAO,EAAE,wBAAwB,CAAC,uBAAuB,CAAC,CAAC;CAC5D,CAAC;AAEF,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,wBAAwB,CAAC,gBAAgB,CAAC,CAAC;CACrD,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,4CAA4C,GAAG;IACzD,IAAI,EAAE,yCAAyC,CAAC;IAChD,OAAO,EAAE,wBAAwB,CAAC,gBAAgB,CAAC,CAAC;CACrD,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,+CAA+C,GAAG;IAC5D,IAAI,EAAE,4CAA4C,CAAC;IACnD,OAAO,EAAE,wBAAwB,CAAC,mBAAmB,CAAC,CAAC;CACxD,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,uDAAuD,GAAG;IACpE,IAAI,EAAE,oDAAoD,CAAC;IAC3D,OAAO,EAAE,wBAAwB,CAAC,2BAA2B,CAAC,CAAC;CAChE,CAAC;AAEF,MAAM,MAAM,mDAAmD,GAAG;IAChE,IAAI,EAAE,gDAAgD,CAAC;IACvD,OAAO,EAAE,wBAAwB,CAAC,uBAAuB,CAAC,CAAC;CAC5D,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,qDAAqD,GAAG;IAClE,IAAI,EAAE,kDAAkD,CAAC;IACzD,OAAO,EAAE,wBAAwB,CAAC,yBAAyB,CAAC,CAAC;CAC9D,CAAC;AAEF,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,wBAAwB,CAAC,YAAY,CAAC,CAAC;CACjD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAC7C,2CAA2C,GAC3C,mDAAmD,GACnD,4CAA4C,GAC5C,4CAA4C,GAC5C,+CAA+C,GAC/C,uDAAuD,GACvD,mDAAmD,GACnD,qDAAqD,GACrD,wCAAwC,CAAC"}
@@ -3,4 +3,4 @@
3
3
  * Do not edit manually.
4
4
  */
5
5
  export {};
6
- //# sourceMappingURL=AuthenticationController-method-action-types.mjs.map
6
+ //# sourceMappingURL=AuthenticationController-method-action-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthenticationController-method-action-types.js","sourceRoot":"","sources":["../../../src/controllers/authentication/AuthenticationController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { AuthenticationController } from './AuthenticationController.js';\n\nexport type AuthenticationControllerPerformSignInAction = {\n type: `AuthenticationController:performSignIn`;\n handler: AuthenticationController['performSignIn'];\n};\n\n/**\n * Marks profile pairing as needed. Clients call this when the SRP set\n * changes (e.g. a new keyring was added) so the next auto-sign-in cycle\n * re-runs `performSignIn` and re-pairs.\n */\nexport type AuthenticationControllerRequestProfilePairingAction = {\n type: `AuthenticationController:requestProfilePairing`;\n handler: AuthenticationController['requestProfilePairing'];\n};\n\nexport type AuthenticationControllerPerformSignOutAction = {\n type: `AuthenticationController:performSignOut`;\n handler: AuthenticationController['performSignOut'];\n};\n\n/**\n * Returns a bearer token for the specified SRP, logging in if needed.\n *\n * When called without `entropySourceId`, returns the primary (first) SRP's\n * access token, which is effectively the canonical\n * profile's token that can be used by alias-aware consumers for cross-SRP\n * operations.\n *\n * @param entropySourceId - The entropy source ID. Omit for the primary SRP.\n * @returns The OIDC access token.\n */\nexport type AuthenticationControllerGetBearerTokenAction = {\n type: `AuthenticationController:getBearerToken`;\n handler: AuthenticationController['getBearerToken'];\n};\n\n/**\n * Returns the cached session profile, logging in if no session exists.\n *\n * The returned `canonicalProfileId` reflects the value from the most recent\n * login or pairing. In the rare event where a canonical changed because of\n * a pairing that happened on another device, the cached value may be stale\n * until the next login. For guaranteed freshness, call\n * `refreshCanonicalProfileId()` before reading `canonicalProfileId`.\n *\n * @param entropySourceId - The entropy source ID used to derive the key,\n * when multiple sources are available (Multi-SRP).\n * @returns profile for the session.\n */\nexport type AuthenticationControllerGetSessionProfileAction = {\n type: `AuthenticationController:getSessionProfile`;\n handler: AuthenticationController['getSessionProfile'];\n};\n\n/**\n * Forces a fresh retrieval of the canonical profile ID from the server\n * and propagates it to all cached SRP sessions.\n *\n * This method invalidates the primary SRP's cached session and forces a\n * re-login. Use it before operations that require a guaranteed-fresh\n * canonical (e.g. storage key derivation for Accounts ADR 0005). For\n * best-effort reads, use\n * `getSessionProfile().canonicalProfileId` instead.\n *\n * Only the primary SRP is re-logged-in regardless of how many SRPs exist —\n * the server returns the current canonical for the entire pairing group\n * from any single SRP login.\n *\n * @returns The refreshed canonical profile ID.\n */\nexport type AuthenticationControllerRefreshCanonicalProfileIdAction = {\n type: `AuthenticationController:refreshCanonicalProfileId`;\n handler: AuthenticationController['refreshCanonicalProfileId'];\n};\n\nexport type AuthenticationControllerGetUserProfileLineageAction = {\n type: `AuthenticationController:getUserProfileLineage`;\n handler: AuthenticationController['getUserProfileLineage'];\n};\n\n/**\n * Returns a Customer Service specific access token for the specified SRP,\n * logging in if needed.\n *\n * Exchanges the OIDC access token for a short-lived token scoped to the\n * customer-service audience. Customer Service tooling consumes this token to\n * identify and authenticate the user.\n *\n * @param entropySourceId - The entropy source ID. Omit for the primary SRP.\n * @returns The customer-service access token.\n */\nexport type AuthenticationControllerGetCustomerServiceTokenAction = {\n type: `AuthenticationController:getCustomerServiceToken`;\n handler: AuthenticationController['getCustomerServiceToken'];\n};\n\nexport type AuthenticationControllerIsSignedInAction = {\n type: `AuthenticationController:isSignedIn`;\n handler: AuthenticationController['isSignedIn'];\n};\n\n/**\n * Union of all AuthenticationController action types.\n */\nexport type AuthenticationControllerMethodActions =\n | AuthenticationControllerPerformSignInAction\n | AuthenticationControllerRequestProfilePairingAction\n | AuthenticationControllerPerformSignOutAction\n | AuthenticationControllerGetBearerTokenAction\n | AuthenticationControllerGetSessionProfileAction\n | AuthenticationControllerRefreshCanonicalProfileIdAction\n | AuthenticationControllerGetUserProfileLineageAction\n | AuthenticationControllerGetCustomerServiceTokenAction\n | AuthenticationControllerIsSignedInAction;\n"]}
@@ -1,12 +1,12 @@
1
- import { BaseController } from "@metamask/base-controller";
2
- import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller";
3
- import type { KeyringControllerGetStateAction, KeyringControllerLockEvent, KeyringControllerUnlockEvent, KeyringControllerWithKeyringV2UnsafeAction } from "@metamask/keyring-controller";
4
- import type { Messenger } from "@metamask/messenger";
5
- import type { SeedlessOnboardingControllerGetStateAction } from "@metamask/seedless-onboarding-controller";
6
- import type { LoginResponse, ProfileAlias, UserProfile, UserProfileLineage } from "../../sdk/index.mjs";
7
- import { Env } from "../../sdk/index.mjs";
8
- import type { MetaMetricsAuth } from "../../shared/types/services.mjs";
9
- import { AuthenticationControllerMethodActions } from "./AuthenticationController-method-action-types.mjs";
1
+ import { BaseController } from '@metamask/base-controller';
2
+ import type { ControllerGetStateAction, ControllerStateChangeEvent } from '@metamask/base-controller';
3
+ import type { KeyringControllerGetStateAction, KeyringControllerLockEvent, KeyringControllerUnlockEvent, KeyringControllerWithKeyringV2UnsafeAction } from '@metamask/keyring-controller';
4
+ import type { Messenger } from '@metamask/messenger';
5
+ import type { SeedlessOnboardingControllerGetStateAction } from '@metamask/seedless-onboarding-controller';
6
+ import type { LoginResponse, ProfileAlias, UserProfile, UserProfileLineage } from '../../sdk/index.js';
7
+ import { Env } from '../../sdk/index.js';
8
+ import type { MetaMetricsAuth } from '../../shared/types/services.js';
9
+ import { AuthenticationControllerMethodActions } from './AuthenticationController-method-action-types.js';
10
10
  declare const controllerName = "AuthenticationController";
11
11
  export type AuthenticationControllerState = {
12
12
  isSignedIn: boolean;
@@ -127,4 +127,4 @@ export declare class AuthenticationController extends BaseController<typeof cont
127
127
  isSignedIn(): boolean;
128
128
  }
129
129
  export {};
130
- //# sourceMappingURL=AuthenticationController.d.mts.map
130
+ //# sourceMappingURL=AuthenticationController.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthenticationController.d.ts","sourceRoot":"","sources":["../../../src/controllers/authentication/AuthenticationController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EACV,+BAA+B,EAC/B,0BAA0B,EAC1B,4BAA4B,EAC5B,0CAA0C,EAC3C,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,0CAA0C,EAAE,MAAM,0CAA0C,CAAC;AAG3G,OAAO,KAAK,EAEV,aAAa,EACb,YAAY,EAGZ,WAAW,EACX,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGL,GAAG,EAEJ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAUtE,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAE1G,QAAA,MAAM,cAAc,6BAA6B,CAAC;AAGlD,MAAM,MAAM,6BAA6B,GAAG;IAC1C,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC/C;;;;;;;;;;OAUG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AACF,eAAO,MAAM,YAAY,EAAE,6BAG1B,CAAC;AA4CF,KAAK,gBAAgB,GAAG;IACtB,GAAG,EAAE,GAAG,CAAC;CACV,CAAC;AAcF,MAAM,MAAM,OAAO,GACf,sCAAsC,GACtC,qCAAqC,CAAC;AAE1C,MAAM,MAAM,sCAAsC,GAAG,wBAAwB,CAC3E,OAAO,cAAc,EACrB,6BAA6B,CAC9B,CAAC;AAEF,MAAM,MAAM,wCAAwC,GAClD,0BAA0B,CACxB,OAAO,cAAc,EACrB,6BAA6B,CAC9B,CAAC;AAEJ,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,YAAY,EAAE,CAAC;IAC/B,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,0CAA0C,GAAG;IACvD,IAAI,EAAE,GAAG,OAAO,cAAc,gBAAgB,CAAC;IAC/C,OAAO,EAAE,CAAC,iBAAiB,CAAC,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,MAAM,GACd,wCAAwC,GACxC,0CAA0C,CAAC;AAG/C,KAAK,cAAc,GACf,+BAA+B,GAC/B,0CAA0C,GAC1C,0CAA0C,CAAC;AAE/C,KAAK,aAAa,GAAG,0BAA0B,GAAG,4BAA4B,CAAC;AAG/E,MAAM,MAAM,iCAAiC,GAAG,SAAS,CACvD,OAAO,cAAc,EACrB,OAAO,GAAG,cAAc,EACxB,MAAM,GAAG,aAAa,CACvB,CAAC;AAEF;;;GAGG;AACH,qBAAa,wBAAyB,SAAQ,cAAc,CAC1D,OAAO,cAAc,EACrB,6BAA6B,EAC7B,iCAAiC,CAClC;;IA+BC,YAAY,EACV,SAAS,EACT,KAAK,EACL,MAAM,EACN,WAAW,GACZ,EAAE;QACD,SAAS,EAAE,iCAAiC,CAAC;QAC7C,KAAK,CAAC,EAAE,6BAA6B,CAAC;QACtC,MAAM,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;QACnC;;;WAGG;QACH,WAAW,EAAE,eAAe,CAAC;KAC9B,EA8CA;IAmJY,aAAa,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CA2B9C;IAED;;;;OAIG;IACI,qBAAqB,IAAI,IAAI,CAOnC;IAuGM,cAAc,IAAI,IAAI,CAK5B;IAED;;;;;;;;;;OAUG;IACU,cAAc,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAIrE;IAED;;;;;;;;;;;;OAYG;IACU,iBAAiB,CAC5B,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,WAAW,CAAC,CAItB;IAED;;;;;;;;;;;;;;;OAeG;IACU,yBAAyB,IAAI,OAAO,CAAC,MAAM,CAAC,CAgBxD;IAcY,qBAAqB,CAChC,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,kBAAkB,CAAC,CAI7B;IAED;;;;;;;;;;OAUG;IACU,uBAAuB,CAClC,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,MAAM,CAAC,CAIjB;IAEM,UAAU,IAAI,OAAO,CAE3B;CA8EF"}
@@ -0,0 +1,536 @@
1
+ import { BaseController } from '@metamask/base-controller';
2
+ import { assertMessageStartsWithMetamask, AuthType, Env, JwtBearerAuth, } from '../../sdk/index.js';
3
+ import { getHdKeyringEntropySourceIds, getPrimaryHdKeyringEntropySourceId, } from '../../shared/utils/entropy-source.js';
4
+ import { getHdKeyringSeed } from '../../shared/utils/hd-keyring-seed.js';
5
+ import { getMessageSigningPublicKey, signMessageWithMessageSigningKey, } from '../../shared/utils/message-signing.js';
6
+ const controllerName = 'AuthenticationController';
7
+ export const defaultState = {
8
+ isSignedIn: false,
9
+ needsProfilePairing: true,
10
+ };
11
+ const metadata = {
12
+ isSignedIn: {
13
+ includeInStateLogs: true,
14
+ persist: true,
15
+ includeInDebugSnapshot: true,
16
+ usedInUi: true,
17
+ },
18
+ needsProfilePairing: {
19
+ includeInStateLogs: true,
20
+ persist: true,
21
+ includeInDebugSnapshot: true,
22
+ usedInUi: true,
23
+ },
24
+ srpSessionData: {
25
+ // Remove access token from state logs
26
+ includeInStateLogs: (srpSessionData) => {
27
+ // Unreachable branch, included just to fix a type error for the case where this property is
28
+ // unset. The type gets collapsed to include `| undefined` even though `undefined` is never
29
+ // set here, because we don't yet use `exactOptionalPropertyTypes`.
30
+ // TODO: Remove branch after enabling `exactOptionalPropertyTypes`
31
+ // ref: https://github.com/MetaMask/core/issues/6565
32
+ if (srpSessionData === null || srpSessionData === undefined) {
33
+ return null;
34
+ }
35
+ return Object.entries(srpSessionData).reduce((sanitizedSrpSessionData, [key, value]) => {
36
+ const { accessToken: _unused, ...tokenWithoutAccessToken } = value.token;
37
+ sanitizedSrpSessionData[key] = {
38
+ ...value,
39
+ token: tokenWithoutAccessToken,
40
+ };
41
+ return sanitizedSrpSessionData;
42
+ }, {});
43
+ },
44
+ persist: true,
45
+ includeInDebugSnapshot: false,
46
+ usedInUi: true,
47
+ },
48
+ };
49
+ const MESSENGER_EXPOSED_METHODS = [
50
+ 'performSignIn',
51
+ 'performSignOut',
52
+ 'getBearerToken',
53
+ 'getSessionProfile',
54
+ 'refreshCanonicalProfileId',
55
+ 'getUserProfileLineage',
56
+ 'getCustomerServiceToken',
57
+ 'isSignedIn',
58
+ 'requestProfilePairing',
59
+ ];
60
+ /**
61
+ * Controller that enables authentication for restricted endpoints.
62
+ * Used for Backup & Sync, Notifications, and other services.
63
+ */
64
+ export class AuthenticationController extends BaseController {
65
+ #metametrics;
66
+ #auth;
67
+ #config = {
68
+ env: Env.PRD,
69
+ };
70
+ #isUnlocked = false;
71
+ // Bumped by `requestProfilePairing`. `performSignIn` snapshots this
72
+ // before its first await; if it changes mid-flight we must NOT clear
73
+ // `needsProfilePairing` (the rearm signal wins).
74
+ #profilePairingRequestEpoch = 0;
75
+ #keyringController = {
76
+ setupLockedStateSubscriptions: () => {
77
+ const { isUnlocked } = this.messenger.call('KeyringController:getState');
78
+ this.#isUnlocked = isUnlocked;
79
+ this.messenger.subscribe('KeyringController:unlock', () => {
80
+ this.#isUnlocked = true;
81
+ });
82
+ this.messenger.subscribe('KeyringController:lock', () => {
83
+ this.#isUnlocked = false;
84
+ });
85
+ },
86
+ };
87
+ constructor({ messenger, state, config, metametrics, }) {
88
+ super({
89
+ messenger,
90
+ metadata,
91
+ name: controllerName,
92
+ state: { ...defaultState, ...state },
93
+ });
94
+ if (!metametrics) {
95
+ throw new Error('`metametrics` field is required');
96
+ }
97
+ this.#config = {
98
+ ...this.#config,
99
+ ...config,
100
+ };
101
+ this.#metametrics = metametrics;
102
+ this.#auth = new JwtBearerAuth({
103
+ env: this.#config.env,
104
+ platform: metametrics.agent,
105
+ type: AuthType.SRP,
106
+ }, {
107
+ storage: {
108
+ getLoginResponse: this.#getLoginResponseFromState.bind(this),
109
+ setLoginResponse: this.#setLoginResponseToState.bind(this),
110
+ },
111
+ signing: {
112
+ getIdentifier: this.#getPublicKey.bind(this),
113
+ signMessage: this.#signMessage.bind(this),
114
+ },
115
+ getLoginTag: this.#getLoginTag.bind(this),
116
+ getLoginIdentifierType: this.#getLoginIdentifierType.bind(this),
117
+ metametrics: this.#metametrics,
118
+ });
119
+ this.#keyringController.setupLockedStateSubscriptions();
120
+ this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
121
+ }
122
+ async #getLoginResponseFromState(entropySourceId) {
123
+ const resolvedId = entropySourceId ?? this.#getPrimaryEntropySourceId();
124
+ if (!this.state.srpSessionData?.[resolvedId]) {
125
+ return null;
126
+ }
127
+ return this.state.srpSessionData[resolvedId];
128
+ }
129
+ async #setLoginResponseToState(loginResponse, entropySourceId) {
130
+ const resolvedId = entropySourceId ?? this.#getPrimaryEntropySourceId();
131
+ const metaMetricsId = await this.#metametrics.getMetaMetricsId();
132
+ this.update((state) => {
133
+ state.isSignedIn = true;
134
+ if (!state.srpSessionData) {
135
+ state.srpSessionData = {};
136
+ }
137
+ state.srpSessionData[resolvedId] = {
138
+ ...loginResponse,
139
+ profile: {
140
+ ...loginResponse.profile,
141
+ metaMetricsId,
142
+ },
143
+ };
144
+ });
145
+ }
146
+ #assertIsUnlocked(methodName) {
147
+ if (!this.#isUnlocked) {
148
+ throw new Error(`${methodName} - unable to proceed, wallet is locked`);
149
+ }
150
+ }
151
+ /**
152
+ * Reads the HD keyring entropy source IDs from KeyringController.
153
+ *
154
+ * @returns The HD keyring metadata IDs, primary first.
155
+ */
156
+ #getHdKeyringEntropySourceIds() {
157
+ const { keyrings } = this.messenger.call('KeyringController:getState');
158
+ return getHdKeyringEntropySourceIds(keyrings);
159
+ }
160
+ /**
161
+ * Resolves the primary SRP's entropy source ID from KeyringController rather
162
+ * than the message-signing snap, so callers like `getBearerToken()` are not
163
+ * blocked on snap boot.
164
+ *
165
+ * @returns The primary HD keyring metadata ID.
166
+ * @throws If no HD keyring is available; callers must only resolve while
167
+ * the wallet is unlocked.
168
+ */
169
+ #getPrimaryEntropySourceId() {
170
+ const { keyrings } = this.messenger.call('KeyringController:getState');
171
+ return getPrimaryHdKeyringEntropySourceId(keyrings);
172
+ }
173
+ /**
174
+ * Resolves the SRP login tag for `raw_message`.
175
+ *
176
+ * - `primary` for the first HD entropy source
177
+ * - `secondary` for any other entropy source
178
+ *
179
+ * @param entropySourceId - Entropy source for this login attempt.
180
+ * @returns The login tag to append to the signed message.
181
+ */
182
+ async #getLoginTag(entropySourceId) {
183
+ const primaryEntropySourceId = this.#getPrimaryEntropySourceId();
184
+ const resolvedId = entropySourceId ?? primaryEntropySourceId;
185
+ return resolvedId === primaryEntropySourceId ? 'primary' : 'secondary';
186
+ }
187
+ /**
188
+ * Resolves metametrics `identifier_type` for `/srp/login`
189
+ * (`SRP` | `GOOGLE` | `APPLE` | `TELEGRAM`).
190
+ *
191
+ * This is the auth method for the entropy source, independent of
192
+ * {@link SrpLoginTag} (`primary` / `secondary`).
193
+ *
194
+ * SeedlessOnboarding currently exposes a single vault-level
195
+ * `authConnection`, which always backs the primary entropy source. Non-
196
+ * primary sources therefore return `SRP`. If social identities become
197
+ * per-entropy later, resolve from that metadata instead of assuming
198
+ * primary === social.
199
+ *
200
+ * Soft-fails to `SRP` when SeedlessOnboarding is not registered.
201
+ *
202
+ * @param entropySourceId - Entropy source for this login attempt.
203
+ * @returns The login identifier type.
204
+ */
205
+ async #getLoginIdentifierType(entropySourceId) {
206
+ const primaryEntropySourceId = this.#getPrimaryEntropySourceId();
207
+ const resolvedId = entropySourceId ?? primaryEntropySourceId;
208
+ // Social vault authConnection is only associated with the primary source.
209
+ if (resolvedId !== primaryEntropySourceId) {
210
+ return 'SRP';
211
+ }
212
+ return this.#resolveSocialIdentifierType();
213
+ }
214
+ /**
215
+ * Maps `SeedlessOnboardingController.state.authConnection` to a login
216
+ * identifier type when a social vault is present.
217
+ *
218
+ * Returns `SRP` if there is no vault, the provider is unrecognized, or
219
+ * SeedlessOnboardingController is unavailable on the messenger.
220
+ *
221
+ * @returns The social provider identifier type, or `SRP`.
222
+ */
223
+ #resolveSocialIdentifierType() {
224
+ try {
225
+ const { vault, authConnection } = this.messenger.call('SeedlessOnboardingController:getState');
226
+ if (vault === null || vault === undefined) {
227
+ return 'SRP';
228
+ }
229
+ // Match provider strings from SeedlessOnboarding state rather than
230
+ // importing AuthConnection — a value import would load that package
231
+ // (and its heavy deps) whenever this controller is imported.
232
+ switch (authConnection) {
233
+ case 'google':
234
+ return 'GOOGLE';
235
+ case 'apple':
236
+ return 'APPLE';
237
+ case 'telegram':
238
+ return 'TELEGRAM';
239
+ default:
240
+ return 'SRP';
241
+ }
242
+ }
243
+ catch {
244
+ return 'SRP';
245
+ }
246
+ }
247
+ async performSignIn() {
248
+ this.#assertIsUnlocked('performSignIn');
249
+ const epochAtStart = this.#profilePairingRequestEpoch;
250
+ const entropySourceIds = this.#getHdKeyringEntropySourceIds();
251
+ const accessTokens = [];
252
+ // We iterate sequentially in order to be sure that the first entry
253
+ // is the primary SRP LoginResponse.
254
+ for (const entropySourceId of entropySourceIds) {
255
+ const accessToken = await this.#auth.getAccessToken(entropySourceId);
256
+ accessTokens.push(accessToken);
257
+ }
258
+ if (entropySourceIds.length < 2) {
259
+ // Single-SRP wallet: nothing to pair.
260
+ this.#tryClearNeedsProfilePairing(epochAtStart);
261
+ }
262
+ else {
263
+ // Pair failures must not break sign-in; the gate stays `true` for retry.
264
+ try {
265
+ await this.#doPair(accessTokens, epochAtStart);
266
+ }
267
+ catch {
268
+ // noop
269
+ }
270
+ }
271
+ return accessTokens;
272
+ }
273
+ /**
274
+ * Marks profile pairing as needed. Clients call this when the SRP set
275
+ * changes (e.g. a new keyring was added) so the next auto-sign-in cycle
276
+ * re-runs `performSignIn` and re-pairs.
277
+ */
278
+ requestProfilePairing() {
279
+ this.#profilePairingRequestEpoch += 1;
280
+ if (!this.state.needsProfilePairing) {
281
+ this.update((state) => {
282
+ state.needsProfilePairing = true;
283
+ });
284
+ }
285
+ }
286
+ /**
287
+ * Clears `needsProfilePairing` only if no `requestProfilePairing` call
288
+ * landed since `epochAtStart` was captured. Prevents `performSignIn`
289
+ * from silently overwriting a concurrent rearm.
290
+ *
291
+ * @param epochAtStart - Epoch value captured at the start of `performSignIn`.
292
+ */
293
+ #tryClearNeedsProfilePairing(epochAtStart) {
294
+ if (this.#profilePairingRequestEpoch !== epochAtStart) {
295
+ return;
296
+ }
297
+ if (this.state.needsProfilePairing) {
298
+ this.update((state) => {
299
+ state.needsProfilePairing = false;
300
+ });
301
+ }
302
+ }
303
+ /**
304
+ * Pairs all SRPs via `POST /profile/pair`, propagates the canonical
305
+ * profile ID, clears `needsProfilePairing`, and emits
306
+ * `AuthenticationController:profileSignIn` when the canonical changes or
307
+ * new aliases are returned. Throws on failure.
308
+ *
309
+ * @param accessTokens - Per-SRP access tokens, primary first.
310
+ * @param epochAtStart - Pairing-request epoch captured by the caller.
311
+ * Used to skip the gate clear if `requestProfilePairing` ran while the
312
+ * pair API call was in-flight.
313
+ */
314
+ async #doPair(accessTokens, epochAtStart) {
315
+ const previousCanonical = this.#getCanonicalProfileId();
316
+ const profileAliases = await this.#pairSrpProfiles(accessTokens);
317
+ const newCanonical = this.#getCanonicalProfileId();
318
+ // If somehow we cannot compute the new canonical profile ID after pairing,
319
+ // we just return now and do not update the `needsProfilePairing` flag.
320
+ if (!newCanonical) {
321
+ return;
322
+ }
323
+ this.#tryClearNeedsProfilePairing(epochAtStart);
324
+ const profileIdChanged = previousCanonical !== newCanonical;
325
+ const shouldEmitProfileSignInEvent = profileIdChanged || profileAliases.length > 0;
326
+ if (shouldEmitProfileSignInEvent) {
327
+ this.messenger.publish('AuthenticationController:profileSignIn', {
328
+ profileId: newCanonical,
329
+ profileAliases,
330
+ profileIdChanged,
331
+ });
332
+ }
333
+ }
334
+ async #pairSrpProfiles(accessTokens) {
335
+ if (accessTokens.length < 2) {
336
+ return [];
337
+ }
338
+ const primaryAccessToken = accessTokens[0]; // Associated with primary SRP.
339
+ const { profileAliases, profile: { canonicalProfileId }, } = await this.#auth.pairSrpProfiles(accessTokens, primaryAccessToken);
340
+ this.#propagateCanonical(canonicalProfileId);
341
+ return profileAliases;
342
+ }
343
+ #propagateCanonical(canonicalProfileId) {
344
+ const { srpSessionData } = this.state;
345
+ if (!srpSessionData) {
346
+ return;
347
+ }
348
+ this.update((state) => {
349
+ for (const entry of Object.values(state.srpSessionData ?? {})) {
350
+ if (entry?.profile) {
351
+ entry.profile.canonicalProfileId = canonicalProfileId;
352
+ }
353
+ }
354
+ });
355
+ }
356
+ /**
357
+ * Returns the canonical profile id from the primary SRP's cached session.
358
+ * Returns `null` when no session exists yet for the primary SRP.
359
+ *
360
+ * Always reads from the primary SRP because the canonical is shared across
361
+ * all paired SRPs after `#propagateCanonical`.
362
+ *
363
+ * @returns The canonical profile id, or `null` if unavailable.
364
+ */
365
+ #getCanonicalProfileId() {
366
+ const primaryEntropySourceId = this.#getPrimaryEntropySourceId();
367
+ return (this.state.srpSessionData?.[primaryEntropySourceId]?.profile
368
+ ?.canonicalProfileId ?? null);
369
+ }
370
+ performSignOut() {
371
+ this.update((state) => {
372
+ state.isSignedIn = false;
373
+ state.srpSessionData = undefined;
374
+ });
375
+ }
376
+ /**
377
+ * Returns a bearer token for the specified SRP, logging in if needed.
378
+ *
379
+ * When called without `entropySourceId`, returns the primary (first) SRP's
380
+ * access token, which is effectively the canonical
381
+ * profile's token that can be used by alias-aware consumers for cross-SRP
382
+ * operations.
383
+ *
384
+ * @param entropySourceId - The entropy source ID. Omit for the primary SRP.
385
+ * @returns The OIDC access token.
386
+ */
387
+ async getBearerToken(entropySourceId) {
388
+ this.#assertIsUnlocked('getBearerToken');
389
+ const resolvedId = entropySourceId ?? this.#getPrimaryEntropySourceId();
390
+ return await this.#auth.getAccessToken(resolvedId);
391
+ }
392
+ /**
393
+ * Returns the cached session profile, logging in if no session exists.
394
+ *
395
+ * The returned `canonicalProfileId` reflects the value from the most recent
396
+ * login or pairing. In the rare event where a canonical changed because of
397
+ * a pairing that happened on another device, the cached value may be stale
398
+ * until the next login. For guaranteed freshness, call
399
+ * `refreshCanonicalProfileId()` before reading `canonicalProfileId`.
400
+ *
401
+ * @param entropySourceId - The entropy source ID used to derive the key,
402
+ * when multiple sources are available (Multi-SRP).
403
+ * @returns profile for the session.
404
+ */
405
+ async getSessionProfile(entropySourceId) {
406
+ this.#assertIsUnlocked('getSessionProfile');
407
+ const resolvedId = entropySourceId ?? this.#getPrimaryEntropySourceId();
408
+ return await this.#auth.getUserProfile(resolvedId);
409
+ }
410
+ /**
411
+ * Forces a fresh retrieval of the canonical profile ID from the server
412
+ * and propagates it to all cached SRP sessions.
413
+ *
414
+ * This method invalidates the primary SRP's cached session and forces a
415
+ * re-login. Use it before operations that require a guaranteed-fresh
416
+ * canonical (e.g. storage key derivation for Accounts ADR 0005). For
417
+ * best-effort reads, use
418
+ * `getSessionProfile().canonicalProfileId` instead.
419
+ *
420
+ * Only the primary SRP is re-logged-in regardless of how many SRPs exist —
421
+ * the server returns the current canonical for the entire pairing group
422
+ * from any single SRP login.
423
+ *
424
+ * @returns The refreshed canonical profile ID.
425
+ */
426
+ async refreshCanonicalProfileId() {
427
+ this.#assertIsUnlocked('refreshCanonicalProfileId');
428
+ const primaryEntropySourceId = this.#getPrimaryEntropySourceId();
429
+ this.#invalidateSrpSession(primaryEntropySourceId);
430
+ await this.#auth.getAccessToken(primaryEntropySourceId);
431
+ const canonical = this.#getCanonicalProfileId();
432
+ if (!canonical) {
433
+ throw new Error('refreshCanonicalProfileId - Unable to resolve canonical profile ID');
434
+ }
435
+ this.#propagateCanonical(canonical);
436
+ return canonical;
437
+ }
438
+ #invalidateSrpSession(entropySourceId) {
439
+ this.update((state) => {
440
+ const entry = state.srpSessionData?.[entropySourceId];
441
+ if (entry?.profile) {
442
+ // Setting canonicalProfileId to '' forces a re-fetch on the next
443
+ // #getAuthSession call. The falsy check (!auth.profile.canonicalProfileId)
444
+ // treats '' the same as undefined/null — all signal an invalid session.
445
+ entry.profile.canonicalProfileId = '';
446
+ }
447
+ });
448
+ }
449
+ async getUserProfileLineage(entropySourceId) {
450
+ this.#assertIsUnlocked('getUserProfileLineage');
451
+ const resolvedId = entropySourceId ?? this.#getPrimaryEntropySourceId();
452
+ return await this.#auth.getUserProfileLineage(resolvedId);
453
+ }
454
+ /**
455
+ * Returns a Customer Service specific access token for the specified SRP,
456
+ * logging in if needed.
457
+ *
458
+ * Exchanges the OIDC access token for a short-lived token scoped to the
459
+ * customer-service audience. Customer Service tooling consumes this token to
460
+ * identify and authenticate the user.
461
+ *
462
+ * @param entropySourceId - The entropy source ID. Omit for the primary SRP.
463
+ * @returns The customer-service access token.
464
+ */
465
+ async getCustomerServiceToken(entropySourceId) {
466
+ this.#assertIsUnlocked('getCustomerServiceToken');
467
+ const resolvedId = entropySourceId ?? this.#getPrimaryEntropySourceId();
468
+ return await this.#auth.getCustomerServiceToken(resolvedId);
469
+ }
470
+ isSignedIn() {
471
+ return this.state.isSignedIn;
472
+ }
473
+ /**
474
+ * Reads the BIP-39 seed for an HD entropy source from KeyringController.
475
+ *
476
+ * @param entropySourceId - Entropy source ID. Defaults to the primary HD
477
+ * keyring.
478
+ * @returns The HD keyring seed.
479
+ */
480
+ async #getHdKeyringSeed(entropySourceId) {
481
+ const resolvedId = entropySourceId ?? this.#getPrimaryEntropySourceId();
482
+ return getHdKeyringSeed(this.messenger, resolvedId);
483
+ }
484
+ /**
485
+ * Returns the message-signing public key via native SIP-6 derivation
486
+ * (same key as `@metamask/message-signing-snap` with empty salt).
487
+ *
488
+ * @param entropySourceId - The entropy source ID used to derive the key,
489
+ * when multiple sources are available (Multi-SRP).
490
+ * @returns The public key hex.
491
+ */
492
+ async #getPublicKey(entropySourceId) {
493
+ this.#assertIsUnlocked('#getPublicKey');
494
+ const seed = await this.#getHdKeyringSeed(entropySourceId);
495
+ return getMessageSigningPublicKey(seed);
496
+ }
497
+ #_signMessageCache = {};
498
+ /**
499
+ * Builds a cache key scoped to a specific entropy source, so each SRP's
500
+ * signature stays isolated (same pattern as `UserStorageController`).
501
+ *
502
+ * When `entropySourceId` is omitted (primary SRP), it is resolved to the
503
+ * primary HD keyring's metadata ID rather than a stable literal. Because that
504
+ * ID is randomly regenerated whenever the vault is recreated (e.g. on
505
+ * restore), the cached entry is naturally invalidated across vaults — a
506
+ * different SRP can never inherit the previous primary's cached signature.
507
+ *
508
+ * @param message - The tagged message used for signing.
509
+ * @param entropySourceId - The entropy source ID. Omit for the primary SRP.
510
+ * @returns The scoped cache key.
511
+ */
512
+ #scopedCacheKey(message, entropySourceId) {
513
+ return `${entropySourceId ?? this.#getPrimaryEntropySourceId()}:${message}`;
514
+ }
515
+ /**
516
+ * Signs a `metamask:…` message with the native SIP-6 message-signing key.
517
+ *
518
+ * @param message - A specific tagged message to sign.
519
+ * @param entropySourceId - The entropy source ID used to derive the key,
520
+ * when multiple sources are available (Multi-SRP).
521
+ * @returns Compact secp256k1 signature hex.
522
+ */
523
+ async #signMessage(message, entropySourceId) {
524
+ assertMessageStartsWithMetamask(message);
525
+ this.#assertIsUnlocked('#signMessage');
526
+ const cacheKey = this.#scopedCacheKey(message, entropySourceId);
527
+ if (this.#_signMessageCache[cacheKey]) {
528
+ return this.#_signMessageCache[cacheKey];
529
+ }
530
+ const seed = await this.#getHdKeyringSeed(entropySourceId);
531
+ const result = await signMessageWithMessageSigningKey(message, seed);
532
+ this.#_signMessageCache[cacheKey] = result;
533
+ return result;
534
+ }
535
+ }
536
+ //# sourceMappingURL=AuthenticationController.js.map