@metamask-previews/profile-sync-controller 29.0.0-preview-3e34650c2 → 29.0.0-preview-4f4c98e

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 (541) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/dist/controllers/authentication/{AuthenticationController-method-action-types.d.mts → AuthenticationController-method-action-types.d.ts} +2 -2
  3. package/dist/controllers/authentication/AuthenticationController-method-action-types.d.ts.map +1 -0
  4. package/dist/controllers/authentication/{AuthenticationController-method-action-types.mjs → AuthenticationController-method-action-types.js} +1 -1
  5. package/dist/controllers/authentication/AuthenticationController-method-action-types.js.map +1 -0
  6. package/dist/controllers/authentication/{AuthenticationController.d.mts → AuthenticationController.d.ts} +10 -10
  7. package/dist/controllers/authentication/AuthenticationController.d.ts.map +1 -0
  8. package/dist/controllers/authentication/{AuthenticationController.mjs → AuthenticationController.js} +11 -11
  9. package/dist/controllers/authentication/AuthenticationController.js.map +1 -0
  10. package/dist/controllers/authentication/{index.d.cts → index.d.ts} +5 -5
  11. package/dist/controllers/authentication/index.d.ts.map +1 -0
  12. package/dist/controllers/authentication/index.js +6 -0
  13. package/dist/controllers/authentication/index.js.map +1 -0
  14. package/dist/controllers/authentication/mocks/index.d.ts +2 -0
  15. package/dist/controllers/authentication/mocks/index.d.ts.map +1 -0
  16. package/dist/controllers/authentication/mocks/index.js +2 -0
  17. package/dist/controllers/authentication/mocks/index.js.map +1 -0
  18. package/dist/controllers/authentication/mocks/{mockResponses.d.mts → mockResponses.d.ts} +1 -1
  19. package/dist/controllers/authentication/mocks/mockResponses.d.ts.map +1 -0
  20. package/dist/controllers/authentication/mocks/{mockResponses.mjs → mockResponses.js} +2 -2
  21. package/dist/controllers/authentication/mocks/mockResponses.js.map +1 -0
  22. package/dist/controllers/index.d.ts +3 -0
  23. package/dist/controllers/index.d.ts.map +1 -0
  24. package/dist/controllers/index.js +3 -0
  25. package/dist/controllers/index.js.map +1 -0
  26. package/dist/controllers/user-storage/{UserStorageController-method-action-types.d.mts → UserStorageController-method-action-types.d.ts} +2 -2
  27. package/dist/controllers/user-storage/UserStorageController-method-action-types.d.ts.map +1 -0
  28. package/dist/controllers/user-storage/{UserStorageController-method-action-types.mjs → UserStorageController-method-action-types.js} +1 -1
  29. package/dist/controllers/user-storage/UserStorageController-method-action-types.js.map +1 -0
  30. package/dist/controllers/user-storage/{UserStorageController.d.cts → UserStorageController.d.ts} +14 -14
  31. package/dist/controllers/user-storage/UserStorageController.d.ts.map +1 -0
  32. package/dist/controllers/user-storage/{UserStorageController.mjs → UserStorageController.js} +15 -15
  33. package/dist/controllers/user-storage/UserStorageController.js.map +1 -0
  34. package/dist/controllers/user-storage/constants.d.ts +15 -0
  35. package/dist/controllers/user-storage/constants.d.ts.map +1 -0
  36. package/dist/controllers/user-storage/{constants.mjs → constants.js} +1 -1
  37. package/dist/controllers/user-storage/constants.js.map +1 -0
  38. package/dist/controllers/user-storage/contact-syncing/{constants.d.cts → constants.d.ts} +1 -1
  39. package/dist/controllers/user-storage/contact-syncing/constants.d.ts.map +1 -0
  40. package/dist/controllers/user-storage/contact-syncing/{constants.mjs → constants.js} +1 -1
  41. package/dist/controllers/user-storage/contact-syncing/constants.js.map +1 -0
  42. package/dist/controllers/user-storage/contact-syncing/{controller-integration.d.cts → controller-integration.d.ts} +3 -3
  43. package/dist/controllers/user-storage/contact-syncing/controller-integration.d.ts.map +1 -0
  44. package/dist/controllers/user-storage/contact-syncing/{controller-integration.mjs → controller-integration.js} +6 -6
  45. package/dist/controllers/user-storage/contact-syncing/controller-integration.js.map +1 -0
  46. package/dist/controllers/user-storage/contact-syncing/{setup-subscriptions.d.cts → setup-subscriptions.d.ts} +2 -2
  47. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.ts.map +1 -0
  48. package/dist/controllers/user-storage/contact-syncing/{setup-subscriptions.mjs → setup-subscriptions.js} +4 -4
  49. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.js.map +1 -0
  50. package/dist/controllers/user-storage/contact-syncing/{sync-utils.d.cts → sync-utils.d.ts} +2 -2
  51. package/dist/controllers/user-storage/contact-syncing/sync-utils.d.ts.map +1 -0
  52. package/dist/controllers/user-storage/contact-syncing/{sync-utils.mjs → sync-utils.js} +1 -1
  53. package/dist/controllers/user-storage/contact-syncing/sync-utils.js.map +1 -0
  54. package/dist/controllers/user-storage/contact-syncing/{types.d.cts → types.d.ts} +6 -6
  55. package/dist/controllers/user-storage/contact-syncing/types.d.ts.map +1 -0
  56. package/dist/controllers/user-storage/contact-syncing/types.js +2 -0
  57. package/dist/controllers/user-storage/contact-syncing/types.js.map +1 -0
  58. package/dist/controllers/user-storage/contact-syncing/{utils.d.mts → utils.d.ts} +3 -3
  59. package/dist/controllers/user-storage/contact-syncing/utils.d.ts.map +1 -0
  60. package/dist/controllers/user-storage/contact-syncing/{utils.mjs → utils.js} +2 -2
  61. package/dist/controllers/user-storage/contact-syncing/utils.js.map +1 -0
  62. package/dist/controllers/user-storage/{index.d.cts → index.d.ts} +8 -8
  63. package/dist/controllers/user-storage/index.d.ts.map +1 -0
  64. package/dist/controllers/user-storage/index.js +9 -0
  65. package/dist/controllers/user-storage/index.js.map +1 -0
  66. package/dist/controllers/user-storage/mocks/index.d.ts +3 -0
  67. package/dist/controllers/user-storage/mocks/index.d.ts.map +1 -0
  68. package/dist/controllers/user-storage/mocks/index.js +3 -0
  69. package/dist/controllers/user-storage/mocks/index.js.map +1 -0
  70. package/dist/controllers/user-storage/mocks/{mockResponses.d.mts → mockResponses.d.ts} +3 -3
  71. package/dist/controllers/user-storage/mocks/mockResponses.d.ts.map +1 -0
  72. package/dist/controllers/user-storage/mocks/{mockResponses.mjs → mockResponses.js} +4 -4
  73. package/dist/controllers/user-storage/mocks/mockResponses.js.map +1 -0
  74. package/dist/controllers/user-storage/mocks/{mockStorage.d.cts → mockStorage.d.ts} +1 -1
  75. package/dist/controllers/user-storage/mocks/mockStorage.d.ts.map +1 -0
  76. package/dist/controllers/user-storage/mocks/{mockStorage.mjs → mockStorage.js} +2 -2
  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.mjs → flow-siwe.js} +5 -5
  93. package/dist/sdk/authentication-jwt-bearer/flow-siwe.js.map +1 -0
  94. package/dist/sdk/authentication-jwt-bearer/{flow-srp.d.cts → flow-srp.d.ts} +5 -5
  95. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.ts.map +1 -0
  96. package/dist/sdk/authentication-jwt-bearer/{flow-srp.mjs → flow-srp.js} +8 -8
  97. package/dist/sdk/authentication-jwt-bearer/flow-srp.js.map +1 -0
  98. package/dist/sdk/authentication-jwt-bearer/{services.d.cts → services.d.ts} +5 -5
  99. package/dist/sdk/authentication-jwt-bearer/services.d.ts.map +1 -0
  100. package/dist/sdk/authentication-jwt-bearer/{services.mjs → services.js} +6 -6
  101. package/dist/sdk/authentication-jwt-bearer/services.js.map +1 -0
  102. package/dist/sdk/authentication-jwt-bearer/{types.d.cts → types.d.ts} +2 -2
  103. package/dist/sdk/authentication-jwt-bearer/types.d.ts.map +1 -0
  104. package/dist/sdk/authentication-jwt-bearer/{types.mjs → types.js} +1 -1
  105. package/dist/sdk/authentication-jwt-bearer/types.js.map +1 -0
  106. package/dist/sdk/authentication-jwt-bearer/utils/{identifier.d.cts → identifier.d.ts} +2 -2
  107. package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.ts.map +1 -0
  108. package/dist/sdk/authentication-jwt-bearer/utils/{identifier.mjs → identifier.js} +2 -2
  109. package/dist/sdk/authentication-jwt-bearer/utils/identifier.js.map +1 -0
  110. package/dist/sdk/authentication-jwt-bearer/utils/{time.d.cts → time.d.ts} +1 -1
  111. package/dist/sdk/authentication-jwt-bearer/utils/time.d.ts.map +1 -0
  112. package/dist/sdk/authentication-jwt-bearer/utils/{time.mjs → time.js} +1 -1
  113. package/dist/sdk/authentication-jwt-bearer/utils/time.js.map +1 -0
  114. package/dist/sdk/{authentication.d.cts → authentication.d.ts} +9 -9
  115. package/dist/sdk/authentication.d.ts.map +1 -0
  116. package/dist/sdk/{authentication.mjs → authentication.js} +9 -9
  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} +2 -2
  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.mjs → user-storage.js} +6 -6
  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} +3 -3
  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.mjs → encryption.js} +9 -9
  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} +1 -1
  201. package/dist/shared/utils/event-queue.js.map +1 -0
  202. package/dist/shared/utils/{hd-keyring-seed.d.mts → hd-keyring-seed.d.ts} +3 -3
  203. package/dist/shared/utils/hd-keyring-seed.d.ts.map +1 -0
  204. package/dist/shared/utils/{hd-keyring-seed.mjs → hd-keyring-seed.js} +1 -1
  205. package/dist/shared/utils/hd-keyring-seed.js.map +1 -0
  206. package/dist/shared/utils/{message-signing.d.mts → message-signing.d.ts} +1 -1
  207. package/dist/shared/utils/message-signing.d.ts.map +1 -0
  208. package/dist/shared/utils/{message-signing.mjs → message-signing.js} +7 -7
  209. package/dist/shared/utils/message-signing.js.map +1 -0
  210. package/package.json +22 -56
  211. package/dist/controllers/authentication/AuthenticationController-method-action-types.cjs +0 -7
  212. package/dist/controllers/authentication/AuthenticationController-method-action-types.cjs.map +0 -1
  213. package/dist/controllers/authentication/AuthenticationController-method-action-types.d.cts +0 -102
  214. package/dist/controllers/authentication/AuthenticationController-method-action-types.d.cts.map +0 -1
  215. package/dist/controllers/authentication/AuthenticationController-method-action-types.d.mts.map +0 -1
  216. package/dist/controllers/authentication/AuthenticationController-method-action-types.mjs.map +0 -1
  217. package/dist/controllers/authentication/AuthenticationController.cjs +0 -489
  218. package/dist/controllers/authentication/AuthenticationController.cjs.map +0 -1
  219. package/dist/controllers/authentication/AuthenticationController.d.cts +0 -130
  220. package/dist/controllers/authentication/AuthenticationController.d.cts.map +0 -1
  221. package/dist/controllers/authentication/AuthenticationController.d.mts.map +0 -1
  222. package/dist/controllers/authentication/AuthenticationController.mjs.map +0 -1
  223. package/dist/controllers/authentication/index.cjs +0 -35
  224. package/dist/controllers/authentication/index.cjs.map +0 -1
  225. package/dist/controllers/authentication/index.d.cts.map +0 -1
  226. package/dist/controllers/authentication/index.d.mts +0 -7
  227. package/dist/controllers/authentication/index.d.mts.map +0 -1
  228. package/dist/controllers/authentication/index.mjs +0 -6
  229. package/dist/controllers/authentication/index.mjs.map +0 -1
  230. package/dist/controllers/authentication/mocks/index.cjs +0 -18
  231. package/dist/controllers/authentication/mocks/index.cjs.map +0 -1
  232. package/dist/controllers/authentication/mocks/index.d.cts +0 -2
  233. package/dist/controllers/authentication/mocks/index.d.cts.map +0 -1
  234. package/dist/controllers/authentication/mocks/index.d.mts +0 -2
  235. package/dist/controllers/authentication/mocks/index.d.mts.map +0 -1
  236. package/dist/controllers/authentication/mocks/index.mjs +0 -2
  237. package/dist/controllers/authentication/mocks/index.mjs.map +0 -1
  238. package/dist/controllers/authentication/mocks/mockResponses.cjs +0 -126
  239. package/dist/controllers/authentication/mocks/mockResponses.cjs.map +0 -1
  240. package/dist/controllers/authentication/mocks/mockResponses.d.cts +0 -58
  241. package/dist/controllers/authentication/mocks/mockResponses.d.cts.map +0 -1
  242. package/dist/controllers/authentication/mocks/mockResponses.d.mts.map +0 -1
  243. package/dist/controllers/authentication/mocks/mockResponses.mjs.map +0 -1
  244. package/dist/controllers/index.cjs +0 -29
  245. package/dist/controllers/index.cjs.map +0 -1
  246. package/dist/controllers/index.d.cts +0 -3
  247. package/dist/controllers/index.d.cts.map +0 -1
  248. package/dist/controllers/index.d.mts +0 -3
  249. package/dist/controllers/index.d.mts.map +0 -1
  250. package/dist/controllers/index.mjs +0 -3
  251. package/dist/controllers/index.mjs.map +0 -1
  252. package/dist/controllers/user-storage/UserStorageController-method-action-types.cjs +0 -7
  253. package/dist/controllers/user-storage/UserStorageController-method-action-types.cjs.map +0 -1
  254. package/dist/controllers/user-storage/UserStorageController-method-action-types.d.cts +0 -137
  255. package/dist/controllers/user-storage/UserStorageController-method-action-types.d.cts.map +0 -1
  256. package/dist/controllers/user-storage/UserStorageController-method-action-types.d.mts.map +0 -1
  257. package/dist/controllers/user-storage/UserStorageController-method-action-types.mjs.map +0 -1
  258. package/dist/controllers/user-storage/UserStorageController.cjs +0 -412
  259. package/dist/controllers/user-storage/UserStorageController.cjs.map +0 -1
  260. package/dist/controllers/user-storage/UserStorageController.d.cts.map +0 -1
  261. package/dist/controllers/user-storage/UserStorageController.d.mts +0 -182
  262. package/dist/controllers/user-storage/UserStorageController.d.mts.map +0 -1
  263. package/dist/controllers/user-storage/UserStorageController.mjs.map +0 -1
  264. package/dist/controllers/user-storage/constants.cjs +0 -19
  265. package/dist/controllers/user-storage/constants.cjs.map +0 -1
  266. package/dist/controllers/user-storage/constants.d.cts +0 -15
  267. package/dist/controllers/user-storage/constants.d.cts.map +0 -1
  268. package/dist/controllers/user-storage/constants.d.mts +0 -15
  269. package/dist/controllers/user-storage/constants.d.mts.map +0 -1
  270. package/dist/controllers/user-storage/constants.mjs.map +0 -1
  271. package/dist/controllers/user-storage/contact-syncing/constants.cjs +0 -12
  272. package/dist/controllers/user-storage/contact-syncing/constants.cjs.map +0 -1
  273. package/dist/controllers/user-storage/contact-syncing/constants.d.cts.map +0 -1
  274. package/dist/controllers/user-storage/contact-syncing/constants.d.mts +0 -9
  275. package/dist/controllers/user-storage/contact-syncing/constants.d.mts.map +0 -1
  276. package/dist/controllers/user-storage/contact-syncing/constants.mjs.map +0 -1
  277. package/dist/controllers/user-storage/contact-syncing/controller-integration.cjs +0 -346
  278. package/dist/controllers/user-storage/contact-syncing/controller-integration.cjs.map +0 -1
  279. package/dist/controllers/user-storage/contact-syncing/controller-integration.d.cts.map +0 -1
  280. package/dist/controllers/user-storage/contact-syncing/controller-integration.d.mts +0 -47
  281. package/dist/controllers/user-storage/contact-syncing/controller-integration.d.mts.map +0 -1
  282. package/dist/controllers/user-storage/contact-syncing/controller-integration.mjs.map +0 -1
  283. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.cjs +0 -50
  284. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.cjs.map +0 -1
  285. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.cts.map +0 -1
  286. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.mts +0 -8
  287. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.mts.map +0 -1
  288. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.mjs.map +0 -1
  289. package/dist/controllers/user-storage/contact-syncing/sync-utils.cjs +0 -23
  290. package/dist/controllers/user-storage/contact-syncing/sync-utils.cjs.map +0 -1
  291. package/dist/controllers/user-storage/contact-syncing/sync-utils.d.cts.map +0 -1
  292. package/dist/controllers/user-storage/contact-syncing/sync-utils.d.mts +0 -9
  293. package/dist/controllers/user-storage/contact-syncing/sync-utils.d.mts.map +0 -1
  294. package/dist/controllers/user-storage/contact-syncing/sync-utils.mjs.map +0 -1
  295. package/dist/controllers/user-storage/contact-syncing/types.cjs +0 -3
  296. package/dist/controllers/user-storage/contact-syncing/types.cjs.map +0 -1
  297. package/dist/controllers/user-storage/contact-syncing/types.d.cts.map +0 -1
  298. package/dist/controllers/user-storage/contact-syncing/types.d.mts +0 -37
  299. package/dist/controllers/user-storage/contact-syncing/types.d.mts.map +0 -1
  300. package/dist/controllers/user-storage/contact-syncing/types.mjs +0 -2
  301. package/dist/controllers/user-storage/contact-syncing/types.mjs.map +0 -1
  302. package/dist/controllers/user-storage/contact-syncing/utils.cjs +0 -64
  303. package/dist/controllers/user-storage/contact-syncing/utils.cjs.map +0 -1
  304. package/dist/controllers/user-storage/contact-syncing/utils.d.cts +0 -36
  305. package/dist/controllers/user-storage/contact-syncing/utils.d.cts.map +0 -1
  306. package/dist/controllers/user-storage/contact-syncing/utils.d.mts.map +0 -1
  307. package/dist/controllers/user-storage/contact-syncing/utils.mjs.map +0 -1
  308. package/dist/controllers/user-storage/index.cjs +0 -38
  309. package/dist/controllers/user-storage/index.cjs.map +0 -1
  310. package/dist/controllers/user-storage/index.d.cts.map +0 -1
  311. package/dist/controllers/user-storage/index.d.mts +0 -10
  312. package/dist/controllers/user-storage/index.d.mts.map +0 -1
  313. package/dist/controllers/user-storage/index.mjs +0 -9
  314. package/dist/controllers/user-storage/index.mjs.map +0 -1
  315. package/dist/controllers/user-storage/mocks/index.cjs +0 -19
  316. package/dist/controllers/user-storage/mocks/index.cjs.map +0 -1
  317. package/dist/controllers/user-storage/mocks/index.d.cts +0 -3
  318. package/dist/controllers/user-storage/mocks/index.d.cts.map +0 -1
  319. package/dist/controllers/user-storage/mocks/index.d.mts +0 -3
  320. package/dist/controllers/user-storage/mocks/index.d.mts.map +0 -1
  321. package/dist/controllers/user-storage/mocks/index.mjs +0 -3
  322. package/dist/controllers/user-storage/mocks/index.mjs.map +0 -1
  323. package/dist/controllers/user-storage/mocks/mockResponses.cjs +0 -113
  324. package/dist/controllers/user-storage/mocks/mockResponses.cjs.map +0 -1
  325. package/dist/controllers/user-storage/mocks/mockResponses.d.cts +0 -66
  326. package/dist/controllers/user-storage/mocks/mockResponses.d.cts.map +0 -1
  327. package/dist/controllers/user-storage/mocks/mockResponses.d.mts.map +0 -1
  328. package/dist/controllers/user-storage/mocks/mockResponses.mjs.map +0 -1
  329. package/dist/controllers/user-storage/mocks/mockStorage.cjs +0 -36
  330. package/dist/controllers/user-storage/mocks/mockStorage.cjs.map +0 -1
  331. package/dist/controllers/user-storage/mocks/mockStorage.d.cts.map +0 -1
  332. package/dist/controllers/user-storage/mocks/mockStorage.d.mts +0 -5
  333. package/dist/controllers/user-storage/mocks/mockStorage.d.mts.map +0 -1
  334. package/dist/controllers/user-storage/mocks/mockStorage.mjs.map +0 -1
  335. package/dist/controllers/user-storage/types.cjs +0 -3
  336. package/dist/controllers/user-storage/types.cjs.map +0 -1
  337. package/dist/controllers/user-storage/types.d.cts.map +0 -1
  338. package/dist/controllers/user-storage/types.d.mts +0 -23
  339. package/dist/controllers/user-storage/types.d.mts.map +0 -1
  340. package/dist/controllers/user-storage/types.mjs +0 -2
  341. package/dist/controllers/user-storage/types.mjs.map +0 -1
  342. package/dist/controllers/user-storage/utils.cjs +0 -32
  343. package/dist/controllers/user-storage/utils.cjs.map +0 -1
  344. package/dist/controllers/user-storage/utils.d.cts.map +0 -1
  345. package/dist/controllers/user-storage/utils.d.mts +0 -19
  346. package/dist/controllers/user-storage/utils.d.mts.map +0 -1
  347. package/dist/controllers/user-storage/utils.mjs.map +0 -1
  348. package/dist/index.cjs +0 -30
  349. package/dist/index.cjs.map +0 -1
  350. package/dist/index.d.cts +0 -4
  351. package/dist/index.d.cts.map +0 -1
  352. package/dist/index.d.mts +0 -4
  353. package/dist/index.d.mts.map +0 -1
  354. package/dist/index.mjs +0 -4
  355. package/dist/index.mjs.map +0 -1
  356. package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs +0 -114
  357. package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs.map +0 -1
  358. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.cts.map +0 -1
  359. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.mts +0 -25
  360. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.mts.map +0 -1
  361. package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs.map +0 -1
  362. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs +0 -290
  363. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs.map +0 -1
  364. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts.map +0 -1
  365. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts +0 -44
  366. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts.map +0 -1
  367. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs.map +0 -1
  368. package/dist/sdk/authentication-jwt-bearer/services.cjs +0 -400
  369. package/dist/sdk/authentication-jwt-bearer/services.cjs.map +0 -1
  370. package/dist/sdk/authentication-jwt-bearer/services.d.cts.map +0 -1
  371. package/dist/sdk/authentication-jwt-bearer/services.d.mts +0 -105
  372. package/dist/sdk/authentication-jwt-bearer/services.d.mts.map +0 -1
  373. package/dist/sdk/authentication-jwt-bearer/services.mjs.map +0 -1
  374. package/dist/sdk/authentication-jwt-bearer/types.cjs +0 -12
  375. package/dist/sdk/authentication-jwt-bearer/types.cjs.map +0 -1
  376. package/dist/sdk/authentication-jwt-bearer/types.d.cts.map +0 -1
  377. package/dist/sdk/authentication-jwt-bearer/types.d.mts +0 -114
  378. package/dist/sdk/authentication-jwt-bearer/types.d.mts.map +0 -1
  379. package/dist/sdk/authentication-jwt-bearer/types.mjs.map +0 -1
  380. package/dist/sdk/authentication-jwt-bearer/utils/identifier.cjs +0 -27
  381. package/dist/sdk/authentication-jwt-bearer/utils/identifier.cjs.map +0 -1
  382. package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.cts.map +0 -1
  383. package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.mts +0 -13
  384. package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.mts.map +0 -1
  385. package/dist/sdk/authentication-jwt-bearer/utils/identifier.mjs.map +0 -1
  386. package/dist/sdk/authentication-jwt-bearer/utils/time.cjs +0 -17
  387. package/dist/sdk/authentication-jwt-bearer/utils/time.cjs.map +0 -1
  388. package/dist/sdk/authentication-jwt-bearer/utils/time.d.cts.map +0 -1
  389. package/dist/sdk/authentication-jwt-bearer/utils/time.d.mts +0 -8
  390. package/dist/sdk/authentication-jwt-bearer/utils/time.d.mts.map +0 -1
  391. package/dist/sdk/authentication-jwt-bearer/utils/time.mjs.map +0 -1
  392. package/dist/sdk/authentication.cjs +0 -132
  393. package/dist/sdk/authentication.cjs.map +0 -1
  394. package/dist/sdk/authentication.d.cts.map +0 -1
  395. package/dist/sdk/authentication.d.mts +0 -38
  396. package/dist/sdk/authentication.d.mts.map +0 -1
  397. package/dist/sdk/authentication.mjs.map +0 -1
  398. package/dist/sdk/constants.cjs +0 -7
  399. package/dist/sdk/constants.cjs.map +0 -1
  400. package/dist/sdk/constants.d.cts.map +0 -1
  401. package/dist/sdk/constants.d.mts +0 -4
  402. package/dist/sdk/constants.d.mts.map +0 -1
  403. package/dist/sdk/constants.mjs.map +0 -1
  404. package/dist/sdk/errors.cjs +0 -76
  405. package/dist/sdk/errors.cjs.map +0 -1
  406. package/dist/sdk/errors.d.cts.map +0 -1
  407. package/dist/sdk/errors.d.mts +0 -34
  408. package/dist/sdk/errors.d.mts.map +0 -1
  409. package/dist/sdk/errors.mjs.map +0 -1
  410. package/dist/sdk/index.cjs +0 -24
  411. package/dist/sdk/index.cjs.map +0 -1
  412. package/dist/sdk/index.d.cts +0 -8
  413. package/dist/sdk/index.d.cts.map +0 -1
  414. package/dist/sdk/index.d.mts +0 -8
  415. package/dist/sdk/index.d.mts.map +0 -1
  416. package/dist/sdk/index.mjs +0 -8
  417. package/dist/sdk/index.mjs.map +0 -1
  418. package/dist/sdk/mocks/auth.cjs +0 -82
  419. package/dist/sdk/mocks/auth.cjs.map +0 -1
  420. package/dist/sdk/mocks/auth.d.cts.map +0 -1
  421. package/dist/sdk/mocks/auth.d.mts +0 -69
  422. package/dist/sdk/mocks/auth.d.mts.map +0 -1
  423. package/dist/sdk/mocks/auth.mjs.map +0 -1
  424. package/dist/sdk/mocks/userstorage.cjs +0 -43
  425. package/dist/sdk/mocks/userstorage.cjs.map +0 -1
  426. package/dist/sdk/mocks/userstorage.d.cts.map +0 -1
  427. package/dist/sdk/mocks/userstorage.d.mts +0 -10
  428. package/dist/sdk/mocks/userstorage.d.mts.map +0 -1
  429. package/dist/sdk/mocks/userstorage.mjs.map +0 -1
  430. package/dist/sdk/user-storage.cjs +0 -386
  431. package/dist/sdk/user-storage.cjs.map +0 -1
  432. package/dist/sdk/user-storage.d.cts +0 -47
  433. package/dist/sdk/user-storage.d.cts.map +0 -1
  434. package/dist/sdk/user-storage.d.mts.map +0 -1
  435. package/dist/sdk/user-storage.mjs.map +0 -1
  436. package/dist/sdk/utils/eip-6963-metamask-provider.cjs +0 -70
  437. package/dist/sdk/utils/eip-6963-metamask-provider.cjs.map +0 -1
  438. package/dist/sdk/utils/eip-6963-metamask-provider.d.cts.map +0 -1
  439. package/dist/sdk/utils/eip-6963-metamask-provider.d.mts +0 -25
  440. package/dist/sdk/utils/eip-6963-metamask-provider.d.mts.map +0 -1
  441. package/dist/sdk/utils/eip-6963-metamask-provider.mjs.map +0 -1
  442. package/dist/sdk/utils/messaging-signing-snap-requests.cjs +0 -96
  443. package/dist/sdk/utils/messaging-signing-snap-requests.cjs.map +0 -1
  444. package/dist/sdk/utils/messaging-signing-snap-requests.d.cts.map +0 -1
  445. package/dist/sdk/utils/messaging-signing-snap-requests.d.mts +0 -41
  446. package/dist/sdk/utils/messaging-signing-snap-requests.d.mts.map +0 -1
  447. package/dist/sdk/utils/messaging-signing-snap-requests.mjs.map +0 -1
  448. package/dist/sdk/utils/validate-login-response.cjs +0 -49
  449. package/dist/sdk/utils/validate-login-response.cjs.map +0 -1
  450. package/dist/sdk/utils/validate-login-response.d.cts +0 -14
  451. package/dist/sdk/utils/validate-login-response.d.cts.map +0 -1
  452. package/dist/sdk/utils/validate-login-response.d.mts.map +0 -1
  453. package/dist/sdk/utils/validate-login-response.mjs.map +0 -1
  454. package/dist/sdk/utils/validate-pair-response.cjs +0 -29
  455. package/dist/sdk/utils/validate-pair-response.cjs.map +0 -1
  456. package/dist/sdk/utils/validate-pair-response.d.cts.map +0 -1
  457. package/dist/sdk/utils/validate-pair-response.d.mts +0 -26
  458. package/dist/sdk/utils/validate-pair-response.d.mts.map +0 -1
  459. package/dist/sdk/utils/validate-pair-response.mjs.map +0 -1
  460. package/dist/shared/encryption/cache.cjs +0 -77
  461. package/dist/shared/encryption/cache.cjs.map +0 -1
  462. package/dist/shared/encryption/cache.d.cts.map +0 -1
  463. package/dist/shared/encryption/cache.d.mts +0 -32
  464. package/dist/shared/encryption/cache.d.mts.map +0 -1
  465. package/dist/shared/encryption/cache.mjs.map +0 -1
  466. package/dist/shared/encryption/constants.cjs +0 -17
  467. package/dist/shared/encryption/constants.cjs.map +0 -1
  468. package/dist/shared/encryption/constants.d.cts.map +0 -1
  469. package/dist/shared/encryption/constants.d.mts +0 -9
  470. package/dist/shared/encryption/constants.d.mts.map +0 -1
  471. package/dist/shared/encryption/constants.mjs.map +0 -1
  472. package/dist/shared/encryption/encryption.cjs +0 -209
  473. package/dist/shared/encryption/encryption.cjs.map +0 -1
  474. package/dist/shared/encryption/encryption.d.cts.map +0 -1
  475. package/dist/shared/encryption/encryption.d.mts +0 -30
  476. package/dist/shared/encryption/encryption.d.mts.map +0 -1
  477. package/dist/shared/encryption/encryption.mjs.map +0 -1
  478. package/dist/shared/encryption/index.cjs +0 -25
  479. package/dist/shared/encryption/index.cjs.map +0 -1
  480. package/dist/shared/encryption/index.d.cts +0 -5
  481. package/dist/shared/encryption/index.d.cts.map +0 -1
  482. package/dist/shared/encryption/index.d.mts +0 -5
  483. package/dist/shared/encryption/index.d.mts.map +0 -1
  484. package/dist/shared/encryption/index.mjs +0 -5
  485. package/dist/shared/encryption/index.mjs.map +0 -1
  486. package/dist/shared/encryption/utils.cjs +0 -21
  487. package/dist/shared/encryption/utils.cjs.map +0 -1
  488. package/dist/shared/encryption/utils.d.cts.map +0 -1
  489. package/dist/shared/encryption/utils.d.mts +0 -5
  490. package/dist/shared/encryption/utils.d.mts.map +0 -1
  491. package/dist/shared/encryption/utils.mjs.map +0 -1
  492. package/dist/shared/env.cjs +0 -85
  493. package/dist/shared/env.cjs.map +0 -1
  494. package/dist/shared/env.d.cts.map +0 -1
  495. package/dist/shared/env.d.mts +0 -34
  496. package/dist/shared/env.d.mts.map +0 -1
  497. package/dist/shared/env.mjs.map +0 -1
  498. package/dist/shared/storage-schema.cjs +0 -42
  499. package/dist/shared/storage-schema.cjs.map +0 -1
  500. package/dist/shared/storage-schema.d.cts +0 -34
  501. package/dist/shared/storage-schema.d.cts.map +0 -1
  502. package/dist/shared/storage-schema.d.mts.map +0 -1
  503. package/dist/shared/storage-schema.mjs.map +0 -1
  504. package/dist/shared/types/encryption.cjs +0 -3
  505. package/dist/shared/types/encryption.cjs.map +0 -1
  506. package/dist/shared/types/encryption.d.cts.map +0 -1
  507. package/dist/shared/types/encryption.d.mts +0 -2
  508. package/dist/shared/types/encryption.d.mts.map +0 -1
  509. package/dist/shared/types/encryption.mjs +0 -2
  510. package/dist/shared/types/encryption.mjs.map +0 -1
  511. package/dist/shared/types/services.cjs +0 -3
  512. package/dist/shared/types/services.cjs.map +0 -1
  513. package/dist/shared/types/services.d.cts.map +0 -1
  514. package/dist/shared/types/services.d.mts +0 -17
  515. package/dist/shared/types/services.d.mts.map +0 -1
  516. package/dist/shared/types/services.mjs +0 -2
  517. package/dist/shared/types/services.mjs.map +0 -1
  518. package/dist/shared/utils/entropy-source.cjs +0 -37
  519. package/dist/shared/utils/entropy-source.cjs.map +0 -1
  520. package/dist/shared/utils/entropy-source.d.cts.map +0 -1
  521. package/dist/shared/utils/entropy-source.d.mts +0 -22
  522. package/dist/shared/utils/entropy-source.d.mts.map +0 -1
  523. package/dist/shared/utils/entropy-source.mjs.map +0 -1
  524. package/dist/shared/utils/event-queue.cjs +0 -24
  525. package/dist/shared/utils/event-queue.cjs.map +0 -1
  526. package/dist/shared/utils/event-queue.d.cts.map +0 -1
  527. package/dist/shared/utils/event-queue.d.mts +0 -6
  528. package/dist/shared/utils/event-queue.d.mts.map +0 -1
  529. package/dist/shared/utils/event-queue.mjs.map +0 -1
  530. package/dist/shared/utils/hd-keyring-seed.cjs +0 -49
  531. package/dist/shared/utils/hd-keyring-seed.cjs.map +0 -1
  532. package/dist/shared/utils/hd-keyring-seed.d.cts +0 -27
  533. package/dist/shared/utils/hd-keyring-seed.d.cts.map +0 -1
  534. package/dist/shared/utils/hd-keyring-seed.d.mts.map +0 -1
  535. package/dist/shared/utils/hd-keyring-seed.mjs.map +0 -1
  536. package/dist/shared/utils/message-signing.cjs +0 -147
  537. package/dist/shared/utils/message-signing.cjs.map +0 -1
  538. package/dist/shared/utils/message-signing.d.cts +0 -73
  539. package/dist/shared/utils/message-signing.d.cts.map +0 -1
  540. package/dist/shared/utils/message-signing.d.mts.map +0 -1
  541. package/dist/shared/utils/message-signing.mjs.map +0 -1
@@ -1,412 +0,0 @@
1
- "use strict";
2
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
- 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");
5
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
- };
7
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8
- if (kind === "m") throw new TypeError("Private method is not writable");
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
10
- 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");
11
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
12
- };
13
- var _UserStorageController_instances, _UserStorageController_userStorage, _UserStorageController_auth, _UserStorageController_config, _UserStorageController_trace, _UserStorageController_isUnlocked, _UserStorageController_storageKeyCache, _UserStorageController_signMessageCache, _UserStorageController_keyringController, _UserStorageController_nativeScryptCrypto, _UserStorageController_getHdKeyringEntropySourceIds, _UserStorageController_getPrimaryEntropySourceId, _UserStorageController_scopedCacheKey, _UserStorageController_signMessage, _UserStorageController_setIsBackupAndSyncUpdateLoading;
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.UserStorageController = exports.defaultState = void 0;
16
- const base_controller_1 = require("@metamask/base-controller");
17
- const index_js_1 = require("../../sdk/index.cjs");
18
- const entropy_source_js_1 = require("../../shared/utils/entropy-source.cjs");
19
- const event_queue_js_1 = require("../../shared/utils/event-queue.cjs");
20
- const hd_keyring_seed_js_1 = require("../../shared/utils/hd-keyring-seed.cjs");
21
- const message_signing_js_1 = require("../../shared/utils/message-signing.cjs");
22
- const constants_js_1 = require("./constants.cjs");
23
- const controller_integration_js_1 = require("./contact-syncing/controller-integration.cjs");
24
- const setup_subscriptions_js_1 = require("./contact-syncing/setup-subscriptions.cjs");
25
- const controllerName = 'UserStorageController';
26
- exports.defaultState = {
27
- isBackupAndSyncEnabled: true,
28
- isBackupAndSyncUpdateLoading: false,
29
- isAccountSyncingEnabled: true,
30
- isContactSyncingEnabled: true,
31
- isContactSyncingInProgress: false,
32
- };
33
- const metadata = {
34
- isBackupAndSyncEnabled: {
35
- includeInStateLogs: true,
36
- persist: true,
37
- includeInDebugSnapshot: true,
38
- usedInUi: true,
39
- },
40
- isBackupAndSyncUpdateLoading: {
41
- includeInStateLogs: false,
42
- persist: false,
43
- includeInDebugSnapshot: false,
44
- usedInUi: true,
45
- },
46
- isAccountSyncingEnabled: {
47
- includeInStateLogs: true,
48
- persist: true,
49
- includeInDebugSnapshot: true,
50
- usedInUi: true,
51
- },
52
- isContactSyncingEnabled: {
53
- includeInStateLogs: true,
54
- persist: true,
55
- includeInDebugSnapshot: true,
56
- usedInUi: true,
57
- },
58
- isContactSyncingInProgress: {
59
- includeInStateLogs: false,
60
- persist: false,
61
- includeInDebugSnapshot: false,
62
- usedInUi: true,
63
- },
64
- };
65
- const MESSENGER_EXPOSED_METHODS = [
66
- 'performGetStorage',
67
- 'performGetStorageAllFeatureEntries',
68
- 'performSetStorage',
69
- 'performBatchSetStorage',
70
- 'performDeleteStorage',
71
- 'performBatchDeleteStorage',
72
- 'getStorageKey',
73
- 'performDeleteStorageAllFeatureEntries',
74
- 'listEntropySources',
75
- 'setIsBackupAndSyncFeatureEnabled',
76
- 'setIsContactSyncingInProgress',
77
- 'syncContactsWithUserStorage',
78
- ];
79
- /**
80
- * Reusable controller that allows any team to store synchronized data for a given user.
81
- * These can be settings shared cross MetaMask clients, or data we want to persist when uninstalling/reinstalling.
82
- *
83
- * NOTE:
84
- * - data stored on UserStorage is FULLY encrypted, with the only keys stored/managed on the client.
85
- * - No one can access this data unless they are have the SRP and are able to run the signing snap.
86
- */
87
- class UserStorageController extends base_controller_1.BaseController {
88
- constructor({ messenger, state, config, nativeScryptCrypto, trace, }) {
89
- super({
90
- messenger,
91
- metadata,
92
- name: controllerName,
93
- state: { ...exports.defaultState, ...state },
94
- });
95
- _UserStorageController_instances.add(this);
96
- _UserStorageController_userStorage.set(this, void 0);
97
- _UserStorageController_auth.set(this, {
98
- getProfileId: async (entropySourceId) => {
99
- const sessionProfile = await this.messenger.call('AuthenticationController:getSessionProfile', entropySourceId);
100
- return sessionProfile?.profileId;
101
- },
102
- isSignedIn: () => {
103
- return this.messenger.call('AuthenticationController:isSignedIn');
104
- },
105
- signIn: async () => {
106
- return await this.messenger.call('AuthenticationController:performSignIn');
107
- },
108
- });
109
- _UserStorageController_config.set(this, {
110
- env: index_js_1.Env.PRD,
111
- });
112
- _UserStorageController_trace.set(this, void 0);
113
- _UserStorageController_isUnlocked.set(this, false);
114
- // Both caches are keyed by `${entropySourceId}:${message}` (the primary SRP
115
- // resolves to its HD keyring metadata ID) so two SRPs that transiently
116
- // resolve to the same `profileId` can never share a cached storage key /
117
- // signature and leak data across each other's user storage.
118
- _UserStorageController_storageKeyCache.set(this, {});
119
- _UserStorageController_signMessageCache.set(this, {});
120
- _UserStorageController_keyringController.set(this, {
121
- setupLockedStateSubscriptions: () => {
122
- const { isUnlocked } = this.messenger.call('KeyringController:getState');
123
- __classPrivateFieldSet(this, _UserStorageController_isUnlocked, isUnlocked, "f");
124
- this.messenger.subscribe('KeyringController:unlock', () => {
125
- __classPrivateFieldSet(this, _UserStorageController_isUnlocked, true, "f");
126
- });
127
- this.messenger.subscribe('KeyringController:lock', () => {
128
- __classPrivateFieldSet(this, _UserStorageController_isUnlocked, false, "f");
129
- });
130
- },
131
- });
132
- _UserStorageController_nativeScryptCrypto.set(this, undefined);
133
- this.eventQueue = new event_queue_js_1.EventQueue();
134
- __classPrivateFieldSet(this, _UserStorageController_config, {
135
- ...__classPrivateFieldGet(this, _UserStorageController_config, "f"),
136
- ...config,
137
- }, "f");
138
- __classPrivateFieldSet(this, _UserStorageController_trace, trace ??
139
- (async (_request, fn) => {
140
- if (!fn) {
141
- return undefined;
142
- }
143
- return await Promise.resolve(fn());
144
- }), "f");
145
- __classPrivateFieldSet(this, _UserStorageController_userStorage, new index_js_1.UserStorage({
146
- env: __classPrivateFieldGet(this, _UserStorageController_config, "f").env,
147
- auth: {
148
- getAccessToken: (entropySourceId) => this.messenger.call('AuthenticationController:getBearerToken', entropySourceId),
149
- getUserProfile: async (entropySourceId) => {
150
- return await this.messenger.call('AuthenticationController:getSessionProfile', entropySourceId);
151
- },
152
- signMessage: (message, entropySourceId) => __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_signMessage).call(this, message, entropySourceId),
153
- },
154
- }, {
155
- storage: {
156
- getStorageKey: async (message, entropySourceId) => {
157
- // No derived key can exist while locked (the KeyringController
158
- // clears its keyrings on lock, so the scope is unresolvable).
159
- if (!__classPrivateFieldGet(this, _UserStorageController_isUnlocked, "f")) {
160
- return null;
161
- }
162
- return (__classPrivateFieldGet(this, _UserStorageController_storageKeyCache, "f")[__classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_scopedCacheKey).call(this, message, entropySourceId)] ?? null);
163
- },
164
- // Only ever reached after a successful signature, i.e. while unlocked.
165
- setStorageKey: async (message, key, entropySourceId) => {
166
- __classPrivateFieldGet(this, _UserStorageController_storageKeyCache, "f")[__classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_scopedCacheKey).call(this, message, entropySourceId)] = key;
167
- },
168
- },
169
- }), "f");
170
- this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
171
- __classPrivateFieldGet(this, _UserStorageController_keyringController, "f").setupLockedStateSubscriptions();
172
- __classPrivateFieldSet(this, _UserStorageController_nativeScryptCrypto, nativeScryptCrypto, "f");
173
- // Contact Syncing
174
- (0, setup_subscriptions_js_1.setupContactSyncingSubscriptions)({
175
- getUserStorageControllerInstance: () => this,
176
- getMessenger: () => this.messenger,
177
- trace: __classPrivateFieldGet(this, _UserStorageController_trace, "f"),
178
- });
179
- }
180
- /**
181
- * Allows retrieval of stored data. Data stored is string formatted.
182
- * Developers can extend the entry path and entry name through the `schema.ts` file.
183
- *
184
- * @param path - string in the form of `${feature}.${key}` that matches schema
185
- * @param entropySourceId - The entropy source ID used to generate the encryption key.
186
- * @returns the decrypted string contents found from user storage (or null if not found)
187
- */
188
- async performGetStorage(path, entropySourceId) {
189
- return await __classPrivateFieldGet(this, _UserStorageController_userStorage, "f").getItem(path, {
190
- nativeScryptCrypto: __classPrivateFieldGet(this, _UserStorageController_nativeScryptCrypto, "f"),
191
- entropySourceId,
192
- });
193
- }
194
- /**
195
- * Allows retrieval of all stored data for a specific feature. Data stored is formatted as an array of strings.
196
- * Developers can extend the entry path through the `schema.ts` file.
197
- *
198
- * @param path - string in the form of `${feature}` that matches schema
199
- * @param entropySourceId - The entropy source ID used to generate the encryption key.
200
- * @returns the array of decrypted string contents found from user storage (or null if not found)
201
- */
202
- async performGetStorageAllFeatureEntries(path, entropySourceId) {
203
- return await __classPrivateFieldGet(this, _UserStorageController_userStorage, "f").getAllFeatureItems(path, {
204
- nativeScryptCrypto: __classPrivateFieldGet(this, _UserStorageController_nativeScryptCrypto, "f"),
205
- entropySourceId,
206
- });
207
- }
208
- /**
209
- * Allows storage of user data. Data stored must be string formatted.
210
- * Developers can extend the entry path and entry name through the `schema.ts` file.
211
- *
212
- * @param path - string in the form of `${feature}.${key}` that matches schema
213
- * @param value - The string data you want to store.
214
- * @param entropySourceId - The entropy source ID used to generate the encryption key.
215
- * @returns nothing. NOTE that an error is thrown if fails to store data.
216
- */
217
- async performSetStorage(path, value, entropySourceId) {
218
- return await __classPrivateFieldGet(this, _UserStorageController_userStorage, "f").setItem(path, value, {
219
- nativeScryptCrypto: __classPrivateFieldGet(this, _UserStorageController_nativeScryptCrypto, "f"),
220
- entropySourceId,
221
- });
222
- }
223
- /**
224
- * Allows storage of multiple user data entries for one specific feature. Data stored must be string formatted.
225
- * Developers can extend the entry path through the `schema.ts` file.
226
- *
227
- * @param path - string in the form of `${feature}` that matches schema
228
- * @param values - data to store, in the form of an array of `[entryKey, entryValue]` pairs
229
- * @param entropySourceId - The entropy source ID used to generate the encryption key.
230
- * @returns nothing. NOTE that an error is thrown if fails to store data.
231
- */
232
- async performBatchSetStorage(path, values, entropySourceId) {
233
- return await __classPrivateFieldGet(this, _UserStorageController_userStorage, "f").batchSetItems(path, values, {
234
- nativeScryptCrypto: __classPrivateFieldGet(this, _UserStorageController_nativeScryptCrypto, "f"),
235
- entropySourceId,
236
- });
237
- }
238
- /**
239
- * Allows deletion of user data. Developers can extend the entry path and entry name through the `schema.ts` file.
240
- *
241
- * @param path - string in the form of `${feature}.${key}` that matches schema
242
- * @param entropySourceId - The entropy source ID used to generate the encryption key.
243
- * @returns nothing. NOTE that an error is thrown if fails to delete data.
244
- */
245
- async performDeleteStorage(path, entropySourceId) {
246
- return await __classPrivateFieldGet(this, _UserStorageController_userStorage, "f").deleteItem(path, {
247
- nativeScryptCrypto: __classPrivateFieldGet(this, _UserStorageController_nativeScryptCrypto, "f"),
248
- entropySourceId,
249
- });
250
- }
251
- /**
252
- * Allows deletion of all user data entries for a specific feature.
253
- * Developers can extend the entry path through the `schema.ts` file.
254
- *
255
- * @param path - string in the form of `${feature}` that matches schema
256
- * @param entropySourceId - The entropy source ID used to generate the encryption key.
257
- * @returns nothing. NOTE that an error is thrown if fails to delete data.
258
- */
259
- async performDeleteStorageAllFeatureEntries(path, entropySourceId) {
260
- return await __classPrivateFieldGet(this, _UserStorageController_userStorage, "f").deleteAllFeatureItems(path, {
261
- nativeScryptCrypto: __classPrivateFieldGet(this, _UserStorageController_nativeScryptCrypto, "f"),
262
- entropySourceId,
263
- });
264
- }
265
- /**
266
- * Allows delete of multiple user data entries for one specific feature. Data deleted must be string formatted.
267
- * Developers can extend the entry path through the `schema.ts` file.
268
- *
269
- * @param path - string in the form of `${feature}` that matches schema
270
- * @param values - data to store, in the form of an array of entryKey[]
271
- * @param entropySourceId - The entropy source ID used to generate the encryption key.
272
- * @returns nothing. NOTE that an error is thrown if fails to store data.
273
- */
274
- async performBatchDeleteStorage(path, values, entropySourceId) {
275
- return await __classPrivateFieldGet(this, _UserStorageController_userStorage, "f").batchDeleteItems(path, values, {
276
- nativeScryptCrypto: __classPrivateFieldGet(this, _UserStorageController_nativeScryptCrypto, "f"),
277
- entropySourceId,
278
- });
279
- }
280
- /**
281
- * Retrieves the storage key, for internal use only!
282
- *
283
- * @returns the storage key
284
- */
285
- async getStorageKey() {
286
- return await __classPrivateFieldGet(this, _UserStorageController_userStorage, "f").getStorageKey();
287
- }
288
- /**
289
- * Flushes the storage key cache.
290
- * CAUTION: This is only public for testing purposes.
291
- * It should not be used in production code.
292
- */
293
- flushStorageKeyCache() {
294
- __classPrivateFieldSet(this, _UserStorageController_storageKeyCache, {}, "f");
295
- }
296
- /**
297
- * Lists all the available HD keyring metadata IDs.
298
- * These IDs can be used in a multi-SRP context to segregate data specific to different SRPs.
299
- *
300
- * @returns A promise that resolves to an array of HD keyring metadata IDs.
301
- */
302
- async listEntropySources() {
303
- if (!__classPrivateFieldGet(this, _UserStorageController_isUnlocked, "f")) {
304
- throw new Error('listEntropySources - unable to list entropy sources, wallet is locked');
305
- }
306
- return __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_getHdKeyringEntropySourceIds).call(this);
307
- }
308
- async setIsBackupAndSyncFeatureEnabled(feature, enabled) {
309
- try {
310
- __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_setIsBackupAndSyncUpdateLoading).call(this, true);
311
- if (enabled) {
312
- // If any of the features are enabled, we need to ensure the user is signed in
313
- const isSignedIn = __classPrivateFieldGet(this, _UserStorageController_auth, "f").isSignedIn();
314
- if (!isSignedIn) {
315
- await __classPrivateFieldGet(this, _UserStorageController_auth, "f").signIn();
316
- }
317
- }
318
- this.update((state) => {
319
- if (feature === constants_js_1.BACKUPANDSYNC_FEATURES.main) {
320
- state.isBackupAndSyncEnabled = enabled;
321
- }
322
- if (feature === constants_js_1.BACKUPANDSYNC_FEATURES.accountSyncing) {
323
- state.isAccountSyncingEnabled = enabled;
324
- }
325
- if (feature === constants_js_1.BACKUPANDSYNC_FEATURES.contactSyncing) {
326
- state.isContactSyncingEnabled = enabled;
327
- }
328
- });
329
- }
330
- catch (e) {
331
- // istanbul ignore next
332
- const errorMessage = e instanceof Error ? e.message : JSON.stringify(e);
333
- // istanbul ignore next
334
- throw new Error(`${controllerName} - failed to ${enabled ? 'enable' : 'disable'} ${feature} - ${errorMessage}`);
335
- }
336
- finally {
337
- __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_setIsBackupAndSyncUpdateLoading).call(this, false);
338
- }
339
- }
340
- /**
341
- * Sets the isContactSyncingInProgress flag to prevent infinite loops during contact synchronization
342
- *
343
- * @param isContactSyncingInProgress - Whether contact syncing is in progress
344
- */
345
- async setIsContactSyncingInProgress(isContactSyncingInProgress) {
346
- this.update((state) => {
347
- state.isContactSyncingInProgress = isContactSyncingInProgress;
348
- });
349
- }
350
- /**
351
- * Syncs the address book list with the user storage address book list.
352
- * This method is used to make sure that the address book list is up-to-date with the user storage address book list and vice-versa.
353
- * It will add new contacts to the address book list, update/merge conflicting contacts and re-upload the results in some cases to the user storage.
354
- */
355
- async syncContactsWithUserStorage() {
356
- const profileId = await __classPrivateFieldGet(this, _UserStorageController_auth, "f").getProfileId();
357
- const config = {
358
- onContactUpdated: () => {
359
- __classPrivateFieldGet(this, _UserStorageController_config, "f")?.contactSyncing?.onContactUpdated?.(profileId);
360
- },
361
- onContactDeleted: () => {
362
- __classPrivateFieldGet(this, _UserStorageController_config, "f")?.contactSyncing?.onContactDeleted?.(profileId);
363
- },
364
- onContactSyncErroneousSituation: (errorMessage, sentryContext) => {
365
- __classPrivateFieldGet(this, _UserStorageController_config, "f")?.contactSyncing?.onContactSyncErroneousSituation?.(profileId, errorMessage, sentryContext);
366
- },
367
- };
368
- await (0, controller_integration_js_1.syncContactsWithUserStorage)(config, {
369
- getMessenger: () => this.messenger,
370
- getUserStorageControllerInstance: () => this,
371
- trace: __classPrivateFieldGet(this, _UserStorageController_trace, "f"),
372
- });
373
- }
374
- }
375
- exports.UserStorageController = UserStorageController;
376
- _UserStorageController_userStorage = new WeakMap(), _UserStorageController_auth = new WeakMap(), _UserStorageController_config = new WeakMap(), _UserStorageController_trace = new WeakMap(), _UserStorageController_isUnlocked = new WeakMap(), _UserStorageController_storageKeyCache = new WeakMap(), _UserStorageController_signMessageCache = new WeakMap(), _UserStorageController_keyringController = new WeakMap(), _UserStorageController_nativeScryptCrypto = new WeakMap(), _UserStorageController_instances = new WeakSet(), _UserStorageController_getHdKeyringEntropySourceIds = function _UserStorageController_getHdKeyringEntropySourceIds() {
377
- const { keyrings } = this.messenger.call('KeyringController:getState');
378
- return (0, entropy_source_js_1.getHdKeyringEntropySourceIds)(keyrings);
379
- }, _UserStorageController_getPrimaryEntropySourceId = function _UserStorageController_getPrimaryEntropySourceId() {
380
- const { keyrings } = this.messenger.call('KeyringController:getState');
381
- return (0, entropy_source_js_1.getPrimaryHdKeyringEntropySourceId)(keyrings);
382
- }, _UserStorageController_scopedCacheKey = function _UserStorageController_scopedCacheKey(message, entropySourceId) {
383
- return `${entropySourceId ?? __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_getPrimaryEntropySourceId).call(this)}:${message}`;
384
- }, _UserStorageController_signMessage =
385
- /**
386
- * Signs a `metamask:…` message with the native SIP-6 message-signing key
387
- * (same key as `@metamask/message-signing-snap` with empty salt).
388
- *
389
- * @param message - A specific tagged message to sign.
390
- * @param entropySourceId - The entropy source ID used to derive the key,
391
- * when multiple sources are available (Multi-SRP).
392
- * @returns Compact secp256k1 signature hex.
393
- */
394
- async function _UserStorageController_signMessage(message, entropySourceId) {
395
- if (!__classPrivateFieldGet(this, _UserStorageController_isUnlocked, "f")) {
396
- throw new Error('#signMessage - unable to proceed, wallet is locked');
397
- }
398
- const cacheKey = __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_scopedCacheKey).call(this, message, entropySourceId);
399
- if (__classPrivateFieldGet(this, _UserStorageController_signMessageCache, "f")[cacheKey]) {
400
- return __classPrivateFieldGet(this, _UserStorageController_signMessageCache, "f")[cacheKey];
401
- }
402
- const resolvedId = entropySourceId ?? __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_getPrimaryEntropySourceId).call(this);
403
- const seed = await (0, hd_keyring_seed_js_1.getHdKeyringSeed)(this.messenger, resolvedId);
404
- const result = await (0, message_signing_js_1.signMessageWithMessageSigningKey)(message, seed);
405
- __classPrivateFieldGet(this, _UserStorageController_signMessageCache, "f")[cacheKey] = result;
406
- return result;
407
- }, _UserStorageController_setIsBackupAndSyncUpdateLoading = function _UserStorageController_setIsBackupAndSyncUpdateLoading(isBackupAndSyncUpdateLoading) {
408
- this.update((state) => {
409
- state.isBackupAndSyncUpdateLoading = isBackupAndSyncUpdateLoading;
410
- });
411
- };
412
- //# sourceMappingURL=UserStorageController.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UserStorageController.cjs","sourceRoot":"","sources":["../../../src/controllers/user-storage/UserStorageController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAQA,+DAA2D;AAwB3D,kDAAsD;AAEtD,6EAG8C;AAC9C,uEAA+D;AAC/D,+EAAyE;AACzE,+EAAyF;AAOzF,kDAAwD;AACxD,4FAA0F;AAC1F,sFAA4F;AAG5F,MAAM,cAAc,GAAG,uBAAuB,CAAC;AA0BlC,QAAA,YAAY,GAA+B;IACtD,sBAAsB,EAAE,IAAI;IAC5B,4BAA4B,EAAE,KAAK;IACnC,uBAAuB,EAAE,IAAI;IAC7B,uBAAuB,EAAE,IAAI;IAC7B,0BAA0B,EAAE,KAAK;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C,OAAO,MAAM,CAAC;AAChB,CAAC,2HA2CC,4BAAqC;IAErC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;QACpB,KAAK,CAAC,4BAA4B,GAAG,4BAA4B,CAAC;IACpE,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type {\n AddressBookControllerContactUpdatedEvent,\n AddressBookControllerContactDeletedEvent,\n AddressBookControllerActions,\n AddressBookControllerListAction,\n AddressBookControllerSetAction,\n AddressBookControllerDeleteAction,\n} from '@metamask/address-book-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport type {\n TraceCallback,\n TraceContext,\n TraceRequest,\n} from '@metamask/controller-utils';\nimport type {\n KeyringControllerGetStateAction,\n KeyringControllerLockEvent,\n KeyringControllerUnlockEvent,\n KeyringControllerWithKeyringV2UnsafeAction,\n} from '@metamask/keyring-controller';\nimport type { Messenger } from '@metamask/messenger';\n\nimport type {\n UserStorageGenericFeatureKey,\n UserStorageGenericPathWithFeatureAndKey,\n UserStorageGenericPathWithFeatureOnly,\n} from '../../sdk/index.js';\nimport { Env, UserStorage } from '../../sdk/index.js';\nimport type { NativeScrypt } from '../../shared/types/encryption.js';\nimport {\n getHdKeyringEntropySourceIds,\n getPrimaryHdKeyringEntropySourceId,\n} from '../../shared/utils/entropy-source.js';\nimport { EventQueue } from '../../shared/utils/event-queue.js';\nimport { getHdKeyringSeed } from '../../shared/utils/hd-keyring-seed.js';\nimport { signMessageWithMessageSigningKey } from '../../shared/utils/message-signing.js';\nimport type {\n AuthenticationControllerGetBearerTokenAction,\n AuthenticationControllerGetSessionProfileAction,\n AuthenticationControllerIsSignedInAction,\n AuthenticationControllerPerformSignInAction,\n} from '../authentication/AuthenticationController-method-action-types.js';\nimport { BACKUPANDSYNC_FEATURES } from './constants.js';\nimport { syncContactsWithUserStorage } from './contact-syncing/controller-integration.js';\nimport { setupContactSyncingSubscriptions } from './contact-syncing/setup-subscriptions.js';\nimport type { UserStorageControllerMethodActions } from './UserStorageController-method-action-types.js';\n\nconst controllerName = 'UserStorageController';\n\n// State\nexport type UserStorageControllerState = {\n /**\n * Condition used by UI and to determine if we can use some of the User Storage methods.\n */\n isBackupAndSyncEnabled: boolean;\n /**\n * Loading state for the backup and sync update\n */\n isBackupAndSyncUpdateLoading: boolean;\n /**\n * Condition used by UI to determine if account syncing is enabled.\n */\n isAccountSyncingEnabled: boolean;\n /**\n * Condition used by UI to determine if contact syncing is enabled.\n */\n isContactSyncingEnabled: boolean;\n /**\n * Condition used by UI to determine if contact syncing is in progress.\n */\n isContactSyncingInProgress: boolean;\n};\n\nexport const defaultState: UserStorageControllerState = {\n isBackupAndSyncEnabled: true,\n isBackupAndSyncUpdateLoading: false,\n isAccountSyncingEnabled: true,\n isContactSyncingEnabled: true,\n isContactSyncingInProgress: false,\n};\n\nconst metadata: StateMetadata<UserStorageControllerState> = {\n isBackupAndSyncEnabled: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n isBackupAndSyncUpdateLoading: {\n includeInStateLogs: false,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n isAccountSyncingEnabled: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n isContactSyncingEnabled: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n isContactSyncingInProgress: {\n includeInStateLogs: false,\n persist: false,\n includeInDebugSnapshot: false,\n usedInUi: true,\n },\n};\n\ntype ControllerConfig = {\n env: Env;\n contactSyncing?: {\n /**\n * Callback that fires when contact sync updates a contact.\n * This is used for analytics.\n */\n onContactUpdated?: (profileId: string) => void;\n\n /**\n * Callback that fires when contact sync deletes a contact.\n * This is used for analytics.\n */\n onContactDeleted?: (profileId: string) => void;\n\n /**\n * Callback that fires when an erroneous situation happens during contact sync.\n * This is used for analytics.\n */\n onContactSyncErroneousSituation?: (\n profileId: string,\n situationMessage: string,\n sentryContext?: Record<string, unknown>,\n ) => void;\n };\n};\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'performGetStorage',\n 'performGetStorageAllFeatureEntries',\n 'performSetStorage',\n 'performBatchSetStorage',\n 'performDeleteStorage',\n 'performBatchDeleteStorage',\n 'getStorageKey',\n 'performDeleteStorageAllFeatureEntries',\n 'listEntropySources',\n 'setIsBackupAndSyncFeatureEnabled',\n 'setIsContactSyncingInProgress',\n 'syncContactsWithUserStorage',\n] as const;\n\nexport type UserStorageControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n UserStorageControllerState\n>;\nexport type Actions =\n | UserStorageControllerGetStateAction\n | UserStorageControllerMethodActions;\n\nexport type AllowedActions =\n // Keyring Requests\n | KeyringControllerGetStateAction\n | KeyringControllerWithKeyringV2UnsafeAction\n // Auth Requests\n | AuthenticationControllerGetBearerTokenAction\n | AuthenticationControllerGetSessionProfileAction\n | AuthenticationControllerPerformSignInAction\n | AuthenticationControllerIsSignedInAction\n // Contact Syncing\n | AddressBookControllerListAction\n | AddressBookControllerSetAction\n | AddressBookControllerDeleteAction\n | AddressBookControllerActions;\n\n// Messenger events\nexport type UserStorageControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n UserStorageControllerState\n>;\n\nexport type Events = UserStorageControllerStateChangeEvent;\n\nexport type AllowedEvents =\n | KeyringControllerLockEvent\n | KeyringControllerUnlockEvent\n // Address Book Events\n | AddressBookControllerContactUpdatedEvent\n | AddressBookControllerContactDeletedEvent;\n\n// Messenger\nexport type UserStorageControllerMessenger = Messenger<\n typeof controllerName,\n Actions | AllowedActions,\n Events | AllowedEvents\n>;\n\n/**\n * Reusable controller that allows any team to store synchronized data for a given user.\n * These can be settings shared cross MetaMask clients, or data we want to persist when uninstalling/reinstalling.\n *\n * NOTE:\n * - data stored on UserStorage is FULLY encrypted, with the only keys stored/managed on the client.\n * - No one can access this data unless they are have the SRP and are able to run the signing snap.\n */\nexport class UserStorageController extends BaseController<\n typeof controllerName,\n UserStorageControllerState,\n UserStorageControllerMessenger\n> {\n readonly #userStorage: UserStorage;\n\n readonly #auth = {\n getProfileId: async (entropySourceId?: string) => {\n const sessionProfile = await this.messenger.call(\n 'AuthenticationController:getSessionProfile',\n entropySourceId,\n );\n return sessionProfile?.profileId;\n },\n isSignedIn: () => {\n return this.messenger.call('AuthenticationController:isSignedIn');\n },\n signIn: async () => {\n return await this.messenger.call(\n 'AuthenticationController:performSignIn',\n );\n },\n };\n\n readonly #config: ControllerConfig = {\n env: Env.PRD,\n };\n\n readonly #trace: TraceCallback;\n\n #isUnlocked = false;\n\n // Both caches are keyed by `${entropySourceId}:${message}` (the primary SRP\n // resolves to its HD keyring metadata ID) so two SRPs that transiently\n // resolve to the same `profileId` can never share a cached storage key /\n // signature and leak data across each other's user storage.\n #storageKeyCache: Record<string, string> = {};\n\n #signMessageCache: Record<string, string> = {};\n\n readonly #keyringController = {\n setupLockedStateSubscriptions: () => {\n const { isUnlocked } = this.messenger.call('KeyringController:getState');\n this.#isUnlocked = isUnlocked;\n\n this.messenger.subscribe('KeyringController:unlock', () => {\n this.#isUnlocked = true;\n });\n\n this.messenger.subscribe('KeyringController:lock', () => {\n this.#isUnlocked = false;\n });\n },\n };\n\n readonly #nativeScryptCrypto: NativeScrypt | undefined = undefined;\n\n eventQueue = new EventQueue();\n\n constructor({\n messenger,\n state,\n config,\n nativeScryptCrypto,\n trace,\n }: {\n messenger: UserStorageControllerMessenger;\n state?: UserStorageControllerState;\n config?: Partial<ControllerConfig>;\n nativeScryptCrypto?: NativeScrypt;\n trace?: TraceCallback;\n }) {\n super({\n messenger,\n metadata,\n name: controllerName,\n state: { ...defaultState, ...state },\n });\n\n this.#config = {\n ...this.#config,\n ...config,\n };\n this.#trace =\n trace ??\n (async <ReturnType>(\n _request: TraceRequest,\n fn?: (context?: TraceContext) => ReturnType,\n ): Promise<ReturnType> => {\n if (!fn) {\n return undefined as ReturnType;\n }\n return await Promise.resolve(fn());\n });\n\n this.#userStorage = new UserStorage(\n {\n env: this.#config.env,\n auth: {\n getAccessToken: (entropySourceId?: string) =>\n this.messenger.call(\n 'AuthenticationController:getBearerToken',\n entropySourceId,\n ),\n getUserProfile: async (entropySourceId?: string) => {\n return await this.messenger.call(\n 'AuthenticationController:getSessionProfile',\n entropySourceId,\n );\n },\n signMessage: (message: string, entropySourceId?: string) =>\n this.#signMessage(message, entropySourceId),\n },\n },\n {\n storage: {\n getStorageKey: async (message, entropySourceId) => {\n // No derived key can exist while locked (the KeyringController\n // clears its keyrings on lock, so the scope is unresolvable).\n if (!this.#isUnlocked) {\n return null;\n }\n return (\n this.#storageKeyCache[\n this.#scopedCacheKey(message, entropySourceId)\n ] ?? null\n );\n },\n // Only ever reached after a successful signature, i.e. while unlocked.\n setStorageKey: async (message, key, entropySourceId) => {\n this.#storageKeyCache[\n this.#scopedCacheKey(message, entropySourceId)\n ] = key;\n },\n },\n },\n );\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n\n this.#keyringController.setupLockedStateSubscriptions();\n this.#nativeScryptCrypto = nativeScryptCrypto;\n\n // Contact Syncing\n setupContactSyncingSubscriptions({\n getUserStorageControllerInstance: () => this,\n getMessenger: () => this.messenger,\n trace: this.#trace,\n });\n }\n\n /**\n * Allows retrieval of stored data. Data stored is string formatted.\n * Developers can extend the entry path and entry name through the `schema.ts` file.\n *\n * @param path - string in the form of `${feature}.${key}` that matches schema\n * @param entropySourceId - The entropy source ID used to generate the encryption key.\n * @returns the decrypted string contents found from user storage (or null if not found)\n */\n public async performGetStorage(\n path: UserStorageGenericPathWithFeatureAndKey,\n entropySourceId?: string,\n ): Promise<string | null> {\n return await this.#userStorage.getItem(path, {\n nativeScryptCrypto: this.#nativeScryptCrypto,\n entropySourceId,\n });\n }\n\n /**\n * Allows retrieval of all stored data for a specific feature. Data stored is formatted as an array of strings.\n * Developers can extend the entry path through the `schema.ts` file.\n *\n * @param path - string in the form of `${feature}` that matches schema\n * @param entropySourceId - The entropy source ID used to generate the encryption key.\n * @returns the array of decrypted string contents found from user storage (or null if not found)\n */\n public async performGetStorageAllFeatureEntries(\n path: UserStorageGenericPathWithFeatureOnly,\n entropySourceId?: string,\n ): Promise<string[] | null> {\n return await this.#userStorage.getAllFeatureItems(path, {\n nativeScryptCrypto: this.#nativeScryptCrypto,\n entropySourceId,\n });\n }\n\n /**\n * Allows storage of user data. Data stored must be string formatted.\n * Developers can extend the entry path and entry name through the `schema.ts` file.\n *\n * @param path - string in the form of `${feature}.${key}` that matches schema\n * @param value - The string data you want to store.\n * @param entropySourceId - The entropy source ID used to generate the encryption key.\n * @returns nothing. NOTE that an error is thrown if fails to store data.\n */\n public async performSetStorage(\n path: UserStorageGenericPathWithFeatureAndKey,\n value: string,\n entropySourceId?: string,\n ): Promise<void> {\n return await this.#userStorage.setItem(path, value, {\n nativeScryptCrypto: this.#nativeScryptCrypto,\n entropySourceId,\n });\n }\n\n /**\n * Allows storage of multiple user data entries for one specific feature. Data stored must be string formatted.\n * Developers can extend the entry path through the `schema.ts` file.\n *\n * @param path - string in the form of `${feature}` that matches schema\n * @param values - data to store, in the form of an array of `[entryKey, entryValue]` pairs\n * @param entropySourceId - The entropy source ID used to generate the encryption key.\n * @returns nothing. NOTE that an error is thrown if fails to store data.\n */\n public async performBatchSetStorage(\n path: UserStorageGenericPathWithFeatureOnly,\n values: [UserStorageGenericFeatureKey, string][],\n entropySourceId?: string,\n ): Promise<void> {\n return await this.#userStorage.batchSetItems(path, values, {\n nativeScryptCrypto: this.#nativeScryptCrypto,\n entropySourceId,\n });\n }\n\n /**\n * Allows deletion of user data. Developers can extend the entry path and entry name through the `schema.ts` file.\n *\n * @param path - string in the form of `${feature}.${key}` that matches schema\n * @param entropySourceId - The entropy source ID used to generate the encryption key.\n * @returns nothing. NOTE that an error is thrown if fails to delete data.\n */\n public async performDeleteStorage(\n path: UserStorageGenericPathWithFeatureAndKey,\n entropySourceId?: string,\n ): Promise<void> {\n return await this.#userStorage.deleteItem(path, {\n nativeScryptCrypto: this.#nativeScryptCrypto,\n entropySourceId,\n });\n }\n\n /**\n * Allows deletion of all user data entries for a specific feature.\n * Developers can extend the entry path through the `schema.ts` file.\n *\n * @param path - string in the form of `${feature}` that matches schema\n * @param entropySourceId - The entropy source ID used to generate the encryption key.\n * @returns nothing. NOTE that an error is thrown if fails to delete data.\n */\n public async performDeleteStorageAllFeatureEntries(\n path: UserStorageGenericPathWithFeatureOnly,\n entropySourceId?: string,\n ): Promise<void> {\n return await this.#userStorage.deleteAllFeatureItems(path, {\n nativeScryptCrypto: this.#nativeScryptCrypto,\n entropySourceId,\n });\n }\n\n /**\n * Allows delete of multiple user data entries for one specific feature. Data deleted must be string formatted.\n * Developers can extend the entry path through the `schema.ts` file.\n *\n * @param path - string in the form of `${feature}` that matches schema\n * @param values - data to store, in the form of an array of entryKey[]\n * @param entropySourceId - The entropy source ID used to generate the encryption key.\n * @returns nothing. NOTE that an error is thrown if fails to store data.\n */\n public async performBatchDeleteStorage(\n path: UserStorageGenericPathWithFeatureOnly,\n values: UserStorageGenericFeatureKey[],\n entropySourceId?: string,\n ): Promise<void> {\n return await this.#userStorage.batchDeleteItems(path, values, {\n nativeScryptCrypto: this.#nativeScryptCrypto,\n entropySourceId,\n });\n }\n\n /**\n * Retrieves the storage key, for internal use only!\n *\n * @returns the storage key\n */\n public async getStorageKey(): Promise<string> {\n return await this.#userStorage.getStorageKey();\n }\n\n /**\n * Flushes the storage key cache.\n * CAUTION: This is only public for testing purposes.\n * It should not be used in production code.\n */\n public flushStorageKeyCache(): void {\n this.#storageKeyCache = {};\n }\n\n /**\n * Lists all the available HD keyring metadata IDs.\n * These IDs can be used in a multi-SRP context to segregate data specific to different SRPs.\n *\n * @returns A promise that resolves to an array of HD keyring metadata IDs.\n */\n async listEntropySources(): Promise<string[]> {\n if (!this.#isUnlocked) {\n throw new Error(\n 'listEntropySources - unable to list entropy sources, wallet is locked',\n );\n }\n\n return this.#getHdKeyringEntropySourceIds();\n }\n\n /**\n * Reads the HD keyring entropy source IDs from KeyringController.\n *\n * @returns The HD keyring metadata IDs, primary first.\n */\n #getHdKeyringEntropySourceIds(): string[] {\n const { keyrings } = this.messenger.call('KeyringController:getState');\n return getHdKeyringEntropySourceIds(keyrings);\n }\n\n /**\n * Resolves the primary SRP's entropy source ID, used to scope the primary's\n * cache entries. The ID is randomly regenerated whenever the vault is\n * recreated (e.g. on restore), so a new primary can never inherit a previous\n * vault's cached key.\n *\n * @returns The primary HD keyring metadata ID.\n * @throws If no HD keyring is available; callers must only resolve the scope\n * while the wallet is unlocked.\n */\n #getPrimaryEntropySourceId(): string {\n const { keyrings } = this.messenger.call('KeyringController:getState');\n return getPrimaryHdKeyringEntropySourceId(keyrings);\n }\n\n /**\n * Builds a cache key scoped to a specific entropy source, so each SRP's\n * signature/storage key derivation stays isolated even when two SRPs\n * transiently resolve to the same `profileId` (see `#storageKeyCache`).\n *\n * When `entropySourceId` is omitted (primary SRP), it is resolved to the\n * primary HD keyring's metadata ID rather than a stable literal. Because that\n * ID is randomly regenerated whenever the vault is recreated (e.g. on\n * restore), the cached entry is naturally invalidated across vaults — a\n * different SRP can never inherit the previous primary's cached key.\n *\n * @param message - The tagged message used for signing.\n * @param entropySourceId - The entropy source ID. Omit for the primary SRP.\n * @returns The scoped cache key.\n */\n #scopedCacheKey(\n message: `metamask:${string}`,\n entropySourceId?: string,\n ): string {\n return `${entropySourceId ?? this.#getPrimaryEntropySourceId()}:${message}`;\n }\n\n /**\n * Signs a `metamask:…` message with the native SIP-6 message-signing key\n * (same key as `@metamask/message-signing-snap` with empty salt).\n *\n * @param message - A specific tagged message to sign.\n * @param entropySourceId - The entropy source ID used to derive the key,\n * when multiple sources are available (Multi-SRP).\n * @returns Compact secp256k1 signature hex.\n */\n async #signMessage(\n message: string,\n entropySourceId?: string,\n ): Promise<string> {\n if (!this.#isUnlocked) {\n throw new Error('#signMessage - unable to proceed, wallet is locked');\n }\n\n const cacheKey = this.#scopedCacheKey(\n message as `metamask:${string}`,\n entropySourceId,\n );\n if (this.#signMessageCache[cacheKey]) {\n return this.#signMessageCache[cacheKey];\n }\n\n const resolvedId = entropySourceId ?? this.#getPrimaryEntropySourceId();\n const seed = await getHdKeyringSeed(this.messenger, resolvedId);\n const result = await signMessageWithMessageSigningKey(message, seed);\n\n this.#signMessageCache[cacheKey] = result;\n\n return result;\n }\n\n public async setIsBackupAndSyncFeatureEnabled(\n feature: keyof typeof BACKUPANDSYNC_FEATURES,\n enabled: boolean,\n ): Promise<void> {\n try {\n this.#setIsBackupAndSyncUpdateLoading(true);\n\n if (enabled) {\n // If any of the features are enabled, we need to ensure the user is signed in\n const isSignedIn = this.#auth.isSignedIn();\n if (!isSignedIn) {\n await this.#auth.signIn();\n }\n }\n\n this.update((state) => {\n if (feature === BACKUPANDSYNC_FEATURES.main) {\n state.isBackupAndSyncEnabled = enabled;\n }\n\n if (feature === BACKUPANDSYNC_FEATURES.accountSyncing) {\n state.isAccountSyncingEnabled = enabled;\n }\n\n if (feature === BACKUPANDSYNC_FEATURES.contactSyncing) {\n state.isContactSyncingEnabled = enabled;\n }\n });\n } catch (e) {\n // istanbul ignore next\n const errorMessage = e instanceof Error ? e.message : JSON.stringify(e);\n // istanbul ignore next\n throw new Error(\n `${controllerName} - failed to ${enabled ? 'enable' : 'disable'} ${feature} - ${errorMessage}`,\n );\n } finally {\n this.#setIsBackupAndSyncUpdateLoading(false);\n }\n }\n\n #setIsBackupAndSyncUpdateLoading(\n isBackupAndSyncUpdateLoading: boolean,\n ): void {\n this.update((state) => {\n state.isBackupAndSyncUpdateLoading = isBackupAndSyncUpdateLoading;\n });\n }\n\n /**\n * Sets the isContactSyncingInProgress flag to prevent infinite loops during contact synchronization\n *\n * @param isContactSyncingInProgress - Whether contact syncing is in progress\n */\n async setIsContactSyncingInProgress(\n isContactSyncingInProgress: boolean,\n ): Promise<void> {\n this.update((state) => {\n state.isContactSyncingInProgress = isContactSyncingInProgress;\n });\n }\n\n /**\n * Syncs the address book list with the user storage address book list.\n * This method is used to make sure that the address book list is up-to-date with the user storage address book list and vice-versa.\n * It will add new contacts to the address book list, update/merge conflicting contacts and re-upload the results in some cases to the user storage.\n */\n async syncContactsWithUserStorage(): Promise<void> {\n const profileId = await this.#auth.getProfileId();\n\n const config = {\n onContactUpdated: () => {\n this.#config?.contactSyncing?.onContactUpdated?.(profileId);\n },\n onContactDeleted: () => {\n this.#config?.contactSyncing?.onContactDeleted?.(profileId);\n },\n onContactSyncErroneousSituation: (\n errorMessage: string,\n sentryContext?: Record<string, unknown>,\n ) => {\n this.#config?.contactSyncing?.onContactSyncErroneousSituation?.(\n profileId,\n errorMessage,\n sentryContext,\n );\n },\n };\n\n await syncContactsWithUserStorage(config, {\n getMessenger: () => this.messenger,\n getUserStorageControllerInstance: () => this,\n trace: this.#trace,\n });\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"UserStorageController.d.cts","sourceRoot":"","sources":["../../../src/controllers/user-storage/UserStorageController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wCAAwC,EACxC,wCAAwC,EACxC,4BAA4B,EAC5B,+BAA+B,EAC/B,8BAA8B,EAC9B,iCAAiC,EAClC,0CAA0C;AAC3C,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,KAAK,EACV,aAAa,EAGd,mCAAmC;AACpC,OAAO,KAAK,EACV,+BAA+B,EAC/B,0BAA0B,EAC1B,4BAA4B,EAC5B,0CAA0C,EAC3C,qCAAqC;AACtC,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD,OAAO,KAAK,EACV,4BAA4B,EAC5B,uCAAuC,EACvC,qCAAqC,EACtC,4BAA2B;AAC5B,OAAO,EAAE,GAAG,EAAe,4BAA2B;AACtD,OAAO,KAAK,EAAE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