@metamask/profile-sync-controller 8.1.1 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (303) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/README.md +32 -0
  3. package/auth/mocks/package.json +2 -2
  4. package/dist/controllers/authentication/AuthenticationController.cjs +53 -86
  5. package/dist/controllers/authentication/AuthenticationController.cjs.map +1 -1
  6. package/dist/controllers/authentication/AuthenticationController.d.cts +11 -23
  7. package/dist/controllers/authentication/AuthenticationController.d.cts.map +1 -1
  8. package/dist/controllers/authentication/AuthenticationController.d.mts +11 -23
  9. package/dist/controllers/authentication/AuthenticationController.d.mts.map +1 -1
  10. package/dist/controllers/authentication/AuthenticationController.mjs +53 -86
  11. package/dist/controllers/authentication/AuthenticationController.mjs.map +1 -1
  12. package/dist/controllers/authentication/index.cjs +1 -1
  13. package/dist/controllers/authentication/index.cjs.map +1 -1
  14. package/dist/controllers/authentication/index.d.cts +1 -1
  15. package/dist/controllers/authentication/index.d.cts.map +1 -1
  16. package/dist/controllers/authentication/index.d.mts +1 -1
  17. package/dist/controllers/authentication/index.d.mts.map +1 -1
  18. package/dist/controllers/authentication/index.mjs +1 -1
  19. package/dist/controllers/authentication/index.mjs.map +1 -1
  20. package/dist/controllers/authentication/mocks/index.cjs.map +1 -0
  21. package/dist/controllers/authentication/mocks/index.d.cts.map +1 -0
  22. package/dist/controllers/authentication/mocks/index.d.mts.map +1 -0
  23. package/dist/controllers/authentication/mocks/index.mjs.map +1 -0
  24. package/dist/controllers/authentication/mocks/mockResponses.cjs +34 -0
  25. package/dist/controllers/authentication/mocks/mockResponses.cjs.map +1 -0
  26. package/dist/controllers/authentication/mocks/mockResponses.d.cts +55 -0
  27. package/dist/controllers/authentication/mocks/mockResponses.d.cts.map +1 -0
  28. package/dist/controllers/authentication/mocks/mockResponses.d.mts +55 -0
  29. package/dist/controllers/authentication/mocks/mockResponses.d.mts.map +1 -0
  30. package/dist/controllers/authentication/mocks/mockResponses.mjs +28 -0
  31. package/dist/controllers/authentication/mocks/mockResponses.mjs.map +1 -0
  32. package/dist/controllers/user-storage/UserStorageController.cjs +71 -127
  33. package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -1
  34. package/dist/controllers/user-storage/UserStorageController.d.cts +5 -4
  35. package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -1
  36. package/dist/controllers/user-storage/UserStorageController.d.mts +5 -4
  37. package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -1
  38. package/dist/controllers/user-storage/UserStorageController.mjs +71 -127
  39. package/dist/controllers/user-storage/UserStorageController.mjs.map +1 -1
  40. package/dist/controllers/user-storage/account-syncing/controller-integration.cjs +2 -2
  41. package/dist/controllers/user-storage/account-syncing/controller-integration.cjs.map +1 -1
  42. package/dist/controllers/user-storage/account-syncing/controller-integration.mjs +2 -2
  43. package/dist/controllers/user-storage/account-syncing/controller-integration.mjs.map +1 -1
  44. package/dist/controllers/user-storage/account-syncing/sync-utils.cjs +1 -0
  45. package/dist/controllers/user-storage/account-syncing/sync-utils.cjs.map +1 -1
  46. package/dist/controllers/user-storage/account-syncing/sync-utils.d.cts.map +1 -1
  47. package/dist/controllers/user-storage/account-syncing/sync-utils.d.mts.map +1 -1
  48. package/dist/controllers/user-storage/account-syncing/sync-utils.mjs +1 -0
  49. package/dist/controllers/user-storage/account-syncing/sync-utils.mjs.map +1 -1
  50. package/dist/controllers/user-storage/account-syncing/utils.cjs +2 -2
  51. package/dist/controllers/user-storage/account-syncing/utils.cjs.map +1 -1
  52. package/dist/controllers/user-storage/account-syncing/utils.mjs +2 -2
  53. package/dist/controllers/user-storage/account-syncing/utils.mjs.map +1 -1
  54. package/dist/controllers/user-storage/index.cjs +1 -1
  55. package/dist/controllers/user-storage/index.cjs.map +1 -1
  56. package/dist/controllers/user-storage/index.d.cts +1 -1
  57. package/dist/controllers/user-storage/index.d.cts.map +1 -1
  58. package/dist/controllers/user-storage/index.d.mts +1 -1
  59. package/dist/controllers/user-storage/index.d.mts.map +1 -1
  60. package/dist/controllers/user-storage/index.mjs +1 -1
  61. package/dist/controllers/user-storage/index.mjs.map +1 -1
  62. package/dist/controllers/user-storage/mocks/index.cjs.map +1 -0
  63. package/dist/controllers/user-storage/mocks/index.d.cts.map +1 -0
  64. package/dist/controllers/user-storage/mocks/index.d.mts.map +1 -0
  65. package/dist/controllers/user-storage/mocks/index.mjs.map +1 -0
  66. package/dist/controllers/user-storage/{__fixtures__ → mocks}/mockResponses.cjs +3 -3
  67. package/dist/controllers/user-storage/mocks/mockResponses.cjs.map +1 -0
  68. package/dist/controllers/user-storage/{__fixtures__ → mocks}/mockResponses.d.cts +1 -1
  69. package/dist/controllers/user-storage/mocks/mockResponses.d.cts.map +1 -0
  70. package/dist/controllers/user-storage/{__fixtures__ → mocks}/mockResponses.d.mts +1 -1
  71. package/dist/controllers/user-storage/mocks/mockResponses.d.mts.map +1 -0
  72. package/dist/controllers/user-storage/{__fixtures__ → mocks}/mockResponses.mjs +3 -3
  73. package/dist/controllers/user-storage/mocks/mockResponses.mjs.map +1 -0
  74. package/dist/controllers/user-storage/mocks/mockStorage.cjs.map +1 -0
  75. package/dist/controllers/user-storage/mocks/mockStorage.d.cts.map +1 -0
  76. package/dist/controllers/user-storage/mocks/mockStorage.d.mts.map +1 -0
  77. package/dist/controllers/user-storage/mocks/mockStorage.mjs.map +1 -0
  78. package/dist/controllers/user-storage/network-syncing/controller-integration.cjs +14 -14
  79. package/dist/controllers/user-storage/network-syncing/controller-integration.cjs.map +1 -1
  80. package/dist/controllers/user-storage/network-syncing/controller-integration.d.cts +3 -3
  81. package/dist/controllers/user-storage/network-syncing/controller-integration.d.cts.map +1 -1
  82. package/dist/controllers/user-storage/network-syncing/controller-integration.d.mts +3 -3
  83. package/dist/controllers/user-storage/network-syncing/controller-integration.d.mts.map +1 -1
  84. package/dist/controllers/user-storage/network-syncing/controller-integration.mjs +14 -14
  85. package/dist/controllers/user-storage/network-syncing/controller-integration.mjs.map +1 -1
  86. package/dist/controllers/user-storage/network-syncing/services.cjs +27 -23
  87. package/dist/controllers/user-storage/network-syncing/services.cjs.map +1 -1
  88. package/dist/controllers/user-storage/network-syncing/services.d.cts +16 -7
  89. package/dist/controllers/user-storage/network-syncing/services.d.cts.map +1 -1
  90. package/dist/controllers/user-storage/network-syncing/services.d.mts +16 -7
  91. package/dist/controllers/user-storage/network-syncing/services.d.mts.map +1 -1
  92. package/dist/controllers/user-storage/network-syncing/services.mjs +27 -23
  93. package/dist/controllers/user-storage/network-syncing/services.mjs.map +1 -1
  94. package/dist/controllers/user-storage/network-syncing/sync-mutations.cjs.map +1 -1
  95. package/dist/controllers/user-storage/network-syncing/sync-mutations.d.cts +13 -5
  96. package/dist/controllers/user-storage/network-syncing/sync-mutations.d.cts.map +1 -1
  97. package/dist/controllers/user-storage/network-syncing/sync-mutations.d.mts +13 -5
  98. package/dist/controllers/user-storage/network-syncing/sync-mutations.d.mts.map +1 -1
  99. package/dist/controllers/user-storage/network-syncing/sync-mutations.mjs.map +1 -1
  100. package/dist/controllers/user-storage/types.cjs +3 -0
  101. package/dist/controllers/user-storage/types.cjs.map +1 -0
  102. package/dist/controllers/user-storage/types.d.cts +23 -0
  103. package/dist/controllers/user-storage/types.d.cts.map +1 -0
  104. package/dist/controllers/user-storage/types.d.mts +23 -0
  105. package/dist/controllers/user-storage/types.d.mts.map +1 -0
  106. package/dist/controllers/user-storage/types.mjs +2 -0
  107. package/dist/controllers/user-storage/types.mjs.map +1 -0
  108. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs +7 -8
  109. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs.map +1 -1
  110. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts +2 -0
  111. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts.map +1 -1
  112. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts +2 -0
  113. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts.map +1 -1
  114. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs +8 -9
  115. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs.map +1 -1
  116. package/dist/sdk/authentication-jwt-bearer/services.cjs +10 -2
  117. package/dist/sdk/authentication-jwt-bearer/services.cjs.map +1 -1
  118. package/dist/sdk/authentication-jwt-bearer/services.d.cts +3 -1
  119. package/dist/sdk/authentication-jwt-bearer/services.d.cts.map +1 -1
  120. package/dist/sdk/authentication-jwt-bearer/services.d.mts +3 -1
  121. package/dist/sdk/authentication-jwt-bearer/services.d.mts.map +1 -1
  122. package/dist/sdk/authentication-jwt-bearer/services.mjs +10 -2
  123. package/dist/sdk/authentication-jwt-bearer/services.mjs.map +1 -1
  124. package/dist/sdk/authentication-jwt-bearer/types.cjs.map +1 -1
  125. package/dist/sdk/authentication-jwt-bearer/types.mjs.map +1 -1
  126. package/dist/sdk/authentication.cjs.map +1 -1
  127. package/dist/sdk/authentication.d.cts +1 -1
  128. package/dist/sdk/authentication.d.cts.map +1 -1
  129. package/dist/sdk/authentication.d.mts +1 -1
  130. package/dist/sdk/authentication.d.mts.map +1 -1
  131. package/dist/sdk/authentication.mjs.map +1 -1
  132. package/dist/sdk/mocks/auth.cjs +44 -0
  133. package/dist/sdk/mocks/auth.cjs.map +1 -0
  134. package/dist/sdk/{__fixtures__/mock-auth.d.cts → mocks/auth.d.cts} +22 -25
  135. package/dist/sdk/mocks/auth.d.cts.map +1 -0
  136. package/dist/sdk/{__fixtures__/mock-auth.d.mts → mocks/auth.d.mts} +22 -25
  137. package/dist/sdk/mocks/auth.d.mts.map +1 -0
  138. package/dist/sdk/mocks/auth.mjs +41 -0
  139. package/dist/sdk/mocks/auth.mjs.map +1 -0
  140. package/dist/sdk/mocks/userstorage.cjs +43 -0
  141. package/dist/sdk/mocks/userstorage.cjs.map +1 -0
  142. package/dist/sdk/mocks/userstorage.d.cts +10 -0
  143. package/dist/sdk/mocks/userstorage.d.cts.map +1 -0
  144. package/dist/sdk/mocks/userstorage.d.mts +10 -0
  145. package/dist/sdk/mocks/userstorage.d.mts.map +1 -0
  146. package/dist/sdk/mocks/userstorage.mjs +15 -0
  147. package/dist/sdk/mocks/userstorage.mjs.map +1 -0
  148. package/dist/sdk/user-storage.cjs +34 -39
  149. package/dist/sdk/user-storage.cjs.map +1 -1
  150. package/dist/sdk/user-storage.d.cts +11 -6
  151. package/dist/sdk/user-storage.d.cts.map +1 -1
  152. package/dist/sdk/user-storage.d.mts +11 -6
  153. package/dist/sdk/user-storage.d.mts.map +1 -1
  154. package/dist/sdk/user-storage.mjs +34 -39
  155. package/dist/sdk/user-storage.mjs.map +1 -1
  156. package/dist/sdk/utils/messaging-signing-snap-requests.cjs +12 -1
  157. package/dist/sdk/utils/messaging-signing-snap-requests.cjs.map +1 -1
  158. package/dist/sdk/utils/messaging-signing-snap-requests.d.cts +6 -0
  159. package/dist/sdk/utils/messaging-signing-snap-requests.d.cts.map +1 -1
  160. package/dist/sdk/utils/messaging-signing-snap-requests.d.mts +6 -0
  161. package/dist/sdk/utils/messaging-signing-snap-requests.d.mts.map +1 -1
  162. package/dist/sdk/utils/messaging-signing-snap-requests.mjs +10 -0
  163. package/dist/sdk/utils/messaging-signing-snap-requests.mjs.map +1 -1
  164. package/dist/shared/types/services.cjs +3 -0
  165. package/dist/shared/types/services.cjs.map +1 -0
  166. package/dist/shared/types/services.d.cts +10 -0
  167. package/dist/shared/types/services.d.cts.map +1 -0
  168. package/dist/shared/types/services.d.mts +10 -0
  169. package/dist/shared/types/services.d.mts.map +1 -0
  170. package/dist/shared/types/services.mjs +2 -0
  171. package/dist/shared/types/services.mjs.map +1 -0
  172. package/package.json +14 -14
  173. package/user-storage/mocks/package.json +2 -2
  174. package/dist/controllers/authentication/__fixtures__/index.cjs.map +0 -1
  175. package/dist/controllers/authentication/__fixtures__/index.d.cts.map +0 -1
  176. package/dist/controllers/authentication/__fixtures__/index.d.mts.map +0 -1
  177. package/dist/controllers/authentication/__fixtures__/index.mjs.map +0 -1
  178. package/dist/controllers/authentication/__fixtures__/mockResponses.cjs +0 -47
  179. package/dist/controllers/authentication/__fixtures__/mockResponses.cjs.map +0 -1
  180. package/dist/controllers/authentication/__fixtures__/mockResponses.d.cts +0 -23
  181. package/dist/controllers/authentication/__fixtures__/mockResponses.d.cts.map +0 -1
  182. package/dist/controllers/authentication/__fixtures__/mockResponses.d.mts +0 -23
  183. package/dist/controllers/authentication/__fixtures__/mockResponses.d.mts.map +0 -1
  184. package/dist/controllers/authentication/__fixtures__/mockResponses.mjs +0 -41
  185. package/dist/controllers/authentication/__fixtures__/mockResponses.mjs.map +0 -1
  186. package/dist/controllers/authentication/__fixtures__/mockServices.cjs +0 -37
  187. package/dist/controllers/authentication/__fixtures__/mockServices.cjs.map +0 -1
  188. package/dist/controllers/authentication/__fixtures__/mockServices.d.cts +0 -10
  189. package/dist/controllers/authentication/__fixtures__/mockServices.d.cts.map +0 -1
  190. package/dist/controllers/authentication/__fixtures__/mockServices.d.mts +0 -10
  191. package/dist/controllers/authentication/__fixtures__/mockServices.d.mts.map +0 -1
  192. package/dist/controllers/authentication/__fixtures__/mockServices.mjs +0 -35
  193. package/dist/controllers/authentication/__fixtures__/mockServices.mjs.map +0 -1
  194. package/dist/controllers/authentication/services.cjs +0 -132
  195. package/dist/controllers/authentication/services.cjs.map +0 -1
  196. package/dist/controllers/authentication/services.d.cts +0 -72
  197. package/dist/controllers/authentication/services.d.cts.map +0 -1
  198. package/dist/controllers/authentication/services.d.mts +0 -72
  199. package/dist/controllers/authentication/services.d.mts.map +0 -1
  200. package/dist/controllers/authentication/services.mjs +0 -129
  201. package/dist/controllers/authentication/services.mjs.map +0 -1
  202. package/dist/controllers/user-storage/__fixtures__/index.cjs.map +0 -1
  203. package/dist/controllers/user-storage/__fixtures__/index.d.cts.map +0 -1
  204. package/dist/controllers/user-storage/__fixtures__/index.d.mts.map +0 -1
  205. package/dist/controllers/user-storage/__fixtures__/index.mjs.map +0 -1
  206. package/dist/controllers/user-storage/__fixtures__/mockMessenger.cjs +0 -167
  207. package/dist/controllers/user-storage/__fixtures__/mockMessenger.cjs.map +0 -1
  208. package/dist/controllers/user-storage/__fixtures__/mockMessenger.d.cts +0 -105
  209. package/dist/controllers/user-storage/__fixtures__/mockMessenger.d.cts.map +0 -1
  210. package/dist/controllers/user-storage/__fixtures__/mockMessenger.d.mts +0 -105
  211. package/dist/controllers/user-storage/__fixtures__/mockMessenger.d.mts.map +0 -1
  212. package/dist/controllers/user-storage/__fixtures__/mockMessenger.mjs +0 -162
  213. package/dist/controllers/user-storage/__fixtures__/mockMessenger.mjs.map +0 -1
  214. package/dist/controllers/user-storage/__fixtures__/mockResponses.cjs.map +0 -1
  215. package/dist/controllers/user-storage/__fixtures__/mockResponses.d.cts.map +0 -1
  216. package/dist/controllers/user-storage/__fixtures__/mockResponses.d.mts.map +0 -1
  217. package/dist/controllers/user-storage/__fixtures__/mockResponses.mjs.map +0 -1
  218. package/dist/controllers/user-storage/__fixtures__/mockServices.cjs +0 -82
  219. package/dist/controllers/user-storage/__fixtures__/mockServices.cjs.map +0 -1
  220. package/dist/controllers/user-storage/__fixtures__/mockServices.d.cts +0 -15
  221. package/dist/controllers/user-storage/__fixtures__/mockServices.d.cts.map +0 -1
  222. package/dist/controllers/user-storage/__fixtures__/mockServices.d.mts +0 -15
  223. package/dist/controllers/user-storage/__fixtures__/mockServices.d.mts.map +0 -1
  224. package/dist/controllers/user-storage/__fixtures__/mockServices.mjs +0 -76
  225. package/dist/controllers/user-storage/__fixtures__/mockServices.mjs.map +0 -1
  226. package/dist/controllers/user-storage/__fixtures__/mockStorage.cjs.map +0 -1
  227. package/dist/controllers/user-storage/__fixtures__/mockStorage.d.cts.map +0 -1
  228. package/dist/controllers/user-storage/__fixtures__/mockStorage.d.mts.map +0 -1
  229. package/dist/controllers/user-storage/__fixtures__/mockStorage.mjs.map +0 -1
  230. package/dist/controllers/user-storage/__fixtures__/test-utils.cjs +0 -78
  231. package/dist/controllers/user-storage/__fixtures__/test-utils.cjs.map +0 -1
  232. package/dist/controllers/user-storage/__fixtures__/test-utils.d.cts +0 -38
  233. package/dist/controllers/user-storage/__fixtures__/test-utils.d.cts.map +0 -1
  234. package/dist/controllers/user-storage/__fixtures__/test-utils.d.mts +0 -38
  235. package/dist/controllers/user-storage/__fixtures__/test-utils.d.mts.map +0 -1
  236. package/dist/controllers/user-storage/__fixtures__/test-utils.mjs +0 -68
  237. package/dist/controllers/user-storage/__fixtures__/test-utils.mjs.map +0 -1
  238. package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.cjs +0 -178
  239. package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.cjs.map +0 -1
  240. package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.d.cts +0 -91
  241. package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.d.cts.map +0 -1
  242. package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.d.mts +0 -91
  243. package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.d.mts.map +0 -1
  244. package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.mjs +0 -174
  245. package/dist/controllers/user-storage/account-syncing/__fixtures__/mockAccounts.mjs.map +0 -1
  246. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.cjs +0 -58
  247. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.cjs.map +0 -1
  248. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.cts +0 -87
  249. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.cts.map +0 -1
  250. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.mts +0 -87
  251. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.d.mts.map +0 -1
  252. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.mjs +0 -52
  253. package/dist/controllers/user-storage/account-syncing/__fixtures__/test-utils.mjs.map +0 -1
  254. package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.cjs +0 -43
  255. package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.cjs.map +0 -1
  256. package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.d.cts +0 -11
  257. package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.d.cts.map +0 -1
  258. package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.d.mts +0 -11
  259. package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.d.mts.map +0 -1
  260. package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.mjs +0 -36
  261. package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.mjs.map +0 -1
  262. package/dist/controllers/user-storage/services.cjs +0 -306
  263. package/dist/controllers/user-storage/services.cjs.map +0 -1
  264. package/dist/controllers/user-storage/services.d.cts +0 -85
  265. package/dist/controllers/user-storage/services.d.cts.map +0 -1
  266. package/dist/controllers/user-storage/services.d.mts +0 -85
  267. package/dist/controllers/user-storage/services.d.mts.map +0 -1
  268. package/dist/controllers/user-storage/services.mjs +0 -276
  269. package/dist/controllers/user-storage/services.mjs.map +0 -1
  270. package/dist/sdk/__fixtures__/mock-auth.cjs +0 -124
  271. package/dist/sdk/__fixtures__/mock-auth.cjs.map +0 -1
  272. package/dist/sdk/__fixtures__/mock-auth.d.cts.map +0 -1
  273. package/dist/sdk/__fixtures__/mock-auth.d.mts.map +0 -1
  274. package/dist/sdk/__fixtures__/mock-auth.mjs +0 -119
  275. package/dist/sdk/__fixtures__/mock-auth.mjs.map +0 -1
  276. package/dist/sdk/__fixtures__/mock-userstorage.cjs +0 -111
  277. package/dist/sdk/__fixtures__/mock-userstorage.cjs.map +0 -1
  278. package/dist/sdk/__fixtures__/mock-userstorage.d.cts +0 -20
  279. package/dist/sdk/__fixtures__/mock-userstorage.d.cts.map +0 -1
  280. package/dist/sdk/__fixtures__/mock-userstorage.d.mts +0 -20
  281. package/dist/sdk/__fixtures__/mock-userstorage.d.mts.map +0 -1
  282. package/dist/sdk/__fixtures__/mock-userstorage.mjs +0 -81
  283. package/dist/sdk/__fixtures__/mock-userstorage.mjs.map +0 -1
  284. package/dist/sdk/__fixtures__/test-utils.cjs +0 -90
  285. package/dist/sdk/__fixtures__/test-utils.cjs.map +0 -1
  286. package/dist/sdk/__fixtures__/test-utils.d.cts +0 -37
  287. package/dist/sdk/__fixtures__/test-utils.d.cts.map +0 -1
  288. package/dist/sdk/__fixtures__/test-utils.d.mts +0 -37
  289. package/dist/sdk/__fixtures__/test-utils.d.mts.map +0 -1
  290. package/dist/sdk/__fixtures__/test-utils.mjs +0 -84
  291. package/dist/sdk/__fixtures__/test-utils.mjs.map +0 -1
  292. /package/dist/controllers/authentication/{__fixtures__ → mocks}/index.cjs +0 -0
  293. /package/dist/controllers/authentication/{__fixtures__ → mocks}/index.d.cts +0 -0
  294. /package/dist/controllers/authentication/{__fixtures__ → mocks}/index.d.mts +0 -0
  295. /package/dist/controllers/authentication/{__fixtures__ → mocks}/index.mjs +0 -0
  296. /package/dist/controllers/user-storage/{__fixtures__ → mocks}/index.cjs +0 -0
  297. /package/dist/controllers/user-storage/{__fixtures__ → mocks}/index.d.cts +0 -0
  298. /package/dist/controllers/user-storage/{__fixtures__ → mocks}/index.d.mts +0 -0
  299. /package/dist/controllers/user-storage/{__fixtures__ → mocks}/index.mjs +0 -0
  300. /package/dist/controllers/user-storage/{__fixtures__ → mocks}/mockStorage.cjs +0 -0
  301. /package/dist/controllers/user-storage/{__fixtures__ → mocks}/mockStorage.d.cts +0 -0
  302. /package/dist/controllers/user-storage/{__fixtures__ → mocks}/mockStorage.d.mts +0 -0
  303. /package/dist/controllers/user-storage/{__fixtures__ → mocks}/mockStorage.mjs +0 -0
@@ -10,15 +10,14 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
10
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
11
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
12
12
  };
13
- var _UserStorageController_instances, _UserStorageController_env, _UserStorageController_auth, _UserStorageController_config, _UserStorageController_isUnlocked, _UserStorageController_keyringController, _UserStorageController_nativeScryptCrypto, _UserStorageController_registerMessageHandlers, _UserStorageController_getStorageOptions, _UserStorageController_getStorageKeyAndBearerToken, _UserStorageController_createStorageKey, _UserStorageController__snapSignMessageCache, _UserStorageController_snapSignMessage, _UserStorageController_setIsProfileSyncingUpdateLoading;
13
+ var _UserStorageController_instances, _UserStorageController_env, _UserStorageController_userStorage, _UserStorageController_auth, _UserStorageController_config, _UserStorageController_isUnlocked, _UserStorageController_storageKeyCache, _UserStorageController_keyringController, _UserStorageController_nativeScryptCrypto, _UserStorageController_registerMessageHandlers, _UserStorageController__snapSignMessageCache, _UserStorageController_snapSignMessage, _UserStorageController_setIsProfileSyncingUpdateLoading;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.defaultState = void 0;
16
16
  const base_controller_1 = require("@metamask/base-controller");
17
17
  const controller_integration_1 = require("./account-syncing/controller-integration.cjs");
18
18
  const setup_subscriptions_1 = require("./account-syncing/setup-subscriptions.cjs");
19
19
  const controller_integration_2 = require("./network-syncing/controller-integration.cjs");
20
- const services_1 = require("./services.cjs");
21
- const encryption_1 = require("../../shared/encryption/index.cjs");
20
+ const sdk_1 = require("../../sdk/index.cjs");
22
21
  const auth_snap_requests_1 = require("../authentication/auth-snap-requests.cjs");
23
22
  const controllerName = 'UserStorageController';
24
23
  exports.defaultState = {
@@ -77,10 +76,8 @@ class UserStorageController extends base_controller_1.BaseController {
77
76
  isAccountSyncingEnabled: false,
78
77
  isNetworkSyncingEnabled: false,
79
78
  });
79
+ _UserStorageController_userStorage.set(this, void 0);
80
80
  _UserStorageController_auth.set(this, {
81
- getBearerToken: async () => {
82
- return await this.messagingSystem.call('AuthenticationController:getBearerToken');
83
- },
84
81
  getProfileId: async () => {
85
82
  const sessionProfile = await this.messagingSystem.call('AuthenticationController:getSessionProfile');
86
83
  return sessionProfile?.profileId;
@@ -91,12 +88,10 @@ class UserStorageController extends base_controller_1.BaseController {
91
88
  signIn: async () => {
92
89
  return await this.messagingSystem.call('AuthenticationController:performSignIn');
93
90
  },
94
- signOut: async () => {
95
- return this.messagingSystem.call('AuthenticationController:performSignOut');
96
- },
97
91
  });
98
92
  _UserStorageController_config.set(this, void 0);
99
93
  _UserStorageController_isUnlocked.set(this, false);
94
+ _UserStorageController_storageKeyCache.set(this, null);
100
95
  _UserStorageController_keyringController.set(this, {
101
96
  setupLockedStateSubscriptions: () => {
102
97
  const { isUnlocked } = this.messagingSystem.call('KeyringController:getState');
@@ -114,6 +109,23 @@ class UserStorageController extends base_controller_1.BaseController {
114
109
  __classPrivateFieldGet(this, _UserStorageController_env, "f").isAccountSyncingEnabled = Boolean(env?.isAccountSyncingEnabled);
115
110
  __classPrivateFieldGet(this, _UserStorageController_env, "f").isNetworkSyncingEnabled = Boolean(env?.isNetworkSyncingEnabled);
116
111
  __classPrivateFieldSet(this, _UserStorageController_config, config, "f");
112
+ __classPrivateFieldSet(this, _UserStorageController_userStorage, new sdk_1.UserStorage({
113
+ env: sdk_1.Env.PRD,
114
+ auth: {
115
+ getAccessToken: () => this.messagingSystem.call('AuthenticationController:getBearerToken'),
116
+ getUserProfile: async () => {
117
+ return await this.messagingSystem.call('AuthenticationController:getSessionProfile');
118
+ },
119
+ signMessage: (message) => __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_snapSignMessage).call(this, message),
120
+ },
121
+ }, {
122
+ storage: {
123
+ getStorageKey: async () => __classPrivateFieldGet(this, _UserStorageController_storageKeyCache, "f"),
124
+ setStorageKey: async (key) => {
125
+ __classPrivateFieldSet(this, _UserStorageController_storageKeyCache, key, "f");
126
+ },
127
+ },
128
+ }), "f");
117
129
  __classPrivateFieldGet(this, _UserStorageController_keyringController, "f").setupLockedStateSubscriptions();
118
130
  __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_registerMessageHandlers).call(this);
119
131
  __classPrivateFieldSet(this, _UserStorageController_nativeScryptCrypto, nativeScryptCrypto, "f");
@@ -128,47 +140,11 @@ class UserStorageController extends base_controller_1.BaseController {
128
140
  if (__classPrivateFieldGet(this, _UserStorageController_env, "f").isNetworkSyncingEnabled) {
129
141
  (0, controller_integration_2.startNetworkSyncing)({
130
142
  messenger,
131
- getStorageConfig: () => __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_getStorageOptions).call(this),
143
+ getUserStorageControllerInstance: () => this,
132
144
  isMutationSyncBlocked: () => !this.state.hasNetworkSyncingSyncedAtLeastOnce,
133
145
  });
134
146
  }
135
147
  }
136
- async enableProfileSyncing() {
137
- try {
138
- __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_setIsProfileSyncingUpdateLoading).call(this, true);
139
- const isSignedIn = __classPrivateFieldGet(this, _UserStorageController_auth, "f").isSignedIn();
140
- if (!isSignedIn) {
141
- await __classPrivateFieldGet(this, _UserStorageController_auth, "f").signIn();
142
- }
143
- this.update((state) => {
144
- state.isProfileSyncingEnabled = true;
145
- });
146
- __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_setIsProfileSyncingUpdateLoading).call(this, false);
147
- }
148
- catch (e) {
149
- __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_setIsProfileSyncingUpdateLoading).call(this, false);
150
- const errorMessage = e instanceof Error ? e.message : JSON.stringify(e);
151
- throw new Error(`${controllerName} - failed to enable profile syncing - ${errorMessage}`);
152
- }
153
- }
154
- async disableProfileSyncing() {
155
- const isAlreadyDisabled = !this.state.isProfileSyncingEnabled;
156
- if (isAlreadyDisabled) {
157
- return;
158
- }
159
- try {
160
- __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_setIsProfileSyncingUpdateLoading).call(this, true);
161
- __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_setIsProfileSyncingUpdateLoading).call(this, false);
162
- this.update((state) => {
163
- state.isProfileSyncingEnabled = false;
164
- });
165
- }
166
- catch (e) {
167
- __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_setIsProfileSyncingUpdateLoading).call(this, false);
168
- const errorMessage = e instanceof Error ? e.message : JSON.stringify(e);
169
- throw new Error(`${controllerName} - failed to disable profile syncing - ${errorMessage}`);
170
- }
171
- }
172
148
  /**
173
149
  * Allows retrieval of stored data. Data stored is string formatted.
174
150
  * Developers can extend the entry path and entry name through the `schema.ts` file.
@@ -177,14 +153,10 @@ class UserStorageController extends base_controller_1.BaseController {
177
153
  * @returns the decrypted string contents found from user storage (or null if not found)
178
154
  */
179
155
  async performGetStorage(path) {
180
- const { bearerToken, storageKey } = await __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_getStorageKeyAndBearerToken).call(this);
181
- const result = await (0, services_1.getUserStorage)({
182
- path,
183
- bearerToken,
184
- storageKey,
156
+ return await __classPrivateFieldGet(this, _UserStorageController_userStorage, "f").getItem(path, {
185
157
  nativeScryptCrypto: __classPrivateFieldGet(this, _UserStorageController_nativeScryptCrypto, "f"),
158
+ validateAgainstSchema: true,
186
159
  });
187
- return result;
188
160
  }
189
161
  /**
190
162
  * Allows retrieval of all stored data for a specific feature. Data stored is formatted as an array of strings.
@@ -194,14 +166,10 @@ class UserStorageController extends base_controller_1.BaseController {
194
166
  * @returns the array of decrypted string contents found from user storage (or null if not found)
195
167
  */
196
168
  async performGetStorageAllFeatureEntries(path) {
197
- const { bearerToken, storageKey } = await __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_getStorageKeyAndBearerToken).call(this);
198
- const result = await (0, services_1.getUserStorageAllFeatureEntries)({
199
- path,
200
- bearerToken,
201
- storageKey,
169
+ return await __classPrivateFieldGet(this, _UserStorageController_userStorage, "f").getAllFeatureItems(path, {
202
170
  nativeScryptCrypto: __classPrivateFieldGet(this, _UserStorageController_nativeScryptCrypto, "f"),
171
+ validateAgainstSchema: true,
203
172
  });
204
- return result;
205
173
  }
206
174
  /**
207
175
  * Allows storage of user data. Data stored must be string formatted.
@@ -212,12 +180,9 @@ class UserStorageController extends base_controller_1.BaseController {
212
180
  * @returns nothing. NOTE that an error is thrown if fails to store data.
213
181
  */
214
182
  async performSetStorage(path, value) {
215
- const { bearerToken, storageKey } = await __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_getStorageKeyAndBearerToken).call(this);
216
- await (0, services_1.upsertUserStorage)(value, {
217
- path,
218
- bearerToken,
219
- storageKey,
183
+ return await __classPrivateFieldGet(this, _UserStorageController_userStorage, "f").setItem(path, value, {
220
184
  nativeScryptCrypto: __classPrivateFieldGet(this, _UserStorageController_nativeScryptCrypto, "f"),
185
+ validateAgainstSchema: true,
221
186
  });
222
187
  }
223
188
  /**
@@ -229,12 +194,9 @@ class UserStorageController extends base_controller_1.BaseController {
229
194
  * @returns nothing. NOTE that an error is thrown if fails to store data.
230
195
  */
231
196
  async performBatchSetStorage(path, values) {
232
- const { bearerToken, storageKey } = await __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_getStorageKeyAndBearerToken).call(this);
233
- await (0, services_1.batchUpsertUserStorage)(values, {
234
- path,
235
- bearerToken,
236
- storageKey,
197
+ return await __classPrivateFieldGet(this, _UserStorageController_userStorage, "f").batchSetItems(path, values, {
237
198
  nativeScryptCrypto: __classPrivateFieldGet(this, _UserStorageController_nativeScryptCrypto, "f"),
199
+ validateAgainstSchema: true,
238
200
  });
239
201
  }
240
202
  /**
@@ -244,11 +206,9 @@ class UserStorageController extends base_controller_1.BaseController {
244
206
  * @returns nothing. NOTE that an error is thrown if fails to delete data.
245
207
  */
246
208
  async performDeleteStorage(path) {
247
- const { bearerToken, storageKey } = await __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_getStorageKeyAndBearerToken).call(this);
248
- await (0, services_1.deleteUserStorage)({
249
- path,
250
- bearerToken,
251
- storageKey,
209
+ return await __classPrivateFieldGet(this, _UserStorageController_userStorage, "f").deleteItem(path, {
210
+ nativeScryptCrypto: __classPrivateFieldGet(this, _UserStorageController_nativeScryptCrypto, "f"),
211
+ validateAgainstSchema: true,
252
212
  });
253
213
  }
254
214
  /**
@@ -259,12 +219,7 @@ class UserStorageController extends base_controller_1.BaseController {
259
219
  * @returns nothing. NOTE that an error is thrown if fails to delete data.
260
220
  */
261
221
  async performDeleteStorageAllFeatureEntries(path) {
262
- const { bearerToken, storageKey } = await __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_getStorageKeyAndBearerToken).call(this);
263
- await (0, services_1.deleteUserStorageAllFeatureEntries)({
264
- path,
265
- bearerToken,
266
- storageKey,
267
- });
222
+ return await __classPrivateFieldGet(this, _UserStorageController_userStorage, "f").deleteAllFeatureItems(path);
268
223
  }
269
224
  /**
270
225
  * Allows delete of multiple user data entries for one specific feature. Data deleted must be string formatted.
@@ -275,13 +230,7 @@ class UserStorageController extends base_controller_1.BaseController {
275
230
  * @returns nothing. NOTE that an error is thrown if fails to store data.
276
231
  */
277
232
  async performBatchDeleteStorage(path, values) {
278
- const { bearerToken, storageKey } = await __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_getStorageKeyAndBearerToken).call(this);
279
- await (0, services_1.batchDeleteUserStorage)(values, {
280
- path,
281
- bearerToken,
282
- storageKey,
283
- nativeScryptCrypto: __classPrivateFieldGet(this, _UserStorageController_nativeScryptCrypto, "f"),
284
- });
233
+ return await __classPrivateFieldGet(this, _UserStorageController_userStorage, "f").batchDeleteItems(path, values);
285
234
  }
286
235
  /**
287
236
  * Retrieves the storage key, for internal use only!
@@ -289,8 +238,40 @@ class UserStorageController extends base_controller_1.BaseController {
289
238
  * @returns the storage key
290
239
  */
291
240
  async getStorageKey() {
292
- const storageKey = await __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_createStorageKey).call(this);
293
- return storageKey;
241
+ return await __classPrivateFieldGet(this, _UserStorageController_userStorage, "f").getStorageKey();
242
+ }
243
+ flushStorageKeyCache() {
244
+ __classPrivateFieldSet(this, _UserStorageController_storageKeyCache, null, "f");
245
+ }
246
+ async enableProfileSyncing() {
247
+ try {
248
+ __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_setIsProfileSyncingUpdateLoading).call(this, true);
249
+ const isSignedIn = __classPrivateFieldGet(this, _UserStorageController_auth, "f").isSignedIn();
250
+ if (!isSignedIn) {
251
+ await __classPrivateFieldGet(this, _UserStorageController_auth, "f").signIn();
252
+ }
253
+ this.update((state) => {
254
+ state.isProfileSyncingEnabled = true;
255
+ });
256
+ __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_setIsProfileSyncingUpdateLoading).call(this, false);
257
+ }
258
+ catch (e) {
259
+ __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_setIsProfileSyncingUpdateLoading).call(this, false);
260
+ // istanbul ignore next
261
+ const errorMessage = e instanceof Error ? e.message : JSON.stringify(e);
262
+ throw new Error(`${controllerName} - failed to enable profile syncing - ${errorMessage}`);
263
+ }
264
+ }
265
+ async disableProfileSyncing() {
266
+ const isAlreadyDisabled = !this.state.isProfileSyncingEnabled;
267
+ if (isAlreadyDisabled) {
268
+ return;
269
+ }
270
+ __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_setIsProfileSyncingUpdateLoading).call(this, true);
271
+ this.update((state) => {
272
+ state.isProfileSyncingEnabled = false;
273
+ });
274
+ __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_setIsProfileSyncingUpdateLoading).call(this, false);
294
275
  }
295
276
  async setHasAccountSyncingSyncedAtLeastOnce(hasAccountSyncingSyncedAtLeastOnce) {
296
277
  this.update((state) => {
@@ -345,7 +326,7 @@ class UserStorageController extends base_controller_1.BaseController {
345
326
  const profileId = await __classPrivateFieldGet(this, _UserStorageController_auth, "f").getProfileId();
346
327
  await (0, controller_integration_2.performMainNetworkSync)({
347
328
  messenger: this.messagingSystem,
348
- getStorageConfig: () => __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_getStorageOptions).call(this),
329
+ getUserStorageControllerInstance: () => this,
349
330
  maxNetworksToAdd: __classPrivateFieldGet(this, _UserStorageController_config, "f")?.networkSyncing?.maxNumberOfNetworksToAdd,
350
331
  onNetworkAdded: (cId) => __classPrivateFieldGet(this, _UserStorageController_config, "f")?.networkSyncing?.onNetworkAdded?.(profileId, cId),
351
332
  onNetworkUpdated: (cId) => __classPrivateFieldGet(this, _UserStorageController_config, "f")?.networkSyncing?.onNetworkUpdated?.(profileId, cId),
@@ -356,7 +337,7 @@ class UserStorageController extends base_controller_1.BaseController {
356
337
  });
357
338
  }
358
339
  }
359
- _UserStorageController_env = new WeakMap(), _UserStorageController_auth = new WeakMap(), _UserStorageController_config = new WeakMap(), _UserStorageController_isUnlocked = new WeakMap(), _UserStorageController_keyringController = new WeakMap(), _UserStorageController_nativeScryptCrypto = new WeakMap(), _UserStorageController__snapSignMessageCache = new WeakMap(), _UserStorageController_instances = new WeakSet(), _UserStorageController_registerMessageHandlers = function _UserStorageController_registerMessageHandlers() {
340
+ _UserStorageController_env = new WeakMap(), _UserStorageController_userStorage = new WeakMap(), _UserStorageController_auth = new WeakMap(), _UserStorageController_config = new WeakMap(), _UserStorageController_isUnlocked = new WeakMap(), _UserStorageController_storageKeyCache = new WeakMap(), _UserStorageController_keyringController = new WeakMap(), _UserStorageController_nativeScryptCrypto = new WeakMap(), _UserStorageController__snapSignMessageCache = new WeakMap(), _UserStorageController_instances = new WeakSet(), _UserStorageController_registerMessageHandlers = function _UserStorageController_registerMessageHandlers() {
360
341
  this.messagingSystem.registerActionHandler('UserStorageController:performGetStorage', this.performGetStorage.bind(this));
361
342
  this.messagingSystem.registerActionHandler('UserStorageController:performGetStorageAllFeatureEntries', this.performGetStorageAllFeatureEntries.bind(this));
362
343
  this.messagingSystem.registerActionHandler('UserStorageController:performSetStorage', this.performSetStorage.bind(this));
@@ -368,43 +349,6 @@ _UserStorageController_env = new WeakMap(), _UserStorageController_auth = new We
368
349
  this.messagingSystem.registerActionHandler('UserStorageController:disableProfileSyncing', this.disableProfileSyncing.bind(this));
369
350
  this.messagingSystem.registerActionHandler('UserStorageController:syncInternalAccountsWithUserStorage', this.syncInternalAccountsWithUserStorage.bind(this));
370
351
  this.messagingSystem.registerActionHandler('UserStorageController:saveInternalAccountToUserStorage', this.saveInternalAccountToUserStorage.bind(this));
371
- }, _UserStorageController_getStorageOptions = async function _UserStorageController_getStorageOptions() {
372
- if (!this.state.isProfileSyncingEnabled) {
373
- return null;
374
- }
375
- const { storageKey, bearerToken } = await __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_getStorageKeyAndBearerToken).call(this);
376
- return {
377
- storageKey,
378
- bearerToken,
379
- nativeScryptCrypto: __classPrivateFieldGet(this, _UserStorageController_nativeScryptCrypto, "f"),
380
- };
381
- }, _UserStorageController_getStorageKeyAndBearerToken =
382
- /**
383
- * Utility to get the bearer token and storage key
384
- *
385
- * @returns the bearer token and storage key
386
- */
387
- async function _UserStorageController_getStorageKeyAndBearerToken() {
388
- const bearerToken = await __classPrivateFieldGet(this, _UserStorageController_auth, "f").getBearerToken();
389
- if (!bearerToken) {
390
- throw new Error('UserStorageController - unable to get bearer token');
391
- }
392
- const storageKey = await __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_createStorageKey).call(this);
393
- return { bearerToken, storageKey };
394
- }, _UserStorageController_createStorageKey =
395
- /**
396
- * Rather than storing the storage key, we can compute the storage key when needed.
397
- *
398
- * @returns the storage key
399
- */
400
- async function _UserStorageController_createStorageKey() {
401
- const id = await __classPrivateFieldGet(this, _UserStorageController_auth, "f").getProfileId();
402
- if (!id) {
403
- throw new Error('UserStorageController - unable to create storage key');
404
- }
405
- const storageKeySignature = await __classPrivateFieldGet(this, _UserStorageController_instances, "m", _UserStorageController_snapSignMessage).call(this, `metamask:${id}`);
406
- const storageKey = (0, encryption_1.createSHA256Hash)(storageKeySignature);
407
- return storageKey;
408
352
  }, _UserStorageController_snapSignMessage =
409
353
  /**
410
354
  * Signs a specific message using an underlying auth snap.
@@ -1 +1 @@
1
- {"version":3,"file":"UserStorageController.cjs","sourceRoot":"","sources":["../../../src/controllers/user-storage/UserStorageController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAYA,+DAA2D;AAiB3D,yFAGkD;AAClD,mFAAyF;AACzF,yFAGkD;AAClD,6CAQoB;AACpB,kEAA2D;AAO3D,iFAAoF;AASpF,MAAM,cAAc,GAAG,uBAAuB,CAAC;AA8BlC,QAAA,YAAY,GAA+B;IACtD,uBAAuB,EAAE,IAAI;IAC7B,6BAA6B,EAAE,KAAK;IACpC,kCAAkC,EAAE,KAAK;IACzC,mCAAmC,EAAE,KAAK;IAC1C,0BAA0B,EAAE,KAAK;CAClC,CAAC;AAEF,MAAM,QAAQ,GAA8C;IAC1D,uBAAuB,EAAE;QACvB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,IAAI;KAChB;IACD,6BAA6B,EAAE;QAC7B,OAAO,EAAE,KAAK;QACd,SAAS,EAAE,KAAK;KACjB;IACD,kCAAkC,EAAE;QAClC,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,KAAK;KACjB;IACD,mCAAmC,EAAE;QACnC,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,KAAK;KACjB;IACD,0BAA0B,EAAE;QAC1B,OAAO,EAAE,KAAK;QACd,SAAS,EAAE,KAAK;KACjB;IACD,kCAAkC,EAAE;QAClC,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,KAAK;KACjB;CACF,CAAC;AA0JF;;;;;;;GAOG;AACH,MAAqB,qBAAsB,SAAQ,gCAIlD;IA0DC,YAAY,EACV,SAAS,EACT,KAAK,EACL,GAAG,EACH,MAAM,EACN,kBAAkB,GAUnB;QACC,KAAK,CAAC;YACJ,SAAS;YACT,QAAQ;YACR,IAAI,EAAE,cAAc;YACpB,KAAK,EAAE,EAAE,GAAG,oBAAY,EAAE,GAA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EAAC,mBAAmB,CAAC,CAAC;IACzD,OAAO,UAAU,CAAC;AACpB,CAAC;AAID;;;;;GAKG;AACH,KAAK,iDAAkB,OAA6B;IAClD,IAAI,uBAAA,IAAI,oDAAuB,CAAC,OAAO,CAAC,EAAE;QACxC,OAAO,uBAAA,IAAI,oDAAuB,CAAC,OAAO,CAAC,CAAC;KAC7C;IAED,IAAI,CAAC,uBAAA,IAAI,yCAAY,EAAE;QACrB,MAAM,IAAI,KAAK,CACb,0DAA0D,CAC3D,CAAC;KACH;IAED,MAAM,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,CAC7C,8BAA8B,EAC9B,IAAA,iDAA4B,EAAC,OAAO,CAAC,CACtC,CAAW,CAAC;IAEb,uBAAA,IAAI,oDAAuB,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC;IAE9C,OAAO,MAAM,CAAC;AAChB,CAAC,6HAGC,6BAAsC;IAEtC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;QACpB,KAAK,CAAC,6BAA6B,GAAG,6BAA6B,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC;kBAzdkB,qBAAqB","sourcesContent":["import type {\n AccountsControllerListAccountsAction,\n AccountsControllerUpdateAccountMetadataAction,\n AccountsControllerAccountRenamedEvent,\n AccountsControllerAccountAddedEvent,\n} from '@metamask/accounts-controller';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n RestrictedMessenger,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport {\n type KeyringControllerGetStateAction,\n type KeyringControllerLockEvent,\n type KeyringControllerUnlockEvent,\n type KeyringControllerWithKeyringAction,\n} from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type {\n NetworkControllerAddNetworkAction,\n NetworkControllerGetStateAction,\n NetworkControllerNetworkRemovedEvent,\n NetworkControllerRemoveNetworkAction,\n NetworkControllerUpdateNetworkAction,\n} from '@metamask/network-controller';\nimport type { HandleSnapRequest } from '@metamask/snaps-controllers';\n\nimport {\n saveInternalAccountToUserStorage,\n syncInternalAccountsWithUserStorage,\n} from './account-syncing/controller-integration';\nimport { setupAccountSyncingSubscriptions } from './account-syncing/setup-subscriptions';\nimport {\n performMainNetworkSync,\n startNetworkSyncing,\n} from './network-syncing/controller-integration';\nimport {\n batchDeleteUserStorage,\n batchUpsertUserStorage,\n deleteUserStorage,\n deleteUserStorageAllFeatureEntries,\n getUserStorage,\n getUserStorageAllFeatureEntries,\n upsertUserStorage,\n} from './services';\nimport { createSHA256Hash } from '../../shared/encryption';\nimport type { UserStorageFeatureKeys } from '../../shared/storage-schema';\nimport {\n type UserStoragePathWithFeatureAndKey,\n type UserStoragePathWithFeatureOnly,\n} from '../../shared/storage-schema';\nimport type { NativeScrypt } from '../../shared/types/encryption';\nimport { createSnapSignMessageRequest } from '../authentication/auth-snap-requests';\nimport type {\n AuthenticationControllerGetBearerToken,\n AuthenticationControllerGetSessionProfile,\n AuthenticationControllerIsSignedIn,\n AuthenticationControllerPerformSignIn,\n AuthenticationControllerPerformSignOut,\n} from '../authentication/AuthenticationController';\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 isProfileSyncingEnabled: boolean | null;\n /**\n * Loading state for the profile syncing update\n */\n isProfileSyncingUpdateLoading: boolean;\n /**\n * Condition used by E2E tests to determine if account syncing has been dispatched at least once.\n */\n hasAccountSyncingSyncedAtLeastOnce: boolean;\n /**\n * Condition used by UI to determine if account syncing is ready to be dispatched.\n */\n isAccountSyncingReadyToBeDispatched: boolean;\n /**\n * Condition used by UI to determine if account syncing is in progress.\n */\n isAccountSyncingInProgress: boolean;\n /**\n * Condition used to ensure that we do not perform any network sync mutations until we have synced at least once\n */\n hasNetworkSyncingSyncedAtLeastOnce?: boolean;\n};\n\nexport const defaultState: UserStorageControllerState = {\n isProfileSyncingEnabled: true,\n isProfileSyncingUpdateLoading: false,\n hasAccountSyncingSyncedAtLeastOnce: false,\n isAccountSyncingReadyToBeDispatched: false,\n isAccountSyncingInProgress: false,\n};\n\nconst metadata: StateMetadata<UserStorageControllerState> = {\n isProfileSyncingEnabled: {\n persist: true,\n anonymous: true,\n },\n isProfileSyncingUpdateLoading: {\n persist: false,\n anonymous: false,\n },\n hasAccountSyncingSyncedAtLeastOnce: {\n persist: true,\n anonymous: false,\n },\n isAccountSyncingReadyToBeDispatched: {\n persist: true,\n anonymous: false,\n },\n isAccountSyncingInProgress: {\n persist: false,\n anonymous: false,\n },\n hasNetworkSyncingSyncedAtLeastOnce: {\n persist: true,\n anonymous: false,\n },\n};\n\ntype ControllerConfig = {\n accountSyncing?: {\n maxNumberOfAccountsToAdd?: number;\n /**\n * Callback that fires when account sync adds an account.\n * This is used for analytics.\n */\n onAccountAdded?: (profileId: string) => void;\n\n /**\n * Callback that fires when account sync updates the name of an account.\n * This is used for analytics.\n */\n onAccountNameUpdated?: (profileId: string) => void;\n\n /**\n * Callback that fires when an erroneous situation happens during account sync.\n * This is used for analytics.\n */\n onAccountSyncErroneousSituation?: (\n profileId: string,\n situationMessage: string,\n sentryContext?: Record<string, unknown>,\n ) => void;\n };\n\n networkSyncing?: {\n maxNumberOfNetworksToAdd?: number;\n /**\n * Callback that fires when network sync adds a network\n * This is used for analytics.\n *\n * @param profileId - ID for a given User (shared cross devices once authenticated)\n * @param chainId - Chain ID for the network added (in hex)\n */\n onNetworkAdded?: (profileId: string, chainId: string) => void;\n /**\n * Callback that fires when network sync updates a network\n * This is used for analytics.\n *\n * @param profileId - ID for a given User (shared cross devices once authenticated)\n * @param chainId - Chain ID for the network added (in hex)\n */\n onNetworkUpdated?: (profileId: string, chainId: string) => void;\n /**\n * Callback that fires when network sync deletes a network\n * This is used for analytics.\n *\n * @param profileId - ID for a given User (shared cross devices once authenticated)\n * @param chainId - Chain ID for the network added (in hex)\n */\n onNetworkRemoved?: (profileId: string, chainId: string) => void;\n };\n};\n\n// Messenger Actions\ntype CreateActionsObj<Controller extends keyof UserStorageController> = {\n [K in Controller]: {\n type: `${typeof controllerName}:${K}`;\n handler: UserStorageController[K];\n };\n};\ntype ActionsObj = CreateActionsObj<\n | 'performGetStorage'\n | 'performGetStorageAllFeatureEntries'\n | 'performSetStorage'\n | 'performBatchSetStorage'\n | 'performDeleteStorage'\n | 'performBatchDeleteStorage'\n | 'getStorageKey'\n | 'enableProfileSyncing'\n | 'disableProfileSyncing'\n | 'syncInternalAccountsWithUserStorage'\n | 'saveInternalAccountToUserStorage'\n>;\nexport type UserStorageControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n UserStorageControllerState\n>;\nexport type Actions =\n | ActionsObj[keyof ActionsObj]\n | UserStorageControllerGetStateAction;\nexport type UserStorageControllerPerformGetStorage =\n ActionsObj['performGetStorage'];\nexport type UserStorageControllerPerformGetStorageAllFeatureEntries =\n ActionsObj['performGetStorageAllFeatureEntries'];\nexport type UserStorageControllerPerformSetStorage =\n ActionsObj['performSetStorage'];\nexport type UserStorageControllerPerformBatchSetStorage =\n ActionsObj['performBatchSetStorage'];\nexport type UserStorageControllerPerformDeleteStorage =\n ActionsObj['performDeleteStorage'];\nexport type UserStorageControllerPerformBatchDeleteStorage =\n ActionsObj['performBatchDeleteStorage'];\nexport type UserStorageControllerGetStorageKey = ActionsObj['getStorageKey'];\nexport type UserStorageControllerEnableProfileSyncing =\n ActionsObj['enableProfileSyncing'];\nexport type UserStorageControllerDisableProfileSyncing =\n ActionsObj['disableProfileSyncing'];\nexport type UserStorageControllerSyncInternalAccountsWithUserStorage =\n ActionsObj['syncInternalAccountsWithUserStorage'];\nexport type UserStorageControllerSaveInternalAccountToUserStorage =\n ActionsObj['saveInternalAccountToUserStorage'];\n\nexport type AllowedActions =\n // Keyring Requests\n | KeyringControllerGetStateAction\n // Snap Requests\n | HandleSnapRequest\n // Auth Requests\n | AuthenticationControllerGetBearerToken\n | AuthenticationControllerGetSessionProfile\n | AuthenticationControllerPerformSignIn\n | AuthenticationControllerIsSignedIn\n | AuthenticationControllerPerformSignOut\n // Account Syncing\n | AccountsControllerListAccountsAction\n | AccountsControllerUpdateAccountMetadataAction\n | KeyringControllerWithKeyringAction\n // Network Syncing\n | NetworkControllerGetStateAction\n | NetworkControllerAddNetworkAction\n | NetworkControllerRemoveNetworkAction\n | NetworkControllerUpdateNetworkAction;\n\n// Messenger events\nexport type UserStorageControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n UserStorageControllerState\n>;\n\nexport type Events = UserStorageControllerStateChangeEvent;\n\nexport type AllowedEvents =\n | UserStorageControllerStateChangeEvent\n | KeyringControllerLockEvent\n | KeyringControllerUnlockEvent\n // Account Syncing Events\n | AccountsControllerAccountAddedEvent\n | AccountsControllerAccountRenamedEvent\n // Network Syncing Events\n | NetworkControllerNetworkRemovedEvent;\n\n// Messenger\nexport type UserStorageControllerMessenger = RestrictedMessenger<\n typeof controllerName,\n Actions | AllowedActions,\n Events | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\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 default class UserStorageController extends BaseController<\n typeof controllerName,\n UserStorageControllerState,\n UserStorageControllerMessenger\n> {\n // This is replaced with the actual value in the constructor\n // We will remove this once the feature will be released\n readonly #env = {\n isAccountSyncingEnabled: false,\n isNetworkSyncingEnabled: false,\n };\n\n readonly #auth = {\n getBearerToken: async () => {\n return await this.messagingSystem.call(\n 'AuthenticationController:getBearerToken',\n );\n },\n getProfileId: async () => {\n const sessionProfile = await this.messagingSystem.call(\n 'AuthenticationController:getSessionProfile',\n );\n return sessionProfile?.profileId;\n },\n isSignedIn: () => {\n return this.messagingSystem.call('AuthenticationController:isSignedIn');\n },\n signIn: async () => {\n return await this.messagingSystem.call(\n 'AuthenticationController:performSignIn',\n );\n },\n signOut: async () => {\n return this.messagingSystem.call(\n 'AuthenticationController:performSignOut',\n );\n },\n };\n\n readonly #config?: ControllerConfig;\n\n #isUnlocked = false;\n\n readonly #keyringController = {\n setupLockedStateSubscriptions: () => {\n const { isUnlocked } = this.messagingSystem.call(\n 'KeyringController:getState',\n );\n this.#isUnlocked = isUnlocked;\n\n this.messagingSystem.subscribe('KeyringController:unlock', () => {\n this.#isUnlocked = true;\n });\n\n this.messagingSystem.subscribe('KeyringController:lock', () => {\n this.#isUnlocked = false;\n });\n },\n };\n\n readonly #nativeScryptCrypto: NativeScrypt | undefined = undefined;\n\n constructor({\n messenger,\n state,\n env,\n config,\n nativeScryptCrypto,\n }: {\n messenger: UserStorageControllerMessenger;\n state?: UserStorageControllerState;\n config?: ControllerConfig;\n env?: {\n isAccountSyncingEnabled?: boolean;\n isNetworkSyncingEnabled?: boolean;\n };\n nativeScryptCrypto?: NativeScrypt;\n }) {\n super({\n messenger,\n metadata,\n name: controllerName,\n state: { ...defaultState, ...state },\n });\n\n this.#env.isAccountSyncingEnabled = Boolean(env?.isAccountSyncingEnabled);\n this.#env.isNetworkSyncingEnabled = Boolean(env?.isNetworkSyncingEnabled);\n this.#config = config;\n\n this.#keyringController.setupLockedStateSubscriptions();\n this.#registerMessageHandlers();\n this.#nativeScryptCrypto = nativeScryptCrypto;\n\n // Account Syncing\n if (this.#env.isAccountSyncingEnabled) {\n setupAccountSyncingSubscriptions(\n { isAccountSyncingEnabled: true },\n {\n getUserStorageControllerInstance: () => this,\n getMessenger: () => this.messagingSystem,\n },\n );\n }\n\n // Network Syncing\n if (this.#env.isNetworkSyncingEnabled) {\n startNetworkSyncing({\n messenger,\n getStorageConfig: () => this.#getStorageOptions(),\n isMutationSyncBlocked: () =>\n !this.state.hasNetworkSyncingSyncedAtLeastOnce,\n });\n }\n }\n\n /**\n * Constructor helper for registering this controller's messaging system\n * actions.\n */\n #registerMessageHandlers(): void {\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:performGetStorage',\n this.performGetStorage.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:performGetStorageAllFeatureEntries',\n this.performGetStorageAllFeatureEntries.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:performSetStorage',\n this.performSetStorage.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:performBatchSetStorage',\n this.performBatchSetStorage.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:performDeleteStorage',\n this.performDeleteStorage.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:performBatchDeleteStorage',\n this.performBatchDeleteStorage.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:getStorageKey',\n this.getStorageKey.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:enableProfileSyncing',\n this.enableProfileSyncing.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:disableProfileSyncing',\n this.disableProfileSyncing.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:syncInternalAccountsWithUserStorage',\n this.syncInternalAccountsWithUserStorage.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:saveInternalAccountToUserStorage',\n this.saveInternalAccountToUserStorage.bind(this),\n );\n }\n\n async #getStorageOptions() {\n if (!this.state.isProfileSyncingEnabled) {\n return null;\n }\n\n const { storageKey, bearerToken } =\n await this.#getStorageKeyAndBearerToken();\n return {\n storageKey,\n bearerToken,\n nativeScryptCrypto: this.#nativeScryptCrypto,\n };\n }\n\n public async enableProfileSyncing(): Promise<void> {\n try {\n this.#setIsProfileSyncingUpdateLoading(true);\n\n const isSignedIn = this.#auth.isSignedIn();\n if (!isSignedIn) {\n await this.#auth.signIn();\n }\n\n this.update((state) => {\n state.isProfileSyncingEnabled = true;\n });\n\n this.#setIsProfileSyncingUpdateLoading(false);\n } catch (e) {\n this.#setIsProfileSyncingUpdateLoading(false);\n const errorMessage = e instanceof Error ? e.message : JSON.stringify(e);\n throw new Error(\n `${controllerName} - failed to enable profile syncing - ${errorMessage}`,\n );\n }\n }\n\n public async disableProfileSyncing(): Promise<void> {\n const isAlreadyDisabled = !this.state.isProfileSyncingEnabled;\n if (isAlreadyDisabled) {\n return;\n }\n\n try {\n this.#setIsProfileSyncingUpdateLoading(true);\n\n this.#setIsProfileSyncingUpdateLoading(false);\n\n this.update((state) => {\n state.isProfileSyncingEnabled = false;\n });\n } catch (e) {\n this.#setIsProfileSyncingUpdateLoading(false);\n const errorMessage = e instanceof Error ? e.message : JSON.stringify(e);\n throw new Error(\n `${controllerName} - failed to disable profile syncing - ${errorMessage}`,\n );\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 * @returns the decrypted string contents found from user storage (or null if not found)\n */\n public async performGetStorage(\n path: UserStoragePathWithFeatureAndKey,\n ): Promise<string | null> {\n const { bearerToken, storageKey } =\n await this.#getStorageKeyAndBearerToken();\n\n const result = await getUserStorage({\n path,\n bearerToken,\n storageKey,\n nativeScryptCrypto: this.#nativeScryptCrypto,\n });\n\n return result;\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 * @returns the array of decrypted string contents found from user storage (or null if not found)\n */\n public async performGetStorageAllFeatureEntries(\n path: UserStoragePathWithFeatureOnly,\n ): Promise<string[] | null> {\n const { bearerToken, storageKey } =\n await this.#getStorageKeyAndBearerToken();\n\n const result = await getUserStorageAllFeatureEntries({\n path,\n bearerToken,\n storageKey,\n nativeScryptCrypto: this.#nativeScryptCrypto,\n });\n\n return result;\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 * @returns nothing. NOTE that an error is thrown if fails to store data.\n */\n public async performSetStorage(\n path: UserStoragePathWithFeatureAndKey,\n value: string,\n ): Promise<void> {\n const { bearerToken, storageKey } =\n await this.#getStorageKeyAndBearerToken();\n\n await upsertUserStorage(value, {\n path,\n bearerToken,\n storageKey,\n nativeScryptCrypto: this.#nativeScryptCrypto,\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 * @returns nothing. NOTE that an error is thrown if fails to store data.\n */\n public async performBatchSetStorage<\n FeatureName extends UserStoragePathWithFeatureOnly,\n >(\n path: FeatureName,\n values: [UserStorageFeatureKeys<FeatureName>, string][],\n ): Promise<void> {\n const { bearerToken, storageKey } =\n await this.#getStorageKeyAndBearerToken();\n\n await batchUpsertUserStorage(values, {\n path,\n bearerToken,\n storageKey,\n nativeScryptCrypto: this.#nativeScryptCrypto,\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 * @returns nothing. NOTE that an error is thrown if fails to delete data.\n */\n public async performDeleteStorage(\n path: UserStoragePathWithFeatureAndKey,\n ): Promise<void> {\n const { bearerToken, storageKey } =\n await this.#getStorageKeyAndBearerToken();\n\n await deleteUserStorage({\n path,\n bearerToken,\n storageKey,\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 * @returns nothing. NOTE that an error is thrown if fails to delete data.\n */\n public async performDeleteStorageAllFeatureEntries(\n path: UserStoragePathWithFeatureOnly,\n ): Promise<void> {\n const { bearerToken, storageKey } =\n await this.#getStorageKeyAndBearerToken();\n\n await deleteUserStorageAllFeatureEntries({\n path,\n bearerToken,\n storageKey,\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 * @returns nothing. NOTE that an error is thrown if fails to store data.\n */\n public async performBatchDeleteStorage<\n FeatureName extends UserStoragePathWithFeatureOnly,\n >(\n path: FeatureName,\n values: UserStorageFeatureKeys<FeatureName>[],\n ): Promise<void> {\n const { bearerToken, storageKey } =\n await this.#getStorageKeyAndBearerToken();\n\n await batchDeleteUserStorage(values, {\n path,\n bearerToken,\n storageKey,\n nativeScryptCrypto: this.#nativeScryptCrypto,\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 const storageKey = await this.#createStorageKey();\n return storageKey;\n }\n\n /**\n * Utility to get the bearer token and storage key\n *\n * @returns the bearer token and storage key\n */\n async #getStorageKeyAndBearerToken(): Promise<{\n bearerToken: string;\n storageKey: string;\n }> {\n const bearerToken = await this.#auth.getBearerToken();\n if (!bearerToken) {\n throw new Error('UserStorageController - unable to get bearer token');\n }\n const storageKey = await this.#createStorageKey();\n\n return { bearerToken, storageKey };\n }\n\n /**\n * Rather than storing the storage key, we can compute the storage key when needed.\n *\n * @returns the storage key\n */\n async #createStorageKey(): Promise<string> {\n const id: string = await this.#auth.getProfileId();\n if (!id) {\n throw new Error('UserStorageController - unable to create storage key');\n }\n\n const storageKeySignature = await this.#snapSignMessage(`metamask:${id}`);\n const storageKey = createSHA256Hash(storageKeySignature);\n return storageKey;\n }\n\n #_snapSignMessageCache: Record<`metamask:${string}`, string> = {};\n\n /**\n * Signs a specific message using an underlying auth snap.\n *\n * @param message - A specific tagged message to sign.\n * @returns A Signature created by the snap.\n */\n async #snapSignMessage(message: `metamask:${string}`): Promise<string> {\n if (this.#_snapSignMessageCache[message]) {\n return this.#_snapSignMessageCache[message];\n }\n\n if (!this.#isUnlocked) {\n throw new Error(\n '#snapSignMessage - unable to call snap, wallet is locked',\n );\n }\n\n const result = (await this.messagingSystem.call(\n 'SnapController:handleRequest',\n createSnapSignMessageRequest(message),\n )) as string;\n\n this.#_snapSignMessageCache[message] = result;\n\n return result;\n }\n\n #setIsProfileSyncingUpdateLoading(\n isProfileSyncingUpdateLoading: boolean,\n ): void {\n this.update((state) => {\n state.isProfileSyncingUpdateLoading = isProfileSyncingUpdateLoading;\n });\n }\n\n async setHasAccountSyncingSyncedAtLeastOnce(\n hasAccountSyncingSyncedAtLeastOnce: boolean,\n ): Promise<void> {\n this.update((state) => {\n state.hasAccountSyncingSyncedAtLeastOnce =\n hasAccountSyncingSyncedAtLeastOnce;\n });\n }\n\n async setIsAccountSyncingReadyToBeDispatched(\n isAccountSyncingReadyToBeDispatched: boolean,\n ): Promise<void> {\n this.update((state) => {\n state.isAccountSyncingReadyToBeDispatched =\n isAccountSyncingReadyToBeDispatched;\n });\n }\n\n async setIsAccountSyncingInProgress(\n isAccountSyncingInProgress: boolean,\n ): Promise<void> {\n this.update((state) => {\n state.isAccountSyncingInProgress = isAccountSyncingInProgress;\n });\n }\n\n /**\n * Syncs the internal accounts list with the user storage accounts list.\n * This method is used to make sure that the internal accounts list is up-to-date with the user storage accounts list and vice-versa.\n * It will add new accounts to the internal accounts list, update/merge conflicting names and re-upload the results in some cases to the user storage.\n */\n async syncInternalAccountsWithUserStorage(): Promise<void> {\n const profileId = await this.#auth.getProfileId();\n\n await syncInternalAccountsWithUserStorage(\n {\n isAccountSyncingEnabled: this.#env.isAccountSyncingEnabled,\n maxNumberOfAccountsToAdd:\n this.#config?.accountSyncing?.maxNumberOfAccountsToAdd,\n onAccountAdded: () =>\n this.#config?.accountSyncing?.onAccountAdded?.(profileId),\n onAccountNameUpdated: () =>\n this.#config?.accountSyncing?.onAccountNameUpdated?.(profileId),\n onAccountSyncErroneousSituation: (situationMessage, sentryContext) =>\n this.#config?.accountSyncing?.onAccountSyncErroneousSituation?.(\n profileId,\n situationMessage,\n sentryContext,\n ),\n },\n {\n getMessenger: () => this.messagingSystem,\n getUserStorageControllerInstance: () => this,\n },\n );\n }\n\n /**\n * Saves an individual internal account to the user storage.\n *\n * @param internalAccount - The internal account to save\n */\n async saveInternalAccountToUserStorage(\n internalAccount: InternalAccount,\n ): Promise<void> {\n await saveInternalAccountToUserStorage(\n internalAccount,\n { isAccountSyncingEnabled: this.#env.isAccountSyncingEnabled },\n {\n getMessenger: () => this.messagingSystem,\n getUserStorageControllerInstance: () => this,\n },\n );\n }\n\n async syncNetworks() {\n if (!this.#env.isNetworkSyncingEnabled) {\n return;\n }\n\n const profileId = await this.#auth.getProfileId();\n\n await performMainNetworkSync({\n messenger: this.messagingSystem,\n getStorageConfig: () => this.#getStorageOptions(),\n maxNetworksToAdd: this.#config?.networkSyncing?.maxNumberOfNetworksToAdd,\n onNetworkAdded: (cId) =>\n this.#config?.networkSyncing?.onNetworkAdded?.(profileId, cId),\n onNetworkUpdated: (cId) =>\n this.#config?.networkSyncing?.onNetworkUpdated?.(profileId, cId),\n onNetworkRemoved: (cId) =>\n this.#config?.networkSyncing?.onNetworkRemoved?.(profileId, cId),\n });\n\n this.update((s) => {\n s.hasNetworkSyncingSyncedAtLeastOnce = true;\n });\n }\n}\n"]}
1
+ {"version":3,"file":"UserStorageController.cjs","sourceRoot":"","sources":["../../../src/controllers/user-storage/UserStorageController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAYA,+DAA2D;AAiB3D,yFAGkD;AAClD,mFAAyF;AACzF,yFAGkD;AAClD,6CAA6C;AAO7C,iFAAoF;AAQpF,MAAM,cAAc,GAAG,uBAAuB,CAAC;AA8BlC,QAAA,YAAY,GAA+B;IACtD,uBAAuB,EAAE,IAAI;IAC7B,6BAA6B,EAAE,KAAK;IACpC,kCAAkC,EAAE,KAAK;IACzC,m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\n AccountsControllerAccountRenamedEvent,\n AccountsControllerAccountAddedEvent,\n} from '@metamask/accounts-controller';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n RestrictedMessenger,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport {\n type KeyringControllerGetStateAction,\n type KeyringControllerLockEvent,\n type KeyringControllerUnlockEvent,\n type KeyringControllerWithKeyringAction,\n} from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\nimport type {\n NetworkControllerAddNetworkAction,\n NetworkControllerGetStateAction,\n NetworkControllerNetworkRemovedEvent,\n NetworkControllerRemoveNetworkAction,\n NetworkControllerUpdateNetworkAction,\n} from '@metamask/network-controller';\nimport type { HandleSnapRequest } from '@metamask/snaps-controllers';\n\nimport {\n saveInternalAccountToUserStorage,\n syncInternalAccountsWithUserStorage,\n} from './account-syncing/controller-integration';\nimport { setupAccountSyncingSubscriptions } from './account-syncing/setup-subscriptions';\nimport {\n performMainNetworkSync,\n startNetworkSyncing,\n} from './network-syncing/controller-integration';\nimport { Env, UserStorage } from '../../sdk';\nimport type { UserStorageFeatureKeys } from '../../shared/storage-schema';\nimport {\n type UserStoragePathWithFeatureAndKey,\n type UserStoragePathWithFeatureOnly,\n} from '../../shared/storage-schema';\nimport type { NativeScrypt } from '../../shared/types/encryption';\nimport { createSnapSignMessageRequest } from '../authentication/auth-snap-requests';\nimport type {\n AuthenticationControllerGetBearerToken,\n AuthenticationControllerGetSessionProfile,\n AuthenticationControllerIsSignedIn,\n AuthenticationControllerPerformSignIn,\n} from '../authentication/AuthenticationController';\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 isProfileSyncingEnabled: boolean | null;\n /**\n * Loading state for the profile syncing update\n */\n isProfileSyncingUpdateLoading: boolean;\n /**\n * Condition used by E2E tests to determine if account syncing has been dispatched at least once.\n */\n hasAccountSyncingSyncedAtLeastOnce: boolean;\n /**\n * Condition used by UI to determine if account syncing is ready to be dispatched.\n */\n isAccountSyncingReadyToBeDispatched: boolean;\n /**\n * Condition used by UI to determine if account syncing is in progress.\n */\n isAccountSyncingInProgress: boolean;\n /**\n * Condition used to ensure that we do not perform any network sync mutations until we have synced at least once\n */\n hasNetworkSyncingSyncedAtLeastOnce?: boolean;\n};\n\nexport const defaultState: UserStorageControllerState = {\n isProfileSyncingEnabled: true,\n isProfileSyncingUpdateLoading: false,\n hasAccountSyncingSyncedAtLeastOnce: false,\n isAccountSyncingReadyToBeDispatched: false,\n isAccountSyncingInProgress: false,\n};\n\nconst metadata: StateMetadata<UserStorageControllerState> = {\n isProfileSyncingEnabled: {\n persist: true,\n anonymous: true,\n },\n isProfileSyncingUpdateLoading: {\n persist: false,\n anonymous: false,\n },\n hasAccountSyncingSyncedAtLeastOnce: {\n persist: true,\n anonymous: false,\n },\n isAccountSyncingReadyToBeDispatched: {\n persist: true,\n anonymous: false,\n },\n isAccountSyncingInProgress: {\n persist: false,\n anonymous: false,\n },\n hasNetworkSyncingSyncedAtLeastOnce: {\n persist: true,\n anonymous: false,\n },\n};\n\ntype ControllerConfig = {\n accountSyncing?: {\n maxNumberOfAccountsToAdd?: number;\n /**\n * Callback that fires when account sync adds an account.\n * This is used for analytics.\n */\n onAccountAdded?: (profileId: string) => void;\n\n /**\n * Callback that fires when account sync updates the name of an account.\n * This is used for analytics.\n */\n onAccountNameUpdated?: (profileId: string) => void;\n\n /**\n * Callback that fires when an erroneous situation happens during account sync.\n * This is used for analytics.\n */\n onAccountSyncErroneousSituation?: (\n profileId: string,\n situationMessage: string,\n sentryContext?: Record<string, unknown>,\n ) => void;\n };\n\n networkSyncing?: {\n maxNumberOfNetworksToAdd?: number;\n /**\n * Callback that fires when network sync adds a network\n * This is used for analytics.\n *\n * @param profileId - ID for a given User (shared cross devices once authenticated)\n * @param chainId - Chain ID for the network added (in hex)\n */\n onNetworkAdded?: (profileId: string, chainId: string) => void;\n /**\n * Callback that fires when network sync updates a network\n * This is used for analytics.\n *\n * @param profileId - ID for a given User (shared cross devices once authenticated)\n * @param chainId - Chain ID for the network added (in hex)\n */\n onNetworkUpdated?: (profileId: string, chainId: string) => void;\n /**\n * Callback that fires when network sync deletes a network\n * This is used for analytics.\n *\n * @param profileId - ID for a given User (shared cross devices once authenticated)\n * @param chainId - Chain ID for the network added (in hex)\n */\n onNetworkRemoved?: (profileId: string, chainId: string) => void;\n };\n};\n\n// Messenger Actions\ntype CreateActionsObj<Controller extends keyof UserStorageController> = {\n [K in Controller]: {\n type: `${typeof controllerName}:${K}`;\n handler: UserStorageController[K];\n };\n};\ntype ActionsObj = CreateActionsObj<\n | 'performGetStorage'\n | 'performGetStorageAllFeatureEntries'\n | 'performSetStorage'\n | 'performBatchSetStorage'\n | 'performDeleteStorage'\n | 'performBatchDeleteStorage'\n | 'getStorageKey'\n | 'enableProfileSyncing'\n | 'disableProfileSyncing'\n | 'syncInternalAccountsWithUserStorage'\n | 'saveInternalAccountToUserStorage'\n>;\nexport type UserStorageControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n UserStorageControllerState\n>;\nexport type Actions =\n | ActionsObj[keyof ActionsObj]\n | UserStorageControllerGetStateAction;\nexport type UserStorageControllerPerformGetStorage =\n ActionsObj['performGetStorage'];\nexport type UserStorageControllerPerformGetStorageAllFeatureEntries =\n ActionsObj['performGetStorageAllFeatureEntries'];\nexport type UserStorageControllerPerformSetStorage =\n ActionsObj['performSetStorage'];\nexport type UserStorageControllerPerformBatchSetStorage =\n ActionsObj['performBatchSetStorage'];\nexport type UserStorageControllerPerformDeleteStorage =\n ActionsObj['performDeleteStorage'];\nexport type UserStorageControllerPerformBatchDeleteStorage =\n ActionsObj['performBatchDeleteStorage'];\nexport type UserStorageControllerGetStorageKey = ActionsObj['getStorageKey'];\nexport type UserStorageControllerEnableProfileSyncing =\n ActionsObj['enableProfileSyncing'];\nexport type UserStorageControllerDisableProfileSyncing =\n ActionsObj['disableProfileSyncing'];\nexport type UserStorageControllerSyncInternalAccountsWithUserStorage =\n ActionsObj['syncInternalAccountsWithUserStorage'];\nexport type UserStorageControllerSaveInternalAccountToUserStorage =\n ActionsObj['saveInternalAccountToUserStorage'];\n\nexport type AllowedActions =\n // Keyring Requests\n | KeyringControllerGetStateAction\n // Snap Requests\n | HandleSnapRequest\n // Auth Requests\n | AuthenticationControllerGetBearerToken\n | AuthenticationControllerGetSessionProfile\n | AuthenticationControllerPerformSignIn\n | AuthenticationControllerIsSignedIn\n // Account Syncing\n | AccountsControllerListAccountsAction\n | AccountsControllerUpdateAccountMetadataAction\n | KeyringControllerWithKeyringAction\n // Network Syncing\n | NetworkControllerGetStateAction\n | NetworkControllerAddNetworkAction\n | NetworkControllerRemoveNetworkAction\n | NetworkControllerUpdateNetworkAction;\n\n// Messenger events\nexport type UserStorageControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n UserStorageControllerState\n>;\n\nexport type Events = UserStorageControllerStateChangeEvent;\n\nexport type AllowedEvents =\n | UserStorageControllerStateChangeEvent\n | KeyringControllerLockEvent\n | KeyringControllerUnlockEvent\n // Account Syncing Events\n | AccountsControllerAccountAddedEvent\n | AccountsControllerAccountRenamedEvent\n // Network Syncing Events\n | NetworkControllerNetworkRemovedEvent;\n\n// Messenger\nexport type UserStorageControllerMessenger = RestrictedMessenger<\n typeof controllerName,\n Actions | AllowedActions,\n Events | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\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 default class UserStorageController extends BaseController<\n typeof controllerName,\n UserStorageControllerState,\n UserStorageControllerMessenger\n> {\n // This is replaced with the actual value in the constructor\n // We will remove this once the feature will be released\n readonly #env = {\n isAccountSyncingEnabled: false,\n isNetworkSyncingEnabled: false,\n };\n\n readonly #userStorage: UserStorage;\n\n readonly #auth = {\n getProfileId: async () => {\n const sessionProfile = await this.messagingSystem.call(\n 'AuthenticationController:getSessionProfile',\n );\n return sessionProfile?.profileId;\n },\n isSignedIn: () => {\n return this.messagingSystem.call('AuthenticationController:isSignedIn');\n },\n signIn: async () => {\n return await this.messagingSystem.call(\n 'AuthenticationController:performSignIn',\n );\n },\n };\n\n readonly #config?: ControllerConfig;\n\n #isUnlocked = false;\n\n #storageKeyCache: string | null = null;\n\n readonly #keyringController = {\n setupLockedStateSubscriptions: () => {\n const { isUnlocked } = this.messagingSystem.call(\n 'KeyringController:getState',\n );\n this.#isUnlocked = isUnlocked;\n\n this.messagingSystem.subscribe('KeyringController:unlock', () => {\n this.#isUnlocked = true;\n });\n\n this.messagingSystem.subscribe('KeyringController:lock', () => {\n this.#isUnlocked = false;\n });\n },\n };\n\n readonly #nativeScryptCrypto: NativeScrypt | undefined = undefined;\n\n constructor({\n messenger,\n state,\n env,\n config,\n nativeScryptCrypto,\n }: {\n messenger: UserStorageControllerMessenger;\n state?: UserStorageControllerState;\n config?: ControllerConfig;\n env?: {\n isAccountSyncingEnabled?: boolean;\n isNetworkSyncingEnabled?: boolean;\n };\n nativeScryptCrypto?: NativeScrypt;\n }) {\n super({\n messenger,\n metadata,\n name: controllerName,\n state: { ...defaultState, ...state },\n });\n\n this.#env.isAccountSyncingEnabled = Boolean(env?.isAccountSyncingEnabled);\n this.#env.isNetworkSyncingEnabled = Boolean(env?.isNetworkSyncingEnabled);\n this.#config = config;\n\n this.#userStorage = new UserStorage(\n {\n env: Env.PRD,\n auth: {\n getAccessToken: () =>\n this.messagingSystem.call(\n 'AuthenticationController:getBearerToken',\n ),\n getUserProfile: async () => {\n return await this.messagingSystem.call(\n 'AuthenticationController:getSessionProfile',\n );\n },\n signMessage: (message) =>\n this.#snapSignMessage(message as `metamask:${string}`),\n },\n },\n {\n storage: {\n getStorageKey: async () => this.#storageKeyCache,\n setStorageKey: async (key) => {\n this.#storageKeyCache = key;\n },\n },\n },\n );\n\n this.#keyringController.setupLockedStateSubscriptions();\n this.#registerMessageHandlers();\n this.#nativeScryptCrypto = nativeScryptCrypto;\n\n // Account Syncing\n if (this.#env.isAccountSyncingEnabled) {\n setupAccountSyncingSubscriptions(\n { isAccountSyncingEnabled: true },\n {\n getUserStorageControllerInstance: () => this,\n getMessenger: () => this.messagingSystem,\n },\n );\n }\n\n // Network Syncing\n if (this.#env.isNetworkSyncingEnabled) {\n startNetworkSyncing({\n messenger,\n getUserStorageControllerInstance: () => this,\n isMutationSyncBlocked: () =>\n !this.state.hasNetworkSyncingSyncedAtLeastOnce,\n });\n }\n }\n\n /**\n * Constructor helper for registering this controller's messaging system\n * actions.\n */\n #registerMessageHandlers(): void {\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:performGetStorage',\n this.performGetStorage.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:performGetStorageAllFeatureEntries',\n this.performGetStorageAllFeatureEntries.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:performSetStorage',\n this.performSetStorage.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:performBatchSetStorage',\n this.performBatchSetStorage.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:performDeleteStorage',\n this.performDeleteStorage.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:performBatchDeleteStorage',\n this.performBatchDeleteStorage.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:getStorageKey',\n this.getStorageKey.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:enableProfileSyncing',\n this.enableProfileSyncing.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:disableProfileSyncing',\n this.disableProfileSyncing.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:syncInternalAccountsWithUserStorage',\n this.syncInternalAccountsWithUserStorage.bind(this),\n );\n\n this.messagingSystem.registerActionHandler(\n 'UserStorageController:saveInternalAccountToUserStorage',\n this.saveInternalAccountToUserStorage.bind(this),\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 * @returns the decrypted string contents found from user storage (or null if not found)\n */\n public async performGetStorage(\n path: UserStoragePathWithFeatureAndKey,\n ): Promise<string | null> {\n return await this.#userStorage.getItem(path, {\n nativeScryptCrypto: this.#nativeScryptCrypto,\n validateAgainstSchema: true,\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 * @returns the array of decrypted string contents found from user storage (or null if not found)\n */\n public async performGetStorageAllFeatureEntries(\n path: UserStoragePathWithFeatureOnly,\n ): Promise<string[] | null> {\n return await this.#userStorage.getAllFeatureItems(path, {\n nativeScryptCrypto: this.#nativeScryptCrypto,\n validateAgainstSchema: true,\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 * @returns nothing. NOTE that an error is thrown if fails to store data.\n */\n public async performSetStorage(\n path: UserStoragePathWithFeatureAndKey,\n value: string,\n ): Promise<void> {\n return await this.#userStorage.setItem(path, value, {\n nativeScryptCrypto: this.#nativeScryptCrypto,\n validateAgainstSchema: true,\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 * @returns nothing. NOTE that an error is thrown if fails to store data.\n */\n public async performBatchSetStorage<\n FeatureName extends UserStoragePathWithFeatureOnly,\n >(\n path: FeatureName,\n values: [UserStorageFeatureKeys<FeatureName>, string][],\n ): Promise<void> {\n return await this.#userStorage.batchSetItems(path, values, {\n nativeScryptCrypto: this.#nativeScryptCrypto,\n validateAgainstSchema: true,\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 * @returns nothing. NOTE that an error is thrown if fails to delete data.\n */\n public async performDeleteStorage(\n path: UserStoragePathWithFeatureAndKey,\n ): Promise<void> {\n return await this.#userStorage.deleteItem(path, {\n nativeScryptCrypto: this.#nativeScryptCrypto,\n validateAgainstSchema: true,\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 * @returns nothing. NOTE that an error is thrown if fails to delete data.\n */\n public async performDeleteStorageAllFeatureEntries(\n path: UserStoragePathWithFeatureOnly,\n ): Promise<void> {\n return await this.#userStorage.deleteAllFeatureItems(path);\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 * @returns nothing. NOTE that an error is thrown if fails to store data.\n */\n public async performBatchDeleteStorage<\n FeatureName extends UserStoragePathWithFeatureOnly,\n >(\n path: FeatureName,\n values: UserStorageFeatureKeys<FeatureName>[],\n ): Promise<void> {\n return await this.#userStorage.batchDeleteItems(path, values);\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 public flushStorageKeyCache(): void {\n this.#storageKeyCache = null;\n }\n\n #_snapSignMessageCache: Record<`metamask:${string}`, string> = {};\n\n /**\n * Signs a specific message using an underlying auth snap.\n *\n * @param message - A specific tagged message to sign.\n * @returns A Signature created by the snap.\n */\n async #snapSignMessage(message: `metamask:${string}`): Promise<string> {\n if (this.#_snapSignMessageCache[message]) {\n return this.#_snapSignMessageCache[message];\n }\n\n if (!this.#isUnlocked) {\n throw new Error(\n '#snapSignMessage - unable to call snap, wallet is locked',\n );\n }\n\n const result = (await this.messagingSystem.call(\n 'SnapController:handleRequest',\n createSnapSignMessageRequest(message),\n )) as string;\n\n this.#_snapSignMessageCache[message] = result;\n\n return result;\n }\n\n public async enableProfileSyncing(): Promise<void> {\n try {\n this.#setIsProfileSyncingUpdateLoading(true);\n\n const isSignedIn = this.#auth.isSignedIn();\n if (!isSignedIn) {\n await this.#auth.signIn();\n }\n\n this.update((state) => {\n state.isProfileSyncingEnabled = true;\n });\n\n this.#setIsProfileSyncingUpdateLoading(false);\n } catch (e) {\n this.#setIsProfileSyncingUpdateLoading(false);\n // istanbul ignore next\n const errorMessage = e instanceof Error ? e.message : JSON.stringify(e);\n throw new Error(\n `${controllerName} - failed to enable profile syncing - ${errorMessage}`,\n );\n }\n }\n\n public async disableProfileSyncing(): Promise<void> {\n const isAlreadyDisabled = !this.state.isProfileSyncingEnabled;\n if (isAlreadyDisabled) {\n return;\n }\n\n this.#setIsProfileSyncingUpdateLoading(true);\n\n this.update((state) => {\n state.isProfileSyncingEnabled = false;\n });\n\n this.#setIsProfileSyncingUpdateLoading(false);\n }\n\n #setIsProfileSyncingUpdateLoading(\n isProfileSyncingUpdateLoading: boolean,\n ): void {\n this.update((state) => {\n state.isProfileSyncingUpdateLoading = isProfileSyncingUpdateLoading;\n });\n }\n\n async setHasAccountSyncingSyncedAtLeastOnce(\n hasAccountSyncingSyncedAtLeastOnce: boolean,\n ): Promise<void> {\n this.update((state) => {\n state.hasAccountSyncingSyncedAtLeastOnce =\n hasAccountSyncingSyncedAtLeastOnce;\n });\n }\n\n async setIsAccountSyncingReadyToBeDispatched(\n isAccountSyncingReadyToBeDispatched: boolean,\n ): Promise<void> {\n this.update((state) => {\n state.isAccountSyncingReadyToBeDispatched =\n isAccountSyncingReadyToBeDispatched;\n });\n }\n\n async setIsAccountSyncingInProgress(\n isAccountSyncingInProgress: boolean,\n ): Promise<void> {\n this.update((state) => {\n state.isAccountSyncingInProgress = isAccountSyncingInProgress;\n });\n }\n\n /**\n * Syncs the internal accounts list with the user storage accounts list.\n * This method is used to make sure that the internal accounts list is up-to-date with the user storage accounts list and vice-versa.\n * It will add new accounts to the internal accounts list, update/merge conflicting names and re-upload the results in some cases to the user storage.\n */\n async syncInternalAccountsWithUserStorage(): Promise<void> {\n const profileId = await this.#auth.getProfileId();\n\n await syncInternalAccountsWithUserStorage(\n {\n isAccountSyncingEnabled: this.#env.isAccountSyncingEnabled,\n maxNumberOfAccountsToAdd:\n this.#config?.accountSyncing?.maxNumberOfAccountsToAdd,\n onAccountAdded: () =>\n this.#config?.accountSyncing?.onAccountAdded?.(profileId),\n onAccountNameUpdated: () =>\n this.#config?.accountSyncing?.onAccountNameUpdated?.(profileId),\n onAccountSyncErroneousSituation: (situationMessage, sentryContext) =>\n this.#config?.accountSyncing?.onAccountSyncErroneousSituation?.(\n profileId,\n situationMessage,\n sentryContext,\n ),\n },\n {\n getMessenger: () => this.messagingSystem,\n getUserStorageControllerInstance: () => this,\n },\n );\n }\n\n /**\n * Saves an individual internal account to the user storage.\n *\n * @param internalAccount - The internal account to save\n */\n async saveInternalAccountToUserStorage(\n internalAccount: InternalAccount,\n ): Promise<void> {\n await saveInternalAccountToUserStorage(\n internalAccount,\n { isAccountSyncingEnabled: this.#env.isAccountSyncingEnabled },\n {\n getMessenger: () => this.messagingSystem,\n getUserStorageControllerInstance: () => this,\n },\n );\n }\n\n async syncNetworks() {\n if (!this.#env.isNetworkSyncingEnabled) {\n return;\n }\n\n const profileId = await this.#auth.getProfileId();\n\n await performMainNetworkSync({\n messenger: this.messagingSystem,\n getUserStorageControllerInstance: () => this,\n maxNetworksToAdd: this.#config?.networkSyncing?.maxNumberOfNetworksToAdd,\n onNetworkAdded: (cId) =>\n this.#config?.networkSyncing?.onNetworkAdded?.(profileId, cId),\n onNetworkUpdated: (cId) =>\n this.#config?.networkSyncing?.onNetworkUpdated?.(profileId, cId),\n onNetworkRemoved: (cId) =>\n this.#config?.networkSyncing?.onNetworkRemoved?.(profileId, cId),\n });\n\n this.update((s) => {\n s.hasNetworkSyncingSyncedAtLeastOnce = true;\n });\n }\n}\n"]}
@@ -8,7 +8,7 @@ import type { HandleSnapRequest } from "@metamask/snaps-controllers";
8
8
  import type { UserStorageFeatureKeys } from "../../shared/storage-schema.cjs";
9
9
  import { type UserStoragePathWithFeatureAndKey, type UserStoragePathWithFeatureOnly } from "../../shared/storage-schema.cjs";
10
10
  import type { NativeScrypt } from "../../shared/types/encryption.cjs";
11
- import type { AuthenticationControllerGetBearerToken, AuthenticationControllerGetSessionProfile, AuthenticationControllerIsSignedIn, AuthenticationControllerPerformSignIn, AuthenticationControllerPerformSignOut } from "../authentication/AuthenticationController.cjs";
11
+ import type { AuthenticationControllerGetBearerToken, AuthenticationControllerGetSessionProfile, AuthenticationControllerIsSignedIn, AuthenticationControllerPerformSignIn } from "../authentication/AuthenticationController.cjs";
12
12
  declare const controllerName = "UserStorageController";
13
13
  export type UserStorageControllerState = {
14
14
  /**
@@ -104,7 +104,7 @@ export type UserStorageControllerEnableProfileSyncing = ActionsObj['enableProfil
104
104
  export type UserStorageControllerDisableProfileSyncing = ActionsObj['disableProfileSyncing'];
105
105
  export type UserStorageControllerSyncInternalAccountsWithUserStorage = ActionsObj['syncInternalAccountsWithUserStorage'];
106
106
  export type UserStorageControllerSaveInternalAccountToUserStorage = ActionsObj['saveInternalAccountToUserStorage'];
107
- export type AllowedActions = KeyringControllerGetStateAction | HandleSnapRequest | AuthenticationControllerGetBearerToken | AuthenticationControllerGetSessionProfile | AuthenticationControllerPerformSignIn | AuthenticationControllerIsSignedIn | AuthenticationControllerPerformSignOut | AccountsControllerListAccountsAction | AccountsControllerUpdateAccountMetadataAction | KeyringControllerWithKeyringAction | NetworkControllerGetStateAction | NetworkControllerAddNetworkAction | NetworkControllerRemoveNetworkAction | NetworkControllerUpdateNetworkAction;
107
+ export type AllowedActions = KeyringControllerGetStateAction | HandleSnapRequest | AuthenticationControllerGetBearerToken | AuthenticationControllerGetSessionProfile | AuthenticationControllerPerformSignIn | AuthenticationControllerIsSignedIn | AccountsControllerListAccountsAction | AccountsControllerUpdateAccountMetadataAction | KeyringControllerWithKeyringAction | NetworkControllerGetStateAction | NetworkControllerAddNetworkAction | NetworkControllerRemoveNetworkAction | NetworkControllerUpdateNetworkAction;
108
108
  export type UserStorageControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, UserStorageControllerState>;
109
109
  export type Events = UserStorageControllerStateChangeEvent;
110
110
  export type AllowedEvents = UserStorageControllerStateChangeEvent | KeyringControllerLockEvent | KeyringControllerUnlockEvent | AccountsControllerAccountAddedEvent | AccountsControllerAccountRenamedEvent | NetworkControllerNetworkRemovedEvent;
@@ -129,8 +129,6 @@ export default class UserStorageController extends BaseController<typeof control
129
129
  };
130
130
  nativeScryptCrypto?: NativeScrypt;
131
131
  });
132
- enableProfileSyncing(): Promise<void>;
133
- disableProfileSyncing(): Promise<void>;
134
132
  /**
135
133
  * Allows retrieval of stored data. Data stored is string formatted.
136
134
  * Developers can extend the entry path and entry name through the `schema.ts` file.
@@ -195,6 +193,9 @@ export default class UserStorageController extends BaseController<typeof control
195
193
  * @returns the storage key
196
194
  */
197
195
  getStorageKey(): Promise<string>;
196
+ flushStorageKeyCache(): void;
197
+ enableProfileSyncing(): Promise<void>;
198
+ disableProfileSyncing(): Promise<void>;
198
199
  setHasAccountSyncingSyncedAtLeastOnce(hasAccountSyncingSyncedAtLeastOnce: boolean): Promise<void>;
199
200
  setIsAccountSyncingReadyToBeDispatched(isAccountSyncingReadyToBeDispatched: boolean): Promise<void>;
200
201
  setIsAccountSyncingInProgress(isAccountSyncingInProgress: boolean): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"UserStorageController.d.cts","sourceRoot":"","sources":["../../../src/controllers/user-storage/UserStorageController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oCAAoC,EACpC,6CAA6C,EAC7C,qCAAqC,EACrC,mCAAmC,EACpC,sCAAsC;AACvC,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,mBAAmB,EAEpB,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,EACL,KAAK,+BAA+B,EACpC,KAAK,0BAA0B,EAC/B,KAAK,4BAA4B,EACjC,KAAK,kCAAkC,EACxC,qCAAqC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,uCAAuC;AACtE,OAAO,KAAK,EACV,iCAAiC,EACjC,+BAA+B,EAC/B,oCAAoC,EACpC,oCAAoC,EACpC,oCAAoC,EACrC,qCAAqC;AACtC,OAAO,KAAK,EAAE,iBAAiB,EAAE,oCAAoC;AAqBrE,OAAO,KAAK,EAAE,sBAAsB,EAAE,wCAAoC;AAC1E,OAAO,EACL,KAAK,gCAAgC,EACrC,KAAK,8BAA8B,EACpC,wCAAoC;AACrC,OAAO,KAAK,EAAE,YAAY,EAAE,0CAAsC;AAElE,OAAO,KAAK,EACV,sCAAsC,EACtC,yCAAyC,EACzC,kCAAkC,EAClC,qCAAqC,EACrC,sCAAsC,EACvC,uDAAmD;AAEpD,QAAA,MAAM,cAAc,0BAA0B,CAAC;AAG/C,MAAM,MAAM,0BAA0B,GAAG;IACvC;;OAEG;IACH,uBAAuB,EAAE,OAAO,GAAG,IAAI,CAAC;IACxC;;OAEG;IACH,6BAA6B,EAAE,OAAO,CAAC;IACvC;;OAEG;IACH,kCAAkC,EAAE,OAAO,CAAC;IAC5C;;OAEG;IACH,mCAAmC,EAAE,OAAO,CAAC;IAC7C;;OAEG;IACH,0BAA0B,EAAE,OAAO,CAAC;IACpC;;OAEG;IACH,kCAAkC,CAAC,EAAE,OAAO,CAAC;CAC9C,CAAC;AAEF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tC,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC;IAYhB;;;;;;;OAOG;IACU,sBAAsB,CACjC,WAAW,SAAS,8BAA8B,EAElD,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,CAAC,sBAAsB,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,EAAE,GACtD,OAAO,CAAC,IAAI,CAAC;IAYhB;;;;;OAKG;IACU,oBAAoB,CAC/B,IAAI,EAAE,gCAAgC,GACrC,OAAO,CAAC,IAAI,CAAC;IAWhB;;;;;;OAMG;IACU,qCAAqC,CAChD,IAAI,EAAE,8BAA8B,GACnC,OAAO,CAAC,IAAI,CAAC;IAWhB;;;;;;;OAOG;IACU,yBAAyB,CACpC,WAAW,SAAS,8BAA8B,EAElD,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,sBAAsB,CAAC,WAAW,CAAC,EAAE,GAC5C,OAAO,CAAC,IAAI,CAAC;IAYhB;;;;OAIG;IACU,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IA4EvC,qCAAqC,CACzC,kCAAkC,EAAE,OAAO,GAC1C,OAAO,CAAC,IAAI,CAAC;IAOV,sCAAsC,CAC1C,mCAAmC,EAAE,OAAO,GAC3C,OAAO,CAAC,IAAI,CAAC;IAOV,6BAA6B,CACjC,0BAA0B,EAAE,OAAO,GAClC,OAAO,CAAC,IAAI,CAAC;IAMhB;;;;OAIG;IACG,mCAAmC,IAAI,OAAO,CAAC,IAAI,CAAC;IA0B1D;;;;OAIG;IACG,gCAAgC,CACpC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAAC,IAAI,CAAC;IAWV,YAAY;CAuBnB"}
1
+ {"version":3,"file":"UserStorageController.d.cts","sourceRoot":"","sources":["../../../src/controllers/user-storage/UserStorageController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oCAAoC,EACpC,6CAA6C,EAC7C,qCAAqC,EACrC,mCAAmC,EACpC,sCAAsC;AACvC,OAAO,KAAK,EAC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CAAC,IAAI,CAAC;IAOhB;;;;;;OAMG;IACU,qCAAqC,CAChD,IAAI,EAAE,8BAA8B,GACnC,OAAO,CAAC,IAAI,CAAC;IAIhB;;;;;;;OAOG;IACU,yBAAyB,CACpC,WAAW,SAAS,8BAA8B,EAElD,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,sBAAsB,CAAC,WAAW,CAAC,EAAE,GAC5C,OAAO,CAAC,IAAI,CAAC;IAIhB;;;;OAIG;IACU,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAItC,oBAAoB,IAAI,IAAI;IAiCtB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAwBrC,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAuB7C,qCAAqC,CACzC,kCAAkC,EAAE,OAAO,GAC1C,OAAO,CAAC,IAAI,CAAC;IAOV,sCAAsC,CAC1C,mCAAmC,EAAE,OAAO,GAC3C,OAAO,CAAC,IAAI,CAAC;IAOV,6BAA6B,CACjC,0BAA0B,EAAE,OAAO,GAClC,OAAO,CAAC,IAAI,CAAC;IAMhB;;;;OAIG;IACG,mCAAmC,IAAI,OAAO,CAAC,IAAI,CAAC;IA0B1D;;;;OAIG;IACG,gCAAgC,CACpC,eAAe,EAAE,eAAe,GAC/B,OAAO,CAAC,IAAI,CAAC;IAWV,YAAY;CAuBnB"}
@@ -8,7 +8,7 @@ import type { HandleSnapRequest } from "@metamask/snaps-controllers";
8
8
  import type { UserStorageFeatureKeys } from "../../shared/storage-schema.mjs";
9
9
  import { type UserStoragePathWithFeatureAndKey, type UserStoragePathWithFeatureOnly } from "../../shared/storage-schema.mjs";
10
10
  import type { NativeScrypt } from "../../shared/types/encryption.mjs";
11
- import type { AuthenticationControllerGetBearerToken, AuthenticationControllerGetSessionProfile, AuthenticationControllerIsSignedIn, AuthenticationControllerPerformSignIn, AuthenticationControllerPerformSignOut } from "../authentication/AuthenticationController.mjs";
11
+ import type { AuthenticationControllerGetBearerToken, AuthenticationControllerGetSessionProfile, AuthenticationControllerIsSignedIn, AuthenticationControllerPerformSignIn } from "../authentication/AuthenticationController.mjs";
12
12
  declare const controllerName = "UserStorageController";
13
13
  export type UserStorageControllerState = {
14
14
  /**
@@ -104,7 +104,7 @@ export type UserStorageControllerEnableProfileSyncing = ActionsObj['enableProfil
104
104
  export type UserStorageControllerDisableProfileSyncing = ActionsObj['disableProfileSyncing'];
105
105
  export type UserStorageControllerSyncInternalAccountsWithUserStorage = ActionsObj['syncInternalAccountsWithUserStorage'];
106
106
  export type UserStorageControllerSaveInternalAccountToUserStorage = ActionsObj['saveInternalAccountToUserStorage'];
107
- export type AllowedActions = KeyringControllerGetStateAction | HandleSnapRequest | AuthenticationControllerGetBearerToken | AuthenticationControllerGetSessionProfile | AuthenticationControllerPerformSignIn | AuthenticationControllerIsSignedIn | AuthenticationControllerPerformSignOut | AccountsControllerListAccountsAction | AccountsControllerUpdateAccountMetadataAction | KeyringControllerWithKeyringAction | NetworkControllerGetStateAction | NetworkControllerAddNetworkAction | NetworkControllerRemoveNetworkAction | NetworkControllerUpdateNetworkAction;
107
+ export type AllowedActions = KeyringControllerGetStateAction | HandleSnapRequest | AuthenticationControllerGetBearerToken | AuthenticationControllerGetSessionProfile | AuthenticationControllerPerformSignIn | AuthenticationControllerIsSignedIn | AccountsControllerListAccountsAction | AccountsControllerUpdateAccountMetadataAction | KeyringControllerWithKeyringAction | NetworkControllerGetStateAction | NetworkControllerAddNetworkAction | NetworkControllerRemoveNetworkAction | NetworkControllerUpdateNetworkAction;
108
108
  export type UserStorageControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, UserStorageControllerState>;
109
109
  export type Events = UserStorageControllerStateChangeEvent;
110
110
  export type AllowedEvents = UserStorageControllerStateChangeEvent | KeyringControllerLockEvent | KeyringControllerUnlockEvent | AccountsControllerAccountAddedEvent | AccountsControllerAccountRenamedEvent | NetworkControllerNetworkRemovedEvent;
@@ -129,8 +129,6 @@ export default class UserStorageController extends BaseController<typeof control
129
129
  };
130
130
  nativeScryptCrypto?: NativeScrypt;
131
131
  });
132
- enableProfileSyncing(): Promise<void>;
133
- disableProfileSyncing(): Promise<void>;
134
132
  /**
135
133
  * Allows retrieval of stored data. Data stored is string formatted.
136
134
  * Developers can extend the entry path and entry name through the `schema.ts` file.
@@ -195,6 +193,9 @@ export default class UserStorageController extends BaseController<typeof control
195
193
  * @returns the storage key
196
194
  */
197
195
  getStorageKey(): Promise<string>;
196
+ flushStorageKeyCache(): void;
197
+ enableProfileSyncing(): Promise<void>;
198
+ disableProfileSyncing(): Promise<void>;
198
199
  setHasAccountSyncingSyncedAtLeastOnce(hasAccountSyncingSyncedAtLeastOnce: boolean): Promise<void>;
199
200
  setIsAccountSyncingReadyToBeDispatched(isAccountSyncingReadyToBeDispatched: boolean): Promise<void>;
200
201
  setIsAccountSyncingInProgress(isAccountSyncingInProgress: boolean): Promise<void>;