@metamask/profile-sync-controller 0.5.0 → 0.6.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 (606) hide show
  1. package/CHANGELOG.md +38 -1
  2. package/dist/controllers/authentication/AuthenticationController.cjs +211 -0
  3. package/dist/controllers/authentication/AuthenticationController.cjs.map +1 -0
  4. package/dist/{types/controllers/authentication/AuthenticationController.d.ts → controllers/authentication/AuthenticationController.d.cts} +5 -5
  5. package/dist/controllers/authentication/AuthenticationController.d.cts.map +1 -0
  6. package/dist/controllers/authentication/AuthenticationController.d.mts +78 -0
  7. package/dist/controllers/authentication/AuthenticationController.d.mts.map +1 -0
  8. package/dist/controllers/authentication/AuthenticationController.mjs +206 -11
  9. package/dist/controllers/authentication/AuthenticationController.mjs.map +1 -1
  10. package/dist/controllers/authentication/__fixtures__/index.cjs +18 -0
  11. package/dist/controllers/authentication/__fixtures__/index.cjs.map +1 -0
  12. package/dist/controllers/authentication/__fixtures__/index.d.cts +2 -0
  13. package/dist/controllers/authentication/__fixtures__/index.d.cts.map +1 -0
  14. package/dist/controllers/authentication/__fixtures__/index.d.mts +2 -0
  15. package/dist/controllers/authentication/__fixtures__/index.d.mts.map +1 -0
  16. package/dist/controllers/authentication/__fixtures__/index.mjs +2 -0
  17. package/dist/controllers/authentication/__fixtures__/index.mjs.map +1 -0
  18. package/dist/controllers/authentication/__fixtures__/mockResponses.cjs +52 -0
  19. package/dist/controllers/authentication/__fixtures__/mockResponses.cjs.map +1 -0
  20. package/dist/{types/controllers/authentication/__fixtures__/mockResponses.d.ts → controllers/authentication/__fixtures__/mockResponses.d.cts} +2 -2
  21. package/dist/controllers/authentication/__fixtures__/mockResponses.d.cts.map +1 -0
  22. package/dist/controllers/authentication/__fixtures__/mockResponses.d.mts +23 -0
  23. package/dist/controllers/authentication/__fixtures__/mockResponses.d.mts.map +1 -0
  24. package/dist/controllers/authentication/__fixtures__/mockResponses.mjs +46 -0
  25. package/dist/controllers/authentication/__fixtures__/mockResponses.mjs.map +1 -0
  26. package/dist/controllers/authentication/__fixtures__/mockServices.cjs +37 -0
  27. package/dist/controllers/authentication/__fixtures__/mockServices.cjs.map +1 -0
  28. package/dist/{types/controllers/authentication/__fixtures__/mockServices.d.ts → controllers/authentication/__fixtures__/mockServices.d.cts} +2 -2
  29. package/dist/controllers/authentication/__fixtures__/mockServices.d.cts.map +1 -0
  30. package/dist/controllers/authentication/__fixtures__/mockServices.d.mts +10 -0
  31. package/dist/controllers/authentication/__fixtures__/mockServices.d.mts.map +1 -0
  32. package/dist/controllers/authentication/__fixtures__/mockServices.mjs +35 -0
  33. package/dist/controllers/authentication/__fixtures__/mockServices.mjs.map +1 -0
  34. package/dist/controllers/authentication/auth-snap-requests.cjs +39 -0
  35. package/dist/controllers/authentication/auth-snap-requests.cjs.map +1 -0
  36. package/dist/{types/controllers/authentication/auth-snap-requests.d.ts → controllers/authentication/auth-snap-requests.d.cts} +2 -2
  37. package/dist/controllers/authentication/auth-snap-requests.d.cts.map +1 -0
  38. package/dist/controllers/authentication/auth-snap-requests.d.mts +17 -0
  39. package/dist/controllers/authentication/auth-snap-requests.d.mts.map +1 -0
  40. package/dist/controllers/authentication/auth-snap-requests.mjs +33 -9
  41. package/dist/controllers/authentication/auth-snap-requests.mjs.map +1 -1
  42. package/dist/controllers/authentication/index.cjs +39 -0
  43. package/dist/controllers/authentication/index.cjs.map +1 -0
  44. package/dist/controllers/authentication/index.d.cts +7 -0
  45. package/dist/controllers/authentication/index.d.cts.map +1 -0
  46. package/dist/controllers/authentication/index.d.mts +7 -0
  47. package/dist/controllers/authentication/index.d.mts.map +1 -0
  48. package/dist/controllers/authentication/index.mjs +6 -18
  49. package/dist/controllers/authentication/index.mjs.map +1 -1
  50. package/dist/controllers/authentication/services.cjs +127 -0
  51. package/dist/controllers/authentication/services.cjs.map +1 -0
  52. package/dist/{types/controllers/authentication/services.d.ts → controllers/authentication/services.d.cts} +1 -1
  53. package/dist/controllers/authentication/services.d.cts.map +1 -0
  54. package/dist/controllers/authentication/services.d.mts +70 -0
  55. package/dist/controllers/authentication/services.d.mts.map +1 -0
  56. package/dist/controllers/authentication/services.mjs +118 -19
  57. package/dist/controllers/authentication/services.mjs.map +1 -1
  58. package/dist/controllers/index.cjs +29 -0
  59. package/dist/controllers/index.cjs.map +1 -0
  60. package/dist/controllers/index.d.cts +3 -0
  61. package/dist/controllers/index.d.cts.map +1 -0
  62. package/dist/controllers/index.d.mts +3 -0
  63. package/dist/controllers/index.d.mts.map +1 -0
  64. package/dist/controllers/index.mjs +2 -24
  65. package/dist/controllers/index.mjs.map +1 -1
  66. package/dist/controllers/user-storage/UserStorageController.cjs +462 -0
  67. package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -0
  68. package/dist/{types/controllers/user-storage/UserStorageController.d.ts → controllers/user-storage/UserStorageController.d.cts} +44 -15
  69. package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -0
  70. package/dist/controllers/user-storage/UserStorageController.d.mts +156 -0
  71. package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -0
  72. package/dist/controllers/user-storage/UserStorageController.mjs +457 -18
  73. package/dist/controllers/user-storage/UserStorageController.mjs.map +1 -1
  74. package/dist/controllers/user-storage/__fixtures__/index.cjs +19 -0
  75. package/dist/controllers/user-storage/__fixtures__/index.cjs.map +1 -0
  76. package/dist/controllers/user-storage/__fixtures__/index.d.cts +3 -0
  77. package/dist/controllers/user-storage/__fixtures__/index.d.cts.map +1 -0
  78. package/dist/controllers/user-storage/__fixtures__/index.d.mts +3 -0
  79. package/dist/controllers/user-storage/__fixtures__/index.d.mts.map +1 -0
  80. package/dist/controllers/user-storage/__fixtures__/index.mjs +3 -0
  81. package/dist/controllers/user-storage/__fixtures__/index.mjs.map +1 -0
  82. package/dist/controllers/user-storage/__fixtures__/mockAccounts.cjs +127 -0
  83. package/dist/controllers/user-storage/__fixtures__/mockAccounts.cjs.map +1 -0
  84. package/dist/{types/controllers/user-storage/__fixtures__/mockAccounts.d.ts → controllers/user-storage/__fixtures__/mockAccounts.d.cts} +6 -6
  85. package/dist/controllers/user-storage/__fixtures__/mockAccounts.d.cts.map +1 -0
  86. package/dist/controllers/user-storage/__fixtures__/mockAccounts.d.mts +63 -0
  87. package/dist/controllers/user-storage/__fixtures__/mockAccounts.d.mts.map +1 -0
  88. package/dist/controllers/user-storage/__fixtures__/mockAccounts.mjs +123 -0
  89. package/dist/controllers/user-storage/__fixtures__/mockAccounts.mjs.map +1 -0
  90. package/dist/controllers/user-storage/__fixtures__/mockResponses.cjs +48 -0
  91. package/dist/controllers/user-storage/__fixtures__/mockResponses.cjs.map +1 -0
  92. package/dist/{types/controllers/user-storage/__fixtures__/mockResponses.d.ts → controllers/user-storage/__fixtures__/mockResponses.d.cts} +6 -4
  93. package/dist/controllers/user-storage/__fixtures__/mockResponses.d.cts.map +1 -0
  94. package/dist/controllers/user-storage/__fixtures__/mockResponses.d.mts +21 -0
  95. package/dist/controllers/user-storage/__fixtures__/mockResponses.d.mts.map +1 -0
  96. package/dist/controllers/user-storage/__fixtures__/mockResponses.mjs +39 -0
  97. package/dist/controllers/user-storage/__fixtures__/mockResponses.mjs.map +1 -0
  98. package/dist/controllers/user-storage/__fixtures__/mockServices.cjs +41 -0
  99. package/dist/controllers/user-storage/__fixtures__/mockServices.cjs.map +1 -0
  100. package/dist/{types/controllers/user-storage/__fixtures__/mockServices.d.ts → controllers/user-storage/__fixtures__/mockServices.d.cts} +3 -3
  101. package/dist/controllers/user-storage/__fixtures__/mockServices.d.cts.map +1 -0
  102. package/dist/controllers/user-storage/__fixtures__/mockServices.d.mts +11 -0
  103. package/dist/controllers/user-storage/__fixtures__/mockServices.d.mts.map +1 -0
  104. package/dist/controllers/user-storage/__fixtures__/mockServices.mjs +39 -0
  105. package/dist/controllers/user-storage/__fixtures__/mockServices.mjs.map +1 -0
  106. package/dist/controllers/user-storage/__fixtures__/mockStorage.cjs +36 -0
  107. package/dist/controllers/user-storage/__fixtures__/mockStorage.cjs.map +1 -0
  108. package/dist/{types/controllers/user-storage/__fixtures__/mockStorage.d.ts → controllers/user-storage/__fixtures__/mockStorage.d.cts} +2 -2
  109. package/dist/controllers/user-storage/__fixtures__/mockStorage.d.cts.map +1 -0
  110. package/dist/controllers/user-storage/__fixtures__/mockStorage.d.mts +5 -0
  111. package/dist/controllers/user-storage/__fixtures__/mockStorage.d.mts.map +1 -0
  112. package/dist/controllers/user-storage/__fixtures__/mockStorage.mjs +9 -0
  113. package/dist/controllers/user-storage/__fixtures__/mockStorage.mjs.map +1 -0
  114. package/dist/controllers/user-storage/__fixtures__/test-utils.cjs +31 -0
  115. package/dist/controllers/user-storage/__fixtures__/test-utils.cjs.map +1 -0
  116. package/dist/controllers/user-storage/__fixtures__/test-utils.d.cts +14 -0
  117. package/dist/controllers/user-storage/__fixtures__/test-utils.d.cts.map +1 -0
  118. package/dist/controllers/user-storage/__fixtures__/test-utils.d.mts +14 -0
  119. package/dist/controllers/user-storage/__fixtures__/test-utils.d.mts.map +1 -0
  120. package/dist/controllers/user-storage/__fixtures__/test-utils.mjs +27 -0
  121. package/dist/controllers/user-storage/__fixtures__/test-utils.mjs.map +1 -0
  122. package/dist/controllers/user-storage/accounts/constants.cjs +51 -0
  123. package/dist/controllers/user-storage/accounts/constants.cjs.map +1 -0
  124. package/dist/{types/controllers/user-storage/accounts/constants.d.ts → controllers/user-storage/accounts/constants.d.cts} +1 -1
  125. package/dist/controllers/user-storage/accounts/constants.d.cts.map +1 -0
  126. package/dist/controllers/user-storage/accounts/constants.d.mts +4 -0
  127. package/dist/controllers/user-storage/accounts/constants.d.mts.map +1 -0
  128. package/dist/controllers/user-storage/accounts/constants.mjs +47 -11
  129. package/dist/controllers/user-storage/accounts/constants.mjs.map +1 -1
  130. package/dist/controllers/user-storage/accounts/user-storage.cjs +34 -0
  131. package/dist/controllers/user-storage/accounts/user-storage.cjs.map +1 -0
  132. package/dist/{types/controllers/user-storage/accounts/user-storage.d.ts → controllers/user-storage/accounts/user-storage.d.cts} +3 -3
  133. package/dist/controllers/user-storage/accounts/user-storage.d.cts.map +1 -0
  134. package/dist/controllers/user-storage/accounts/user-storage.d.mts +32 -0
  135. package/dist/controllers/user-storage/accounts/user-storage.d.mts.map +1 -0
  136. package/dist/controllers/user-storage/accounts/user-storage.mjs +27 -9
  137. package/dist/controllers/user-storage/accounts/user-storage.mjs.map +1 -1
  138. package/dist/controllers/user-storage/encryption/cache.cjs +79 -0
  139. package/dist/controllers/user-storage/encryption/cache.cjs.map +1 -0
  140. package/dist/{types/controllers/user-storage/encryption/cache.d.ts → controllers/user-storage/encryption/cache.d.cts} +1 -1
  141. package/dist/controllers/user-storage/encryption/cache.d.cts.map +1 -0
  142. package/dist/controllers/user-storage/encryption/cache.d.mts +31 -0
  143. package/dist/controllers/user-storage/encryption/cache.d.mts.map +1 -0
  144. package/dist/controllers/user-storage/encryption/cache.mjs +71 -11
  145. package/dist/controllers/user-storage/encryption/cache.mjs.map +1 -1
  146. package/dist/controllers/user-storage/encryption/encryption.cjs +151 -0
  147. package/dist/controllers/user-storage/encryption/encryption.cjs.map +1 -0
  148. package/dist/{types/controllers/user-storage/encryption/encryption.d.ts → controllers/user-storage/encryption/encryption.d.cts} +2 -2
  149. package/dist/controllers/user-storage/encryption/encryption.d.cts.map +1 -0
  150. package/dist/controllers/user-storage/encryption/encryption.d.mts +27 -0
  151. package/dist/controllers/user-storage/encryption/encryption.d.mts.map +1 -0
  152. package/dist/controllers/user-storage/encryption/encryption.mjs +145 -10
  153. package/dist/controllers/user-storage/encryption/encryption.mjs.map +1 -1
  154. package/dist/controllers/user-storage/encryption/index.cjs +25 -0
  155. package/dist/controllers/user-storage/encryption/index.cjs.map +1 -0
  156. package/dist/controllers/user-storage/encryption/index.d.cts +5 -0
  157. package/dist/controllers/user-storage/encryption/index.d.cts.map +1 -0
  158. package/dist/controllers/user-storage/encryption/index.d.mts +5 -0
  159. package/dist/controllers/user-storage/encryption/index.d.mts.map +1 -0
  160. package/dist/controllers/user-storage/encryption/index.mjs +4 -15
  161. package/dist/controllers/user-storage/encryption/index.mjs.map +1 -1
  162. package/dist/controllers/user-storage/encryption/utils.cjs +17 -0
  163. package/dist/controllers/user-storage/encryption/utils.cjs.map +1 -0
  164. package/dist/{types/controllers/user-storage/encryption/utils.d.ts → controllers/user-storage/encryption/utils.d.cts} +1 -1
  165. package/dist/controllers/user-storage/encryption/utils.d.cts.map +1 -0
  166. package/dist/controllers/user-storage/encryption/utils.d.mts +4 -0
  167. package/dist/controllers/user-storage/encryption/utils.d.mts.map +1 -0
  168. package/dist/controllers/user-storage/encryption/utils.mjs +9 -10
  169. package/dist/controllers/user-storage/encryption/utils.mjs.map +1 -1
  170. package/dist/controllers/user-storage/index.cjs +40 -0
  171. package/dist/controllers/user-storage/index.cjs.map +1 -0
  172. package/dist/controllers/user-storage/index.d.cts +8 -0
  173. package/dist/controllers/user-storage/index.d.cts.map +1 -0
  174. package/dist/controllers/user-storage/index.d.mts +8 -0
  175. package/dist/controllers/user-storage/index.d.mts.map +1 -0
  176. package/dist/controllers/user-storage/index.mjs +7 -30
  177. package/dist/controllers/user-storage/index.mjs.map +1 -1
  178. package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.cjs +25 -0
  179. package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.cjs.map +1 -0
  180. package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.d.cts +4 -0
  181. package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.d.cts.map +1 -0
  182. package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.d.mts +4 -0
  183. package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.d.mts.map +1 -0
  184. package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.mjs +20 -0
  185. package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.mjs.map +1 -0
  186. package/dist/controllers/user-storage/network-syncing/controller-integration.cjs +65 -0
  187. package/dist/controllers/user-storage/network-syncing/controller-integration.cjs.map +1 -0
  188. package/dist/controllers/user-storage/network-syncing/controller-integration.d.cts +13 -0
  189. package/dist/controllers/user-storage/network-syncing/controller-integration.d.cts.map +1 -0
  190. package/dist/controllers/user-storage/network-syncing/controller-integration.d.mts +13 -0
  191. package/dist/controllers/user-storage/network-syncing/controller-integration.d.mts.map +1 -0
  192. package/dist/controllers/user-storage/network-syncing/controller-integration.mjs +65 -0
  193. package/dist/controllers/user-storage/network-syncing/controller-integration.mjs.map +1 -0
  194. package/dist/controllers/user-storage/network-syncing/services.cjs +64 -0
  195. package/dist/controllers/user-storage/network-syncing/services.cjs.map +1 -0
  196. package/dist/controllers/user-storage/network-syncing/services.d.cts +21 -0
  197. package/dist/controllers/user-storage/network-syncing/services.d.cts.map +1 -0
  198. package/dist/controllers/user-storage/network-syncing/services.d.mts +21 -0
  199. package/dist/controllers/user-storage/network-syncing/services.d.mts.map +1 -0
  200. package/dist/controllers/user-storage/network-syncing/services.mjs +58 -0
  201. package/dist/controllers/user-storage/network-syncing/services.mjs.map +1 -0
  202. package/dist/controllers/user-storage/network-syncing/sync-all.cjs +171 -0
  203. package/dist/controllers/user-storage/network-syncing/sync-all.cjs.map +1 -0
  204. package/dist/controllers/user-storage/network-syncing/sync-all.d.cts +35 -0
  205. package/dist/controllers/user-storage/network-syncing/sync-all.d.cts.map +1 -0
  206. package/dist/controllers/user-storage/network-syncing/sync-all.d.mts +35 -0
  207. package/dist/controllers/user-storage/network-syncing/sync-all.d.mts.map +1 -0
  208. package/dist/controllers/user-storage/network-syncing/sync-all.mjs +162 -0
  209. package/dist/controllers/user-storage/network-syncing/sync-all.mjs.map +1 -0
  210. package/dist/controllers/user-storage/network-syncing/sync-mutations.cjs +28 -0
  211. package/dist/controllers/user-storage/network-syncing/sync-mutations.cjs.map +1 -0
  212. package/dist/controllers/user-storage/network-syncing/sync-mutations.d.cts +9 -0
  213. package/dist/controllers/user-storage/network-syncing/sync-mutations.d.cts.map +1 -0
  214. package/dist/controllers/user-storage/network-syncing/sync-mutations.d.mts +9 -0
  215. package/dist/controllers/user-storage/network-syncing/sync-mutations.d.mts.map +1 -0
  216. package/dist/controllers/user-storage/network-syncing/sync-mutations.mjs +22 -0
  217. package/dist/controllers/user-storage/network-syncing/sync-mutations.mjs.map +1 -0
  218. package/dist/controllers/user-storage/network-syncing/types.cjs +16 -0
  219. package/dist/controllers/user-storage/network-syncing/types.cjs.map +1 -0
  220. package/dist/controllers/user-storage/network-syncing/types.d.cts +18 -0
  221. package/dist/controllers/user-storage/network-syncing/types.d.cts.map +1 -0
  222. package/dist/controllers/user-storage/network-syncing/types.d.mts +18 -0
  223. package/dist/controllers/user-storage/network-syncing/types.d.mts.map +1 -0
  224. package/dist/controllers/user-storage/network-syncing/types.mjs +11 -0
  225. package/dist/controllers/user-storage/network-syncing/types.mjs.map +1 -0
  226. package/dist/controllers/user-storage/schema.cjs +56 -0
  227. package/dist/controllers/user-storage/schema.cjs.map +1 -0
  228. package/dist/{types/controllers/user-storage/schema.d.ts → controllers/user-storage/schema.d.cts} +2 -1
  229. package/dist/controllers/user-storage/schema.d.cts.map +1 -0
  230. package/dist/controllers/user-storage/schema.d.mts +38 -0
  231. package/dist/controllers/user-storage/schema.d.mts.map +1 -0
  232. package/dist/controllers/user-storage/schema.mjs +48 -16
  233. package/dist/controllers/user-storage/schema.mjs.map +1 -1
  234. package/dist/controllers/user-storage/services.cjs +119 -0
  235. package/dist/controllers/user-storage/services.cjs.map +1 -0
  236. package/dist/{types/controllers/user-storage/services.d.ts → controllers/user-storage/services.d.cts} +4 -5
  237. package/dist/controllers/user-storage/services.d.cts.map +1 -0
  238. package/dist/controllers/user-storage/services.d.mts +48 -0
  239. package/dist/controllers/user-storage/services.d.mts.map +1 -0
  240. package/dist/controllers/user-storage/services.mjs +116 -21
  241. package/dist/controllers/user-storage/services.mjs.map +1 -1
  242. package/dist/controllers/user-storage/utils.cjs +30 -0
  243. package/dist/controllers/user-storage/utils.cjs.map +1 -0
  244. package/dist/controllers/user-storage/utils.d.cts +17 -0
  245. package/dist/controllers/user-storage/utils.d.cts.map +1 -0
  246. package/dist/controllers/user-storage/utils.d.mts +17 -0
  247. package/dist/controllers/user-storage/utils.d.mts.map +1 -0
  248. package/dist/controllers/user-storage/utils.mjs +25 -0
  249. package/dist/controllers/user-storage/utils.mjs.map +1 -0
  250. package/dist/index.cjs +30 -0
  251. package/dist/index.cjs.map +1 -0
  252. package/dist/index.d.cts +4 -0
  253. package/dist/index.d.cts.map +1 -0
  254. package/dist/index.d.mts +4 -0
  255. package/dist/index.d.mts.map +1 -0
  256. package/dist/index.mjs +3 -39
  257. package/dist/index.mjs.map +1 -1
  258. package/dist/sdk/__fixtures__/mock-auth.cjs +139 -0
  259. package/dist/sdk/__fixtures__/mock-auth.cjs.map +1 -0
  260. package/dist/{types/sdk/__fixtures__/mock-auth.d.ts → sdk/__fixtures__/mock-auth.d.cts} +2 -2
  261. package/dist/sdk/__fixtures__/mock-auth.d.cts.map +1 -0
  262. package/dist/sdk/__fixtures__/mock-auth.d.mts +42 -0
  263. package/dist/sdk/__fixtures__/mock-auth.d.mts.map +1 -0
  264. package/dist/sdk/__fixtures__/mock-auth.mjs +134 -0
  265. package/dist/sdk/__fixtures__/mock-auth.mjs.map +1 -0
  266. package/dist/sdk/__fixtures__/mock-userstorage.cjs +58 -0
  267. package/dist/sdk/__fixtures__/mock-userstorage.cjs.map +1 -0
  268. package/dist/{types/sdk/__fixtures__/mock-userstorage.d.ts → sdk/__fixtures__/mock-userstorage.d.cts} +2 -2
  269. package/dist/sdk/__fixtures__/mock-userstorage.d.cts.map +1 -0
  270. package/dist/sdk/__fixtures__/mock-userstorage.d.mts +19 -0
  271. package/dist/sdk/__fixtures__/mock-userstorage.d.mts.map +1 -0
  272. package/dist/sdk/__fixtures__/mock-userstorage.mjs +54 -0
  273. package/dist/sdk/__fixtures__/mock-userstorage.mjs.map +1 -0
  274. package/dist/sdk/__fixtures__/test-utils.cjs +74 -0
  275. package/dist/sdk/__fixtures__/test-utils.cjs.map +1 -0
  276. package/dist/{types/sdk/__fixtures__/test-utils.d.ts → sdk/__fixtures__/test-utils.d.cts} +6 -6
  277. package/dist/sdk/__fixtures__/test-utils.d.cts.map +1 -0
  278. package/dist/sdk/__fixtures__/test-utils.d.mts +25 -0
  279. package/dist/sdk/__fixtures__/test-utils.d.mts.map +1 -0
  280. package/dist/sdk/__fixtures__/test-utils.mjs +69 -0
  281. package/dist/sdk/__fixtures__/test-utils.mjs.map +1 -0
  282. package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs +106 -0
  283. package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs.map +1 -0
  284. package/dist/{types/sdk/authentication-jwt-bearer/flow-siwe.d.ts → sdk/authentication-jwt-bearer/flow-siwe.d.cts} +2 -2
  285. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.cts.map +1 -0
  286. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.mts +23 -0
  287. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.mts.map +1 -0
  288. package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs +101 -11
  289. package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs.map +1 -1
  290. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs +111 -0
  291. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs.map +1 -0
  292. package/dist/{types/sdk/authentication-jwt-bearer/flow-srp.d.ts → sdk/authentication-jwt-bearer/flow-srp.d.cts} +2 -2
  293. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts.map +1 -0
  294. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts +17 -0
  295. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts.map +1 -0
  296. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs +105 -13
  297. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs.map +1 -1
  298. package/dist/sdk/authentication-jwt-bearer/services.cjs +180 -0
  299. package/dist/sdk/authentication-jwt-bearer/services.cjs.map +1 -0
  300. package/dist/{types/sdk/authentication-jwt-bearer/services.d.ts → sdk/authentication-jwt-bearer/services.d.cts} +4 -4
  301. package/dist/sdk/authentication-jwt-bearer/services.d.cts.map +1 -0
  302. package/dist/sdk/authentication-jwt-bearer/services.d.mts +63 -0
  303. package/dist/sdk/authentication-jwt-bearer/services.d.mts.map +1 -0
  304. package/dist/sdk/authentication-jwt-bearer/services.mjs +166 -25
  305. package/dist/sdk/authentication-jwt-bearer/services.mjs.map +1 -1
  306. package/dist/sdk/authentication-jwt-bearer/types.cjs +12 -0
  307. package/dist/sdk/authentication-jwt-bearer/types.cjs.map +1 -0
  308. package/dist/{types/sdk/authentication-jwt-bearer/types.d.ts → sdk/authentication-jwt-bearer/types.d.cts} +2 -2
  309. package/dist/sdk/authentication-jwt-bearer/types.d.cts.map +1 -0
  310. package/dist/sdk/authentication-jwt-bearer/types.d.mts +67 -0
  311. package/dist/sdk/authentication-jwt-bearer/types.d.mts.map +1 -0
  312. package/dist/sdk/authentication-jwt-bearer/types.mjs +8 -7
  313. package/dist/sdk/authentication-jwt-bearer/types.mjs.map +1 -1
  314. package/dist/sdk/authentication.cjs +129 -0
  315. package/dist/sdk/authentication.cjs.map +1 -0
  316. package/dist/{types/sdk/authentication.d.ts → sdk/authentication.d.cts} +7 -7
  317. package/dist/sdk/authentication.d.cts.map +1 -0
  318. package/dist/sdk/authentication.d.mts +32 -0
  319. package/dist/sdk/authentication.d.mts.map +1 -0
  320. package/dist/sdk/authentication.mjs +107 -24
  321. package/dist/sdk/authentication.mjs.map +1 -1
  322. package/dist/sdk/encryption.cjs +23 -0
  323. package/dist/sdk/encryption.cjs.map +1 -0
  324. package/dist/sdk/encryption.d.cts +4 -0
  325. package/dist/sdk/encryption.d.cts.map +1 -0
  326. package/dist/sdk/encryption.d.mts +4 -0
  327. package/dist/sdk/encryption.d.mts.map +1 -0
  328. package/dist/sdk/encryption.mjs +3 -13
  329. package/dist/sdk/encryption.mjs.map +1 -1
  330. package/dist/sdk/env.cjs +85 -0
  331. package/dist/sdk/env.cjs.map +1 -0
  332. package/dist/{types/sdk/env.d.ts → sdk/env.d.cts} +1 -1
  333. package/dist/sdk/env.d.cts.map +1 -0
  334. package/dist/sdk/env.d.mts +34 -0
  335. package/dist/sdk/env.d.mts.map +1 -0
  336. package/dist/sdk/env.mjs +78 -12
  337. package/dist/sdk/env.mjs.map +1 -1
  338. package/dist/sdk/errors.cjs +53 -0
  339. package/dist/sdk/errors.cjs.map +1 -0
  340. package/dist/{types/sdk/errors.d.ts → sdk/errors.d.cts} +1 -1
  341. package/dist/sdk/errors.d.cts.map +1 -0
  342. package/dist/sdk/errors.d.mts +22 -0
  343. package/dist/sdk/errors.d.mts.map +1 -0
  344. package/dist/sdk/errors.mjs +42 -19
  345. package/dist/sdk/errors.mjs.map +1 -1
  346. package/dist/sdk/index.cjs +23 -0
  347. package/dist/sdk/index.cjs.map +1 -0
  348. package/dist/sdk/index.d.cts +7 -0
  349. package/dist/sdk/index.d.cts.map +1 -0
  350. package/dist/sdk/index.d.mts +7 -0
  351. package/dist/sdk/index.d.mts.map +1 -0
  352. package/dist/sdk/index.mjs +6 -78
  353. package/dist/sdk/index.mjs.map +1 -1
  354. package/dist/sdk/user-storage.cjs +176 -0
  355. package/dist/sdk/user-storage.cjs.map +1 -0
  356. package/dist/{types/sdk/user-storage.d.ts → sdk/user-storage.d.cts} +4 -4
  357. package/dist/sdk/user-storage.d.cts.map +1 -0
  358. package/dist/sdk/user-storage.d.mts +27 -0
  359. package/dist/sdk/user-storage.d.mts.map +1 -0
  360. package/dist/sdk/user-storage.mjs +146 -16
  361. package/dist/sdk/user-storage.mjs.map +1 -1
  362. package/dist/sdk/utils/eip-6963-metamask-provider.cjs +70 -0
  363. package/dist/sdk/utils/eip-6963-metamask-provider.cjs.map +1 -0
  364. package/dist/{types/sdk/utils/eip-6963-metamask-provider.d.ts → sdk/utils/eip-6963-metamask-provider.d.cts} +2 -2
  365. package/dist/sdk/utils/eip-6963-metamask-provider.d.cts.map +1 -0
  366. package/dist/sdk/utils/eip-6963-metamask-provider.d.mts +25 -0
  367. package/dist/sdk/utils/eip-6963-metamask-provider.d.mts.map +1 -0
  368. package/dist/sdk/utils/eip-6963-metamask-provider.mjs +64 -8
  369. package/dist/sdk/utils/eip-6963-metamask-provider.mjs.map +1 -1
  370. package/dist/sdk/utils/messaging-signing-snap-requests.cjs +89 -0
  371. package/dist/sdk/utils/messaging-signing-snap-requests.cjs.map +1 -0
  372. package/dist/{types/sdk/utils/messaging-signing-snap-requests.d.ts → sdk/utils/messaging-signing-snap-requests.d.cts} +2 -2
  373. package/dist/sdk/utils/messaging-signing-snap-requests.d.cts.map +1 -0
  374. package/dist/sdk/utils/messaging-signing-snap-requests.d.mts +40 -0
  375. package/dist/sdk/utils/messaging-signing-snap-requests.d.mts.map +1 -0
  376. package/dist/sdk/utils/messaging-signing-snap-requests.mjs +80 -16
  377. package/dist/sdk/utils/messaging-signing-snap-requests.mjs.map +1 -1
  378. package/dist/sdk/utils/validate-login-response.cjs +22 -0
  379. package/dist/sdk/utils/validate-login-response.cjs.map +1 -0
  380. package/dist/{types/sdk/utils/validate-login-response.d.ts → sdk/utils/validate-login-response.d.cts} +2 -2
  381. package/dist/sdk/utils/validate-login-response.d.cts.map +1 -0
  382. package/dist/sdk/utils/validate-login-response.d.mts +10 -0
  383. package/dist/sdk/utils/validate-login-response.d.mts.map +1 -0
  384. package/dist/sdk/utils/validate-login-response.mjs +17 -7
  385. package/dist/sdk/utils/validate-login-response.mjs.map +1 -1
  386. package/package.json +20 -14
  387. package/dist/chunk-2CWF7ZTL.mjs +0 -129
  388. package/dist/chunk-2CWF7ZTL.mjs.map +0 -1
  389. package/dist/chunk-2VEMA6OE.mjs +0 -47
  390. package/dist/chunk-2VEMA6OE.mjs.map +0 -1
  391. package/dist/chunk-4LMFZDL4.js +0 -114
  392. package/dist/chunk-4LMFZDL4.js.map +0 -1
  393. package/dist/chunk-4TMLEABQ.js +0 -79
  394. package/dist/chunk-4TMLEABQ.js.map +0 -1
  395. package/dist/chunk-5MQUI24U.js +0 -47
  396. package/dist/chunk-5MQUI24U.js.map +0 -1
  397. package/dist/chunk-5XSXZTED.mjs +0 -57
  398. package/dist/chunk-5XSXZTED.mjs.map +0 -1
  399. package/dist/chunk-6DAK2U35.mjs +0 -11
  400. package/dist/chunk-6DAK2U35.mjs.map +0 -1
  401. package/dist/chunk-76NMME23.mjs +0 -114
  402. package/dist/chunk-76NMME23.mjs.map +0 -1
  403. package/dist/chunk-76VRE4BI.mjs +0 -18
  404. package/dist/chunk-76VRE4BI.mjs.map +0 -1
  405. package/dist/chunk-BKQE7DB5.js +0 -170
  406. package/dist/chunk-BKQE7DB5.js.map +0 -1
  407. package/dist/chunk-CAIIVJAO.mjs +0 -11
  408. package/dist/chunk-CAIIVJAO.mjs.map +0 -1
  409. package/dist/chunk-COBJUBZE.mjs +0 -170
  410. package/dist/chunk-COBJUBZE.mjs.map +0 -1
  411. package/dist/chunk-D4SNJOID.mjs +0 -269
  412. package/dist/chunk-D4SNJOID.mjs.map +0 -1
  413. package/dist/chunk-DF24ZX4H.js +0 -76
  414. package/dist/chunk-DF24ZX4H.js.map +0 -1
  415. package/dist/chunk-DRB2MN4T.js +0 -16
  416. package/dist/chunk-DRB2MN4T.js.map +0 -1
  417. package/dist/chunk-EHZFPUJH.mjs +0 -53
  418. package/dist/chunk-EHZFPUJH.mjs.map +0 -1
  419. package/dist/chunk-F6BAOSH2.js +0 -269
  420. package/dist/chunk-F6BAOSH2.js.map +0 -1
  421. package/dist/chunk-GQXYWBFK.js +0 -28
  422. package/dist/chunk-GQXYWBFK.js.map +0 -1
  423. package/dist/chunk-H25EBXG5.mjs +0 -58
  424. package/dist/chunk-H25EBXG5.mjs.map +0 -1
  425. package/dist/chunk-IGY2S5BC.js +0 -36
  426. package/dist/chunk-IGY2S5BC.js.map +0 -1
  427. package/dist/chunk-JAQ5TPSZ.js +0 -53
  428. package/dist/chunk-JAQ5TPSZ.js.map +0 -1
  429. package/dist/chunk-KHASG4H3.mjs +0 -11
  430. package/dist/chunk-KHASG4H3.mjs.map +0 -1
  431. package/dist/chunk-KIVBL6OM.js +0 -129
  432. package/dist/chunk-KIVBL6OM.js.map +0 -1
  433. package/dist/chunk-KTCSRECK.mjs +0 -76
  434. package/dist/chunk-KTCSRECK.mjs.map +0 -1
  435. package/dist/chunk-LGXQBALM.mjs +0 -106
  436. package/dist/chunk-LGXQBALM.mjs.map +0 -1
  437. package/dist/chunk-LLG4D2SC.js +0 -157
  438. package/dist/chunk-LLG4D2SC.js.map +0 -1
  439. package/dist/chunk-M7AUA5W7.mjs +0 -79
  440. package/dist/chunk-M7AUA5W7.mjs.map +0 -1
  441. package/dist/chunk-MBTBE4P5.js +0 -54
  442. package/dist/chunk-MBTBE4P5.js.map +0 -1
  443. package/dist/chunk-MK7ABX2V.mjs +0 -186
  444. package/dist/chunk-MK7ABX2V.mjs.map +0 -1
  445. package/dist/chunk-NEBLEB3X.mjs +0 -107
  446. package/dist/chunk-NEBLEB3X.mjs.map +0 -1
  447. package/dist/chunk-NIUQ34PY.js +0 -11
  448. package/dist/chunk-NIUQ34PY.js.map +0 -1
  449. package/dist/chunk-NMIF3LSX.mjs +0 -29
  450. package/dist/chunk-NMIF3LSX.mjs.map +0 -1
  451. package/dist/chunk-OLFO6R7Z.mjs +0 -546
  452. package/dist/chunk-OLFO6R7Z.mjs.map +0 -1
  453. package/dist/chunk-PBRUOBEQ.js +0 -11
  454. package/dist/chunk-PBRUOBEQ.js.map +0 -1
  455. package/dist/chunk-PCOIRDTO.js +0 -18
  456. package/dist/chunk-PCOIRDTO.js.map +0 -1
  457. package/dist/chunk-PQMPSEVJ.js +0 -546
  458. package/dist/chunk-PQMPSEVJ.js.map +0 -1
  459. package/dist/chunk-PRYLTXW4.js +0 -92
  460. package/dist/chunk-PRYLTXW4.js.map +0 -1
  461. package/dist/chunk-PU7MAIST.mjs +0 -129
  462. package/dist/chunk-PU7MAIST.mjs.map +0 -1
  463. package/dist/chunk-QCQU4BQL.js +0 -68
  464. package/dist/chunk-QCQU4BQL.js.map +0 -1
  465. package/dist/chunk-QDGLIUUS.mjs +0 -16
  466. package/dist/chunk-QDGLIUUS.mjs.map +0 -1
  467. package/dist/chunk-RG4II6WH.js +0 -57
  468. package/dist/chunk-RG4II6WH.js.map +0 -1
  469. package/dist/chunk-TFFQFIJV.mjs +0 -54
  470. package/dist/chunk-TFFQFIJV.mjs.map +0 -1
  471. package/dist/chunk-TP7SP3AG.mjs +0 -133
  472. package/dist/chunk-TP7SP3AG.mjs.map +0 -1
  473. package/dist/chunk-U5UIDVOO.mjs +0 -36
  474. package/dist/chunk-U5UIDVOO.mjs.map +0 -1
  475. package/dist/chunk-UAXWZN5J.js +0 -58
  476. package/dist/chunk-UAXWZN5J.js.map +0 -1
  477. package/dist/chunk-UEHMUVQQ.js +0 -133
  478. package/dist/chunk-UEHMUVQQ.js.map +0 -1
  479. package/dist/chunk-UEWCUBMX.mjs +0 -68
  480. package/dist/chunk-UEWCUBMX.mjs.map +0 -1
  481. package/dist/chunk-UHP2Y32K.mjs +0 -92
  482. package/dist/chunk-UHP2Y32K.mjs.map +0 -1
  483. package/dist/chunk-UHX7HJAI.js +0 -11
  484. package/dist/chunk-UHX7HJAI.js.map +0 -1
  485. package/dist/chunk-UIRAMHNM.js +0 -186
  486. package/dist/chunk-UIRAMHNM.js.map +0 -1
  487. package/dist/chunk-VWDRFRJU.js +0 -107
  488. package/dist/chunk-VWDRFRJU.js.map +0 -1
  489. package/dist/chunk-Y45XUW33.js +0 -129
  490. package/dist/chunk-Y45XUW33.js.map +0 -1
  491. package/dist/chunk-YHGWG3EQ.js +0 -29
  492. package/dist/chunk-YHGWG3EQ.js.map +0 -1
  493. package/dist/chunk-YLURF2PF.mjs +0 -157
  494. package/dist/chunk-YLURF2PF.mjs.map +0 -1
  495. package/dist/chunk-ZUPTMFEA.mjs +0 -28
  496. package/dist/chunk-ZUPTMFEA.mjs.map +0 -1
  497. package/dist/chunk-ZX2KHPXG.js +0 -106
  498. package/dist/chunk-ZX2KHPXG.js.map +0 -1
  499. package/dist/controllers/authentication/AuthenticationController.js +0 -13
  500. package/dist/controllers/authentication/AuthenticationController.js.map +0 -1
  501. package/dist/controllers/authentication/auth-snap-requests.js +0 -10
  502. package/dist/controllers/authentication/auth-snap-requests.js.map +0 -1
  503. package/dist/controllers/authentication/index.js +0 -19
  504. package/dist/controllers/authentication/index.js.map +0 -1
  505. package/dist/controllers/authentication/services.js +0 -21
  506. package/dist/controllers/authentication/services.js.map +0 -1
  507. package/dist/controllers/index.js +0 -25
  508. package/dist/controllers/index.js.map +0 -1
  509. package/dist/controllers/user-storage/UserStorageController.js +0 -20
  510. package/dist/controllers/user-storage/UserStorageController.js.map +0 -1
  511. package/dist/controllers/user-storage/accounts/constants.js +0 -12
  512. package/dist/controllers/user-storage/accounts/constants.js.map +0 -1
  513. package/dist/controllers/user-storage/accounts/user-storage.js +0 -11
  514. package/dist/controllers/user-storage/accounts/user-storage.js.map +0 -1
  515. package/dist/controllers/user-storage/encryption/cache.js +0 -13
  516. package/dist/controllers/user-storage/encryption/cache.js.map +0 -1
  517. package/dist/controllers/user-storage/encryption/encryption.js +0 -12
  518. package/dist/controllers/user-storage/encryption/encryption.js.map +0 -1
  519. package/dist/controllers/user-storage/encryption/index.js +0 -16
  520. package/dist/controllers/user-storage/encryption/index.js.map +0 -1
  521. package/dist/controllers/user-storage/encryption/utils.js +0 -12
  522. package/dist/controllers/user-storage/encryption/utils.js.map +0 -1
  523. package/dist/controllers/user-storage/index.js +0 -31
  524. package/dist/controllers/user-storage/index.js.map +0 -1
  525. package/dist/controllers/user-storage/schema.js +0 -18
  526. package/dist/controllers/user-storage/schema.js.map +0 -1
  527. package/dist/controllers/user-storage/services.js +0 -22
  528. package/dist/controllers/user-storage/services.js.map +0 -1
  529. package/dist/index.js +0 -40
  530. package/dist/index.js.map +0 -1
  531. package/dist/sdk/authentication-jwt-bearer/flow-siwe.js +0 -13
  532. package/dist/sdk/authentication-jwt-bearer/flow-siwe.js.map +0 -1
  533. package/dist/sdk/authentication-jwt-bearer/flow-srp.js +0 -15
  534. package/dist/sdk/authentication-jwt-bearer/flow-srp.js.map +0 -1
  535. package/dist/sdk/authentication-jwt-bearer/services.js +0 -27
  536. package/dist/sdk/authentication-jwt-bearer/services.js.map +0 -1
  537. package/dist/sdk/authentication-jwt-bearer/types.js +0 -8
  538. package/dist/sdk/authentication-jwt-bearer/types.js.map +0 -1
  539. package/dist/sdk/authentication.js +0 -26
  540. package/dist/sdk/authentication.js.map +0 -1
  541. package/dist/sdk/encryption.js +0 -14
  542. package/dist/sdk/encryption.js.map +0 -1
  543. package/dist/sdk/env.js +0 -14
  544. package/dist/sdk/env.js.map +0 -1
  545. package/dist/sdk/errors.js +0 -20
  546. package/dist/sdk/errors.js.map +0 -1
  547. package/dist/sdk/index.js +0 -79
  548. package/dist/sdk/index.js.map +0 -1
  549. package/dist/sdk/user-storage.js +0 -18
  550. package/dist/sdk/user-storage.js.map +0 -1
  551. package/dist/sdk/utils/eip-6963-metamask-provider.js +0 -10
  552. package/dist/sdk/utils/eip-6963-metamask-provider.js.map +0 -1
  553. package/dist/sdk/utils/messaging-signing-snap-requests.js +0 -18
  554. package/dist/sdk/utils/messaging-signing-snap-requests.js.map +0 -1
  555. package/dist/sdk/utils/validate-login-response.js +0 -8
  556. package/dist/sdk/utils/validate-login-response.js.map +0 -1
  557. package/dist/tsconfig.build.tsbuildinfo +0 -1
  558. package/dist/types/controllers/authentication/AuthenticationController.d.ts.map +0 -1
  559. package/dist/types/controllers/authentication/__fixtures__/index.d.ts +0 -2
  560. package/dist/types/controllers/authentication/__fixtures__/index.d.ts.map +0 -1
  561. package/dist/types/controllers/authentication/__fixtures__/mockResponses.d.ts.map +0 -1
  562. package/dist/types/controllers/authentication/__fixtures__/mockServices.d.ts.map +0 -1
  563. package/dist/types/controllers/authentication/auth-snap-requests.d.ts.map +0 -1
  564. package/dist/types/controllers/authentication/index.d.ts +0 -7
  565. package/dist/types/controllers/authentication/index.d.ts.map +0 -1
  566. package/dist/types/controllers/authentication/services.d.ts.map +0 -1
  567. package/dist/types/controllers/index.d.ts +0 -3
  568. package/dist/types/controllers/index.d.ts.map +0 -1
  569. package/dist/types/controllers/user-storage/UserStorageController.d.ts.map +0 -1
  570. package/dist/types/controllers/user-storage/__fixtures__/index.d.ts +0 -3
  571. package/dist/types/controllers/user-storage/__fixtures__/index.d.ts.map +0 -1
  572. package/dist/types/controllers/user-storage/__fixtures__/mockAccounts.d.ts.map +0 -1
  573. package/dist/types/controllers/user-storage/__fixtures__/mockResponses.d.ts.map +0 -1
  574. package/dist/types/controllers/user-storage/__fixtures__/mockServices.d.ts.map +0 -1
  575. package/dist/types/controllers/user-storage/__fixtures__/mockStorage.d.ts.map +0 -1
  576. package/dist/types/controllers/user-storage/accounts/constants.d.ts.map +0 -1
  577. package/dist/types/controllers/user-storage/accounts/user-storage.d.ts.map +0 -1
  578. package/dist/types/controllers/user-storage/encryption/cache.d.ts.map +0 -1
  579. package/dist/types/controllers/user-storage/encryption/encryption.d.ts.map +0 -1
  580. package/dist/types/controllers/user-storage/encryption/index.d.ts +0 -5
  581. package/dist/types/controllers/user-storage/encryption/index.d.ts.map +0 -1
  582. package/dist/types/controllers/user-storage/encryption/utils.d.ts.map +0 -1
  583. package/dist/types/controllers/user-storage/index.d.ts +0 -8
  584. package/dist/types/controllers/user-storage/index.d.ts.map +0 -1
  585. package/dist/types/controllers/user-storage/schema.d.ts.map +0 -1
  586. package/dist/types/controllers/user-storage/services.d.ts.map +0 -1
  587. package/dist/types/index.d.ts +0 -4
  588. package/dist/types/index.d.ts.map +0 -1
  589. package/dist/types/sdk/__fixtures__/mock-auth.d.ts.map +0 -1
  590. package/dist/types/sdk/__fixtures__/mock-userstorage.d.ts.map +0 -1
  591. package/dist/types/sdk/__fixtures__/test-utils.d.ts.map +0 -1
  592. package/dist/types/sdk/authentication-jwt-bearer/flow-siwe.d.ts.map +0 -1
  593. package/dist/types/sdk/authentication-jwt-bearer/flow-srp.d.ts.map +0 -1
  594. package/dist/types/sdk/authentication-jwt-bearer/services.d.ts.map +0 -1
  595. package/dist/types/sdk/authentication-jwt-bearer/types.d.ts.map +0 -1
  596. package/dist/types/sdk/authentication.d.ts.map +0 -1
  597. package/dist/types/sdk/encryption.d.ts +0 -4
  598. package/dist/types/sdk/encryption.d.ts.map +0 -1
  599. package/dist/types/sdk/env.d.ts.map +0 -1
  600. package/dist/types/sdk/errors.d.ts.map +0 -1
  601. package/dist/types/sdk/index.d.ts +0 -7
  602. package/dist/types/sdk/index.d.ts.map +0 -1
  603. package/dist/types/sdk/user-storage.d.ts.map +0 -1
  604. package/dist/types/sdk/utils/eip-6963-metamask-provider.d.ts.map +0 -1
  605. package/dist/types/sdk/utils/messaging-signing-snap-requests.d.ts.map +0 -1
  606. package/dist/types/sdk/utils/validate-login-response.d.ts.map +0 -1
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toNetworkConfiguration = exports.toRemoteNetworkConfiguration = void 0;
4
+ const toRemoteNetworkConfiguration = (network) => {
5
+ return {
6
+ ...network,
7
+ v: '1',
8
+ };
9
+ };
10
+ exports.toRemoteNetworkConfiguration = toRemoteNetworkConfiguration;
11
+ const toNetworkConfiguration = (network) => {
12
+ const { v: _v, d: _d, ...originalNetwork } = network;
13
+ return originalNetwork;
14
+ };
15
+ exports.toNetworkConfiguration = toNetworkConfiguration;
16
+ //# sourceMappingURL=types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/network-syncing/types.ts"],"names":[],"mappings":";;;AAmBO,MAAM,4BAA4B,GAAG,CAC1C,OAA6B,EACD,EAAE;IAC9B,OAAO;QACL,GAAG,OAAO;QACV,CAAC,EAAE,GAAG;KACP,CAAC;AACJ,CAAC,CAAC;AAPW,QAAA,4BAA4B,gCAOvC;AAEK,MAAM,sBAAsB,GAAG,CACpC,OAAmC,EACb,EAAE;IACxB,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,GAAG,eAAe,EAAE,GAAG,OAAO,CAAC;IACrD,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC;AALW,QAAA,sBAAsB,0BAKjC","sourcesContent":["import type { NetworkConfiguration as _NetworkConfiguration } from '@metamask/network-controller';\n\n// TODO - replace shim once we update NetworkController type\nexport type NetworkConfiguration = _NetworkConfiguration & {\n lastUpdatedAt?: number;\n};\n\nexport type RemoteNetworkConfiguration = NetworkConfiguration & {\n /**\n * `version` property. Enables future versioning of the `NetworkConfiguration` shape\n */\n v: '1';\n /**\n * isDeleted property, used for soft deletion & for correct syncing\n * (delete vs upload network)\n */\n d?: boolean;\n};\n\nexport const toRemoteNetworkConfiguration = (\n network: NetworkConfiguration,\n): RemoteNetworkConfiguration => {\n return {\n ...network,\n v: '1',\n };\n};\n\nexport const toNetworkConfiguration = (\n network: RemoteNetworkConfiguration,\n): NetworkConfiguration => {\n const { v: _v, d: _d, ...originalNetwork } = network;\n return originalNetwork;\n};\n"]}
@@ -0,0 +1,18 @@
1
+ import type { NetworkConfiguration as _NetworkConfiguration } from "@metamask/network-controller";
2
+ export type NetworkConfiguration = _NetworkConfiguration & {
3
+ lastUpdatedAt?: number;
4
+ };
5
+ export type RemoteNetworkConfiguration = NetworkConfiguration & {
6
+ /**
7
+ * `version` property. Enables future versioning of the `NetworkConfiguration` shape
8
+ */
9
+ v: '1';
10
+ /**
11
+ * isDeleted property, used for soft deletion & for correct syncing
12
+ * (delete vs upload network)
13
+ */
14
+ d?: boolean;
15
+ };
16
+ export declare const toRemoteNetworkConfiguration: (network: NetworkConfiguration) => RemoteNetworkConfiguration;
17
+ export declare const toNetworkConfiguration: (network: RemoteNetworkConfiguration) => NetworkConfiguration;
18
+ //# sourceMappingURL=types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/network-syncing/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,IAAI,qBAAqB,EAAE,qCAAqC;AAGlG,MAAM,MAAM,oBAAoB,GAAG,qBAAqB,GAAG;IACzD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG,oBAAoB,GAAG;IAC9D;;OAEG;IACH,CAAC,EAAE,GAAG,CAAC;IACP;;;OAGG;IACH,CAAC,CAAC,EAAE,OAAO,CAAC;CACb,CAAC;AAEF,eAAO,MAAM,4BAA4B,YAC9B,oBAAoB,KAC5B,0BAKF,CAAC;AAEF,eAAO,MAAM,sBAAsB,YACxB,0BAA0B,KAClC,oBAGF,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { NetworkConfiguration as _NetworkConfiguration } from "@metamask/network-controller";
2
+ export type NetworkConfiguration = _NetworkConfiguration & {
3
+ lastUpdatedAt?: number;
4
+ };
5
+ export type RemoteNetworkConfiguration = NetworkConfiguration & {
6
+ /**
7
+ * `version` property. Enables future versioning of the `NetworkConfiguration` shape
8
+ */
9
+ v: '1';
10
+ /**
11
+ * isDeleted property, used for soft deletion & for correct syncing
12
+ * (delete vs upload network)
13
+ */
14
+ d?: boolean;
15
+ };
16
+ export declare const toRemoteNetworkConfiguration: (network: NetworkConfiguration) => RemoteNetworkConfiguration;
17
+ export declare const toNetworkConfiguration: (network: RemoteNetworkConfiguration) => NetworkConfiguration;
18
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../../../src/controllers/user-storage/network-syncing/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,IAAI,qBAAqB,EAAE,qCAAqC;AAGlG,MAAM,MAAM,oBAAoB,GAAG,qBAAqB,GAAG;IACzD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG,oBAAoB,GAAG;IAC9D;;OAEG;IACH,CAAC,EAAE,GAAG,CAAC;IACP;;;OAGG;IACH,CAAC,CAAC,EAAE,OAAO,CAAC;CACb,CAAC;AAEF,eAAO,MAAM,4BAA4B,YAC9B,oBAAoB,KAC5B,0BAKF,CAAC;AAEF,eAAO,MAAM,sBAAsB,YACxB,0BAA0B,KAClC,oBAGF,CAAC"}
@@ -0,0 +1,11 @@
1
+ export const toRemoteNetworkConfiguration = (network) => {
2
+ return {
3
+ ...network,
4
+ v: '1',
5
+ };
6
+ };
7
+ export const toNetworkConfiguration = (network) => {
8
+ const { v: _v, d: _d, ...originalNetwork } = network;
9
+ return originalNetwork;
10
+ };
11
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../../src/controllers/user-storage/network-syncing/types.ts"],"names":[],"mappings":"AAmBA,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC1C,OAA6B,EACD,EAAE;IAC9B,OAAO;QACL,GAAG,OAAO;QACV,CAAC,EAAE,GAAG;KACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,OAAmC,EACb,EAAE;IACxB,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,GAAG,eAAe,EAAE,GAAG,OAAO,CAAC;IACrD,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC","sourcesContent":["import type { NetworkConfiguration as _NetworkConfiguration } from '@metamask/network-controller';\n\n// TODO - replace shim once we update NetworkController type\nexport type NetworkConfiguration = _NetworkConfiguration & {\n lastUpdatedAt?: number;\n};\n\nexport type RemoteNetworkConfiguration = NetworkConfiguration & {\n /**\n * `version` property. Enables future versioning of the `NetworkConfiguration` shape\n */\n v: '1';\n /**\n * isDeleted property, used for soft deletion & for correct syncing\n * (delete vs upload network)\n */\n d?: boolean;\n};\n\nexport const toRemoteNetworkConfiguration = (\n network: NetworkConfiguration,\n): RemoteNetworkConfiguration => {\n return {\n ...network,\n v: '1',\n };\n};\n\nexport const toNetworkConfiguration = (\n network: RemoteNetworkConfiguration,\n): NetworkConfiguration => {\n const { v: _v, d: _d, ...originalNetwork } = network;\n return originalNetwork;\n};\n"]}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createEntryPath = exports.isPathWithFeatureAndKey = exports.getFeatureAndKeyFromPath = exports.USER_STORAGE_SCHEMA = void 0;
4
+ const encryption_1 = require("./encryption/index.cjs");
5
+ /**
6
+ * The User Storage Endpoint requires a feature name and a namespace key.
7
+ * Developers can provide additional features and keys by extending these types below.
8
+ *
9
+ * Adding ALLOW_ARBITRARY_KEYS as the first key in the array allows for any key to be used for this feature.
10
+ * This can be useful for features where keys are not deterministic (eg. accounts addresses).
11
+ */
12
+ const ALLOW_ARBITRARY_KEYS = 'ALLOW_ARBITRARY_KEYS';
13
+ exports.USER_STORAGE_SCHEMA = {
14
+ notifications: ['notificationSettings'],
15
+ accounts: [ALLOW_ARBITRARY_KEYS],
16
+ networks: [ALLOW_ARBITRARY_KEYS], // keyed by chains/networks
17
+ };
18
+ const getFeatureAndKeyFromPath = (path) => {
19
+ const pathRegex = /^\w+\.\w+$/u;
20
+ if (!pathRegex.test(path)) {
21
+ throw new Error(`user-storage - path is not in the correct format. Correct format: 'feature.key'`);
22
+ }
23
+ const [feature, key] = path.split('.');
24
+ if (!(feature in exports.USER_STORAGE_SCHEMA)) {
25
+ throw new Error(`user-storage - invalid feature provided: ${feature}`);
26
+ }
27
+ const validFeature = exports.USER_STORAGE_SCHEMA[feature];
28
+ if (!validFeature.includes(key) &&
29
+ !validFeature.includes(ALLOW_ARBITRARY_KEYS)) {
30
+ const validKeys = exports.USER_STORAGE_SCHEMA[feature].join(', ');
31
+ throw new Error(`user-storage - invalid key provided for this feature: ${key}. Valid keys: ${validKeys}`);
32
+ }
33
+ return { feature, key };
34
+ };
35
+ exports.getFeatureAndKeyFromPath = getFeatureAndKeyFromPath;
36
+ const isPathWithFeatureAndKey = (path) => {
37
+ const pathRegex = /^\w+\.\w+$/u;
38
+ return pathRegex.test(path);
39
+ };
40
+ exports.isPathWithFeatureAndKey = isPathWithFeatureAndKey;
41
+ /**
42
+ * Constructs a unique entry path for a user.
43
+ * This can be done due to the uniqueness of the storage key (no users will share the same storage key).
44
+ * The users entry is a unique hash that cannot be reversed.
45
+ *
46
+ * @param path - string in the form of `${feature}.${key}` that matches schema
47
+ * @param storageKey - users storage key
48
+ * @returns path to store entry
49
+ */
50
+ function createEntryPath(path, storageKey) {
51
+ const { feature, key } = (0, exports.getFeatureAndKeyFromPath)(path);
52
+ const hashedKey = (0, encryption_1.createSHA256Hash)(key + storageKey);
53
+ return `${feature}/${hashedKey}`;
54
+ }
55
+ exports.createEntryPath = createEntryPath;
56
+ //# sourceMappingURL=schema.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.cjs","sourceRoot":"","sources":["../../../src/controllers/user-storage/schema.ts"],"names":[],"mappings":";;;AAAA,uDAAgD;AAEhD;;;;;;GAMG;AACH,MAAM,oBAAoB,GAAG,sBAA+B,CAAC;AAEhD,QAAA,mBAAmB,GAAG;IACjC,aAAa,EAAE,CAAC,sBAAsB,CAAC;IACvC,QAAQ,EAAE,CAAC,oBAAoB,CAAC;IAChC,QAAQ,EAAE,CAAC,oBAAoB,CAAC,EAAE,2BAA2B;CACrD,CAAC;AAoBJ,MAAM,wBAAwB,GAAG,CACtC,IAAsC,EACZ,EAAE;IAC5B,MAAM,SAAS,GAAG,aAAa,CAAC;IAEhC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACzB,MAAM,IAAI,KAAK,CACb,iFAAiF,CAClF,CAAC;KACH;IAED,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAGpC,CAAC;IAEF,IAAI,CAAC,CAAC,OAAO,IAAI,2BAAmB,CAAC,EAAE;QACrC,MAAM,IAAI,KAAK,CAAC,4CAA4C,OAAO,EAAE,CAAC,CAAC;KACxE;IAED,MAAM,YAAY,GAAG,2BAAmB,CAAC,OAAO,CAAsB,CAAC;IAEvE,IACE,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC;QAC3B,CAAC,YAAY,CAAC,QAAQ,CAAC,oBAAoB,CAAC,EAC5C;QACA,MAAM,SAAS,GAAG,2BAAmB,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE1D,MAAM,IAAI,KAAK,CACb,yDAAyD,GAAG,iBAAiB,SAAS,EAAE,CACzF,CAAC;KACH;IAED,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;AAC1B,CAAC,CAAC;AAlCW,QAAA,wBAAwB,4BAkCnC;AAEK,MAAM,uBAAuB,GAAG,CACrC,IAAY,EAC8B,EAAE;IAC5C,MAAM,SAAS,GAAG,aAAa,CAAC;IAEhC,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC,CAAC;AANW,QAAA,uBAAuB,2BAMlC;AAEF;;;;;;;;GAQG;AACH,SAAgB,eAAe,CAC7B,IAAsC,EACtC,UAAkB;IAElB,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,IAAA,gCAAwB,EAAC,IAAI,CAAC,CAAC;IACxD,MAAM,SAAS,GAAG,IAAA,6BAAgB,EAAC,GAAG,GAAG,UAAU,CAAC,CAAC;IAErD,OAAO,GAAG,OAAO,IAAI,SAAS,EAAE,CAAC;AACnC,CAAC;AARD,0CAQC","sourcesContent":["import { createSHA256Hash } from './encryption';\n\n/**\n * The User Storage Endpoint requires a feature name and a namespace key.\n * Developers can provide additional features and keys by extending these types below.\n *\n * Adding ALLOW_ARBITRARY_KEYS as the first key in the array allows for any key to be used for this feature.\n * This can be useful for features where keys are not deterministic (eg. accounts addresses).\n */\nconst ALLOW_ARBITRARY_KEYS = 'ALLOW_ARBITRARY_KEYS' as const;\n\nexport const USER_STORAGE_SCHEMA = {\n notifications: ['notificationSettings'],\n accounts: [ALLOW_ARBITRARY_KEYS], // keyed by account addresses\n networks: [ALLOW_ARBITRARY_KEYS], // keyed by chains/networks\n} as const;\n\ntype UserStorageSchema = typeof USER_STORAGE_SCHEMA;\n\ntype UserStorageFeatures = keyof UserStorageSchema;\ntype UserStorageFeatureKeys<Feature extends UserStorageFeatures> =\n UserStorageSchema[Feature][0] extends typeof ALLOW_ARBITRARY_KEYS\n ? string\n : UserStorageSchema[Feature][number];\n\ntype UserStorageFeatureAndKey = {\n feature: UserStorageFeatures;\n key: UserStorageFeatureKeys<UserStorageFeatures>;\n};\n\nexport type UserStoragePathWithFeatureOnly = keyof UserStorageSchema;\nexport type UserStoragePathWithFeatureAndKey = {\n [K in UserStorageFeatures]: `${K}.${UserStorageFeatureKeys<K>}`;\n}[UserStoragePathWithFeatureOnly];\n\nexport const getFeatureAndKeyFromPath = (\n path: UserStoragePathWithFeatureAndKey,\n): UserStorageFeatureAndKey => {\n const pathRegex = /^\\w+\\.\\w+$/u;\n\n if (!pathRegex.test(path)) {\n throw new Error(\n `user-storage - path is not in the correct format. Correct format: 'feature.key'`,\n );\n }\n\n const [feature, key] = path.split('.') as [\n UserStorageFeatures,\n UserStorageFeatureKeys<UserStorageFeatures>,\n ];\n\n if (!(feature in USER_STORAGE_SCHEMA)) {\n throw new Error(`user-storage - invalid feature provided: ${feature}`);\n }\n\n const validFeature = USER_STORAGE_SCHEMA[feature] as readonly string[];\n\n if (\n !validFeature.includes(key) &&\n !validFeature.includes(ALLOW_ARBITRARY_KEYS)\n ) {\n const validKeys = USER_STORAGE_SCHEMA[feature].join(', ');\n\n throw new Error(\n `user-storage - invalid key provided for this feature: ${key}. Valid keys: ${validKeys}`,\n );\n }\n\n return { feature, key };\n};\n\nexport const isPathWithFeatureAndKey = (\n path: string,\n): path is UserStoragePathWithFeatureAndKey => {\n const pathRegex = /^\\w+\\.\\w+$/u;\n\n return pathRegex.test(path);\n};\n\n/**\n * Constructs a unique entry path for a user.\n * This can be done due to the uniqueness of the storage key (no users will share the same storage key).\n * The users entry is a unique hash that cannot be reversed.\n *\n * @param path - string in the form of `${feature}.${key}` that matches schema\n * @param storageKey - users storage key\n * @returns path to store entry\n */\nexport function createEntryPath(\n path: UserStoragePathWithFeatureAndKey,\n storageKey: string,\n): string {\n const { feature, key } = getFeatureAndKeyFromPath(path);\n const hashedKey = createSHA256Hash(key + storageKey);\n\n return `${feature}/${hashedKey}`;\n}\n"]}
@@ -9,6 +9,7 @@ declare const ALLOW_ARBITRARY_KEYS: "ALLOW_ARBITRARY_KEYS";
9
9
  export declare const USER_STORAGE_SCHEMA: {
10
10
  readonly notifications: readonly ["notificationSettings"];
11
11
  readonly accounts: readonly ["ALLOW_ARBITRARY_KEYS"];
12
+ readonly networks: readonly ["ALLOW_ARBITRARY_KEYS"];
12
13
  };
13
14
  type UserStorageSchema = typeof USER_STORAGE_SCHEMA;
14
15
  type UserStorageFeatures = keyof UserStorageSchema;
@@ -34,4 +35,4 @@ export declare const isPathWithFeatureAndKey: (path: string) => path is UserStor
34
35
  */
35
36
  export declare function createEntryPath(path: UserStoragePathWithFeatureAndKey, storageKey: string): string;
36
37
  export {};
37
- //# sourceMappingURL=schema.d.ts.map
38
+ //# sourceMappingURL=schema.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.cts","sourceRoot":"","sources":["../../../src/controllers/user-storage/schema.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,QAAA,MAAM,oBAAoB,wBAAkC,CAAC;AAE7D,eAAO,MAAM,mBAAmB;;;;CAItB,CAAC;AAEX,KAAK,iBAAiB,GAAG,OAAO,mBAAmB,CAAC;AAEpD,KAAK,mBAAmB,GAAG,MAAM,iBAAiB,CAAC;AACnD,KAAK,sBAAsB,CAAC,OAAO,SAAS,mBAAmB,IAC7D,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,OAAO,oBAAoB,GAC7D,MAAM,GACN,iBAAiB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzC,KAAK,wBAAwB,GAAG;IAC9B,OAAO,EAAE,mBAAmB,CAAC;IAC7B,GAAG,EAAE,sBAAsB,CAAC,mBAAmB,CAAC,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG,MAAM,iBAAiB,CAAC;AACrE,MAAM,MAAM,gCAAgC,GAAG;KAC5C,CAAC,IAAI,mBAAmB,GAAG,GAAG,CAAC,IAAI,sBAAsB,CAAC,CAAC,CAAC,EAAE;CAChE,CAAC,8BAA8B,CAAC,CAAC;AAElC,eAAO,MAAM,wBAAwB,SAC7B,gCAAgC,KACrC,wBAgCF,CAAC;AAEF,eAAO,MAAM,uBAAuB,SAC5B,MAAM,6CAKb,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,gCAAgC,EACtC,UAAU,EAAE,MAAM,GACjB,MAAM,CAKR"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The User Storage Endpoint requires a feature name and a namespace key.
3
+ * Developers can provide additional features and keys by extending these types below.
4
+ *
5
+ * Adding ALLOW_ARBITRARY_KEYS as the first key in the array allows for any key to be used for this feature.
6
+ * This can be useful for features where keys are not deterministic (eg. accounts addresses).
7
+ */
8
+ declare const ALLOW_ARBITRARY_KEYS: "ALLOW_ARBITRARY_KEYS";
9
+ export declare const USER_STORAGE_SCHEMA: {
10
+ readonly notifications: readonly ["notificationSettings"];
11
+ readonly accounts: readonly ["ALLOW_ARBITRARY_KEYS"];
12
+ readonly networks: readonly ["ALLOW_ARBITRARY_KEYS"];
13
+ };
14
+ type UserStorageSchema = typeof USER_STORAGE_SCHEMA;
15
+ type UserStorageFeatures = keyof UserStorageSchema;
16
+ type UserStorageFeatureKeys<Feature extends UserStorageFeatures> = UserStorageSchema[Feature][0] extends typeof ALLOW_ARBITRARY_KEYS ? string : UserStorageSchema[Feature][number];
17
+ type UserStorageFeatureAndKey = {
18
+ feature: UserStorageFeatures;
19
+ key: UserStorageFeatureKeys<UserStorageFeatures>;
20
+ };
21
+ export type UserStoragePathWithFeatureOnly = keyof UserStorageSchema;
22
+ export type UserStoragePathWithFeatureAndKey = {
23
+ [K in UserStorageFeatures]: `${K}.${UserStorageFeatureKeys<K>}`;
24
+ }[UserStoragePathWithFeatureOnly];
25
+ export declare const getFeatureAndKeyFromPath: (path: UserStoragePathWithFeatureAndKey) => UserStorageFeatureAndKey;
26
+ export declare const isPathWithFeatureAndKey: (path: string) => path is UserStoragePathWithFeatureAndKey;
27
+ /**
28
+ * Constructs a unique entry path for a user.
29
+ * This can be done due to the uniqueness of the storage key (no users will share the same storage key).
30
+ * The users entry is a unique hash that cannot be reversed.
31
+ *
32
+ * @param path - string in the form of `${feature}.${key}` that matches schema
33
+ * @param storageKey - users storage key
34
+ * @returns path to store entry
35
+ */
36
+ export declare function createEntryPath(path: UserStoragePathWithFeatureAndKey, storageKey: string): string;
37
+ export {};
38
+ //# sourceMappingURL=schema.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.mts","sourceRoot":"","sources":["../../../src/controllers/user-storage/schema.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,QAAA,MAAM,oBAAoB,wBAAkC,CAAC;AAE7D,eAAO,MAAM,mBAAmB;;;;CAItB,CAAC;AAEX,KAAK,iBAAiB,GAAG,OAAO,mBAAmB,CAAC;AAEpD,KAAK,mBAAmB,GAAG,MAAM,iBAAiB,CAAC;AACnD,KAAK,sBAAsB,CAAC,OAAO,SAAS,mBAAmB,IAC7D,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,OAAO,oBAAoB,GAC7D,MAAM,GACN,iBAAiB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzC,KAAK,wBAAwB,GAAG;IAC9B,OAAO,EAAE,mBAAmB,CAAC;IAC7B,GAAG,EAAE,sBAAsB,CAAC,mBAAmB,CAAC,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG,MAAM,iBAAiB,CAAC;AACrE,MAAM,MAAM,gCAAgC,GAAG;KAC5C,CAAC,IAAI,mBAAmB,GAAG,GAAG,CAAC,IAAI,sBAAsB,CAAC,CAAC,CAAC,EAAE;CAChE,CAAC,8BAA8B,CAAC,CAAC;AAElC,eAAO,MAAM,wBAAwB,SAC7B,gCAAgC,KACrC,wBAgCF,CAAC;AAEF,eAAO,MAAM,uBAAuB,SAC5B,MAAM,6CAKb,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,gCAAgC,EACtC,UAAU,EAAE,MAAM,GACjB,MAAM,CAKR"}
@@ -1,18 +1,50 @@
1
- import {
2
- USER_STORAGE_SCHEMA,
3
- createEntryPath,
4
- getFeatureAndKeyFromPath,
5
- isPathWithFeatureAndKey
6
- } from "../../chunk-2VEMA6OE.mjs";
7
- import "../../chunk-KHASG4H3.mjs";
8
- import "../../chunk-COBJUBZE.mjs";
9
- import "../../chunk-H25EBXG5.mjs";
10
- import "../../chunk-76VRE4BI.mjs";
11
- import "../../chunk-U5UIDVOO.mjs";
12
- export {
13
- USER_STORAGE_SCHEMA,
14
- createEntryPath,
15
- getFeatureAndKeyFromPath,
16
- isPathWithFeatureAndKey
1
+ import { createSHA256Hash } from "./encryption/index.mjs";
2
+ /**
3
+ * The User Storage Endpoint requires a feature name and a namespace key.
4
+ * Developers can provide additional features and keys by extending these types below.
5
+ *
6
+ * Adding ALLOW_ARBITRARY_KEYS as the first key in the array allows for any key to be used for this feature.
7
+ * This can be useful for features where keys are not deterministic (eg. accounts addresses).
8
+ */
9
+ const ALLOW_ARBITRARY_KEYS = 'ALLOW_ARBITRARY_KEYS';
10
+ export const USER_STORAGE_SCHEMA = {
11
+ notifications: ['notificationSettings'],
12
+ accounts: [ALLOW_ARBITRARY_KEYS],
13
+ networks: [ALLOW_ARBITRARY_KEYS], // keyed by chains/networks
17
14
  };
15
+ export const getFeatureAndKeyFromPath = (path) => {
16
+ const pathRegex = /^\w+\.\w+$/u;
17
+ if (!pathRegex.test(path)) {
18
+ throw new Error(`user-storage - path is not in the correct format. Correct format: 'feature.key'`);
19
+ }
20
+ const [feature, key] = path.split('.');
21
+ if (!(feature in USER_STORAGE_SCHEMA)) {
22
+ throw new Error(`user-storage - invalid feature provided: ${feature}`);
23
+ }
24
+ const validFeature = USER_STORAGE_SCHEMA[feature];
25
+ if (!validFeature.includes(key) &&
26
+ !validFeature.includes(ALLOW_ARBITRARY_KEYS)) {
27
+ const validKeys = USER_STORAGE_SCHEMA[feature].join(', ');
28
+ throw new Error(`user-storage - invalid key provided for this feature: ${key}. Valid keys: ${validKeys}`);
29
+ }
30
+ return { feature, key };
31
+ };
32
+ export const isPathWithFeatureAndKey = (path) => {
33
+ const pathRegex = /^\w+\.\w+$/u;
34
+ return pathRegex.test(path);
35
+ };
36
+ /**
37
+ * Constructs a unique entry path for a user.
38
+ * This can be done due to the uniqueness of the storage key (no users will share the same storage key).
39
+ * The users entry is a unique hash that cannot be reversed.
40
+ *
41
+ * @param path - string in the form of `${feature}.${key}` that matches schema
42
+ * @param storageKey - users storage key
43
+ * @returns path to store entry
44
+ */
45
+ export function createEntryPath(path, storageKey) {
46
+ const { feature, key } = getFeatureAndKeyFromPath(path);
47
+ const hashedKey = createSHA256Hash(key + storageKey);
48
+ return `${feature}/${hashedKey}`;
49
+ }
18
50
  //# sourceMappingURL=schema.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"schema.mjs","sourceRoot":"","sources":["../../../src/controllers/user-storage/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,+BAAqB;AAEhD;;;;;;GAMG;AACH,MAAM,oBAAoB,GAAG,sBAA+B,CAAC;AAE7D,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,aAAa,EAAE,CAAC,sBAAsB,CAAC;IACvC,QAAQ,EAAE,CAAC,oBAAoB,CAAC;IAChC,QAAQ,EAAE,CAAC,oBAAoB,CAAC,EAAE,2BAA2B;CACrD,CAAC;AAoBX,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,IAAsC,EACZ,EAAE;IAC5B,MAAM,SAAS,GAAG,aAAa,CAAC;IAEhC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACzB,MAAM,IAAI,KAAK,CACb,iFAAiF,CAClF,CAAC;KACH;IAED,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAGpC,CAAC;IAEF,IAAI,CAAC,CAAC,OAAO,IAAI,mBAAmB,CAAC,EAAE;QACrC,MAAM,IAAI,KAAK,CAAC,4CAA4C,OAAO,EAAE,CAAC,CAAC;KACxE;IAED,MAAM,YAAY,GAAG,mBAAmB,CAAC,OAAO,CAAsB,CAAC;IAEvE,IACE,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC;QAC3B,CAAC,YAAY,CAAC,QAAQ,CAAC,oBAAoB,CAAC,EAC5C;QACA,MAAM,SAAS,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE1D,MAAM,IAAI,KAAK,CACb,yDAAyD,GAAG,iBAAiB,SAAS,EAAE,CACzF,CAAC;KACH;IAED,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;AAC1B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,IAAY,EAC8B,EAAE;IAC5C,MAAM,SAAS,GAAG,aAAa,CAAC;IAEhC,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAC7B,IAAsC,EACtC,UAAkB;IAElB,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,wBAAwB,CAAC,IAAI,CAAC,CAAC;IACxD,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,GAAG,UAAU,CAAC,CAAC;IAErD,OAAO,GAAG,OAAO,IAAI,SAAS,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import { createSHA256Hash } from './encryption';\n\n/**\n * The User Storage Endpoint requires a feature name and a namespace key.\n * Developers can provide additional features and keys by extending these types below.\n *\n * Adding ALLOW_ARBITRARY_KEYS as the first key in the array allows for any key to be used for this feature.\n * This can be useful for features where keys are not deterministic (eg. accounts addresses).\n */\nconst ALLOW_ARBITRARY_KEYS = 'ALLOW_ARBITRARY_KEYS' as const;\n\nexport const USER_STORAGE_SCHEMA = {\n notifications: ['notificationSettings'],\n accounts: [ALLOW_ARBITRARY_KEYS], // keyed by account addresses\n networks: [ALLOW_ARBITRARY_KEYS], // keyed by chains/networks\n} as const;\n\ntype UserStorageSchema = typeof USER_STORAGE_SCHEMA;\n\ntype UserStorageFeatures = keyof UserStorageSchema;\ntype UserStorageFeatureKeys<Feature extends UserStorageFeatures> =\n UserStorageSchema[Feature][0] extends typeof ALLOW_ARBITRARY_KEYS\n ? string\n : UserStorageSchema[Feature][number];\n\ntype UserStorageFeatureAndKey = {\n feature: UserStorageFeatures;\n key: UserStorageFeatureKeys<UserStorageFeatures>;\n};\n\nexport type UserStoragePathWithFeatureOnly = keyof UserStorageSchema;\nexport type UserStoragePathWithFeatureAndKey = {\n [K in UserStorageFeatures]: `${K}.${UserStorageFeatureKeys<K>}`;\n}[UserStoragePathWithFeatureOnly];\n\nexport const getFeatureAndKeyFromPath = (\n path: UserStoragePathWithFeatureAndKey,\n): UserStorageFeatureAndKey => {\n const pathRegex = /^\\w+\\.\\w+$/u;\n\n if (!pathRegex.test(path)) {\n throw new Error(\n `user-storage - path is not in the correct format. Correct format: 'feature.key'`,\n );\n }\n\n const [feature, key] = path.split('.') as [\n UserStorageFeatures,\n UserStorageFeatureKeys<UserStorageFeatures>,\n ];\n\n if (!(feature in USER_STORAGE_SCHEMA)) {\n throw new Error(`user-storage - invalid feature provided: ${feature}`);\n }\n\n const validFeature = USER_STORAGE_SCHEMA[feature] as readonly string[];\n\n if (\n !validFeature.includes(key) &&\n !validFeature.includes(ALLOW_ARBITRARY_KEYS)\n ) {\n const validKeys = USER_STORAGE_SCHEMA[feature].join(', ');\n\n throw new Error(\n `user-storage - invalid key provided for this feature: ${key}. Valid keys: ${validKeys}`,\n );\n }\n\n return { feature, key };\n};\n\nexport const isPathWithFeatureAndKey = (\n path: string,\n): path is UserStoragePathWithFeatureAndKey => {\n const pathRegex = /^\\w+\\.\\w+$/u;\n\n return pathRegex.test(path);\n};\n\n/**\n * Constructs a unique entry path for a user.\n * This can be done due to the uniqueness of the storage key (no users will share the same storage key).\n * The users entry is a unique hash that cannot be reversed.\n *\n * @param path - string in the form of `${feature}.${key}` that matches schema\n * @param storageKey - users storage key\n * @returns path to store entry\n */\nexport function createEntryPath(\n path: UserStoragePathWithFeatureAndKey,\n storageKey: string,\n): string {\n const { feature, key } = getFeatureAndKeyFromPath(path);\n const hashedKey = createSHA256Hash(key + storageKey);\n\n return `${feature}/${hashedKey}`;\n}\n"]}
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.upsertUserStorage = exports.getUserStorageAllFeatureEntries = exports.getUserStorage = exports.USER_STORAGE_ENDPOINT = exports.USER_STORAGE_API = void 0;
7
+ const loglevel_1 = __importDefault(require("loglevel"));
8
+ const env_1 = require("../../sdk/env.cjs");
9
+ const encryption_1 = __importDefault(require("./encryption/index.cjs"));
10
+ const schema_1 = require("./schema.cjs");
11
+ const ENV_URLS = (0, env_1.getEnvUrls)(env_1.Env.PRD);
12
+ exports.USER_STORAGE_API = ENV_URLS.userStorageApiUrl;
13
+ exports.USER_STORAGE_ENDPOINT = `${exports.USER_STORAGE_API}/api/v1/userstorage`;
14
+ /**
15
+ * User Storage Service - Get Storage Entry.
16
+ *
17
+ * @param opts - User Storage Options
18
+ * @returns The storage entry, or null if fails to find entry
19
+ */
20
+ async function getUserStorage(opts) {
21
+ try {
22
+ const { bearerToken, path, storageKey, nativeScryptCrypto } = opts;
23
+ const encryptedPath = (0, schema_1.createEntryPath)(path, storageKey);
24
+ const url = new URL(`${exports.USER_STORAGE_ENDPOINT}/${encryptedPath}`);
25
+ const userStorageResponse = await fetch(url.toString(), {
26
+ headers: {
27
+ 'Content-Type': 'application/json',
28
+ Authorization: `Bearer ${bearerToken}`,
29
+ },
30
+ });
31
+ // Acceptable error - since indicates entry does not exist.
32
+ if (userStorageResponse.status === 404) {
33
+ return null;
34
+ }
35
+ if (userStorageResponse.status !== 200) {
36
+ throw new Error('Unable to get User Storage');
37
+ }
38
+ const userStorage = await userStorageResponse.json();
39
+ const encryptedData = userStorage?.Data ?? null;
40
+ if (!encryptedData) {
41
+ return null;
42
+ }
43
+ const decryptedData = await encryption_1.default.decryptString(encryptedData, opts.storageKey, nativeScryptCrypto);
44
+ return decryptedData;
45
+ }
46
+ catch (e) {
47
+ loglevel_1.default.error('Failed to get user storage', e);
48
+ return null;
49
+ }
50
+ }
51
+ exports.getUserStorage = getUserStorage;
52
+ /**
53
+ * User Storage Service - Get all storage entries for a specific feature.
54
+ *
55
+ * @param opts - User Storage Options
56
+ * @returns The storage entry, or null if fails to find entry
57
+ */
58
+ async function getUserStorageAllFeatureEntries(opts) {
59
+ try {
60
+ const { bearerToken, path, nativeScryptCrypto } = opts;
61
+ const url = new URL(`${exports.USER_STORAGE_ENDPOINT}/${path}`);
62
+ const userStorageResponse = await fetch(url.toString(), {
63
+ headers: {
64
+ 'Content-Type': 'application/json',
65
+ Authorization: `Bearer ${bearerToken}`,
66
+ },
67
+ });
68
+ // Acceptable error - since indicates feature does not exist.
69
+ if (userStorageResponse.status === 404) {
70
+ return null;
71
+ }
72
+ if (userStorageResponse.status !== 200) {
73
+ throw new Error('Unable to get User Storage');
74
+ }
75
+ const userStorage = await userStorageResponse.json();
76
+ if (!Array.isArray(userStorage)) {
77
+ return null;
78
+ }
79
+ const decryptedData = userStorage?.flatMap((entry) => {
80
+ if (!entry.Data) {
81
+ return [];
82
+ }
83
+ return encryption_1.default.decryptString(entry.Data, opts.storageKey, nativeScryptCrypto);
84
+ });
85
+ return (await Promise.allSettled(decryptedData))
86
+ .map((d) => (d.status === 'fulfilled' ? d.value : undefined))
87
+ .filter((d) => d !== undefined);
88
+ }
89
+ catch (e) {
90
+ loglevel_1.default.error('Failed to get user storage', e);
91
+ return null;
92
+ }
93
+ }
94
+ exports.getUserStorageAllFeatureEntries = getUserStorageAllFeatureEntries;
95
+ /**
96
+ * User Storage Service - Set Storage Entry.
97
+ *
98
+ * @param data - data to store
99
+ * @param opts - storage options
100
+ */
101
+ async function upsertUserStorage(data, opts) {
102
+ const { bearerToken, path, storageKey, nativeScryptCrypto } = opts;
103
+ const encryptedData = await encryption_1.default.encryptString(data, opts.storageKey, nativeScryptCrypto);
104
+ const encryptedPath = (0, schema_1.createEntryPath)(path, storageKey);
105
+ const url = new URL(`${exports.USER_STORAGE_ENDPOINT}/${encryptedPath}`);
106
+ const res = await fetch(url.toString(), {
107
+ method: 'PUT',
108
+ headers: {
109
+ 'Content-Type': 'application/json',
110
+ Authorization: `Bearer ${bearerToken}`,
111
+ },
112
+ body: JSON.stringify({ data: encryptedData }),
113
+ });
114
+ if (!res.ok) {
115
+ throw new Error('user-storage - unable to upsert data');
116
+ }
117
+ }
118
+ exports.upsertUserStorage = upsertUserStorage;
119
+ //# sourceMappingURL=services.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"services.cjs","sourceRoot":"","sources":["../../../src/controllers/user-storage/services.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA2B;AAE3B,2CAAgD;AAChD,wEAAsC;AAKtC,yCAA2C;AAG3C,MAAM,QAAQ,GAAG,IAAA,gBAAU,EAAC,SAAG,CAAC,GAAG,CAAC,CAAC;AAExB,QAAA,gBAAgB,GAAW,QAAQ,CAAC,iBAAiB,CAAC;AACtD,QAAA,qBAAqB,GAAG,GAAG,wBAAgB,qBAAqB,CAAC;AAiC9E;;;;;GAKG;AACI,KAAK,UAAU,cAAc,CAClC,IAAwB;IAExB,IAAI;QACF,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,kBAAkB,EAAE,GAAG,IAAI,CAAC;QAEnE,MAAM,aAAa,GAAG,IAAA,wBAAe,EAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QACxD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,6BAAqB,IAAI,aAAa,EAAE,CAAC,CAAC;QAEjE,MAAM,mBAAmB,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE;YACtD,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,aAAa,EAAE,UAAU,WAAW,EAAE;aACvC;SACF,CAAC,CAAC;QAEH,2DAA2D;QAC3D,IAAI,mBAAmB,CAAC,MAAM,KAAK,GAAG,EAAE;YACtC,OAAO,IAAI,CAAC;SACb;QAED,IAAI,mBAAmB,CAAC,MAAM,KAAK,GAAG,EAAE;YACtC,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;SAC/C;QAED,MAAM,WAAW,GACf,MAAM,mBAAmB,CAAC,IAAI,EAAE,CAAC;QACnC,MAAM,aAAa,GAAG,WAAW,EAAE,IAAI,IAAI,IAAI,CAAC;QAEhD,IAAI,CAAC,aAAa,EAAE;YAClB,OAAO,IAAI,CAAC;SACb;QAED,MAAM,aAAa,GAAG,MAAM,oBAAU,CAAC,aAAa,CAClD,aAAa,EACb,IAAI,CAAC,UAAU,EACf,kBAAkB,CACnB,CAAC;QAEF,OAAO,aAAa,CAAC;KACtB;IAAC,OAAO,CAAC,EAAE;QACV,kBAAG,CAAC,KAAK,CAAC,4BAA4B,EAAE,CAAC,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC;KACb;AACH,CAAC;AA5CD,wCA4CC;AAED;;;;;GAKG;AACI,KAAK,UAAU,+BAA+B,CACnD,IAAyC;IAEzC,IAAI;QACF,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,kBAAkB,EAAE,GAAG,IAAI,CAAC;QACvD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,6BAAqB,IAAI,IAAI,EAAE,CAAC,CAAC;QAExD,MAAM,mBAAmB,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE;YACtD,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,aAAa,EAAE,UAAU,WAAW,EAAE;aACvC;SACF,CAAC,CAAC;QAEH,6DAA6D;QAC7D,IAAI,mBAAmB,CAAC,MAAM,KAAK,GAAG,EAAE;YACtC,OAAO,IAAI,CAAC;SACb;QAED,IAAI,mBAAmB,CAAC,MAAM,KAAK,GAAG,EAAE;YACtC,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;SAC/C;QAED,MAAM,WAAW,GACf,MAAM,mBAAmB,CAAC,IAAI,EAAE,CAAC;QAEnC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;YAC/B,OAAO,IAAI,CAAC;SACb;QAED,MAAM,aAAa,GAAG,WAAW,EAAE,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YACnD,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;gBACf,OAAO,EAAE,CAAC;aACX;YAED,OAAO,oBAAU,CAAC,aAAa,CAC7B,KAAK,CAAC,IAAI,EACV,IAAI,CAAC,UAAU,EACf,kBAAkB,CACnB,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,MAAM,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;aAC7C,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;aAC5D,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC;KAChD;IAAC,OAAO,CAAC,EAAE;QACV,kBAAG,CAAC,KAAK,CAAC,4BAA4B,EAAE,CAAC,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC;KACb;AACH,CAAC;AAjDD,0EAiDC;AAED;;;;;GAKG;AACI,KAAK,UAAU,iBAAiB,CACrC,IAAY,EACZ,IAAwB;IAExB,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,kBAAkB,EAAE,GAAG,IAAI,CAAC;IAEnE,MAAM,aAAa,GAAG,MAAM,oBAAU,CAAC,aAAa,CAClD,IAAI,EACJ,IAAI,CAAC,UAAU,EACf,kBAAkB,CACnB,CAAC;IACF,MAAM,aAAa,GAAG,IAAA,wBAAe,EAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACxD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,6BAAqB,IAAI,aAAa,EAAE,CAAC,CAAC;IAEjE,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE;QACtC,MAAM,EAAE,KAAK;QACb,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,aAAa,EAAE,UAAU,WAAW,EAAE;SACvC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;KAC9C,CAAC,CAAC;IAEH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;KACzD;AACH,CAAC;AA1BD,8CA0BC","sourcesContent":["import log from 'loglevel';\n\nimport { Env, getEnvUrls } from '../../sdk/env';\nimport encryption from './encryption';\nimport type {\n UserStoragePathWithFeatureAndKey,\n UserStoragePathWithFeatureOnly,\n} from './schema';\nimport { createEntryPath } from './schema';\nimport type { NativeScrypt } from './UserStorageController';\n\nconst ENV_URLS = getEnvUrls(Env.PRD);\n\nexport const USER_STORAGE_API: string = ENV_URLS.userStorageApiUrl;\nexport const USER_STORAGE_ENDPOINT = `${USER_STORAGE_API}/api/v1/userstorage`;\n\n/**\n * This is the Server Response shape for a feature entry.\n */\nexport type GetUserStorageResponse = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n HashedKey: string;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n Data: string;\n};\n\nexport type GetUserStorageAllFeatureEntriesResponse = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n HashedKey: string;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n Data: string;\n}[];\n\nexport type UserStorageBaseOptions = {\n bearerToken: string;\n storageKey: string;\n nativeScryptCrypto?: NativeScrypt;\n};\n\nexport type UserStorageOptions = UserStorageBaseOptions & {\n path: UserStoragePathWithFeatureAndKey;\n};\n\nexport type UserStorageAllFeatureEntriesOptions = UserStorageBaseOptions & {\n path: UserStoragePathWithFeatureOnly;\n};\n\n/**\n * User Storage Service - Get Storage Entry.\n *\n * @param opts - User Storage Options\n * @returns The storage entry, or null if fails to find entry\n */\nexport async function getUserStorage(\n opts: UserStorageOptions,\n): Promise<string | null> {\n try {\n const { bearerToken, path, storageKey, nativeScryptCrypto } = opts;\n\n const encryptedPath = createEntryPath(path, storageKey);\n const url = new URL(`${USER_STORAGE_ENDPOINT}/${encryptedPath}`);\n\n const userStorageResponse = await fetch(url.toString(), {\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${bearerToken}`,\n },\n });\n\n // Acceptable error - since indicates entry does not exist.\n if (userStorageResponse.status === 404) {\n return null;\n }\n\n if (userStorageResponse.status !== 200) {\n throw new Error('Unable to get User Storage');\n }\n\n const userStorage: GetUserStorageResponse | null =\n await userStorageResponse.json();\n const encryptedData = userStorage?.Data ?? null;\n\n if (!encryptedData) {\n return null;\n }\n\n const decryptedData = await encryption.decryptString(\n encryptedData,\n opts.storageKey,\n nativeScryptCrypto,\n );\n\n return decryptedData;\n } catch (e) {\n log.error('Failed to get user storage', e);\n return null;\n }\n}\n\n/**\n * User Storage Service - Get all storage entries for a specific feature.\n *\n * @param opts - User Storage Options\n * @returns The storage entry, or null if fails to find entry\n */\nexport async function getUserStorageAllFeatureEntries(\n opts: UserStorageAllFeatureEntriesOptions,\n): Promise<string[] | null> {\n try {\n const { bearerToken, path, nativeScryptCrypto } = opts;\n const url = new URL(`${USER_STORAGE_ENDPOINT}/${path}`);\n\n const userStorageResponse = await fetch(url.toString(), {\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${bearerToken}`,\n },\n });\n\n // Acceptable error - since indicates feature does not exist.\n if (userStorageResponse.status === 404) {\n return null;\n }\n\n if (userStorageResponse.status !== 200) {\n throw new Error('Unable to get User Storage');\n }\n\n const userStorage: GetUserStorageAllFeatureEntriesResponse | null =\n await userStorageResponse.json();\n\n if (!Array.isArray(userStorage)) {\n return null;\n }\n\n const decryptedData = userStorage?.flatMap((entry) => {\n if (!entry.Data) {\n return [];\n }\n\n return encryption.decryptString(\n entry.Data,\n opts.storageKey,\n nativeScryptCrypto,\n );\n });\n\n return (await Promise.allSettled(decryptedData))\n .map((d) => (d.status === 'fulfilled' ? d.value : undefined))\n .filter((d): d is string => d !== undefined);\n } catch (e) {\n log.error('Failed to get user storage', e);\n return null;\n }\n}\n\n/**\n * User Storage Service - Set Storage Entry.\n *\n * @param data - data to store\n * @param opts - storage options\n */\nexport async function upsertUserStorage(\n data: string,\n opts: UserStorageOptions,\n): Promise<void> {\n const { bearerToken, path, storageKey, nativeScryptCrypto } = opts;\n\n const encryptedData = await encryption.encryptString(\n data,\n opts.storageKey,\n nativeScryptCrypto,\n );\n const encryptedPath = createEntryPath(path, storageKey);\n const url = new URL(`${USER_STORAGE_ENDPOINT}/${encryptedPath}`);\n\n const res = await fetch(url.toString(), {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${bearerToken}`,\n },\n body: JSON.stringify({ data: encryptedData }),\n });\n\n if (!res.ok) {\n throw new Error('user-storage - unable to upsert data');\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
- import type { UserStoragePathWithFeatureAndKey, UserStoragePathWithFeatureOnly } from './schema';
2
- import type { NativeScrypt } from './UserStorageController';
1
+ import type { UserStoragePathWithFeatureAndKey, UserStoragePathWithFeatureOnly } from "./schema.cjs";
2
+ import type { NativeScrypt } from "./UserStorageController.cjs";
3
3
  export declare const USER_STORAGE_API: string;
4
4
  export declare const USER_STORAGE_ENDPOINT: string;
5
5
  /**
@@ -16,14 +16,13 @@ export type GetUserStorageAllFeatureEntriesResponse = {
16
16
  export type UserStorageBaseOptions = {
17
17
  bearerToken: string;
18
18
  storageKey: string;
19
+ nativeScryptCrypto?: NativeScrypt;
19
20
  };
20
21
  export type UserStorageOptions = UserStorageBaseOptions & {
21
22
  path: UserStoragePathWithFeatureAndKey;
22
- nativeScryptCrypto?: NativeScrypt;
23
23
  };
24
24
  export type UserStorageAllFeatureEntriesOptions = UserStorageBaseOptions & {
25
25
  path: UserStoragePathWithFeatureOnly;
26
- nativeScryptCrypto?: NativeScrypt;
27
26
  };
28
27
  /**
29
28
  * User Storage Service - Get Storage Entry.
@@ -46,4 +45,4 @@ export declare function getUserStorageAllFeatureEntries(opts: UserStorageAllFeat
46
45
  * @param opts - storage options
47
46
  */
48
47
  export declare function upsertUserStorage(data: string, opts: UserStorageOptions): Promise<void>;
49
- //# sourceMappingURL=services.d.ts.map
48
+ //# sourceMappingURL=services.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"services.d.cts","sourceRoot":"","sources":["../../../src/controllers/user-storage/services.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,gCAAgC,EAChC,8BAA8B,EAC/B,qBAAiB;AAElB,OAAO,KAAK,EAAE,YAAY,EAAE,oCAAgC;AAI5D,eAAO,MAAM,gBAAgB,EAAE,MAAmC,CAAC;AACnE,eAAO,MAAM,qBAAqB,QAA2C,CAAC;AAE9E;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IAEnC,SAAS,EAAE,MAAM,CAAC;IAElB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,uCAAuC,GAAG;IAEpD,SAAS,EAAE,MAAM,CAAC;IAElB,IAAI,EAAE,MAAM,CAAC;CACd,EAAE,CAAC;AAEJ,MAAM,MAAM,sBAAsB,GAAG;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,YAAY,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,GAAG;IACxD,IAAI,EAAE,gCAAgC,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAAG,sBAAsB,GAAG;IACzE,IAAI,EAAE,8BAA8B,CAAC;CACtC,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA0CxB;AAED;;;;;GAKG;AACH,wBAAsB,+BAA+B,CACnD,IAAI,EAAE,mCAAmC,GACxC,OAAO,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CA+C1B;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,IAAI,CAAC,CAuBf"}
@@ -0,0 +1,48 @@
1
+ import type { UserStoragePathWithFeatureAndKey, UserStoragePathWithFeatureOnly } from "./schema.mjs";
2
+ import type { NativeScrypt } from "./UserStorageController.mjs";
3
+ export declare const USER_STORAGE_API: string;
4
+ export declare const USER_STORAGE_ENDPOINT: string;
5
+ /**
6
+ * This is the Server Response shape for a feature entry.
7
+ */
8
+ export type GetUserStorageResponse = {
9
+ HashedKey: string;
10
+ Data: string;
11
+ };
12
+ export type GetUserStorageAllFeatureEntriesResponse = {
13
+ HashedKey: string;
14
+ Data: string;
15
+ }[];
16
+ export type UserStorageBaseOptions = {
17
+ bearerToken: string;
18
+ storageKey: string;
19
+ nativeScryptCrypto?: NativeScrypt;
20
+ };
21
+ export type UserStorageOptions = UserStorageBaseOptions & {
22
+ path: UserStoragePathWithFeatureAndKey;
23
+ };
24
+ export type UserStorageAllFeatureEntriesOptions = UserStorageBaseOptions & {
25
+ path: UserStoragePathWithFeatureOnly;
26
+ };
27
+ /**
28
+ * User Storage Service - Get Storage Entry.
29
+ *
30
+ * @param opts - User Storage Options
31
+ * @returns The storage entry, or null if fails to find entry
32
+ */
33
+ export declare function getUserStorage(opts: UserStorageOptions): Promise<string | null>;
34
+ /**
35
+ * User Storage Service - Get all storage entries for a specific feature.
36
+ *
37
+ * @param opts - User Storage Options
38
+ * @returns The storage entry, or null if fails to find entry
39
+ */
40
+ export declare function getUserStorageAllFeatureEntries(opts: UserStorageAllFeatureEntriesOptions): Promise<string[] | null>;
41
+ /**
42
+ * User Storage Service - Set Storage Entry.
43
+ *
44
+ * @param data - data to store
45
+ * @param opts - storage options
46
+ */
47
+ export declare function upsertUserStorage(data: string, opts: UserStorageOptions): Promise<void>;
48
+ //# sourceMappingURL=services.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"services.d.mts","sourceRoot":"","sources":["../../../src/controllers/user-storage/services.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,gCAAgC,EAChC,8BAA8B,EAC/B,qBAAiB;AAElB,OAAO,KAAK,EAAE,YAAY,EAAE,oCAAgC;AAI5D,eAAO,MAAM,gBAAgB,EAAE,MAAmC,CAAC;AACnE,eAAO,MAAM,qBAAqB,QAA2C,CAAC;AAE9E;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IAEnC,SAAS,EAAE,MAAM,CAAC;IAElB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,uCAAuC,GAAG;IAEpD,SAAS,EAAE,MAAM,CAAC;IAElB,IAAI,EAAE,MAAM,CAAC;CACd,EAAE,CAAC;AAEJ,MAAM,MAAM,sBAAsB,GAAG;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,YAAY,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,GAAG;IACxD,IAAI,EAAE,gCAAgC,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAAG,sBAAsB,GAAG;IACzE,IAAI,EAAE,8BAA8B,CAAC;CACtC,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA0CxB;AAED;;;;;GAKG;AACH,wBAAsB,+BAA+B,CACnD,IAAI,EAAE,mCAAmC,GACxC,OAAO,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CA+C1B;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,IAAI,CAAC,CAuBf"}