@metamask/profile-sync-controller 30.0.0 → 31.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 (547) hide show
  1. package/CHANGELOG.md +19 -1
  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 +656 -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.mts → 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.mts → 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.mts → 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 +258 -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.cjs.map → services.js.map} +1 -1
  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 +104 -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} +5 -4
  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 +29 -63
  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 -596
  218. package/dist/controllers/authentication/AuthenticationController.cjs.map +0 -1
  219. package/dist/controllers/authentication/AuthenticationController.d.cts +0 -149
  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 -592
  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 -135
  240. package/dist/controllers/authentication/mocks/mockResponses.cjs.map +0 -1
  241. package/dist/controllers/authentication/mocks/mockResponses.d.cts +0 -69
  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 +0 -182
  262. package/dist/controllers/user-storage/UserStorageController.d.cts.map +0 -1
  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 +0 -37
  300. package/dist/controllers/user-storage/contact-syncing/types.d.cts.map +0 -1
  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 -293
  366. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs.map +0 -1
  367. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts +0 -45
  368. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts.map +0 -1
  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 -266
  371. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs.map +0 -1
  372. package/dist/sdk/authentication-jwt-bearer/services.cjs +0 -443
  373. package/dist/sdk/authentication-jwt-bearer/services.d.cts.map +0 -1
  374. package/dist/sdk/authentication-jwt-bearer/services.d.mts +0 -120
  375. package/dist/sdk/authentication-jwt-bearer/services.d.mts.map +0 -1
  376. package/dist/sdk/authentication-jwt-bearer/services.mjs.map +0 -1
  377. package/dist/sdk/authentication-jwt-bearer/types.cjs +0 -12
  378. package/dist/sdk/authentication-jwt-bearer/types.cjs.map +0 -1
  379. package/dist/sdk/authentication-jwt-bearer/types.d.cts.map +0 -1
  380. package/dist/sdk/authentication-jwt-bearer/types.d.mts +0 -133
  381. package/dist/sdk/authentication-jwt-bearer/types.d.mts.map +0 -1
  382. package/dist/sdk/authentication-jwt-bearer/types.mjs.map +0 -1
  383. package/dist/sdk/authentication-jwt-bearer/utils/identifier.cjs +0 -27
  384. package/dist/sdk/authentication-jwt-bearer/utils/identifier.cjs.map +0 -1
  385. package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.cts.map +0 -1
  386. package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.mts +0 -13
  387. package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.mts.map +0 -1
  388. package/dist/sdk/authentication-jwt-bearer/utils/identifier.mjs.map +0 -1
  389. package/dist/sdk/authentication-jwt-bearer/utils/time.cjs +0 -17
  390. package/dist/sdk/authentication-jwt-bearer/utils/time.cjs.map +0 -1
  391. package/dist/sdk/authentication-jwt-bearer/utils/time.d.cts.map +0 -1
  392. package/dist/sdk/authentication-jwt-bearer/utils/time.d.mts +0 -8
  393. package/dist/sdk/authentication-jwt-bearer/utils/time.d.mts.map +0 -1
  394. package/dist/sdk/authentication-jwt-bearer/utils/time.mjs.map +0 -1
  395. package/dist/sdk/authentication.cjs +0 -136
  396. package/dist/sdk/authentication.cjs.map +0 -1
  397. package/dist/sdk/authentication.d.cts.map +0 -1
  398. package/dist/sdk/authentication.d.mts +0 -39
  399. package/dist/sdk/authentication.d.mts.map +0 -1
  400. package/dist/sdk/authentication.mjs +0 -116
  401. package/dist/sdk/authentication.mjs.map +0 -1
  402. package/dist/sdk/constants.cjs +0 -8
  403. package/dist/sdk/constants.cjs.map +0 -1
  404. package/dist/sdk/constants.d.cts.map +0 -1
  405. package/dist/sdk/constants.d.mts +0 -5
  406. package/dist/sdk/constants.d.mts.map +0 -1
  407. package/dist/sdk/constants.mjs.map +0 -1
  408. package/dist/sdk/errors.cjs +0 -89
  409. package/dist/sdk/errors.cjs.map +0 -1
  410. package/dist/sdk/errors.d.cts.map +0 -1
  411. package/dist/sdk/errors.d.mts +0 -43
  412. package/dist/sdk/errors.d.mts.map +0 -1
  413. package/dist/sdk/errors.mjs.map +0 -1
  414. package/dist/sdk/index.cjs +0 -24
  415. package/dist/sdk/index.cjs.map +0 -1
  416. package/dist/sdk/index.d.cts +0 -8
  417. package/dist/sdk/index.d.cts.map +0 -1
  418. package/dist/sdk/index.d.mts +0 -8
  419. package/dist/sdk/index.d.mts.map +0 -1
  420. package/dist/sdk/index.mjs +0 -8
  421. package/dist/sdk/index.mjs.map +0 -1
  422. package/dist/sdk/mocks/auth.cjs +0 -93
  423. package/dist/sdk/mocks/auth.cjs.map +0 -1
  424. package/dist/sdk/mocks/auth.d.cts.map +0 -1
  425. package/dist/sdk/mocks/auth.d.mts +0 -80
  426. package/dist/sdk/mocks/auth.d.mts.map +0 -1
  427. package/dist/sdk/mocks/auth.mjs.map +0 -1
  428. package/dist/sdk/mocks/userstorage.cjs +0 -43
  429. package/dist/sdk/mocks/userstorage.cjs.map +0 -1
  430. package/dist/sdk/mocks/userstorage.d.cts.map +0 -1
  431. package/dist/sdk/mocks/userstorage.d.mts +0 -10
  432. package/dist/sdk/mocks/userstorage.d.mts.map +0 -1
  433. package/dist/sdk/mocks/userstorage.mjs.map +0 -1
  434. package/dist/sdk/user-storage.cjs +0 -386
  435. package/dist/sdk/user-storage.cjs.map +0 -1
  436. package/dist/sdk/user-storage.d.cts +0 -47
  437. package/dist/sdk/user-storage.d.cts.map +0 -1
  438. package/dist/sdk/user-storage.d.mts.map +0 -1
  439. package/dist/sdk/user-storage.mjs +0 -358
  440. package/dist/sdk/user-storage.mjs.map +0 -1
  441. package/dist/sdk/utils/eip-6963-metamask-provider.cjs +0 -70
  442. package/dist/sdk/utils/eip-6963-metamask-provider.cjs.map +0 -1
  443. package/dist/sdk/utils/eip-6963-metamask-provider.d.cts.map +0 -1
  444. package/dist/sdk/utils/eip-6963-metamask-provider.d.mts +0 -25
  445. package/dist/sdk/utils/eip-6963-metamask-provider.d.mts.map +0 -1
  446. package/dist/sdk/utils/eip-6963-metamask-provider.mjs.map +0 -1
  447. package/dist/sdk/utils/messaging-signing-snap-requests.cjs +0 -96
  448. package/dist/sdk/utils/messaging-signing-snap-requests.cjs.map +0 -1
  449. package/dist/sdk/utils/messaging-signing-snap-requests.d.cts.map +0 -1
  450. package/dist/sdk/utils/messaging-signing-snap-requests.d.mts +0 -41
  451. package/dist/sdk/utils/messaging-signing-snap-requests.d.mts.map +0 -1
  452. package/dist/sdk/utils/messaging-signing-snap-requests.mjs.map +0 -1
  453. package/dist/sdk/utils/validate-login-response.cjs +0 -49
  454. package/dist/sdk/utils/validate-login-response.cjs.map +0 -1
  455. package/dist/sdk/utils/validate-login-response.d.cts +0 -14
  456. package/dist/sdk/utils/validate-login-response.d.cts.map +0 -1
  457. package/dist/sdk/utils/validate-login-response.d.mts.map +0 -1
  458. package/dist/sdk/utils/validate-login-response.mjs.map +0 -1
  459. package/dist/sdk/utils/validate-pair-response.cjs +0 -29
  460. package/dist/sdk/utils/validate-pair-response.cjs.map +0 -1
  461. package/dist/sdk/utils/validate-pair-response.d.cts.map +0 -1
  462. package/dist/sdk/utils/validate-pair-response.d.mts +0 -26
  463. package/dist/sdk/utils/validate-pair-response.d.mts.map +0 -1
  464. package/dist/sdk/utils/validate-pair-response.mjs.map +0 -1
  465. package/dist/shared/encryption/cache.cjs +0 -77
  466. package/dist/shared/encryption/cache.cjs.map +0 -1
  467. package/dist/shared/encryption/cache.d.cts.map +0 -1
  468. package/dist/shared/encryption/cache.d.mts +0 -32
  469. package/dist/shared/encryption/cache.d.mts.map +0 -1
  470. package/dist/shared/encryption/cache.mjs.map +0 -1
  471. package/dist/shared/encryption/constants.cjs +0 -17
  472. package/dist/shared/encryption/constants.cjs.map +0 -1
  473. package/dist/shared/encryption/constants.d.cts.map +0 -1
  474. package/dist/shared/encryption/constants.d.mts +0 -9
  475. package/dist/shared/encryption/constants.d.mts.map +0 -1
  476. package/dist/shared/encryption/constants.mjs.map +0 -1
  477. package/dist/shared/encryption/encryption.cjs +0 -209
  478. package/dist/shared/encryption/encryption.cjs.map +0 -1
  479. package/dist/shared/encryption/encryption.d.cts.map +0 -1
  480. package/dist/shared/encryption/encryption.d.mts +0 -30
  481. package/dist/shared/encryption/encryption.d.mts.map +0 -1
  482. package/dist/shared/encryption/encryption.mjs +0 -205
  483. package/dist/shared/encryption/encryption.mjs.map +0 -1
  484. package/dist/shared/encryption/index.cjs +0 -25
  485. package/dist/shared/encryption/index.cjs.map +0 -1
  486. package/dist/shared/encryption/index.d.cts +0 -5
  487. package/dist/shared/encryption/index.d.cts.map +0 -1
  488. package/dist/shared/encryption/index.d.mts +0 -5
  489. package/dist/shared/encryption/index.d.mts.map +0 -1
  490. package/dist/shared/encryption/index.mjs +0 -5
  491. package/dist/shared/encryption/index.mjs.map +0 -1
  492. package/dist/shared/encryption/utils.cjs +0 -21
  493. package/dist/shared/encryption/utils.cjs.map +0 -1
  494. package/dist/shared/encryption/utils.d.cts.map +0 -1
  495. package/dist/shared/encryption/utils.d.mts +0 -5
  496. package/dist/shared/encryption/utils.d.mts.map +0 -1
  497. package/dist/shared/encryption/utils.mjs.map +0 -1
  498. package/dist/shared/env.cjs +0 -85
  499. package/dist/shared/env.cjs.map +0 -1
  500. package/dist/shared/env.d.cts.map +0 -1
  501. package/dist/shared/env.d.mts +0 -34
  502. package/dist/shared/env.d.mts.map +0 -1
  503. package/dist/shared/env.mjs.map +0 -1
  504. package/dist/shared/storage-schema.cjs +0 -42
  505. package/dist/shared/storage-schema.cjs.map +0 -1
  506. package/dist/shared/storage-schema.d.cts +0 -34
  507. package/dist/shared/storage-schema.d.cts.map +0 -1
  508. package/dist/shared/storage-schema.d.mts.map +0 -1
  509. package/dist/shared/storage-schema.mjs.map +0 -1
  510. package/dist/shared/types/encryption.cjs +0 -3
  511. package/dist/shared/types/encryption.cjs.map +0 -1
  512. package/dist/shared/types/encryption.d.cts.map +0 -1
  513. package/dist/shared/types/encryption.d.mts +0 -2
  514. package/dist/shared/types/encryption.d.mts.map +0 -1
  515. package/dist/shared/types/encryption.mjs +0 -2
  516. package/dist/shared/types/encryption.mjs.map +0 -1
  517. package/dist/shared/types/services.cjs +0 -3
  518. package/dist/shared/types/services.cjs.map +0 -1
  519. package/dist/shared/types/services.d.cts.map +0 -1
  520. package/dist/shared/types/services.d.mts +0 -17
  521. package/dist/shared/types/services.d.mts.map +0 -1
  522. package/dist/shared/types/services.mjs +0 -2
  523. package/dist/shared/types/services.mjs.map +0 -1
  524. package/dist/shared/utils/entropy-source.cjs +0 -37
  525. package/dist/shared/utils/entropy-source.cjs.map +0 -1
  526. package/dist/shared/utils/entropy-source.d.cts.map +0 -1
  527. package/dist/shared/utils/entropy-source.d.mts +0 -22
  528. package/dist/shared/utils/entropy-source.d.mts.map +0 -1
  529. package/dist/shared/utils/entropy-source.mjs.map +0 -1
  530. package/dist/shared/utils/event-queue.cjs +0 -24
  531. package/dist/shared/utils/event-queue.cjs.map +0 -1
  532. package/dist/shared/utils/event-queue.d.cts.map +0 -1
  533. package/dist/shared/utils/event-queue.d.mts +0 -6
  534. package/dist/shared/utils/event-queue.d.mts.map +0 -1
  535. package/dist/shared/utils/event-queue.mjs.map +0 -1
  536. package/dist/shared/utils/hd-keyring-seed.cjs +0 -49
  537. package/dist/shared/utils/hd-keyring-seed.cjs.map +0 -1
  538. package/dist/shared/utils/hd-keyring-seed.d.cts +0 -27
  539. package/dist/shared/utils/hd-keyring-seed.d.cts.map +0 -1
  540. package/dist/shared/utils/hd-keyring-seed.d.mts.map +0 -1
  541. package/dist/shared/utils/hd-keyring-seed.mjs.map +0 -1
  542. package/dist/shared/utils/message-signing.cjs +0 -147
  543. package/dist/shared/utils/message-signing.cjs.map +0 -1
  544. package/dist/shared/utils/message-signing.d.cts +0 -73
  545. package/dist/shared/utils/message-signing.d.cts.map +0 -1
  546. package/dist/shared/utils/message-signing.d.mts.map +0 -1
  547. package/dist/shared/utils/message-signing.mjs.map +0 -1
@@ -1,592 +0,0 @@
1
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
- };
6
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7
- if (kind === "m") throw new TypeError("Private method is not writable");
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
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
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
- };
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
- import { BaseController } from "@metamask/base-controller";
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";
18
- const controllerName = 'AuthenticationController';
19
- export const defaultState = {
20
- isSignedIn: false,
21
- needsProfilePairing: true,
22
- needsSocialPairing: true,
23
- };
24
- const metadata = {
25
- isSignedIn: {
26
- includeInStateLogs: true,
27
- persist: true,
28
- includeInDebugSnapshot: true,
29
- usedInUi: true,
30
- },
31
- needsProfilePairing: {
32
- includeInStateLogs: true,
33
- persist: true,
34
- includeInDebugSnapshot: true,
35
- usedInUi: true,
36
- },
37
- needsSocialPairing: {
38
- includeInStateLogs: true,
39
- persist: true,
40
- includeInDebugSnapshot: true,
41
- usedInUi: true,
42
- },
43
- srpSessionData: {
44
- // Remove access token from state logs
45
- includeInStateLogs: (srpSessionData) => {
46
- // Unreachable branch, included just to fix a type error for the case where this property is
47
- // unset. The type gets collapsed to include `| undefined` even though `undefined` is never
48
- // set here, because we don't yet use `exactOptionalPropertyTypes`.
49
- // TODO: Remove branch after enabling `exactOptionalPropertyTypes`
50
- // ref: https://github.com/MetaMask/core/issues/6565
51
- if (srpSessionData === null || srpSessionData === undefined) {
52
- return null;
53
- }
54
- return Object.entries(srpSessionData).reduce((sanitizedSrpSessionData, [key, value]) => {
55
- const { accessToken: _unused, ...tokenWithoutAccessToken } = value.token;
56
- sanitizedSrpSessionData[key] = {
57
- ...value,
58
- token: tokenWithoutAccessToken,
59
- };
60
- return sanitizedSrpSessionData;
61
- }, {});
62
- },
63
- persist: true,
64
- includeInDebugSnapshot: false,
65
- usedInUi: true,
66
- },
67
- };
68
- const MESSENGER_EXPOSED_METHODS = [
69
- 'performSignIn',
70
- 'performSignOut',
71
- 'getBearerToken',
72
- 'getSessionProfile',
73
- 'refreshCanonicalProfileId',
74
- 'getUserProfileLineage',
75
- 'getCustomerServiceToken',
76
- 'isSignedIn',
77
- 'requestProfilePairing',
78
- ];
79
- /**
80
- * Controller that enables authentication for restricted endpoints.
81
- * Used for Backup & Sync, Notifications, and other services.
82
- */
83
- export class AuthenticationController extends BaseController {
84
- constructor({ messenger, state, config, metametrics, }) {
85
- super({
86
- messenger,
87
- metadata,
88
- name: controllerName,
89
- state: { ...defaultState, ...state },
90
- });
91
- _AuthenticationController_instances.add(this);
92
- _AuthenticationController_metametrics.set(this, void 0);
93
- _AuthenticationController_auth.set(this, void 0);
94
- _AuthenticationController_config.set(this, {
95
- env: Env.PRD,
96
- isSocialPairingEnabled: () => false,
97
- });
98
- _AuthenticationController_isUnlocked.set(this, false);
99
- // Bumped by `requestProfilePairing`. `performSignIn` snapshots this
100
- // before its first await; if it changes mid-flight we must NOT clear
101
- // `needsProfilePairing` (the rearm signal wins).
102
- _AuthenticationController_profilePairingRequestEpoch.set(this, 0);
103
- _AuthenticationController_keyringController.set(this, {
104
- setupLockedStateSubscriptions: () => {
105
- const { isUnlocked } = this.messenger.call('KeyringController:getState');
106
- __classPrivateFieldSet(this, _AuthenticationController_isUnlocked, isUnlocked, "f");
107
- this.messenger.subscribe('KeyringController:unlock', () => {
108
- __classPrivateFieldSet(this, _AuthenticationController_isUnlocked, true, "f");
109
- });
110
- this.messenger.subscribe('KeyringController:lock', () => {
111
- __classPrivateFieldSet(this, _AuthenticationController_isUnlocked, false, "f");
112
- });
113
- },
114
- });
115
- _AuthenticationController__signMessageCache.set(this, {});
116
- if (!metametrics) {
117
- throw new Error('`metametrics` field is required');
118
- }
119
- __classPrivateFieldSet(this, _AuthenticationController_config, {
120
- ...__classPrivateFieldGet(this, _AuthenticationController_config, "f"),
121
- ...config,
122
- isSocialPairingEnabled: config?.isSocialPairingEnabled ?? __classPrivateFieldGet(this, _AuthenticationController_config, "f").isSocialPairingEnabled,
123
- }, "f");
124
- __classPrivateFieldSet(this, _AuthenticationController_metametrics, metametrics, "f");
125
- __classPrivateFieldSet(this, _AuthenticationController_auth, new JwtBearerAuth({
126
- env: __classPrivateFieldGet(this, _AuthenticationController_config, "f").env,
127
- platform: metametrics.agent,
128
- type: AuthType.SRP,
129
- }, {
130
- storage: {
131
- getLoginResponse: __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getLoginResponseFromState).bind(this),
132
- setLoginResponse: __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_setLoginResponseToState).bind(this),
133
- },
134
- signing: {
135
- getIdentifier: __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPublicKey).bind(this),
136
- signMessage: __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_signMessage).bind(this),
137
- },
138
- getLoginTag: __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getLoginTag).bind(this),
139
- getLoginIdentifierType: __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getLoginIdentifierType).bind(this),
140
- metametrics: __classPrivateFieldGet(this, _AuthenticationController_metametrics, "f"),
141
- }), "f");
142
- __classPrivateFieldGet(this, _AuthenticationController_keyringController, "f").setupLockedStateSubscriptions();
143
- this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
144
- }
145
- async performSignIn() {
146
- __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, 'performSignIn');
147
- const epochAtStart = __classPrivateFieldGet(this, _AuthenticationController_profilePairingRequestEpoch, "f");
148
- const entropySourceIds = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getHdKeyringEntropySourceIds).call(this);
149
- const accessTokens = [];
150
- // We iterate sequentially in order to be sure that the first entry
151
- // is the primary SRP LoginResponse.
152
- for (const entropySourceId of entropySourceIds) {
153
- const accessToken = await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").getAccessToken(entropySourceId);
154
- accessTokens.push(accessToken);
155
- }
156
- if (entropySourceIds.length < 2) {
157
- // Single-SRP wallet: nothing to pair.
158
- __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_tryClearNeedsProfilePairing).call(this, epochAtStart);
159
- }
160
- else {
161
- // Pair failures must not break sign-in; the gate stays `true` for retry.
162
- try {
163
- await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_doPair).call(this, accessTokens, epochAtStart);
164
- }
165
- catch {
166
- // noop
167
- }
168
- }
169
- try {
170
- await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_trySocialPairing).call(this, accessTokens[0]);
171
- }
172
- catch {
173
- // noop
174
- }
175
- return accessTokens;
176
- }
177
- /**
178
- * Marks profile pairing as needed. Clients call this when the SRP set
179
- * changes (e.g. a new keyring was added) so the next auto-sign-in cycle
180
- * re-runs `performSignIn` and re-pairs.
181
- */
182
- requestProfilePairing() {
183
- __classPrivateFieldSet(this, _AuthenticationController_profilePairingRequestEpoch, __classPrivateFieldGet(this, _AuthenticationController_profilePairingRequestEpoch, "f") + 1, "f");
184
- if (!this.state.needsProfilePairing) {
185
- this.update((state) => {
186
- state.needsProfilePairing = true;
187
- });
188
- }
189
- }
190
- performSignOut() {
191
- this.update((state) => {
192
- state.isSignedIn = false;
193
- state.srpSessionData = undefined;
194
- });
195
- }
196
- /**
197
- * Returns a bearer token for the specified SRP, logging in if needed.
198
- *
199
- * When called without `entropySourceId`, returns the primary (first) SRP's
200
- * access token, which is effectively the canonical
201
- * profile's token that can be used by alias-aware consumers for cross-SRP
202
- * operations.
203
- *
204
- * @param entropySourceId - The entropy source ID. Omit for the primary SRP.
205
- * @returns The OIDC access token.
206
- */
207
- async getBearerToken(entropySourceId) {
208
- __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, 'getBearerToken');
209
- const resolvedId = entropySourceId ?? __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
210
- return await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").getAccessToken(resolvedId);
211
- }
212
- /**
213
- * Returns the cached session profile, logging in if no session exists.
214
- *
215
- * The returned `canonicalProfileId` reflects the value from the most recent
216
- * login or pairing. In the rare event where a canonical changed because of
217
- * a pairing that happened on another device, the cached value may be stale
218
- * until the next login. For guaranteed freshness, call
219
- * `refreshCanonicalProfileId()` before reading `canonicalProfileId`.
220
- *
221
- * @param entropySourceId - The entropy source ID used to derive the key,
222
- * when multiple sources are available (Multi-SRP).
223
- * @returns profile for the session.
224
- */
225
- async getSessionProfile(entropySourceId) {
226
- __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, 'getSessionProfile');
227
- const resolvedId = entropySourceId ?? __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
228
- return await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").getUserProfile(resolvedId);
229
- }
230
- /**
231
- * Forces a fresh retrieval of the canonical profile ID from the server
232
- * and propagates it to all cached SRP sessions.
233
- *
234
- * This method invalidates the primary SRP's cached session and forces a
235
- * re-login. Use it before operations that require a guaranteed-fresh
236
- * canonical (e.g. storage key derivation for Accounts ADR 0005). For
237
- * best-effort reads, use
238
- * `getSessionProfile().canonicalProfileId` instead.
239
- *
240
- * Only the primary SRP is re-logged-in regardless of how many SRPs exist —
241
- * the server returns the current canonical for the entire pairing group
242
- * from any single SRP login.
243
- *
244
- * @returns The refreshed canonical profile ID.
245
- */
246
- async refreshCanonicalProfileId() {
247
- __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, 'refreshCanonicalProfileId');
248
- const primaryEntropySourceId = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
249
- __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_invalidateSrpSession).call(this, primaryEntropySourceId);
250
- await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").getAccessToken(primaryEntropySourceId);
251
- const canonical = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getCanonicalProfileId).call(this);
252
- if (!canonical) {
253
- throw new Error('refreshCanonicalProfileId - Unable to resolve canonical profile ID');
254
- }
255
- __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_propagateCanonical).call(this, canonical);
256
- return canonical;
257
- }
258
- async getUserProfileLineage(entropySourceId) {
259
- __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, 'getUserProfileLineage');
260
- const resolvedId = entropySourceId ?? __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
261
- return await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").getUserProfileLineage(resolvedId);
262
- }
263
- /**
264
- * Returns a Customer Service specific access token for the specified SRP,
265
- * logging in if needed.
266
- *
267
- * Exchanges the OIDC access token for a short-lived token scoped to the
268
- * customer-service audience. Customer Service tooling consumes this token to
269
- * identify and authenticate the user.
270
- *
271
- * @param entropySourceId - The entropy source ID. Omit for the primary SRP.
272
- * @returns The customer-service access token.
273
- */
274
- async getCustomerServiceToken(entropySourceId) {
275
- __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, 'getCustomerServiceToken');
276
- const resolvedId = entropySourceId ?? __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
277
- return await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").getCustomerServiceToken(resolvedId);
278
- }
279
- isSignedIn() {
280
- return this.state.isSignedIn;
281
- }
282
- }
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);
285
- if (!this.state.srpSessionData?.[resolvedId]) {
286
- return null;
287
- }
288
- return this.state.srpSessionData[resolvedId];
289
- }, _AuthenticationController_setLoginResponseToState = async function _AuthenticationController_setLoginResponseToState(loginResponse, entropySourceId) {
290
- const resolvedId = entropySourceId ?? __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
291
- const metaMetricsId = await __classPrivateFieldGet(this, _AuthenticationController_metametrics, "f").getMetaMetricsId();
292
- this.update((state) => {
293
- state.isSignedIn = true;
294
- if (!state.srpSessionData) {
295
- state.srpSessionData = {};
296
- }
297
- state.srpSessionData[resolvedId] = {
298
- ...loginResponse,
299
- profile: {
300
- ...loginResponse.profile,
301
- metaMetricsId,
302
- },
303
- };
304
- });
305
- }, _AuthenticationController_assertIsUnlocked = function _AuthenticationController_assertIsUnlocked(methodName) {
306
- if (!__classPrivateFieldGet(this, _AuthenticationController_isUnlocked, "f")) {
307
- throw new Error(`${methodName} - unable to proceed, wallet is locked`);
308
- }
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);
457
- }
458
- catch (error) {
459
- if (error instanceof PairConflictError) {
460
- __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_clearNeedsSocialPairing).call(this);
461
- return;
462
- }
463
- throw error;
464
- }
465
- }, _AuthenticationController_clearNeedsSocialPairing = function _AuthenticationController_clearNeedsSocialPairing() {
466
- if (this.state.needsSocialPairing !== false) {
467
- this.update((state) => {
468
- state.needsSocialPairing = false;
469
- });
470
- }
471
- }, _AuthenticationController_tryClearNeedsProfilePairing = function _AuthenticationController_tryClearNeedsProfilePairing(epochAtStart) {
472
- if (__classPrivateFieldGet(this, _AuthenticationController_profilePairingRequestEpoch, "f") !== epochAtStart) {
473
- return;
474
- }
475
- if (this.state.needsProfilePairing) {
476
- this.update((state) => {
477
- state.needsProfilePairing = false;
478
- });
479
- }
480
- }, _AuthenticationController_doPair =
481
- /**
482
- * Pairs all SRPs via `POST /profile/pair`, propagates the canonical
483
- * profile ID, clears `needsProfilePairing`, and emits
484
- * `AuthenticationController:profileSignIn` when the canonical changes or
485
- * new aliases are returned. Throws on failure.
486
- *
487
- * @param accessTokens - Per-SRP access tokens, primary first.
488
- * @param epochAtStart - Pairing-request epoch captured by the caller.
489
- * Used to skip the gate clear if `requestProfilePairing` ran while the
490
- * pair API call was in-flight.
491
- */
492
- async function _AuthenticationController_doPair(accessTokens, epochAtStart) {
493
- const previousCanonical = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getCanonicalProfileId).call(this);
494
- const profileAliases = await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_pairSrpProfiles).call(this, accessTokens);
495
- const newCanonical = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getCanonicalProfileId).call(this);
496
- // If somehow we cannot compute the new canonical profile ID after pairing,
497
- // we just return now and do not update the `needsProfilePairing` flag.
498
- if (!newCanonical) {
499
- return;
500
- }
501
- __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_tryClearNeedsProfilePairing).call(this, epochAtStart);
502
- const profileIdChanged = previousCanonical !== newCanonical;
503
- const shouldEmitProfileSignInEvent = profileIdChanged || profileAliases.length > 0;
504
- if (shouldEmitProfileSignInEvent) {
505
- this.messenger.publish('AuthenticationController:profileSignIn', {
506
- profileId: newCanonical,
507
- profileAliases,
508
- profileIdChanged,
509
- });
510
- }
511
- }, _AuthenticationController_pairSrpProfiles = async function _AuthenticationController_pairSrpProfiles(accessTokens) {
512
- if (accessTokens.length < 2) {
513
- return [];
514
- }
515
- const primaryAccessToken = accessTokens[0]; // Associated with primary SRP.
516
- const { profileAliases, profile: { canonicalProfileId }, } = await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").pairSrpProfiles(accessTokens, primaryAccessToken);
517
- __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_propagateCanonical).call(this, canonicalProfileId);
518
- return profileAliases;
519
- }, _AuthenticationController_propagateCanonical = function _AuthenticationController_propagateCanonical(canonicalProfileId) {
520
- const { srpSessionData } = this.state;
521
- if (!srpSessionData) {
522
- return;
523
- }
524
- this.update((state) => {
525
- for (const entry of Object.values(state.srpSessionData ?? {})) {
526
- if (entry?.profile) {
527
- entry.profile.canonicalProfileId = canonicalProfileId;
528
- }
529
- }
530
- });
531
- }, _AuthenticationController_getCanonicalProfileId = function _AuthenticationController_getCanonicalProfileId() {
532
- const primaryEntropySourceId = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
533
- return (this.state.srpSessionData?.[primaryEntropySourceId]?.profile
534
- ?.canonicalProfileId ?? null);
535
- }, _AuthenticationController_invalidateSrpSession = function _AuthenticationController_invalidateSrpSession(entropySourceId) {
536
- this.update((state) => {
537
- const entry = state.srpSessionData?.[entropySourceId];
538
- if (entry?.profile) {
539
- // Setting canonicalProfileId to '' forces a re-fetch on the next
540
- // #getAuthSession call. The falsy check (!auth.profile.canonicalProfileId)
541
- // treats '' the same as undefined/null — all signal an invalid session.
542
- entry.profile.canonicalProfileId = '';
543
- }
544
- });
545
- }, _AuthenticationController_getHdKeyringSeed =
546
- /**
547
- * Reads the BIP-39 seed for an HD entropy source from KeyringController.
548
- *
549
- * @param entropySourceId - Entropy source ID. Defaults to the primary HD
550
- * keyring.
551
- * @returns The HD keyring seed.
552
- */
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 =
557
- /**
558
- * Returns the message-signing public key via native SIP-6 derivation
559
- * (same key as `@metamask/message-signing-snap` with empty salt).
560
- *
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.
564
- */
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 =
572
- /**
573
- * Signs a `metamask:…` message with the native SIP-6 message-signing key.
574
- *
575
- * @param message - A specific tagged message to sign.
576
- * @param entropySourceId - The entropy source ID used to derive the key,
577
- * when multiple sources are available (Multi-SRP).
578
- * @returns Compact secp256k1 signature hex.
579
- */
580
- async function _AuthenticationController_signMessage(message, entropySourceId) {
581
- assertMessageStartsWithMetamask(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];
586
- }
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;
590
- return result;
591
- };
592
- //# sourceMappingURL=AuthenticationController.mjs.map