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

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 +0 -1
  2. package/dist/controllers/authentication/AuthenticationController-method-action-types.cjs +7 -0
  3. package/dist/controllers/authentication/AuthenticationController-method-action-types.cjs.map +1 -0
  4. package/dist/controllers/authentication/{AuthenticationController-method-action-types.d.ts → AuthenticationController-method-action-types.d.cts} +2 -2
  5. package/dist/controllers/authentication/AuthenticationController-method-action-types.d.cts.map +1 -0
  6. package/dist/controllers/authentication/AuthenticationController-method-action-types.d.mts +102 -0
  7. package/dist/controllers/authentication/AuthenticationController-method-action-types.d.mts.map +1 -0
  8. package/dist/controllers/authentication/{AuthenticationController-method-action-types.js → AuthenticationController-method-action-types.mjs} +1 -1
  9. package/dist/controllers/authentication/AuthenticationController-method-action-types.mjs.map +1 -0
  10. package/dist/controllers/authentication/AuthenticationController.cjs +489 -0
  11. package/dist/controllers/authentication/AuthenticationController.cjs.map +1 -0
  12. package/dist/controllers/authentication/{AuthenticationController.d.ts → AuthenticationController.d.cts} +10 -10
  13. package/dist/controllers/authentication/AuthenticationController.d.cts.map +1 -0
  14. package/dist/controllers/authentication/AuthenticationController.d.mts +130 -0
  15. package/dist/controllers/authentication/AuthenticationController.d.mts.map +1 -0
  16. package/dist/controllers/authentication/AuthenticationController.mjs +485 -0
  17. package/dist/controllers/authentication/AuthenticationController.mjs.map +1 -0
  18. package/dist/controllers/authentication/index.cjs +35 -0
  19. package/dist/controllers/authentication/index.cjs.map +1 -0
  20. package/dist/controllers/authentication/{index.d.ts → index.d.cts} +5 -5
  21. package/dist/controllers/authentication/index.d.cts.map +1 -0
  22. package/dist/controllers/authentication/index.d.mts +7 -0
  23. package/dist/controllers/authentication/index.d.mts.map +1 -0
  24. package/dist/controllers/authentication/index.mjs +6 -0
  25. package/dist/controllers/authentication/index.mjs.map +1 -0
  26. package/dist/controllers/authentication/mocks/index.cjs +18 -0
  27. package/dist/controllers/authentication/mocks/index.cjs.map +1 -0
  28. package/dist/controllers/authentication/mocks/index.d.cts +2 -0
  29. package/dist/controllers/authentication/mocks/index.d.cts.map +1 -0
  30. package/dist/controllers/authentication/mocks/index.d.mts +2 -0
  31. package/dist/controllers/authentication/mocks/index.d.mts.map +1 -0
  32. package/dist/controllers/authentication/mocks/index.mjs +2 -0
  33. package/dist/controllers/authentication/mocks/index.mjs.map +1 -0
  34. package/dist/controllers/authentication/mocks/mockResponses.cjs +126 -0
  35. package/dist/controllers/authentication/mocks/mockResponses.cjs.map +1 -0
  36. package/dist/controllers/authentication/mocks/{mockResponses.d.ts → mockResponses.d.cts} +1 -1
  37. package/dist/controllers/authentication/mocks/mockResponses.d.cts.map +1 -0
  38. package/dist/controllers/authentication/mocks/mockResponses.d.mts +58 -0
  39. package/dist/controllers/authentication/mocks/mockResponses.d.mts.map +1 -0
  40. package/dist/controllers/authentication/mocks/{mockResponses.js → mockResponses.mjs} +2 -2
  41. package/dist/controllers/authentication/mocks/mockResponses.mjs.map +1 -0
  42. package/dist/controllers/index.cjs +29 -0
  43. package/dist/controllers/index.cjs.map +1 -0
  44. package/dist/controllers/index.d.cts +3 -0
  45. package/dist/controllers/index.d.cts.map +1 -0
  46. package/dist/controllers/index.d.mts +3 -0
  47. package/dist/controllers/index.d.mts.map +1 -0
  48. package/dist/controllers/index.mjs +3 -0
  49. package/dist/controllers/index.mjs.map +1 -0
  50. package/dist/controllers/user-storage/UserStorageController-method-action-types.cjs +7 -0
  51. package/dist/controllers/user-storage/UserStorageController-method-action-types.cjs.map +1 -0
  52. package/dist/controllers/user-storage/{UserStorageController-method-action-types.d.ts → UserStorageController-method-action-types.d.cts} +2 -2
  53. package/dist/controllers/user-storage/UserStorageController-method-action-types.d.cts.map +1 -0
  54. package/dist/controllers/user-storage/UserStorageController-method-action-types.d.mts +137 -0
  55. package/dist/controllers/user-storage/UserStorageController-method-action-types.d.mts.map +1 -0
  56. package/dist/controllers/user-storage/{UserStorageController-method-action-types.js → UserStorageController-method-action-types.mjs} +1 -1
  57. package/dist/controllers/user-storage/UserStorageController-method-action-types.mjs.map +1 -0
  58. package/dist/controllers/user-storage/UserStorageController.cjs +412 -0
  59. package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -0
  60. package/dist/controllers/user-storage/{UserStorageController.d.ts → UserStorageController.d.cts} +14 -14
  61. package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -0
  62. package/dist/controllers/user-storage/UserStorageController.d.mts +182 -0
  63. package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -0
  64. package/dist/controllers/user-storage/UserStorageController.mjs +408 -0
  65. package/dist/controllers/user-storage/UserStorageController.mjs.map +1 -0
  66. package/dist/controllers/user-storage/constants.cjs +19 -0
  67. package/dist/controllers/user-storage/constants.cjs.map +1 -0
  68. package/dist/controllers/user-storage/constants.d.cts +15 -0
  69. package/dist/controllers/user-storage/constants.d.cts.map +1 -0
  70. package/dist/controllers/user-storage/constants.d.mts +15 -0
  71. package/dist/controllers/user-storage/constants.d.mts.map +1 -0
  72. package/dist/controllers/user-storage/{constants.js → constants.mjs} +1 -1
  73. package/dist/controllers/user-storage/constants.mjs.map +1 -0
  74. package/dist/controllers/user-storage/contact-syncing/constants.cjs +12 -0
  75. package/dist/controllers/user-storage/contact-syncing/constants.cjs.map +1 -0
  76. package/dist/controllers/user-storage/contact-syncing/{constants.d.ts → constants.d.cts} +1 -1
  77. package/dist/controllers/user-storage/contact-syncing/constants.d.cts.map +1 -0
  78. package/dist/controllers/user-storage/contact-syncing/constants.d.mts +9 -0
  79. package/dist/controllers/user-storage/contact-syncing/constants.d.mts.map +1 -0
  80. package/dist/controllers/user-storage/contact-syncing/{constants.js → constants.mjs} +1 -1
  81. package/dist/controllers/user-storage/contact-syncing/constants.mjs.map +1 -0
  82. package/dist/controllers/user-storage/contact-syncing/controller-integration.cjs +346 -0
  83. package/dist/controllers/user-storage/contact-syncing/controller-integration.cjs.map +1 -0
  84. package/dist/controllers/user-storage/contact-syncing/{controller-integration.d.ts → controller-integration.d.cts} +3 -3
  85. package/dist/controllers/user-storage/contact-syncing/controller-integration.d.cts.map +1 -0
  86. package/dist/controllers/user-storage/contact-syncing/controller-integration.d.mts +47 -0
  87. package/dist/controllers/user-storage/contact-syncing/controller-integration.d.mts.map +1 -0
  88. package/dist/controllers/user-storage/contact-syncing/{controller-integration.js → controller-integration.mjs} +6 -6
  89. package/dist/controllers/user-storage/contact-syncing/controller-integration.mjs.map +1 -0
  90. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.cjs +50 -0
  91. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.cjs.map +1 -0
  92. package/dist/controllers/user-storage/contact-syncing/{setup-subscriptions.d.ts → setup-subscriptions.d.cts} +2 -2
  93. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.cts.map +1 -0
  94. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.mts +8 -0
  95. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.mts.map +1 -0
  96. package/dist/controllers/user-storage/contact-syncing/{setup-subscriptions.js → setup-subscriptions.mjs} +4 -4
  97. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.mjs.map +1 -0
  98. package/dist/controllers/user-storage/contact-syncing/sync-utils.cjs +23 -0
  99. package/dist/controllers/user-storage/contact-syncing/sync-utils.cjs.map +1 -0
  100. package/dist/controllers/user-storage/contact-syncing/{sync-utils.d.ts → sync-utils.d.cts} +2 -2
  101. package/dist/controllers/user-storage/contact-syncing/sync-utils.d.cts.map +1 -0
  102. package/dist/controllers/user-storage/contact-syncing/sync-utils.d.mts +9 -0
  103. package/dist/controllers/user-storage/contact-syncing/sync-utils.d.mts.map +1 -0
  104. package/dist/controllers/user-storage/contact-syncing/{sync-utils.js → sync-utils.mjs} +1 -1
  105. package/dist/controllers/user-storage/contact-syncing/sync-utils.mjs.map +1 -0
  106. package/dist/controllers/user-storage/contact-syncing/types.cjs +3 -0
  107. package/dist/controllers/user-storage/contact-syncing/types.cjs.map +1 -0
  108. package/dist/controllers/user-storage/contact-syncing/{types.d.ts → types.d.cts} +6 -6
  109. package/dist/controllers/user-storage/contact-syncing/types.d.cts.map +1 -0
  110. package/dist/controllers/user-storage/contact-syncing/types.d.mts +37 -0
  111. package/dist/controllers/user-storage/contact-syncing/types.d.mts.map +1 -0
  112. package/dist/controllers/user-storage/contact-syncing/types.mjs +2 -0
  113. package/dist/controllers/user-storage/contact-syncing/types.mjs.map +1 -0
  114. package/dist/controllers/user-storage/contact-syncing/utils.cjs +64 -0
  115. package/dist/controllers/user-storage/contact-syncing/utils.cjs.map +1 -0
  116. package/dist/controllers/user-storage/contact-syncing/{utils.d.ts → utils.d.cts} +3 -3
  117. package/dist/controllers/user-storage/contact-syncing/utils.d.cts.map +1 -0
  118. package/dist/controllers/user-storage/contact-syncing/utils.d.mts +36 -0
  119. package/dist/controllers/user-storage/contact-syncing/utils.d.mts.map +1 -0
  120. package/dist/controllers/user-storage/contact-syncing/{utils.js → utils.mjs} +2 -2
  121. package/dist/controllers/user-storage/contact-syncing/utils.mjs.map +1 -0
  122. package/dist/controllers/user-storage/index.cjs +38 -0
  123. package/dist/controllers/user-storage/index.cjs.map +1 -0
  124. package/dist/controllers/user-storage/{index.d.ts → index.d.cts} +8 -8
  125. package/dist/controllers/user-storage/index.d.cts.map +1 -0
  126. package/dist/controllers/user-storage/index.d.mts +10 -0
  127. package/dist/controllers/user-storage/index.d.mts.map +1 -0
  128. package/dist/controllers/user-storage/index.mjs +9 -0
  129. package/dist/controllers/user-storage/index.mjs.map +1 -0
  130. package/dist/controllers/user-storage/mocks/index.cjs +19 -0
  131. package/dist/controllers/user-storage/mocks/index.cjs.map +1 -0
  132. package/dist/controllers/user-storage/mocks/index.d.cts +3 -0
  133. package/dist/controllers/user-storage/mocks/index.d.cts.map +1 -0
  134. package/dist/controllers/user-storage/mocks/index.d.mts +3 -0
  135. package/dist/controllers/user-storage/mocks/index.d.mts.map +1 -0
  136. package/dist/controllers/user-storage/mocks/index.mjs +3 -0
  137. package/dist/controllers/user-storage/mocks/index.mjs.map +1 -0
  138. package/dist/controllers/user-storage/mocks/mockResponses.cjs +113 -0
  139. package/dist/controllers/user-storage/mocks/mockResponses.cjs.map +1 -0
  140. package/dist/controllers/user-storage/mocks/{mockResponses.d.ts → mockResponses.d.cts} +3 -3
  141. package/dist/controllers/user-storage/mocks/mockResponses.d.cts.map +1 -0
  142. package/dist/controllers/user-storage/mocks/mockResponses.d.mts +66 -0
  143. package/dist/controllers/user-storage/mocks/mockResponses.d.mts.map +1 -0
  144. package/dist/controllers/user-storage/mocks/{mockResponses.js → mockResponses.mjs} +4 -4
  145. package/dist/controllers/user-storage/mocks/mockResponses.mjs.map +1 -0
  146. package/dist/controllers/user-storage/mocks/mockStorage.cjs +36 -0
  147. package/dist/controllers/user-storage/mocks/mockStorage.cjs.map +1 -0
  148. package/dist/controllers/user-storage/mocks/{mockStorage.d.ts → mockStorage.d.cts} +1 -1
  149. package/dist/controllers/user-storage/mocks/mockStorage.d.cts.map +1 -0
  150. package/dist/controllers/user-storage/mocks/mockStorage.d.mts +5 -0
  151. package/dist/controllers/user-storage/mocks/mockStorage.d.mts.map +1 -0
  152. package/dist/controllers/user-storage/mocks/{mockStorage.js → mockStorage.mjs} +3 -3
  153. package/dist/controllers/user-storage/mocks/mockStorage.mjs.map +1 -0
  154. package/dist/controllers/user-storage/types.cjs +3 -0
  155. package/dist/controllers/user-storage/types.cjs.map +1 -0
  156. package/dist/controllers/user-storage/{types.d.ts → types.d.cts} +3 -3
  157. package/dist/controllers/user-storage/types.d.cts.map +1 -0
  158. package/dist/controllers/user-storage/types.d.mts +23 -0
  159. package/dist/controllers/user-storage/types.d.mts.map +1 -0
  160. package/dist/controllers/user-storage/types.mjs +2 -0
  161. package/dist/controllers/user-storage/types.mjs.map +1 -0
  162. package/dist/controllers/user-storage/utils.cjs +32 -0
  163. package/dist/controllers/user-storage/utils.cjs.map +1 -0
  164. package/dist/controllers/user-storage/{utils.d.ts → utils.d.cts} +1 -1
  165. package/dist/controllers/user-storage/utils.d.cts.map +1 -0
  166. package/dist/controllers/user-storage/utils.d.mts +19 -0
  167. package/dist/controllers/user-storage/utils.d.mts.map +1 -0
  168. package/dist/controllers/user-storage/{utils.js → utils.mjs} +1 -1
  169. package/dist/controllers/user-storage/utils.mjs.map +1 -0
  170. package/dist/index.cjs +30 -0
  171. package/dist/index.cjs.map +1 -0
  172. package/dist/index.d.cts +4 -0
  173. package/dist/index.d.cts.map +1 -0
  174. package/dist/index.d.mts +4 -0
  175. package/dist/index.d.mts.map +1 -0
  176. package/dist/index.mjs +4 -0
  177. package/dist/index.mjs.map +1 -0
  178. package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs +114 -0
  179. package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs.map +1 -0
  180. package/dist/sdk/authentication-jwt-bearer/{flow-siwe.d.ts → flow-siwe.d.cts} +2 -2
  181. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.cts.map +1 -0
  182. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.mts +25 -0
  183. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.mts.map +1 -0
  184. package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs +110 -0
  185. package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs.map +1 -0
  186. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs +290 -0
  187. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs.map +1 -0
  188. package/dist/sdk/authentication-jwt-bearer/{flow-srp.d.ts → flow-srp.d.cts} +5 -5
  189. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts.map +1 -0
  190. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts +44 -0
  191. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts.map +1 -0
  192. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs +263 -0
  193. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs.map +1 -0
  194. package/dist/sdk/authentication-jwt-bearer/services.cjs +400 -0
  195. package/dist/sdk/authentication-jwt-bearer/services.cjs.map +1 -0
  196. package/dist/sdk/authentication-jwt-bearer/{services.d.ts → services.d.cts} +5 -5
  197. package/dist/sdk/authentication-jwt-bearer/services.d.cts.map +1 -0
  198. package/dist/sdk/authentication-jwt-bearer/services.d.mts +105 -0
  199. package/dist/sdk/authentication-jwt-bearer/services.d.mts.map +1 -0
  200. package/dist/sdk/authentication-jwt-bearer/{services.js → services.mjs} +6 -6
  201. package/dist/sdk/authentication-jwt-bearer/services.mjs.map +1 -0
  202. package/dist/sdk/authentication-jwt-bearer/types.cjs +12 -0
  203. package/dist/sdk/authentication-jwt-bearer/types.cjs.map +1 -0
  204. package/dist/sdk/authentication-jwt-bearer/{types.d.ts → types.d.cts} +2 -2
  205. package/dist/sdk/authentication-jwt-bearer/types.d.cts.map +1 -0
  206. package/dist/sdk/authentication-jwt-bearer/types.d.mts +114 -0
  207. package/dist/sdk/authentication-jwt-bearer/types.d.mts.map +1 -0
  208. package/dist/sdk/authentication-jwt-bearer/{types.js → types.mjs} +1 -1
  209. package/dist/sdk/authentication-jwt-bearer/types.mjs.map +1 -0
  210. package/dist/sdk/authentication-jwt-bearer/utils/identifier.cjs +27 -0
  211. package/dist/sdk/authentication-jwt-bearer/utils/identifier.cjs.map +1 -0
  212. package/dist/sdk/authentication-jwt-bearer/utils/{identifier.d.ts → identifier.d.cts} +2 -2
  213. package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.cts.map +1 -0
  214. package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.mts +13 -0
  215. package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.mts.map +1 -0
  216. package/dist/sdk/authentication-jwt-bearer/utils/{identifier.js → identifier.mjs} +2 -2
  217. package/dist/sdk/authentication-jwt-bearer/utils/identifier.mjs.map +1 -0
  218. package/dist/sdk/authentication-jwt-bearer/utils/time.cjs +17 -0
  219. package/dist/sdk/authentication-jwt-bearer/utils/time.cjs.map +1 -0
  220. package/dist/sdk/authentication-jwt-bearer/utils/{time.d.ts → time.d.cts} +1 -1
  221. package/dist/sdk/authentication-jwt-bearer/utils/time.d.cts.map +1 -0
  222. package/dist/sdk/authentication-jwt-bearer/utils/time.d.mts +8 -0
  223. package/dist/sdk/authentication-jwt-bearer/utils/time.d.mts.map +1 -0
  224. package/dist/sdk/authentication-jwt-bearer/utils/{time.js → time.mjs} +1 -1
  225. package/dist/sdk/authentication-jwt-bearer/utils/time.mjs.map +1 -0
  226. package/dist/sdk/authentication.cjs +132 -0
  227. package/dist/sdk/authentication.cjs.map +1 -0
  228. package/dist/sdk/{authentication.d.ts → authentication.d.cts} +9 -9
  229. package/dist/sdk/authentication.d.cts.map +1 -0
  230. package/dist/sdk/authentication.d.mts +38 -0
  231. package/dist/sdk/authentication.d.mts.map +1 -0
  232. package/dist/sdk/authentication.mjs +112 -0
  233. package/dist/sdk/authentication.mjs.map +1 -0
  234. package/dist/sdk/constants.cjs +7 -0
  235. package/dist/sdk/constants.cjs.map +1 -0
  236. package/dist/sdk/{constants.d.ts → constants.d.cts} +1 -1
  237. package/dist/sdk/constants.d.cts.map +1 -0
  238. package/dist/sdk/constants.d.mts +4 -0
  239. package/dist/sdk/constants.d.mts.map +1 -0
  240. package/dist/sdk/{constants.js → constants.mjs} +1 -1
  241. package/dist/sdk/constants.mjs.map +1 -0
  242. package/dist/sdk/errors.cjs +76 -0
  243. package/dist/sdk/errors.cjs.map +1 -0
  244. package/dist/sdk/{errors.d.ts → errors.d.cts} +1 -1
  245. package/dist/sdk/errors.d.cts.map +1 -0
  246. package/dist/sdk/errors.d.mts +34 -0
  247. package/dist/sdk/errors.d.mts.map +1 -0
  248. package/dist/sdk/{errors.js → errors.mjs} +3 -4
  249. package/dist/sdk/errors.mjs.map +1 -0
  250. package/dist/sdk/index.cjs +24 -0
  251. package/dist/sdk/index.cjs.map +1 -0
  252. package/dist/sdk/index.d.cts +8 -0
  253. package/dist/sdk/index.d.cts.map +1 -0
  254. package/dist/sdk/index.d.mts +8 -0
  255. package/dist/sdk/index.d.mts.map +1 -0
  256. package/dist/sdk/index.mjs +8 -0
  257. package/dist/sdk/index.mjs.map +1 -0
  258. package/dist/sdk/mocks/auth.cjs +82 -0
  259. package/dist/sdk/mocks/auth.cjs.map +1 -0
  260. package/dist/sdk/mocks/{auth.d.ts → auth.d.cts} +2 -2
  261. package/dist/sdk/mocks/auth.d.cts.map +1 -0
  262. package/dist/sdk/mocks/auth.d.mts +69 -0
  263. package/dist/sdk/mocks/auth.d.mts.map +1 -0
  264. package/dist/sdk/mocks/{auth.js → auth.mjs} +3 -3
  265. package/dist/sdk/mocks/auth.mjs.map +1 -0
  266. package/dist/sdk/mocks/userstorage.cjs +43 -0
  267. package/dist/sdk/mocks/userstorage.cjs.map +1 -0
  268. package/dist/sdk/mocks/{userstorage.d.ts → userstorage.d.cts} +1 -1
  269. package/dist/sdk/mocks/userstorage.d.cts.map +1 -0
  270. package/dist/sdk/mocks/userstorage.d.mts +10 -0
  271. package/dist/sdk/mocks/userstorage.d.mts.map +1 -0
  272. package/dist/sdk/mocks/{userstorage.js → userstorage.mjs} +5 -5
  273. package/dist/sdk/mocks/userstorage.mjs.map +1 -0
  274. package/dist/sdk/user-storage.cjs +386 -0
  275. package/dist/sdk/user-storage.cjs.map +1 -0
  276. package/dist/sdk/{user-storage.d.ts → user-storage.d.cts} +5 -5
  277. package/dist/sdk/user-storage.d.cts.map +1 -0
  278. package/dist/sdk/user-storage.d.mts +47 -0
  279. package/dist/sdk/user-storage.d.mts.map +1 -0
  280. package/dist/sdk/user-storage.mjs +358 -0
  281. package/dist/sdk/user-storage.mjs.map +1 -0
  282. package/dist/sdk/utils/eip-6963-metamask-provider.cjs +70 -0
  283. package/dist/sdk/utils/eip-6963-metamask-provider.cjs.map +1 -0
  284. package/dist/sdk/utils/{eip-6963-metamask-provider.d.ts → eip-6963-metamask-provider.d.cts} +2 -2
  285. package/dist/sdk/utils/eip-6963-metamask-provider.d.cts.map +1 -0
  286. package/dist/sdk/utils/eip-6963-metamask-provider.d.mts +25 -0
  287. package/dist/sdk/utils/eip-6963-metamask-provider.d.mts.map +1 -0
  288. package/dist/sdk/utils/{eip-6963-metamask-provider.js → eip-6963-metamask-provider.mjs} +1 -1
  289. package/dist/sdk/utils/eip-6963-metamask-provider.mjs.map +1 -0
  290. package/dist/sdk/utils/messaging-signing-snap-requests.cjs +96 -0
  291. package/dist/sdk/utils/messaging-signing-snap-requests.cjs.map +1 -0
  292. package/dist/sdk/utils/{messaging-signing-snap-requests.d.ts → messaging-signing-snap-requests.d.cts} +2 -2
  293. package/dist/sdk/utils/messaging-signing-snap-requests.d.cts.map +1 -0
  294. package/dist/sdk/utils/messaging-signing-snap-requests.d.mts +41 -0
  295. package/dist/sdk/utils/messaging-signing-snap-requests.d.mts.map +1 -0
  296. package/dist/sdk/utils/{messaging-signing-snap-requests.js → messaging-signing-snap-requests.mjs} +1 -1
  297. package/dist/sdk/utils/messaging-signing-snap-requests.mjs.map +1 -0
  298. package/dist/sdk/utils/validate-login-response.cjs +49 -0
  299. package/dist/sdk/utils/validate-login-response.cjs.map +1 -0
  300. package/dist/sdk/utils/{validate-login-response.d.ts → validate-login-response.d.cts} +2 -2
  301. package/dist/sdk/utils/validate-login-response.d.cts.map +1 -0
  302. package/dist/sdk/utils/validate-login-response.d.mts +14 -0
  303. package/dist/sdk/utils/validate-login-response.d.mts.map +1 -0
  304. package/dist/sdk/utils/{validate-login-response.js → validate-login-response.mjs} +1 -1
  305. package/dist/sdk/utils/validate-login-response.mjs.map +1 -0
  306. package/dist/sdk/utils/validate-pair-response.cjs +29 -0
  307. package/dist/sdk/utils/validate-pair-response.cjs.map +1 -0
  308. package/dist/sdk/utils/{validate-pair-response.d.ts → validate-pair-response.d.cts} +1 -1
  309. package/dist/sdk/utils/validate-pair-response.d.cts.map +1 -0
  310. package/dist/sdk/utils/validate-pair-response.d.mts +26 -0
  311. package/dist/sdk/utils/validate-pair-response.d.mts.map +1 -0
  312. package/dist/sdk/utils/{validate-pair-response.js → validate-pair-response.mjs} +1 -1
  313. package/dist/sdk/utils/validate-pair-response.mjs.map +1 -0
  314. package/dist/shared/encryption/cache.cjs +77 -0
  315. package/dist/shared/encryption/cache.cjs.map +1 -0
  316. package/dist/shared/encryption/{cache.d.ts → cache.d.cts} +1 -1
  317. package/dist/shared/encryption/cache.d.cts.map +1 -0
  318. package/dist/shared/encryption/cache.d.mts +32 -0
  319. package/dist/shared/encryption/cache.d.mts.map +1 -0
  320. package/dist/shared/encryption/{cache.js → cache.mjs} +4 -4
  321. package/dist/shared/encryption/cache.mjs.map +1 -0
  322. package/dist/shared/encryption/constants.cjs +17 -0
  323. package/dist/shared/encryption/constants.cjs.map +1 -0
  324. package/dist/shared/encryption/{constants.d.ts → constants.d.cts} +2 -2
  325. package/dist/shared/encryption/constants.d.cts.map +1 -0
  326. package/dist/shared/encryption/constants.d.mts +9 -0
  327. package/dist/shared/encryption/constants.d.mts.map +1 -0
  328. package/dist/shared/encryption/{constants.js → constants.mjs} +1 -1
  329. package/dist/shared/encryption/constants.mjs.map +1 -0
  330. package/dist/shared/encryption/encryption.cjs +209 -0
  331. package/dist/shared/encryption/encryption.cjs.map +1 -0
  332. package/dist/shared/encryption/{encryption.d.ts → encryption.d.cts} +3 -3
  333. package/dist/shared/encryption/encryption.d.cts.map +1 -0
  334. package/dist/shared/encryption/encryption.d.mts +30 -0
  335. package/dist/shared/encryption/encryption.d.mts.map +1 -0
  336. package/dist/shared/encryption/encryption.mjs +205 -0
  337. package/dist/shared/encryption/encryption.mjs.map +1 -0
  338. package/dist/shared/encryption/index.cjs +25 -0
  339. package/dist/shared/encryption/index.cjs.map +1 -0
  340. package/dist/shared/encryption/index.d.cts +5 -0
  341. package/dist/shared/encryption/index.d.cts.map +1 -0
  342. package/dist/shared/encryption/index.d.mts +5 -0
  343. package/dist/shared/encryption/index.d.mts.map +1 -0
  344. package/dist/shared/encryption/index.mjs +5 -0
  345. package/dist/shared/encryption/index.mjs.map +1 -0
  346. package/dist/shared/encryption/utils.cjs +21 -0
  347. package/dist/shared/encryption/utils.cjs.map +1 -0
  348. package/dist/shared/encryption/{utils.d.ts → utils.d.cts} +3 -3
  349. package/dist/shared/encryption/utils.d.cts.map +1 -0
  350. package/dist/shared/encryption/utils.d.mts +5 -0
  351. package/dist/shared/encryption/utils.d.mts.map +1 -0
  352. package/dist/shared/encryption/{utils.js → utils.mjs} +1 -1
  353. package/dist/shared/encryption/utils.mjs.map +1 -0
  354. package/dist/shared/env.cjs +85 -0
  355. package/dist/shared/env.cjs.map +1 -0
  356. package/dist/shared/{env.d.ts → env.d.cts} +1 -1
  357. package/dist/shared/env.d.cts.map +1 -0
  358. package/dist/shared/env.d.mts +34 -0
  359. package/dist/shared/env.d.mts.map +1 -0
  360. package/dist/shared/{env.js → env.mjs} +1 -1
  361. package/dist/shared/env.mjs.map +1 -0
  362. package/dist/shared/storage-schema.cjs +42 -0
  363. package/dist/shared/storage-schema.cjs.map +1 -0
  364. package/dist/shared/{storage-schema.d.ts → storage-schema.d.cts} +1 -1
  365. package/dist/shared/storage-schema.d.cts.map +1 -0
  366. package/dist/shared/storage-schema.d.mts +34 -0
  367. package/dist/shared/storage-schema.d.mts.map +1 -0
  368. package/dist/shared/{storage-schema.js → storage-schema.mjs} +2 -2
  369. package/dist/shared/storage-schema.mjs.map +1 -0
  370. package/dist/shared/types/encryption.cjs +3 -0
  371. package/dist/shared/types/encryption.cjs.map +1 -0
  372. package/dist/shared/types/{encryption.d.ts → encryption.d.cts} +1 -1
  373. package/dist/shared/types/encryption.d.cts.map +1 -0
  374. package/dist/shared/types/encryption.d.mts +2 -0
  375. package/dist/shared/types/encryption.d.mts.map +1 -0
  376. package/dist/shared/types/encryption.mjs +2 -0
  377. package/dist/shared/types/encryption.mjs.map +1 -0
  378. package/dist/shared/types/services.cjs +3 -0
  379. package/dist/shared/types/services.cjs.map +1 -0
  380. package/dist/shared/types/{services.d.ts → services.d.cts} +2 -2
  381. package/dist/shared/types/services.d.cts.map +1 -0
  382. package/dist/shared/types/services.d.mts +17 -0
  383. package/dist/shared/types/services.d.mts.map +1 -0
  384. package/dist/shared/types/services.mjs +2 -0
  385. package/dist/shared/types/services.mjs.map +1 -0
  386. package/dist/shared/utils/entropy-source.cjs +37 -0
  387. package/dist/shared/utils/entropy-source.cjs.map +1 -0
  388. package/dist/shared/utils/{entropy-source.d.ts → entropy-source.d.cts} +2 -2
  389. package/dist/shared/utils/entropy-source.d.cts.map +1 -0
  390. package/dist/shared/utils/entropy-source.d.mts +22 -0
  391. package/dist/shared/utils/entropy-source.d.mts.map +1 -0
  392. package/dist/shared/utils/{entropy-source.js → entropy-source.mjs} +2 -2
  393. package/dist/shared/utils/entropy-source.mjs.map +1 -0
  394. package/dist/shared/utils/event-queue.cjs +24 -0
  395. package/dist/shared/utils/event-queue.cjs.map +1 -0
  396. package/dist/shared/utils/{event-queue.d.ts → event-queue.d.cts} +1 -1
  397. package/dist/shared/utils/event-queue.d.cts.map +1 -0
  398. package/dist/shared/utils/event-queue.d.mts +6 -0
  399. package/dist/shared/utils/event-queue.d.mts.map +1 -0
  400. package/dist/shared/utils/{event-queue.js → event-queue.mjs} +4 -2
  401. package/dist/shared/utils/event-queue.mjs.map +1 -0
  402. package/dist/shared/utils/hd-keyring-seed.cjs +49 -0
  403. package/dist/shared/utils/hd-keyring-seed.cjs.map +1 -0
  404. package/dist/shared/utils/{hd-keyring-seed.d.ts → hd-keyring-seed.d.cts} +3 -3
  405. package/dist/shared/utils/hd-keyring-seed.d.cts.map +1 -0
  406. package/dist/shared/utils/hd-keyring-seed.d.mts +27 -0
  407. package/dist/shared/utils/hd-keyring-seed.d.mts.map +1 -0
  408. package/dist/shared/utils/{hd-keyring-seed.js → hd-keyring-seed.mjs} +1 -1
  409. package/dist/shared/utils/hd-keyring-seed.mjs.map +1 -0
  410. package/dist/shared/utils/message-signing.cjs +147 -0
  411. package/dist/shared/utils/message-signing.cjs.map +1 -0
  412. package/dist/shared/utils/{message-signing.d.ts → message-signing.d.cts} +1 -1
  413. package/dist/shared/utils/message-signing.d.cts.map +1 -0
  414. package/dist/shared/utils/message-signing.d.mts +73 -0
  415. package/dist/shared/utils/message-signing.d.mts.map +1 -0
  416. package/dist/shared/utils/{message-signing.js → message-signing.mjs} +7 -7
  417. package/dist/shared/utils/message-signing.mjs.map +1 -0
  418. package/package.json +56 -22
  419. package/dist/controllers/authentication/AuthenticationController-method-action-types.d.ts.map +0 -1
  420. package/dist/controllers/authentication/AuthenticationController-method-action-types.js.map +0 -1
  421. package/dist/controllers/authentication/AuthenticationController.d.ts.map +0 -1
  422. package/dist/controllers/authentication/AuthenticationController.js +0 -536
  423. package/dist/controllers/authentication/AuthenticationController.js.map +0 -1
  424. package/dist/controllers/authentication/index.d.ts.map +0 -1
  425. package/dist/controllers/authentication/index.js +0 -6
  426. package/dist/controllers/authentication/index.js.map +0 -1
  427. package/dist/controllers/authentication/mocks/index.d.ts +0 -2
  428. package/dist/controllers/authentication/mocks/index.d.ts.map +0 -1
  429. package/dist/controllers/authentication/mocks/index.js +0 -2
  430. package/dist/controllers/authentication/mocks/index.js.map +0 -1
  431. package/dist/controllers/authentication/mocks/mockResponses.d.ts.map +0 -1
  432. package/dist/controllers/authentication/mocks/mockResponses.js.map +0 -1
  433. package/dist/controllers/index.d.ts +0 -3
  434. package/dist/controllers/index.d.ts.map +0 -1
  435. package/dist/controllers/index.js +0 -3
  436. package/dist/controllers/index.js.map +0 -1
  437. package/dist/controllers/user-storage/UserStorageController-method-action-types.d.ts.map +0 -1
  438. package/dist/controllers/user-storage/UserStorageController-method-action-types.js.map +0 -1
  439. package/dist/controllers/user-storage/UserStorageController.d.ts.map +0 -1
  440. package/dist/controllers/user-storage/UserStorageController.js +0 -429
  441. package/dist/controllers/user-storage/UserStorageController.js.map +0 -1
  442. package/dist/controllers/user-storage/constants.d.ts +0 -15
  443. package/dist/controllers/user-storage/constants.d.ts.map +0 -1
  444. package/dist/controllers/user-storage/constants.js.map +0 -1
  445. package/dist/controllers/user-storage/contact-syncing/constants.d.ts.map +0 -1
  446. package/dist/controllers/user-storage/contact-syncing/constants.js.map +0 -1
  447. package/dist/controllers/user-storage/contact-syncing/controller-integration.d.ts.map +0 -1
  448. package/dist/controllers/user-storage/contact-syncing/controller-integration.js.map +0 -1
  449. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.ts.map +0 -1
  450. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.js.map +0 -1
  451. package/dist/controllers/user-storage/contact-syncing/sync-utils.d.ts.map +0 -1
  452. package/dist/controllers/user-storage/contact-syncing/sync-utils.js.map +0 -1
  453. package/dist/controllers/user-storage/contact-syncing/types.d.ts.map +0 -1
  454. package/dist/controllers/user-storage/contact-syncing/types.js +0 -2
  455. package/dist/controllers/user-storage/contact-syncing/types.js.map +0 -1
  456. package/dist/controllers/user-storage/contact-syncing/utils.d.ts.map +0 -1
  457. package/dist/controllers/user-storage/contact-syncing/utils.js.map +0 -1
  458. package/dist/controllers/user-storage/index.d.ts.map +0 -1
  459. package/dist/controllers/user-storage/index.js +0 -9
  460. package/dist/controllers/user-storage/index.js.map +0 -1
  461. package/dist/controllers/user-storage/mocks/index.d.ts +0 -3
  462. package/dist/controllers/user-storage/mocks/index.d.ts.map +0 -1
  463. package/dist/controllers/user-storage/mocks/index.js +0 -3
  464. package/dist/controllers/user-storage/mocks/index.js.map +0 -1
  465. package/dist/controllers/user-storage/mocks/mockResponses.d.ts.map +0 -1
  466. package/dist/controllers/user-storage/mocks/mockResponses.js.map +0 -1
  467. package/dist/controllers/user-storage/mocks/mockStorage.d.ts.map +0 -1
  468. package/dist/controllers/user-storage/mocks/mockStorage.js.map +0 -1
  469. package/dist/controllers/user-storage/types.d.ts.map +0 -1
  470. package/dist/controllers/user-storage/types.js +0 -2
  471. package/dist/controllers/user-storage/types.js.map +0 -1
  472. package/dist/controllers/user-storage/utils.d.ts.map +0 -1
  473. package/dist/controllers/user-storage/utils.js.map +0 -1
  474. package/dist/index.d.ts +0 -4
  475. package/dist/index.d.ts.map +0 -1
  476. package/dist/index.js +0 -4
  477. package/dist/index.js.map +0 -1
  478. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.ts.map +0 -1
  479. package/dist/sdk/authentication-jwt-bearer/flow-siwe.js +0 -99
  480. package/dist/sdk/authentication-jwt-bearer/flow-siwe.js.map +0 -1
  481. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.ts.map +0 -1
  482. package/dist/sdk/authentication-jwt-bearer/flow-srp.js +0 -255
  483. package/dist/sdk/authentication-jwt-bearer/flow-srp.js.map +0 -1
  484. package/dist/sdk/authentication-jwt-bearer/services.d.ts.map +0 -1
  485. package/dist/sdk/authentication-jwt-bearer/services.js.map +0 -1
  486. package/dist/sdk/authentication-jwt-bearer/types.d.ts.map +0 -1
  487. package/dist/sdk/authentication-jwt-bearer/types.js.map +0 -1
  488. package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.ts.map +0 -1
  489. package/dist/sdk/authentication-jwt-bearer/utils/identifier.js.map +0 -1
  490. package/dist/sdk/authentication-jwt-bearer/utils/time.d.ts.map +0 -1
  491. package/dist/sdk/authentication-jwt-bearer/utils/time.js.map +0 -1
  492. package/dist/sdk/authentication.d.ts.map +0 -1
  493. package/dist/sdk/authentication.js +0 -100
  494. package/dist/sdk/authentication.js.map +0 -1
  495. package/dist/sdk/constants.d.ts.map +0 -1
  496. package/dist/sdk/constants.js.map +0 -1
  497. package/dist/sdk/errors.d.ts.map +0 -1
  498. package/dist/sdk/errors.js.map +0 -1
  499. package/dist/sdk/index.d.ts +0 -8
  500. package/dist/sdk/index.d.ts.map +0 -1
  501. package/dist/sdk/index.js +0 -8
  502. package/dist/sdk/index.js.map +0 -1
  503. package/dist/sdk/mocks/auth.d.ts.map +0 -1
  504. package/dist/sdk/mocks/auth.js.map +0 -1
  505. package/dist/sdk/mocks/userstorage.d.ts.map +0 -1
  506. package/dist/sdk/mocks/userstorage.js.map +0 -1
  507. package/dist/sdk/user-storage.d.ts.map +0 -1
  508. package/dist/sdk/user-storage.js +0 -364
  509. package/dist/sdk/user-storage.js.map +0 -1
  510. package/dist/sdk/utils/eip-6963-metamask-provider.d.ts.map +0 -1
  511. package/dist/sdk/utils/eip-6963-metamask-provider.js.map +0 -1
  512. package/dist/sdk/utils/messaging-signing-snap-requests.d.ts.map +0 -1
  513. package/dist/sdk/utils/messaging-signing-snap-requests.js.map +0 -1
  514. package/dist/sdk/utils/validate-login-response.d.ts.map +0 -1
  515. package/dist/sdk/utils/validate-login-response.js.map +0 -1
  516. package/dist/sdk/utils/validate-pair-response.d.ts.map +0 -1
  517. package/dist/sdk/utils/validate-pair-response.js.map +0 -1
  518. package/dist/shared/encryption/cache.d.ts.map +0 -1
  519. package/dist/shared/encryption/cache.js.map +0 -1
  520. package/dist/shared/encryption/constants.d.ts.map +0 -1
  521. package/dist/shared/encryption/constants.js.map +0 -1
  522. package/dist/shared/encryption/encryption.d.ts.map +0 -1
  523. package/dist/shared/encryption/encryption.js +0 -202
  524. package/dist/shared/encryption/encryption.js.map +0 -1
  525. package/dist/shared/encryption/index.d.ts +0 -5
  526. package/dist/shared/encryption/index.d.ts.map +0 -1
  527. package/dist/shared/encryption/index.js +0 -5
  528. package/dist/shared/encryption/index.js.map +0 -1
  529. package/dist/shared/encryption/utils.d.ts.map +0 -1
  530. package/dist/shared/encryption/utils.js.map +0 -1
  531. package/dist/shared/env.d.ts.map +0 -1
  532. package/dist/shared/env.js.map +0 -1
  533. package/dist/shared/storage-schema.d.ts.map +0 -1
  534. package/dist/shared/storage-schema.js.map +0 -1
  535. package/dist/shared/types/encryption.d.ts.map +0 -1
  536. package/dist/shared/types/encryption.js +0 -2
  537. package/dist/shared/types/encryption.js.map +0 -1
  538. package/dist/shared/types/services.d.ts.map +0 -1
  539. package/dist/shared/types/services.js +0 -2
  540. package/dist/shared/types/services.js.map +0 -1
  541. package/dist/shared/utils/entropy-source.d.ts.map +0 -1
  542. package/dist/shared/utils/entropy-source.js.map +0 -1
  543. package/dist/shared/utils/event-queue.d.ts.map +0 -1
  544. package/dist/shared/utils/event-queue.js.map +0 -1
  545. package/dist/shared/utils/hd-keyring-seed.d.ts.map +0 -1
  546. package/dist/shared/utils/hd-keyring-seed.js.map +0 -1
  547. package/dist/shared/utils/message-signing.d.ts.map +0 -1
  548. package/dist/shared/utils/message-signing.js.map +0 -1
@@ -0,0 +1,130 @@
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";
10
+ declare const controllerName = "AuthenticationController";
11
+ export type AuthenticationControllerState = {
12
+ isSignedIn: boolean;
13
+ srpSessionData?: Record<string, LoginResponse>;
14
+ /**
15
+ * Client gate for profile pairing. Defaults to `true` (fresh install /
16
+ * upgrade), set to `false` after a successful `performSignIn` pair, set
17
+ * back to `true` via `requestProfilePairing()` when the SRP set changes,
18
+ * and left `true` on pair failure so the next state shift retries.
19
+ *
20
+ * Optional in the type so partial-state selectors stay assignable to
21
+ * `AuthenticationControllerState`. The controller seeds it via
22
+ * `defaultState` at construction; consumers should read `undefined` as
23
+ * `true` to mirror that runtime default.
24
+ */
25
+ needsProfilePairing?: boolean;
26
+ };
27
+ export declare const defaultState: AuthenticationControllerState;
28
+ type ControllerConfig = {
29
+ env: Env;
30
+ };
31
+ export type Actions = AuthenticationControllerGetStateAction | AuthenticationControllerMethodActions;
32
+ export type AuthenticationControllerGetStateAction = ControllerGetStateAction<typeof controllerName, AuthenticationControllerState>;
33
+ export type AuthenticationControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, AuthenticationControllerState>;
34
+ export type ProfileSignInInfo = {
35
+ profileId: string;
36
+ profileAliases: ProfileAlias[];
37
+ profileIdChanged: boolean;
38
+ };
39
+ export type AuthenticationControllerProfileSignInEvent = {
40
+ type: `${typeof controllerName}:profileSignIn`;
41
+ payload: [ProfileSignInInfo];
42
+ };
43
+ export type Events = AuthenticationControllerStateChangeEvent | AuthenticationControllerProfileSignInEvent;
44
+ type AllowedActions = KeyringControllerGetStateAction | KeyringControllerWithKeyringV2UnsafeAction | SeedlessOnboardingControllerGetStateAction;
45
+ type AllowedEvents = KeyringControllerLockEvent | KeyringControllerUnlockEvent;
46
+ export type AuthenticationControllerMessenger = Messenger<typeof controllerName, Actions | AllowedActions, Events | AllowedEvents>;
47
+ /**
48
+ * Controller that enables authentication for restricted endpoints.
49
+ * Used for Backup & Sync, Notifications, and other services.
50
+ */
51
+ export declare class AuthenticationController extends BaseController<typeof controllerName, AuthenticationControllerState, AuthenticationControllerMessenger> {
52
+ #private;
53
+ constructor({ messenger, state, config, metametrics, }: {
54
+ messenger: AuthenticationControllerMessenger;
55
+ state?: AuthenticationControllerState;
56
+ config?: Partial<ControllerConfig>;
57
+ /**
58
+ * Not using the Messaging System as we
59
+ * do not want to tie this strictly to extension
60
+ */
61
+ metametrics: MetaMetricsAuth;
62
+ });
63
+ performSignIn(): Promise<string[]>;
64
+ /**
65
+ * Marks profile pairing as needed. Clients call this when the SRP set
66
+ * changes (e.g. a new keyring was added) so the next auto-sign-in cycle
67
+ * re-runs `performSignIn` and re-pairs.
68
+ */
69
+ requestProfilePairing(): void;
70
+ performSignOut(): void;
71
+ /**
72
+ * Returns a bearer token for the specified SRP, logging in if needed.
73
+ *
74
+ * When called without `entropySourceId`, returns the primary (first) SRP's
75
+ * access token, which is effectively the canonical
76
+ * profile's token that can be used by alias-aware consumers for cross-SRP
77
+ * operations.
78
+ *
79
+ * @param entropySourceId - The entropy source ID. Omit for the primary SRP.
80
+ * @returns The OIDC access token.
81
+ */
82
+ getBearerToken(entropySourceId?: string): Promise<string>;
83
+ /**
84
+ * Returns the cached session profile, logging in if no session exists.
85
+ *
86
+ * The returned `canonicalProfileId` reflects the value from the most recent
87
+ * login or pairing. In the rare event where a canonical changed because of
88
+ * a pairing that happened on another device, the cached value may be stale
89
+ * until the next login. For guaranteed freshness, call
90
+ * `refreshCanonicalProfileId()` before reading `canonicalProfileId`.
91
+ *
92
+ * @param entropySourceId - The entropy source ID used to derive the key,
93
+ * when multiple sources are available (Multi-SRP).
94
+ * @returns profile for the session.
95
+ */
96
+ getSessionProfile(entropySourceId?: string): Promise<UserProfile>;
97
+ /**
98
+ * Forces a fresh retrieval of the canonical profile ID from the server
99
+ * and propagates it to all cached SRP sessions.
100
+ *
101
+ * This method invalidates the primary SRP's cached session and forces a
102
+ * re-login. Use it before operations that require a guaranteed-fresh
103
+ * canonical (e.g. storage key derivation for Accounts ADR 0005). For
104
+ * best-effort reads, use
105
+ * `getSessionProfile().canonicalProfileId` instead.
106
+ *
107
+ * Only the primary SRP is re-logged-in regardless of how many SRPs exist —
108
+ * the server returns the current canonical for the entire pairing group
109
+ * from any single SRP login.
110
+ *
111
+ * @returns The refreshed canonical profile ID.
112
+ */
113
+ refreshCanonicalProfileId(): Promise<string>;
114
+ getUserProfileLineage(entropySourceId?: string): Promise<UserProfileLineage>;
115
+ /**
116
+ * Returns a Customer Service specific access token for the specified SRP,
117
+ * logging in if needed.
118
+ *
119
+ * Exchanges the OIDC access token for a short-lived token scoped to the
120
+ * customer-service audience. Customer Service tooling consumes this token to
121
+ * identify and authenticate the user.
122
+ *
123
+ * @param entropySourceId - The entropy source ID. Omit for the primary SRP.
124
+ * @returns The customer-service access token.
125
+ */
126
+ getCustomerServiceToken(entropySourceId?: string): Promise<string>;
127
+ isSignedIn(): boolean;
128
+ }
129
+ export {};
130
+ //# sourceMappingURL=AuthenticationController.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthenticationController.d.mts","sourceRoot":"","sources":["../../../src/controllers/authentication/AuthenticationController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,KAAK,EACV,+BAA+B,EAC/B,0BAA0B,EAC1B,4BAA4B,EAC5B,0CAA0C,EAC3C,qCAAqC;AACtC,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAAE,0CAA0C,EAAE,iDAAiD;AAG3G,OAAO,KAAK,EAEV,aAAa,EACb,YAAY,EAGZ,WAAW,EACX,kBAAkB,EACnB,4BAA2B;AAC5B,OAAO,EAGL,GAAG,EAEJ,4BAA2B;AAC5B,OAAO,KAAK,EAAE,eAAe,EAAE,wCAAuC;AAUtE,OAAO,EAAE,qCAAqC,EAAE,2DAA0D;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;;gBA+Ba,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;IAiMY,aAAa,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IA6B/C;;;;OAIG;IACI,qBAAqB,IAAI,IAAI;IA8G7B,cAAc,IAAI,IAAI;IAO7B;;;;;;;;;;OAUG;IACU,cAAc,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAMtE;;;;;;;;;;;;OAYG;IACU,iBAAiB,CAC5B,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,WAAW,CAAC;IAMvB;;;;;;;;;;;;;;;OAeG;IACU,yBAAyB,IAAI,OAAO,CAAC,MAAM,CAAC;IA8B5C,qBAAqB,CAChC,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,kBAAkB,CAAC;IAM9B;;;;;;;;;;OAUG;IACU,uBAAuB,CAClC,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,MAAM,CAAC;IAMX,UAAU,IAAI,OAAO;CAgF7B"}
@@ -0,0 +1,485 @@
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_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 } 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
+ };
23
+ const metadata = {
24
+ isSignedIn: {
25
+ includeInStateLogs: true,
26
+ persist: true,
27
+ includeInDebugSnapshot: true,
28
+ usedInUi: true,
29
+ },
30
+ needsProfilePairing: {
31
+ includeInStateLogs: true,
32
+ persist: true,
33
+ includeInDebugSnapshot: true,
34
+ usedInUi: true,
35
+ },
36
+ srpSessionData: {
37
+ // Remove access token from state logs
38
+ includeInStateLogs: (srpSessionData) => {
39
+ // Unreachable branch, included just to fix a type error for the case where this property is
40
+ // unset. The type gets collapsed to include `| undefined` even though `undefined` is never
41
+ // set here, because we don't yet use `exactOptionalPropertyTypes`.
42
+ // TODO: Remove branch after enabling `exactOptionalPropertyTypes`
43
+ // ref: https://github.com/MetaMask/core/issues/6565
44
+ if (srpSessionData === null || srpSessionData === undefined) {
45
+ return null;
46
+ }
47
+ return Object.entries(srpSessionData).reduce((sanitizedSrpSessionData, [key, value]) => {
48
+ const { accessToken: _unused, ...tokenWithoutAccessToken } = value.token;
49
+ sanitizedSrpSessionData[key] = {
50
+ ...value,
51
+ token: tokenWithoutAccessToken,
52
+ };
53
+ return sanitizedSrpSessionData;
54
+ }, {});
55
+ },
56
+ persist: true,
57
+ includeInDebugSnapshot: false,
58
+ usedInUi: true,
59
+ },
60
+ };
61
+ const MESSENGER_EXPOSED_METHODS = [
62
+ 'performSignIn',
63
+ 'performSignOut',
64
+ 'getBearerToken',
65
+ 'getSessionProfile',
66
+ 'refreshCanonicalProfileId',
67
+ 'getUserProfileLineage',
68
+ 'getCustomerServiceToken',
69
+ 'isSignedIn',
70
+ 'requestProfilePairing',
71
+ ];
72
+ /**
73
+ * Controller that enables authentication for restricted endpoints.
74
+ * Used for Backup & Sync, Notifications, and other services.
75
+ */
76
+ export class AuthenticationController extends BaseController {
77
+ constructor({ messenger, state, config, metametrics, }) {
78
+ super({
79
+ messenger,
80
+ metadata,
81
+ name: controllerName,
82
+ state: { ...defaultState, ...state },
83
+ });
84
+ _AuthenticationController_instances.add(this);
85
+ _AuthenticationController_metametrics.set(this, void 0);
86
+ _AuthenticationController_auth.set(this, void 0);
87
+ _AuthenticationController_config.set(this, {
88
+ env: Env.PRD,
89
+ });
90
+ _AuthenticationController_isUnlocked.set(this, false);
91
+ // Bumped by `requestProfilePairing`. `performSignIn` snapshots this
92
+ // before its first await; if it changes mid-flight we must NOT clear
93
+ // `needsProfilePairing` (the rearm signal wins).
94
+ _AuthenticationController_profilePairingRequestEpoch.set(this, 0);
95
+ _AuthenticationController_keyringController.set(this, {
96
+ setupLockedStateSubscriptions: () => {
97
+ const { isUnlocked } = this.messenger.call('KeyringController:getState');
98
+ __classPrivateFieldSet(this, _AuthenticationController_isUnlocked, isUnlocked, "f");
99
+ this.messenger.subscribe('KeyringController:unlock', () => {
100
+ __classPrivateFieldSet(this, _AuthenticationController_isUnlocked, true, "f");
101
+ });
102
+ this.messenger.subscribe('KeyringController:lock', () => {
103
+ __classPrivateFieldSet(this, _AuthenticationController_isUnlocked, false, "f");
104
+ });
105
+ },
106
+ });
107
+ _AuthenticationController__signMessageCache.set(this, {});
108
+ if (!metametrics) {
109
+ throw new Error('`metametrics` field is required');
110
+ }
111
+ __classPrivateFieldSet(this, _AuthenticationController_config, {
112
+ ...__classPrivateFieldGet(this, _AuthenticationController_config, "f"),
113
+ ...config,
114
+ }, "f");
115
+ __classPrivateFieldSet(this, _AuthenticationController_metametrics, metametrics, "f");
116
+ __classPrivateFieldSet(this, _AuthenticationController_auth, new JwtBearerAuth({
117
+ env: __classPrivateFieldGet(this, _AuthenticationController_config, "f").env,
118
+ platform: metametrics.agent,
119
+ type: AuthType.SRP,
120
+ }, {
121
+ storage: {
122
+ getLoginResponse: __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getLoginResponseFromState).bind(this),
123
+ setLoginResponse: __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_setLoginResponseToState).bind(this),
124
+ },
125
+ signing: {
126
+ getIdentifier: __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPublicKey).bind(this),
127
+ signMessage: __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_signMessage).bind(this),
128
+ },
129
+ getLoginTag: __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getLoginTag).bind(this),
130
+ getLoginIdentifierType: __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getLoginIdentifierType).bind(this),
131
+ metametrics: __classPrivateFieldGet(this, _AuthenticationController_metametrics, "f"),
132
+ }), "f");
133
+ __classPrivateFieldGet(this, _AuthenticationController_keyringController, "f").setupLockedStateSubscriptions();
134
+ this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
135
+ }
136
+ async performSignIn() {
137
+ __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, 'performSignIn');
138
+ const epochAtStart = __classPrivateFieldGet(this, _AuthenticationController_profilePairingRequestEpoch, "f");
139
+ const entropySourceIds = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getHdKeyringEntropySourceIds).call(this);
140
+ const accessTokens = [];
141
+ // We iterate sequentially in order to be sure that the first entry
142
+ // is the primary SRP LoginResponse.
143
+ for (const entropySourceId of entropySourceIds) {
144
+ const accessToken = await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").getAccessToken(entropySourceId);
145
+ accessTokens.push(accessToken);
146
+ }
147
+ if (entropySourceIds.length < 2) {
148
+ // Single-SRP wallet: nothing to pair.
149
+ __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_tryClearNeedsProfilePairing).call(this, epochAtStart);
150
+ }
151
+ else {
152
+ // Pair failures must not break sign-in; the gate stays `true` for retry.
153
+ try {
154
+ await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_doPair).call(this, accessTokens, epochAtStart);
155
+ }
156
+ catch {
157
+ // noop
158
+ }
159
+ }
160
+ return accessTokens;
161
+ }
162
+ /**
163
+ * Marks profile pairing as needed. Clients call this when the SRP set
164
+ * changes (e.g. a new keyring was added) so the next auto-sign-in cycle
165
+ * re-runs `performSignIn` and re-pairs.
166
+ */
167
+ requestProfilePairing() {
168
+ __classPrivateFieldSet(this, _AuthenticationController_profilePairingRequestEpoch, __classPrivateFieldGet(this, _AuthenticationController_profilePairingRequestEpoch, "f") + 1, "f");
169
+ if (!this.state.needsProfilePairing) {
170
+ this.update((state) => {
171
+ state.needsProfilePairing = true;
172
+ });
173
+ }
174
+ }
175
+ performSignOut() {
176
+ this.update((state) => {
177
+ state.isSignedIn = false;
178
+ state.srpSessionData = undefined;
179
+ });
180
+ }
181
+ /**
182
+ * Returns a bearer token for the specified SRP, logging in if needed.
183
+ *
184
+ * When called without `entropySourceId`, returns the primary (first) SRP's
185
+ * access token, which is effectively the canonical
186
+ * profile's token that can be used by alias-aware consumers for cross-SRP
187
+ * operations.
188
+ *
189
+ * @param entropySourceId - The entropy source ID. Omit for the primary SRP.
190
+ * @returns The OIDC access token.
191
+ */
192
+ async getBearerToken(entropySourceId) {
193
+ __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, 'getBearerToken');
194
+ const resolvedId = entropySourceId ?? __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
195
+ return await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").getAccessToken(resolvedId);
196
+ }
197
+ /**
198
+ * Returns the cached session profile, logging in if no session exists.
199
+ *
200
+ * The returned `canonicalProfileId` reflects the value from the most recent
201
+ * login or pairing. In the rare event where a canonical changed because of
202
+ * a pairing that happened on another device, the cached value may be stale
203
+ * until the next login. For guaranteed freshness, call
204
+ * `refreshCanonicalProfileId()` before reading `canonicalProfileId`.
205
+ *
206
+ * @param entropySourceId - The entropy source ID used to derive the key,
207
+ * when multiple sources are available (Multi-SRP).
208
+ * @returns profile for the session.
209
+ */
210
+ async getSessionProfile(entropySourceId) {
211
+ __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, 'getSessionProfile');
212
+ const resolvedId = entropySourceId ?? __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
213
+ return await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").getUserProfile(resolvedId);
214
+ }
215
+ /**
216
+ * Forces a fresh retrieval of the canonical profile ID from the server
217
+ * and propagates it to all cached SRP sessions.
218
+ *
219
+ * This method invalidates the primary SRP's cached session and forces a
220
+ * re-login. Use it before operations that require a guaranteed-fresh
221
+ * canonical (e.g. storage key derivation for Accounts ADR 0005). For
222
+ * best-effort reads, use
223
+ * `getSessionProfile().canonicalProfileId` instead.
224
+ *
225
+ * Only the primary SRP is re-logged-in regardless of how many SRPs exist —
226
+ * the server returns the current canonical for the entire pairing group
227
+ * from any single SRP login.
228
+ *
229
+ * @returns The refreshed canonical profile ID.
230
+ */
231
+ async refreshCanonicalProfileId() {
232
+ __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, 'refreshCanonicalProfileId');
233
+ const primaryEntropySourceId = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
234
+ __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_invalidateSrpSession).call(this, primaryEntropySourceId);
235
+ await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").getAccessToken(primaryEntropySourceId);
236
+ const canonical = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getCanonicalProfileId).call(this);
237
+ if (!canonical) {
238
+ throw new Error('refreshCanonicalProfileId - Unable to resolve canonical profile ID');
239
+ }
240
+ __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_propagateCanonical).call(this, canonical);
241
+ return canonical;
242
+ }
243
+ async getUserProfileLineage(entropySourceId) {
244
+ __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, 'getUserProfileLineage');
245
+ const resolvedId = entropySourceId ?? __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
246
+ return await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").getUserProfileLineage(resolvedId);
247
+ }
248
+ /**
249
+ * Returns a Customer Service specific access token for the specified SRP,
250
+ * logging in if needed.
251
+ *
252
+ * Exchanges the OIDC access token for a short-lived token scoped to the
253
+ * customer-service audience. Customer Service tooling consumes this token to
254
+ * identify and authenticate the user.
255
+ *
256
+ * @param entropySourceId - The entropy source ID. Omit for the primary SRP.
257
+ * @returns The customer-service access token.
258
+ */
259
+ async getCustomerServiceToken(entropySourceId) {
260
+ __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, 'getCustomerServiceToken');
261
+ const resolvedId = entropySourceId ?? __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
262
+ return await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").getCustomerServiceToken(resolvedId);
263
+ }
264
+ isSignedIn() {
265
+ return this.state.isSignedIn;
266
+ }
267
+ }
268
+ _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) {
269
+ const resolvedId = entropySourceId ?? __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
270
+ if (!this.state.srpSessionData?.[resolvedId]) {
271
+ return null;
272
+ }
273
+ return this.state.srpSessionData[resolvedId];
274
+ }, _AuthenticationController_setLoginResponseToState = async function _AuthenticationController_setLoginResponseToState(loginResponse, entropySourceId) {
275
+ const resolvedId = entropySourceId ?? __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
276
+ const metaMetricsId = await __classPrivateFieldGet(this, _AuthenticationController_metametrics, "f").getMetaMetricsId();
277
+ this.update((state) => {
278
+ state.isSignedIn = true;
279
+ if (!state.srpSessionData) {
280
+ state.srpSessionData = {};
281
+ }
282
+ state.srpSessionData[resolvedId] = {
283
+ ...loginResponse,
284
+ profile: {
285
+ ...loginResponse.profile,
286
+ metaMetricsId,
287
+ },
288
+ };
289
+ });
290
+ }, _AuthenticationController_assertIsUnlocked = function _AuthenticationController_assertIsUnlocked(methodName) {
291
+ if (!__classPrivateFieldGet(this, _AuthenticationController_isUnlocked, "f")) {
292
+ throw new Error(`${methodName} - unable to proceed, wallet is locked`);
293
+ }
294
+ }, _AuthenticationController_getHdKeyringEntropySourceIds = function _AuthenticationController_getHdKeyringEntropySourceIds() {
295
+ const { keyrings } = this.messenger.call('KeyringController:getState');
296
+ return getHdKeyringEntropySourceIds(keyrings);
297
+ }, _AuthenticationController_getPrimaryEntropySourceId = function _AuthenticationController_getPrimaryEntropySourceId() {
298
+ const { keyrings } = this.messenger.call('KeyringController:getState');
299
+ return getPrimaryHdKeyringEntropySourceId(keyrings);
300
+ }, _AuthenticationController_getLoginTag =
301
+ /**
302
+ * Resolves the SRP login tag for `raw_message`.
303
+ *
304
+ * - `primary` for the first HD entropy source
305
+ * - `secondary` for any other entropy source
306
+ *
307
+ * @param entropySourceId - Entropy source for this login attempt.
308
+ * @returns The login tag to append to the signed message.
309
+ */
310
+ async function _AuthenticationController_getLoginTag(entropySourceId) {
311
+ const primaryEntropySourceId = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
312
+ const resolvedId = entropySourceId ?? primaryEntropySourceId;
313
+ return resolvedId === primaryEntropySourceId ? 'primary' : 'secondary';
314
+ }, _AuthenticationController_getLoginIdentifierType =
315
+ /**
316
+ * Resolves metametrics `identifier_type` for `/srp/login`
317
+ * (`SRP` | `GOOGLE` | `APPLE` | `TELEGRAM`).
318
+ *
319
+ * This is the auth method for the entropy source, independent of
320
+ * {@link SrpLoginTag} (`primary` / `secondary`).
321
+ *
322
+ * SeedlessOnboarding currently exposes a single vault-level
323
+ * `authConnection`, which always backs the primary entropy source. Non-
324
+ * primary sources therefore return `SRP`. If social identities become
325
+ * per-entropy later, resolve from that metadata instead of assuming
326
+ * primary === social.
327
+ *
328
+ * Soft-fails to `SRP` when SeedlessOnboarding is not registered.
329
+ *
330
+ * @param entropySourceId - Entropy source for this login attempt.
331
+ * @returns The login identifier type.
332
+ */
333
+ async function _AuthenticationController_getLoginIdentifierType(entropySourceId) {
334
+ const primaryEntropySourceId = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
335
+ const resolvedId = entropySourceId ?? primaryEntropySourceId;
336
+ // Social vault authConnection is only associated with the primary source.
337
+ if (resolvedId !== primaryEntropySourceId) {
338
+ return 'SRP';
339
+ }
340
+ return __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_resolveSocialIdentifierType).call(this);
341
+ }, _AuthenticationController_resolveSocialIdentifierType = function _AuthenticationController_resolveSocialIdentifierType() {
342
+ try {
343
+ const { vault, authConnection } = this.messenger.call('SeedlessOnboardingController:getState');
344
+ if (vault === null || vault === undefined) {
345
+ return 'SRP';
346
+ }
347
+ // Match provider strings from SeedlessOnboarding state rather than
348
+ // importing AuthConnection — a value import would load that package
349
+ // (and its heavy deps) whenever this controller is imported.
350
+ switch (authConnection) {
351
+ case 'google':
352
+ return 'GOOGLE';
353
+ case 'apple':
354
+ return 'APPLE';
355
+ case 'telegram':
356
+ return 'TELEGRAM';
357
+ default:
358
+ return 'SRP';
359
+ }
360
+ }
361
+ catch {
362
+ return 'SRP';
363
+ }
364
+ }, _AuthenticationController_tryClearNeedsProfilePairing = function _AuthenticationController_tryClearNeedsProfilePairing(epochAtStart) {
365
+ if (__classPrivateFieldGet(this, _AuthenticationController_profilePairingRequestEpoch, "f") !== epochAtStart) {
366
+ return;
367
+ }
368
+ if (this.state.needsProfilePairing) {
369
+ this.update((state) => {
370
+ state.needsProfilePairing = false;
371
+ });
372
+ }
373
+ }, _AuthenticationController_doPair =
374
+ /**
375
+ * Pairs all SRPs via `POST /profile/pair`, propagates the canonical
376
+ * profile ID, clears `needsProfilePairing`, and emits
377
+ * `AuthenticationController:profileSignIn` when the canonical changes or
378
+ * new aliases are returned. Throws on failure.
379
+ *
380
+ * @param accessTokens - Per-SRP access tokens, primary first.
381
+ * @param epochAtStart - Pairing-request epoch captured by the caller.
382
+ * Used to skip the gate clear if `requestProfilePairing` ran while the
383
+ * pair API call was in-flight.
384
+ */
385
+ async function _AuthenticationController_doPair(accessTokens, epochAtStart) {
386
+ const previousCanonical = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getCanonicalProfileId).call(this);
387
+ const profileAliases = await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_pairSrpProfiles).call(this, accessTokens);
388
+ const newCanonical = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getCanonicalProfileId).call(this);
389
+ // If somehow we cannot compute the new canonical profile ID after pairing,
390
+ // we just return now and do not update the `needsProfilePairing` flag.
391
+ if (!newCanonical) {
392
+ return;
393
+ }
394
+ __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_tryClearNeedsProfilePairing).call(this, epochAtStart);
395
+ const profileIdChanged = previousCanonical !== newCanonical;
396
+ const shouldEmitProfileSignInEvent = profileIdChanged || profileAliases.length > 0;
397
+ if (shouldEmitProfileSignInEvent) {
398
+ this.messenger.publish('AuthenticationController:profileSignIn', {
399
+ profileId: newCanonical,
400
+ profileAliases,
401
+ profileIdChanged,
402
+ });
403
+ }
404
+ }, _AuthenticationController_pairSrpProfiles = async function _AuthenticationController_pairSrpProfiles(accessTokens) {
405
+ if (accessTokens.length < 2) {
406
+ return [];
407
+ }
408
+ const primaryAccessToken = accessTokens[0]; // Associated with primary SRP.
409
+ const { profileAliases, profile: { canonicalProfileId }, } = await __classPrivateFieldGet(this, _AuthenticationController_auth, "f").pairSrpProfiles(accessTokens, primaryAccessToken);
410
+ __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_propagateCanonical).call(this, canonicalProfileId);
411
+ return profileAliases;
412
+ }, _AuthenticationController_propagateCanonical = function _AuthenticationController_propagateCanonical(canonicalProfileId) {
413
+ const { srpSessionData } = this.state;
414
+ if (!srpSessionData) {
415
+ return;
416
+ }
417
+ this.update((state) => {
418
+ for (const entry of Object.values(state.srpSessionData ?? {})) {
419
+ if (entry?.profile) {
420
+ entry.profile.canonicalProfileId = canonicalProfileId;
421
+ }
422
+ }
423
+ });
424
+ }, _AuthenticationController_getCanonicalProfileId = function _AuthenticationController_getCanonicalProfileId() {
425
+ const primaryEntropySourceId = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
426
+ return (this.state.srpSessionData?.[primaryEntropySourceId]?.profile
427
+ ?.canonicalProfileId ?? null);
428
+ }, _AuthenticationController_invalidateSrpSession = function _AuthenticationController_invalidateSrpSession(entropySourceId) {
429
+ this.update((state) => {
430
+ const entry = state.srpSessionData?.[entropySourceId];
431
+ if (entry?.profile) {
432
+ // Setting canonicalProfileId to '' forces a re-fetch on the next
433
+ // #getAuthSession call. The falsy check (!auth.profile.canonicalProfileId)
434
+ // treats '' the same as undefined/null — all signal an invalid session.
435
+ entry.profile.canonicalProfileId = '';
436
+ }
437
+ });
438
+ }, _AuthenticationController_getHdKeyringSeed =
439
+ /**
440
+ * Reads the BIP-39 seed for an HD entropy source from KeyringController.
441
+ *
442
+ * @param entropySourceId - Entropy source ID. Defaults to the primary HD
443
+ * keyring.
444
+ * @returns The HD keyring seed.
445
+ */
446
+ async function _AuthenticationController_getHdKeyringSeed(entropySourceId) {
447
+ const resolvedId = entropySourceId ?? __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this);
448
+ return getHdKeyringSeed(this.messenger, resolvedId);
449
+ }, _AuthenticationController_getPublicKey =
450
+ /**
451
+ * Returns the message-signing public key via native SIP-6 derivation
452
+ * (same key as `@metamask/message-signing-snap` with empty salt).
453
+ *
454
+ * @param entropySourceId - The entropy source ID used to derive the key,
455
+ * when multiple sources are available (Multi-SRP).
456
+ * @returns The public key hex.
457
+ */
458
+ async function _AuthenticationController_getPublicKey(entropySourceId) {
459
+ __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, '#getPublicKey');
460
+ const seed = await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getHdKeyringSeed).call(this, entropySourceId);
461
+ return getMessageSigningPublicKey(seed);
462
+ }, _AuthenticationController_scopedCacheKey = function _AuthenticationController_scopedCacheKey(message, entropySourceId) {
463
+ return `${entropySourceId ?? __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getPrimaryEntropySourceId).call(this)}:${message}`;
464
+ }, _AuthenticationController_signMessage =
465
+ /**
466
+ * Signs a `metamask:…` message with the native SIP-6 message-signing key.
467
+ *
468
+ * @param message - A specific tagged message to sign.
469
+ * @param entropySourceId - The entropy source ID used to derive the key,
470
+ * when multiple sources are available (Multi-SRP).
471
+ * @returns Compact secp256k1 signature hex.
472
+ */
473
+ async function _AuthenticationController_signMessage(message, entropySourceId) {
474
+ assertMessageStartsWithMetamask(message);
475
+ __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_assertIsUnlocked).call(this, '#signMessage');
476
+ const cacheKey = __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_scopedCacheKey).call(this, message, entropySourceId);
477
+ if (__classPrivateFieldGet(this, _AuthenticationController__signMessageCache, "f")[cacheKey]) {
478
+ return __classPrivateFieldGet(this, _AuthenticationController__signMessageCache, "f")[cacheKey];
479
+ }
480
+ const seed = await __classPrivateFieldGet(this, _AuthenticationController_instances, "m", _AuthenticationController_getHdKeyringSeed).call(this, entropySourceId);
481
+ const result = await signMessageWithMessageSigningKey(message, seed);
482
+ __classPrivateFieldGet(this, _AuthenticationController__signMessageCache, "f")[cacheKey] = result;
483
+ return result;
484
+ };
485
+ //# sourceMappingURL=AuthenticationController.mjs.map