@metamask/profile-sync-controller 0.5.0 → 0.7.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 (611) hide show
  1. package/CHANGELOG.md +51 -1
  2. package/auth/mocks/package.json +2 -2
  3. package/auth/package.json +2 -2
  4. package/dist/controllers/authentication/AuthenticationController.cjs +211 -0
  5. package/dist/controllers/authentication/AuthenticationController.cjs.map +1 -0
  6. package/dist/{types/controllers/authentication/AuthenticationController.d.ts → controllers/authentication/AuthenticationController.d.cts} +5 -5
  7. package/dist/controllers/authentication/AuthenticationController.d.cts.map +1 -0
  8. package/dist/controllers/authentication/AuthenticationController.d.mts +78 -0
  9. package/dist/controllers/authentication/AuthenticationController.d.mts.map +1 -0
  10. package/dist/controllers/authentication/AuthenticationController.mjs +206 -11
  11. package/dist/controllers/authentication/AuthenticationController.mjs.map +1 -1
  12. package/dist/controllers/authentication/__fixtures__/index.cjs +18 -0
  13. package/dist/controllers/authentication/__fixtures__/index.cjs.map +1 -0
  14. package/dist/controllers/authentication/__fixtures__/index.d.cts +2 -0
  15. package/dist/controllers/authentication/__fixtures__/index.d.cts.map +1 -0
  16. package/dist/controllers/authentication/__fixtures__/index.d.mts +2 -0
  17. package/dist/controllers/authentication/__fixtures__/index.d.mts.map +1 -0
  18. package/dist/controllers/authentication/__fixtures__/index.mjs +2 -0
  19. package/dist/controllers/authentication/__fixtures__/index.mjs.map +1 -0
  20. package/dist/controllers/authentication/__fixtures__/mockResponses.cjs +52 -0
  21. package/dist/controllers/authentication/__fixtures__/mockResponses.cjs.map +1 -0
  22. package/dist/{types/controllers/authentication/__fixtures__/mockResponses.d.ts → controllers/authentication/__fixtures__/mockResponses.d.cts} +2 -2
  23. package/dist/controllers/authentication/__fixtures__/mockResponses.d.cts.map +1 -0
  24. package/dist/controllers/authentication/__fixtures__/mockResponses.d.mts +23 -0
  25. package/dist/controllers/authentication/__fixtures__/mockResponses.d.mts.map +1 -0
  26. package/dist/controllers/authentication/__fixtures__/mockResponses.mjs +46 -0
  27. package/dist/controllers/authentication/__fixtures__/mockResponses.mjs.map +1 -0
  28. package/dist/controllers/authentication/__fixtures__/mockServices.cjs +37 -0
  29. package/dist/controllers/authentication/__fixtures__/mockServices.cjs.map +1 -0
  30. package/dist/{types/controllers/authentication/__fixtures__/mockServices.d.ts → controllers/authentication/__fixtures__/mockServices.d.cts} +2 -2
  31. package/dist/controllers/authentication/__fixtures__/mockServices.d.cts.map +1 -0
  32. package/dist/controllers/authentication/__fixtures__/mockServices.d.mts +10 -0
  33. package/dist/controllers/authentication/__fixtures__/mockServices.d.mts.map +1 -0
  34. package/dist/controllers/authentication/__fixtures__/mockServices.mjs +35 -0
  35. package/dist/controllers/authentication/__fixtures__/mockServices.mjs.map +1 -0
  36. package/dist/controllers/authentication/auth-snap-requests.cjs +39 -0
  37. package/dist/controllers/authentication/auth-snap-requests.cjs.map +1 -0
  38. package/dist/{types/controllers/authentication/auth-snap-requests.d.ts → controllers/authentication/auth-snap-requests.d.cts} +2 -2
  39. package/dist/controllers/authentication/auth-snap-requests.d.cts.map +1 -0
  40. package/dist/controllers/authentication/auth-snap-requests.d.mts +17 -0
  41. package/dist/controllers/authentication/auth-snap-requests.d.mts.map +1 -0
  42. package/dist/controllers/authentication/auth-snap-requests.mjs +33 -9
  43. package/dist/controllers/authentication/auth-snap-requests.mjs.map +1 -1
  44. package/dist/controllers/authentication/index.cjs +39 -0
  45. package/dist/controllers/authentication/index.cjs.map +1 -0
  46. package/dist/controllers/authentication/index.d.cts +7 -0
  47. package/dist/controllers/authentication/index.d.cts.map +1 -0
  48. package/dist/controllers/authentication/index.d.mts +7 -0
  49. package/dist/controllers/authentication/index.d.mts.map +1 -0
  50. package/dist/controllers/authentication/index.mjs +6 -18
  51. package/dist/controllers/authentication/index.mjs.map +1 -1
  52. package/dist/controllers/authentication/services.cjs +127 -0
  53. package/dist/controllers/authentication/services.cjs.map +1 -0
  54. package/dist/{types/controllers/authentication/services.d.ts → controllers/authentication/services.d.cts} +1 -1
  55. package/dist/controllers/authentication/services.d.cts.map +1 -0
  56. package/dist/controllers/authentication/services.d.mts +70 -0
  57. package/dist/controllers/authentication/services.d.mts.map +1 -0
  58. package/dist/controllers/authentication/services.mjs +118 -19
  59. package/dist/controllers/authentication/services.mjs.map +1 -1
  60. package/dist/controllers/index.cjs +29 -0
  61. package/dist/controllers/index.cjs.map +1 -0
  62. package/dist/controllers/index.d.cts +3 -0
  63. package/dist/controllers/index.d.cts.map +1 -0
  64. package/dist/controllers/index.d.mts +3 -0
  65. package/dist/controllers/index.d.mts.map +1 -0
  66. package/dist/controllers/index.mjs +2 -24
  67. package/dist/controllers/index.mjs.map +1 -1
  68. package/dist/controllers/user-storage/UserStorageController.cjs +462 -0
  69. package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -0
  70. package/dist/{types/controllers/user-storage/UserStorageController.d.ts → controllers/user-storage/UserStorageController.d.cts} +44 -15
  71. package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -0
  72. package/dist/controllers/user-storage/UserStorageController.d.mts +156 -0
  73. package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -0
  74. package/dist/controllers/user-storage/UserStorageController.mjs +457 -18
  75. package/dist/controllers/user-storage/UserStorageController.mjs.map +1 -1
  76. package/dist/controllers/user-storage/__fixtures__/index.cjs +19 -0
  77. package/dist/controllers/user-storage/__fixtures__/index.cjs.map +1 -0
  78. package/dist/controllers/user-storage/__fixtures__/index.d.cts +3 -0
  79. package/dist/controllers/user-storage/__fixtures__/index.d.cts.map +1 -0
  80. package/dist/controllers/user-storage/__fixtures__/index.d.mts +3 -0
  81. package/dist/controllers/user-storage/__fixtures__/index.d.mts.map +1 -0
  82. package/dist/controllers/user-storage/__fixtures__/index.mjs +3 -0
  83. package/dist/controllers/user-storage/__fixtures__/index.mjs.map +1 -0
  84. package/dist/controllers/user-storage/__fixtures__/mockAccounts.cjs +127 -0
  85. package/dist/controllers/user-storage/__fixtures__/mockAccounts.cjs.map +1 -0
  86. package/dist/{types/controllers/user-storage/__fixtures__/mockAccounts.d.ts → controllers/user-storage/__fixtures__/mockAccounts.d.cts} +6 -6
  87. package/dist/controllers/user-storage/__fixtures__/mockAccounts.d.cts.map +1 -0
  88. package/dist/controllers/user-storage/__fixtures__/mockAccounts.d.mts +63 -0
  89. package/dist/controllers/user-storage/__fixtures__/mockAccounts.d.mts.map +1 -0
  90. package/dist/controllers/user-storage/__fixtures__/mockAccounts.mjs +123 -0
  91. package/dist/controllers/user-storage/__fixtures__/mockAccounts.mjs.map +1 -0
  92. package/dist/controllers/user-storage/__fixtures__/mockResponses.cjs +48 -0
  93. package/dist/controllers/user-storage/__fixtures__/mockResponses.cjs.map +1 -0
  94. package/dist/{types/controllers/user-storage/__fixtures__/mockResponses.d.ts → controllers/user-storage/__fixtures__/mockResponses.d.cts} +6 -4
  95. package/dist/controllers/user-storage/__fixtures__/mockResponses.d.cts.map +1 -0
  96. package/dist/controllers/user-storage/__fixtures__/mockResponses.d.mts +21 -0
  97. package/dist/controllers/user-storage/__fixtures__/mockResponses.d.mts.map +1 -0
  98. package/dist/controllers/user-storage/__fixtures__/mockResponses.mjs +39 -0
  99. package/dist/controllers/user-storage/__fixtures__/mockResponses.mjs.map +1 -0
  100. package/dist/controllers/user-storage/__fixtures__/mockServices.cjs +41 -0
  101. package/dist/controllers/user-storage/__fixtures__/mockServices.cjs.map +1 -0
  102. package/dist/{types/controllers/user-storage/__fixtures__/mockServices.d.ts → controllers/user-storage/__fixtures__/mockServices.d.cts} +3 -3
  103. package/dist/controllers/user-storage/__fixtures__/mockServices.d.cts.map +1 -0
  104. package/dist/controllers/user-storage/__fixtures__/mockServices.d.mts +11 -0
  105. package/dist/controllers/user-storage/__fixtures__/mockServices.d.mts.map +1 -0
  106. package/dist/controllers/user-storage/__fixtures__/mockServices.mjs +39 -0
  107. package/dist/controllers/user-storage/__fixtures__/mockServices.mjs.map +1 -0
  108. package/dist/controllers/user-storage/__fixtures__/mockStorage.cjs +36 -0
  109. package/dist/controllers/user-storage/__fixtures__/mockStorage.cjs.map +1 -0
  110. package/dist/{types/controllers/user-storage/__fixtures__/mockStorage.d.ts → controllers/user-storage/__fixtures__/mockStorage.d.cts} +2 -2
  111. package/dist/controllers/user-storage/__fixtures__/mockStorage.d.cts.map +1 -0
  112. package/dist/controllers/user-storage/__fixtures__/mockStorage.d.mts +5 -0
  113. package/dist/controllers/user-storage/__fixtures__/mockStorage.d.mts.map +1 -0
  114. package/dist/controllers/user-storage/__fixtures__/mockStorage.mjs +9 -0
  115. package/dist/controllers/user-storage/__fixtures__/mockStorage.mjs.map +1 -0
  116. package/dist/controllers/user-storage/__fixtures__/test-utils.cjs +31 -0
  117. package/dist/controllers/user-storage/__fixtures__/test-utils.cjs.map +1 -0
  118. package/dist/controllers/user-storage/__fixtures__/test-utils.d.cts +14 -0
  119. package/dist/controllers/user-storage/__fixtures__/test-utils.d.cts.map +1 -0
  120. package/dist/controllers/user-storage/__fixtures__/test-utils.d.mts +14 -0
  121. package/dist/controllers/user-storage/__fixtures__/test-utils.d.mts.map +1 -0
  122. package/dist/controllers/user-storage/__fixtures__/test-utils.mjs +27 -0
  123. package/dist/controllers/user-storage/__fixtures__/test-utils.mjs.map +1 -0
  124. package/dist/controllers/user-storage/accounts/constants.cjs +51 -0
  125. package/dist/controllers/user-storage/accounts/constants.cjs.map +1 -0
  126. package/dist/{types/controllers/user-storage/accounts/constants.d.ts → controllers/user-storage/accounts/constants.d.cts} +1 -1
  127. package/dist/controllers/user-storage/accounts/constants.d.cts.map +1 -0
  128. package/dist/controllers/user-storage/accounts/constants.d.mts +4 -0
  129. package/dist/controllers/user-storage/accounts/constants.d.mts.map +1 -0
  130. package/dist/controllers/user-storage/accounts/constants.mjs +47 -11
  131. package/dist/controllers/user-storage/accounts/constants.mjs.map +1 -1
  132. package/dist/controllers/user-storage/accounts/user-storage.cjs +34 -0
  133. package/dist/controllers/user-storage/accounts/user-storage.cjs.map +1 -0
  134. package/dist/{types/controllers/user-storage/accounts/user-storage.d.ts → controllers/user-storage/accounts/user-storage.d.cts} +3 -3
  135. package/dist/controllers/user-storage/accounts/user-storage.d.cts.map +1 -0
  136. package/dist/controllers/user-storage/accounts/user-storage.d.mts +32 -0
  137. package/dist/controllers/user-storage/accounts/user-storage.d.mts.map +1 -0
  138. package/dist/controllers/user-storage/accounts/user-storage.mjs +27 -9
  139. package/dist/controllers/user-storage/accounts/user-storage.mjs.map +1 -1
  140. package/dist/controllers/user-storage/encryption/cache.cjs +79 -0
  141. package/dist/controllers/user-storage/encryption/cache.cjs.map +1 -0
  142. package/dist/{types/controllers/user-storage/encryption/cache.d.ts → controllers/user-storage/encryption/cache.d.cts} +1 -1
  143. package/dist/controllers/user-storage/encryption/cache.d.cts.map +1 -0
  144. package/dist/controllers/user-storage/encryption/cache.d.mts +31 -0
  145. package/dist/controllers/user-storage/encryption/cache.d.mts.map +1 -0
  146. package/dist/controllers/user-storage/encryption/cache.mjs +71 -11
  147. package/dist/controllers/user-storage/encryption/cache.mjs.map +1 -1
  148. package/dist/controllers/user-storage/encryption/encryption.cjs +151 -0
  149. package/dist/controllers/user-storage/encryption/encryption.cjs.map +1 -0
  150. package/dist/{types/controllers/user-storage/encryption/encryption.d.ts → controllers/user-storage/encryption/encryption.d.cts} +2 -2
  151. package/dist/controllers/user-storage/encryption/encryption.d.cts.map +1 -0
  152. package/dist/controllers/user-storage/encryption/encryption.d.mts +27 -0
  153. package/dist/controllers/user-storage/encryption/encryption.d.mts.map +1 -0
  154. package/dist/controllers/user-storage/encryption/encryption.mjs +145 -10
  155. package/dist/controllers/user-storage/encryption/encryption.mjs.map +1 -1
  156. package/dist/controllers/user-storage/encryption/index.cjs +25 -0
  157. package/dist/controllers/user-storage/encryption/index.cjs.map +1 -0
  158. package/dist/controllers/user-storage/encryption/index.d.cts +5 -0
  159. package/dist/controllers/user-storage/encryption/index.d.cts.map +1 -0
  160. package/dist/controllers/user-storage/encryption/index.d.mts +5 -0
  161. package/dist/controllers/user-storage/encryption/index.d.mts.map +1 -0
  162. package/dist/controllers/user-storage/encryption/index.mjs +4 -15
  163. package/dist/controllers/user-storage/encryption/index.mjs.map +1 -1
  164. package/dist/controllers/user-storage/encryption/utils.cjs +17 -0
  165. package/dist/controllers/user-storage/encryption/utils.cjs.map +1 -0
  166. package/dist/{types/controllers/user-storage/encryption/utils.d.ts → controllers/user-storage/encryption/utils.d.cts} +1 -1
  167. package/dist/controllers/user-storage/encryption/utils.d.cts.map +1 -0
  168. package/dist/controllers/user-storage/encryption/utils.d.mts +4 -0
  169. package/dist/controllers/user-storage/encryption/utils.d.mts.map +1 -0
  170. package/dist/controllers/user-storage/encryption/utils.mjs +9 -10
  171. package/dist/controllers/user-storage/encryption/utils.mjs.map +1 -1
  172. package/dist/controllers/user-storage/index.cjs +40 -0
  173. package/dist/controllers/user-storage/index.cjs.map +1 -0
  174. package/dist/controllers/user-storage/index.d.cts +8 -0
  175. package/dist/controllers/user-storage/index.d.cts.map +1 -0
  176. package/dist/controllers/user-storage/index.d.mts +8 -0
  177. package/dist/controllers/user-storage/index.d.mts.map +1 -0
  178. package/dist/controllers/user-storage/index.mjs +7 -30
  179. package/dist/controllers/user-storage/index.mjs.map +1 -1
  180. package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.cjs +25 -0
  181. package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.cjs.map +1 -0
  182. package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.d.cts +4 -0
  183. package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.d.cts.map +1 -0
  184. package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.d.mts +4 -0
  185. package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.d.mts.map +1 -0
  186. package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.mjs +20 -0
  187. package/dist/controllers/user-storage/network-syncing/__fixtures__/mockNetwork.mjs.map +1 -0
  188. package/dist/controllers/user-storage/network-syncing/controller-integration.cjs +65 -0
  189. package/dist/controllers/user-storage/network-syncing/controller-integration.cjs.map +1 -0
  190. package/dist/controllers/user-storage/network-syncing/controller-integration.d.cts +13 -0
  191. package/dist/controllers/user-storage/network-syncing/controller-integration.d.cts.map +1 -0
  192. package/dist/controllers/user-storage/network-syncing/controller-integration.d.mts +13 -0
  193. package/dist/controllers/user-storage/network-syncing/controller-integration.d.mts.map +1 -0
  194. package/dist/controllers/user-storage/network-syncing/controller-integration.mjs +65 -0
  195. package/dist/controllers/user-storage/network-syncing/controller-integration.mjs.map +1 -0
  196. package/dist/controllers/user-storage/network-syncing/services.cjs +64 -0
  197. package/dist/controllers/user-storage/network-syncing/services.cjs.map +1 -0
  198. package/dist/controllers/user-storage/network-syncing/services.d.cts +21 -0
  199. package/dist/controllers/user-storage/network-syncing/services.d.cts.map +1 -0
  200. package/dist/controllers/user-storage/network-syncing/services.d.mts +21 -0
  201. package/dist/controllers/user-storage/network-syncing/services.d.mts.map +1 -0
  202. package/dist/controllers/user-storage/network-syncing/services.mjs +58 -0
  203. package/dist/controllers/user-storage/network-syncing/services.mjs.map +1 -0
  204. package/dist/controllers/user-storage/network-syncing/sync-all.cjs +171 -0
  205. package/dist/controllers/user-storage/network-syncing/sync-all.cjs.map +1 -0
  206. package/dist/controllers/user-storage/network-syncing/sync-all.d.cts +35 -0
  207. package/dist/controllers/user-storage/network-syncing/sync-all.d.cts.map +1 -0
  208. package/dist/controllers/user-storage/network-syncing/sync-all.d.mts +35 -0
  209. package/dist/controllers/user-storage/network-syncing/sync-all.d.mts.map +1 -0
  210. package/dist/controllers/user-storage/network-syncing/sync-all.mjs +162 -0
  211. package/dist/controllers/user-storage/network-syncing/sync-all.mjs.map +1 -0
  212. package/dist/controllers/user-storage/network-syncing/sync-mutations.cjs +28 -0
  213. package/dist/controllers/user-storage/network-syncing/sync-mutations.cjs.map +1 -0
  214. package/dist/controllers/user-storage/network-syncing/sync-mutations.d.cts +9 -0
  215. package/dist/controllers/user-storage/network-syncing/sync-mutations.d.cts.map +1 -0
  216. package/dist/controllers/user-storage/network-syncing/sync-mutations.d.mts +9 -0
  217. package/dist/controllers/user-storage/network-syncing/sync-mutations.d.mts.map +1 -0
  218. package/dist/controllers/user-storage/network-syncing/sync-mutations.mjs +22 -0
  219. package/dist/controllers/user-storage/network-syncing/sync-mutations.mjs.map +1 -0
  220. package/dist/controllers/user-storage/network-syncing/types.cjs +16 -0
  221. package/dist/controllers/user-storage/network-syncing/types.cjs.map +1 -0
  222. package/dist/controllers/user-storage/network-syncing/types.d.cts +18 -0
  223. package/dist/controllers/user-storage/network-syncing/types.d.cts.map +1 -0
  224. package/dist/controllers/user-storage/network-syncing/types.d.mts +18 -0
  225. package/dist/controllers/user-storage/network-syncing/types.d.mts.map +1 -0
  226. package/dist/controllers/user-storage/network-syncing/types.mjs +11 -0
  227. package/dist/controllers/user-storage/network-syncing/types.mjs.map +1 -0
  228. package/dist/controllers/user-storage/schema.cjs +56 -0
  229. package/dist/controllers/user-storage/schema.cjs.map +1 -0
  230. package/dist/{types/controllers/user-storage/schema.d.ts → controllers/user-storage/schema.d.cts} +2 -1
  231. package/dist/controllers/user-storage/schema.d.cts.map +1 -0
  232. package/dist/controllers/user-storage/schema.d.mts +38 -0
  233. package/dist/controllers/user-storage/schema.d.mts.map +1 -0
  234. package/dist/controllers/user-storage/schema.mjs +48 -16
  235. package/dist/controllers/user-storage/schema.mjs.map +1 -1
  236. package/dist/controllers/user-storage/services.cjs +119 -0
  237. package/dist/controllers/user-storage/services.cjs.map +1 -0
  238. package/dist/{types/controllers/user-storage/services.d.ts → controllers/user-storage/services.d.cts} +4 -5
  239. package/dist/controllers/user-storage/services.d.cts.map +1 -0
  240. package/dist/controllers/user-storage/services.d.mts +48 -0
  241. package/dist/controllers/user-storage/services.d.mts.map +1 -0
  242. package/dist/controllers/user-storage/services.mjs +116 -21
  243. package/dist/controllers/user-storage/services.mjs.map +1 -1
  244. package/dist/controllers/user-storage/utils.cjs +30 -0
  245. package/dist/controllers/user-storage/utils.cjs.map +1 -0
  246. package/dist/controllers/user-storage/utils.d.cts +17 -0
  247. package/dist/controllers/user-storage/utils.d.cts.map +1 -0
  248. package/dist/controllers/user-storage/utils.d.mts +17 -0
  249. package/dist/controllers/user-storage/utils.d.mts.map +1 -0
  250. package/dist/controllers/user-storage/utils.mjs +25 -0
  251. package/dist/controllers/user-storage/utils.mjs.map +1 -0
  252. package/dist/index.cjs +30 -0
  253. package/dist/index.cjs.map +1 -0
  254. package/dist/index.d.cts +4 -0
  255. package/dist/index.d.cts.map +1 -0
  256. package/dist/index.d.mts +4 -0
  257. package/dist/index.d.mts.map +1 -0
  258. package/dist/index.mjs +3 -39
  259. package/dist/index.mjs.map +1 -1
  260. package/dist/sdk/__fixtures__/mock-auth.cjs +139 -0
  261. package/dist/sdk/__fixtures__/mock-auth.cjs.map +1 -0
  262. package/dist/{types/sdk/__fixtures__/mock-auth.d.ts → sdk/__fixtures__/mock-auth.d.cts} +2 -2
  263. package/dist/sdk/__fixtures__/mock-auth.d.cts.map +1 -0
  264. package/dist/sdk/__fixtures__/mock-auth.d.mts +42 -0
  265. package/dist/sdk/__fixtures__/mock-auth.d.mts.map +1 -0
  266. package/dist/sdk/__fixtures__/mock-auth.mjs +134 -0
  267. package/dist/sdk/__fixtures__/mock-auth.mjs.map +1 -0
  268. package/dist/sdk/__fixtures__/mock-userstorage.cjs +58 -0
  269. package/dist/sdk/__fixtures__/mock-userstorage.cjs.map +1 -0
  270. package/dist/{types/sdk/__fixtures__/mock-userstorage.d.ts → sdk/__fixtures__/mock-userstorage.d.cts} +2 -2
  271. package/dist/sdk/__fixtures__/mock-userstorage.d.cts.map +1 -0
  272. package/dist/sdk/__fixtures__/mock-userstorage.d.mts +19 -0
  273. package/dist/sdk/__fixtures__/mock-userstorage.d.mts.map +1 -0
  274. package/dist/sdk/__fixtures__/mock-userstorage.mjs +54 -0
  275. package/dist/sdk/__fixtures__/mock-userstorage.mjs.map +1 -0
  276. package/dist/sdk/__fixtures__/test-utils.cjs +74 -0
  277. package/dist/sdk/__fixtures__/test-utils.cjs.map +1 -0
  278. package/dist/{types/sdk/__fixtures__/test-utils.d.ts → sdk/__fixtures__/test-utils.d.cts} +6 -6
  279. package/dist/sdk/__fixtures__/test-utils.d.cts.map +1 -0
  280. package/dist/sdk/__fixtures__/test-utils.d.mts +25 -0
  281. package/dist/sdk/__fixtures__/test-utils.d.mts.map +1 -0
  282. package/dist/sdk/__fixtures__/test-utils.mjs +69 -0
  283. package/dist/sdk/__fixtures__/test-utils.mjs.map +1 -0
  284. package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs +106 -0
  285. package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs.map +1 -0
  286. package/dist/{types/sdk/authentication-jwt-bearer/flow-siwe.d.ts → sdk/authentication-jwt-bearer/flow-siwe.d.cts} +2 -2
  287. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.cts.map +1 -0
  288. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.mts +23 -0
  289. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.mts.map +1 -0
  290. package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs +101 -11
  291. package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs.map +1 -1
  292. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs +125 -0
  293. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs.map +1 -0
  294. package/dist/{types/sdk/authentication-jwt-bearer/flow-srp.d.ts → sdk/authentication-jwt-bearer/flow-srp.d.cts} +4 -2
  295. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts.map +1 -0
  296. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts +19 -0
  297. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts.map +1 -0
  298. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs +119 -13
  299. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs.map +1 -1
  300. package/dist/sdk/authentication-jwt-bearer/services.cjs +180 -0
  301. package/dist/sdk/authentication-jwt-bearer/services.cjs.map +1 -0
  302. package/dist/{types/sdk/authentication-jwt-bearer/services.d.ts → sdk/authentication-jwt-bearer/services.d.cts} +4 -4
  303. package/dist/sdk/authentication-jwt-bearer/services.d.cts.map +1 -0
  304. package/dist/sdk/authentication-jwt-bearer/services.d.mts +63 -0
  305. package/dist/sdk/authentication-jwt-bearer/services.d.mts.map +1 -0
  306. package/dist/sdk/authentication-jwt-bearer/services.mjs +166 -25
  307. package/dist/sdk/authentication-jwt-bearer/services.mjs.map +1 -1
  308. package/dist/sdk/authentication-jwt-bearer/types.cjs +12 -0
  309. package/dist/sdk/authentication-jwt-bearer/types.cjs.map +1 -0
  310. package/dist/{types/sdk/authentication-jwt-bearer/types.d.ts → sdk/authentication-jwt-bearer/types.d.cts} +2 -2
  311. package/dist/sdk/authentication-jwt-bearer/types.d.cts.map +1 -0
  312. package/dist/sdk/authentication-jwt-bearer/types.d.mts +67 -0
  313. package/dist/sdk/authentication-jwt-bearer/types.d.mts.map +1 -0
  314. package/dist/sdk/authentication-jwt-bearer/types.mjs +8 -7
  315. package/dist/sdk/authentication-jwt-bearer/types.mjs.map +1 -1
  316. package/dist/sdk/authentication.cjs +124 -0
  317. package/dist/sdk/authentication.cjs.map +1 -0
  318. package/dist/{types/sdk/authentication.d.ts → sdk/authentication.d.cts} +7 -7
  319. package/dist/sdk/authentication.d.cts.map +1 -0
  320. package/dist/sdk/authentication.d.mts +32 -0
  321. package/dist/sdk/authentication.d.mts.map +1 -0
  322. package/dist/sdk/authentication.mjs +102 -24
  323. package/dist/sdk/authentication.mjs.map +1 -1
  324. package/dist/sdk/encryption.cjs +23 -0
  325. package/dist/sdk/encryption.cjs.map +1 -0
  326. package/dist/sdk/encryption.d.cts +4 -0
  327. package/dist/sdk/encryption.d.cts.map +1 -0
  328. package/dist/sdk/encryption.d.mts +4 -0
  329. package/dist/sdk/encryption.d.mts.map +1 -0
  330. package/dist/sdk/encryption.mjs +3 -13
  331. package/dist/sdk/encryption.mjs.map +1 -1
  332. package/dist/sdk/env.cjs +85 -0
  333. package/dist/sdk/env.cjs.map +1 -0
  334. package/dist/{types/sdk/env.d.ts → sdk/env.d.cts} +1 -1
  335. package/dist/sdk/env.d.cts.map +1 -0
  336. package/dist/sdk/env.d.mts +34 -0
  337. package/dist/sdk/env.d.mts.map +1 -0
  338. package/dist/sdk/env.mjs +78 -12
  339. package/dist/sdk/env.mjs.map +1 -1
  340. package/dist/sdk/errors.cjs +53 -0
  341. package/dist/sdk/errors.cjs.map +1 -0
  342. package/dist/{types/sdk/errors.d.ts → sdk/errors.d.cts} +1 -1
  343. package/dist/sdk/errors.d.cts.map +1 -0
  344. package/dist/sdk/errors.d.mts +22 -0
  345. package/dist/sdk/errors.d.mts.map +1 -0
  346. package/dist/sdk/errors.mjs +42 -19
  347. package/dist/sdk/errors.mjs.map +1 -1
  348. package/dist/sdk/index.cjs +23 -0
  349. package/dist/sdk/index.cjs.map +1 -0
  350. package/dist/sdk/index.d.cts +7 -0
  351. package/dist/sdk/index.d.cts.map +1 -0
  352. package/dist/sdk/index.d.mts +7 -0
  353. package/dist/sdk/index.d.mts.map +1 -0
  354. package/dist/sdk/index.mjs +6 -78
  355. package/dist/sdk/index.mjs.map +1 -1
  356. package/dist/sdk/user-storage.cjs +176 -0
  357. package/dist/sdk/user-storage.cjs.map +1 -0
  358. package/dist/{types/sdk/user-storage.d.ts → sdk/user-storage.d.cts} +4 -4
  359. package/dist/sdk/user-storage.d.cts.map +1 -0
  360. package/dist/sdk/user-storage.d.mts +27 -0
  361. package/dist/sdk/user-storage.d.mts.map +1 -0
  362. package/dist/sdk/user-storage.mjs +146 -16
  363. package/dist/sdk/user-storage.mjs.map +1 -1
  364. package/dist/sdk/utils/eip-6963-metamask-provider.cjs +70 -0
  365. package/dist/sdk/utils/eip-6963-metamask-provider.cjs.map +1 -0
  366. package/dist/{types/sdk/utils/eip-6963-metamask-provider.d.ts → sdk/utils/eip-6963-metamask-provider.d.cts} +2 -2
  367. package/dist/sdk/utils/eip-6963-metamask-provider.d.cts.map +1 -0
  368. package/dist/sdk/utils/eip-6963-metamask-provider.d.mts +25 -0
  369. package/dist/sdk/utils/eip-6963-metamask-provider.d.mts.map +1 -0
  370. package/dist/sdk/utils/eip-6963-metamask-provider.mjs +64 -8
  371. package/dist/sdk/utils/eip-6963-metamask-provider.mjs.map +1 -1
  372. package/dist/sdk/utils/messaging-signing-snap-requests.cjs +73 -0
  373. package/dist/sdk/utils/messaging-signing-snap-requests.cjs.map +1 -0
  374. package/dist/{types/sdk/utils/messaging-signing-snap-requests.d.ts → sdk/utils/messaging-signing-snap-requests.d.cts} +2 -7
  375. package/dist/sdk/utils/messaging-signing-snap-requests.d.cts.map +1 -0
  376. package/dist/sdk/utils/messaging-signing-snap-requests.d.mts +35 -0
  377. package/dist/sdk/utils/messaging-signing-snap-requests.d.mts.map +1 -0
  378. package/dist/sdk/utils/messaging-signing-snap-requests.mjs +65 -16
  379. package/dist/sdk/utils/messaging-signing-snap-requests.mjs.map +1 -1
  380. package/dist/sdk/utils/validate-login-response.cjs +22 -0
  381. package/dist/sdk/utils/validate-login-response.cjs.map +1 -0
  382. package/dist/{types/sdk/utils/validate-login-response.d.ts → sdk/utils/validate-login-response.d.cts} +2 -2
  383. package/dist/sdk/utils/validate-login-response.d.cts.map +1 -0
  384. package/dist/sdk/utils/validate-login-response.d.mts +10 -0
  385. package/dist/sdk/utils/validate-login-response.d.mts.map +1 -0
  386. package/dist/sdk/utils/validate-login-response.mjs +17 -7
  387. package/dist/sdk/utils/validate-login-response.mjs.map +1 -1
  388. package/package.json +62 -30
  389. package/sdk/package.json +9 -0
  390. package/user-storage/mocks/package.json +2 -2
  391. package/user-storage/package.json +2 -2
  392. package/dist/chunk-2CWF7ZTL.mjs +0 -129
  393. package/dist/chunk-2CWF7ZTL.mjs.map +0 -1
  394. package/dist/chunk-2VEMA6OE.mjs +0 -47
  395. package/dist/chunk-2VEMA6OE.mjs.map +0 -1
  396. package/dist/chunk-4LMFZDL4.js +0 -114
  397. package/dist/chunk-4LMFZDL4.js.map +0 -1
  398. package/dist/chunk-4TMLEABQ.js +0 -79
  399. package/dist/chunk-4TMLEABQ.js.map +0 -1
  400. package/dist/chunk-5MQUI24U.js +0 -47
  401. package/dist/chunk-5MQUI24U.js.map +0 -1
  402. package/dist/chunk-5XSXZTED.mjs +0 -57
  403. package/dist/chunk-5XSXZTED.mjs.map +0 -1
  404. package/dist/chunk-6DAK2U35.mjs +0 -11
  405. package/dist/chunk-6DAK2U35.mjs.map +0 -1
  406. package/dist/chunk-76NMME23.mjs +0 -114
  407. package/dist/chunk-76NMME23.mjs.map +0 -1
  408. package/dist/chunk-76VRE4BI.mjs +0 -18
  409. package/dist/chunk-76VRE4BI.mjs.map +0 -1
  410. package/dist/chunk-BKQE7DB5.js +0 -170
  411. package/dist/chunk-BKQE7DB5.js.map +0 -1
  412. package/dist/chunk-CAIIVJAO.mjs +0 -11
  413. package/dist/chunk-CAIIVJAO.mjs.map +0 -1
  414. package/dist/chunk-COBJUBZE.mjs +0 -170
  415. package/dist/chunk-COBJUBZE.mjs.map +0 -1
  416. package/dist/chunk-D4SNJOID.mjs +0 -269
  417. package/dist/chunk-D4SNJOID.mjs.map +0 -1
  418. package/dist/chunk-DF24ZX4H.js +0 -76
  419. package/dist/chunk-DF24ZX4H.js.map +0 -1
  420. package/dist/chunk-DRB2MN4T.js +0 -16
  421. package/dist/chunk-DRB2MN4T.js.map +0 -1
  422. package/dist/chunk-EHZFPUJH.mjs +0 -53
  423. package/dist/chunk-EHZFPUJH.mjs.map +0 -1
  424. package/dist/chunk-F6BAOSH2.js +0 -269
  425. package/dist/chunk-F6BAOSH2.js.map +0 -1
  426. package/dist/chunk-GQXYWBFK.js +0 -28
  427. package/dist/chunk-GQXYWBFK.js.map +0 -1
  428. package/dist/chunk-H25EBXG5.mjs +0 -58
  429. package/dist/chunk-H25EBXG5.mjs.map +0 -1
  430. package/dist/chunk-IGY2S5BC.js +0 -36
  431. package/dist/chunk-IGY2S5BC.js.map +0 -1
  432. package/dist/chunk-JAQ5TPSZ.js +0 -53
  433. package/dist/chunk-JAQ5TPSZ.js.map +0 -1
  434. package/dist/chunk-KHASG4H3.mjs +0 -11
  435. package/dist/chunk-KHASG4H3.mjs.map +0 -1
  436. package/dist/chunk-KIVBL6OM.js +0 -129
  437. package/dist/chunk-KIVBL6OM.js.map +0 -1
  438. package/dist/chunk-KTCSRECK.mjs +0 -76
  439. package/dist/chunk-KTCSRECK.mjs.map +0 -1
  440. package/dist/chunk-LGXQBALM.mjs +0 -106
  441. package/dist/chunk-LGXQBALM.mjs.map +0 -1
  442. package/dist/chunk-LLG4D2SC.js +0 -157
  443. package/dist/chunk-LLG4D2SC.js.map +0 -1
  444. package/dist/chunk-M7AUA5W7.mjs +0 -79
  445. package/dist/chunk-M7AUA5W7.mjs.map +0 -1
  446. package/dist/chunk-MBTBE4P5.js +0 -54
  447. package/dist/chunk-MBTBE4P5.js.map +0 -1
  448. package/dist/chunk-MK7ABX2V.mjs +0 -186
  449. package/dist/chunk-MK7ABX2V.mjs.map +0 -1
  450. package/dist/chunk-NEBLEB3X.mjs +0 -107
  451. package/dist/chunk-NEBLEB3X.mjs.map +0 -1
  452. package/dist/chunk-NIUQ34PY.js +0 -11
  453. package/dist/chunk-NIUQ34PY.js.map +0 -1
  454. package/dist/chunk-NMIF3LSX.mjs +0 -29
  455. package/dist/chunk-NMIF3LSX.mjs.map +0 -1
  456. package/dist/chunk-OLFO6R7Z.mjs +0 -546
  457. package/dist/chunk-OLFO6R7Z.mjs.map +0 -1
  458. package/dist/chunk-PBRUOBEQ.js +0 -11
  459. package/dist/chunk-PBRUOBEQ.js.map +0 -1
  460. package/dist/chunk-PCOIRDTO.js +0 -18
  461. package/dist/chunk-PCOIRDTO.js.map +0 -1
  462. package/dist/chunk-PQMPSEVJ.js +0 -546
  463. package/dist/chunk-PQMPSEVJ.js.map +0 -1
  464. package/dist/chunk-PRYLTXW4.js +0 -92
  465. package/dist/chunk-PRYLTXW4.js.map +0 -1
  466. package/dist/chunk-PU7MAIST.mjs +0 -129
  467. package/dist/chunk-PU7MAIST.mjs.map +0 -1
  468. package/dist/chunk-QCQU4BQL.js +0 -68
  469. package/dist/chunk-QCQU4BQL.js.map +0 -1
  470. package/dist/chunk-QDGLIUUS.mjs +0 -16
  471. package/dist/chunk-QDGLIUUS.mjs.map +0 -1
  472. package/dist/chunk-RG4II6WH.js +0 -57
  473. package/dist/chunk-RG4II6WH.js.map +0 -1
  474. package/dist/chunk-TFFQFIJV.mjs +0 -54
  475. package/dist/chunk-TFFQFIJV.mjs.map +0 -1
  476. package/dist/chunk-TP7SP3AG.mjs +0 -133
  477. package/dist/chunk-TP7SP3AG.mjs.map +0 -1
  478. package/dist/chunk-U5UIDVOO.mjs +0 -36
  479. package/dist/chunk-U5UIDVOO.mjs.map +0 -1
  480. package/dist/chunk-UAXWZN5J.js +0 -58
  481. package/dist/chunk-UAXWZN5J.js.map +0 -1
  482. package/dist/chunk-UEHMUVQQ.js +0 -133
  483. package/dist/chunk-UEHMUVQQ.js.map +0 -1
  484. package/dist/chunk-UEWCUBMX.mjs +0 -68
  485. package/dist/chunk-UEWCUBMX.mjs.map +0 -1
  486. package/dist/chunk-UHP2Y32K.mjs +0 -92
  487. package/dist/chunk-UHP2Y32K.mjs.map +0 -1
  488. package/dist/chunk-UHX7HJAI.js +0 -11
  489. package/dist/chunk-UHX7HJAI.js.map +0 -1
  490. package/dist/chunk-UIRAMHNM.js +0 -186
  491. package/dist/chunk-UIRAMHNM.js.map +0 -1
  492. package/dist/chunk-VWDRFRJU.js +0 -107
  493. package/dist/chunk-VWDRFRJU.js.map +0 -1
  494. package/dist/chunk-Y45XUW33.js +0 -129
  495. package/dist/chunk-Y45XUW33.js.map +0 -1
  496. package/dist/chunk-YHGWG3EQ.js +0 -29
  497. package/dist/chunk-YHGWG3EQ.js.map +0 -1
  498. package/dist/chunk-YLURF2PF.mjs +0 -157
  499. package/dist/chunk-YLURF2PF.mjs.map +0 -1
  500. package/dist/chunk-ZUPTMFEA.mjs +0 -28
  501. package/dist/chunk-ZUPTMFEA.mjs.map +0 -1
  502. package/dist/chunk-ZX2KHPXG.js +0 -106
  503. package/dist/chunk-ZX2KHPXG.js.map +0 -1
  504. package/dist/controllers/authentication/AuthenticationController.js +0 -13
  505. package/dist/controllers/authentication/AuthenticationController.js.map +0 -1
  506. package/dist/controllers/authentication/auth-snap-requests.js +0 -10
  507. package/dist/controllers/authentication/auth-snap-requests.js.map +0 -1
  508. package/dist/controllers/authentication/index.js +0 -19
  509. package/dist/controllers/authentication/index.js.map +0 -1
  510. package/dist/controllers/authentication/services.js +0 -21
  511. package/dist/controllers/authentication/services.js.map +0 -1
  512. package/dist/controllers/index.js +0 -25
  513. package/dist/controllers/index.js.map +0 -1
  514. package/dist/controllers/user-storage/UserStorageController.js +0 -20
  515. package/dist/controllers/user-storage/UserStorageController.js.map +0 -1
  516. package/dist/controllers/user-storage/accounts/constants.js +0 -12
  517. package/dist/controllers/user-storage/accounts/constants.js.map +0 -1
  518. package/dist/controllers/user-storage/accounts/user-storage.js +0 -11
  519. package/dist/controllers/user-storage/accounts/user-storage.js.map +0 -1
  520. package/dist/controllers/user-storage/encryption/cache.js +0 -13
  521. package/dist/controllers/user-storage/encryption/cache.js.map +0 -1
  522. package/dist/controllers/user-storage/encryption/encryption.js +0 -12
  523. package/dist/controllers/user-storage/encryption/encryption.js.map +0 -1
  524. package/dist/controllers/user-storage/encryption/index.js +0 -16
  525. package/dist/controllers/user-storage/encryption/index.js.map +0 -1
  526. package/dist/controllers/user-storage/encryption/utils.js +0 -12
  527. package/dist/controllers/user-storage/encryption/utils.js.map +0 -1
  528. package/dist/controllers/user-storage/index.js +0 -31
  529. package/dist/controllers/user-storage/index.js.map +0 -1
  530. package/dist/controllers/user-storage/schema.js +0 -18
  531. package/dist/controllers/user-storage/schema.js.map +0 -1
  532. package/dist/controllers/user-storage/services.js +0 -22
  533. package/dist/controllers/user-storage/services.js.map +0 -1
  534. package/dist/index.js +0 -40
  535. package/dist/index.js.map +0 -1
  536. package/dist/sdk/authentication-jwt-bearer/flow-siwe.js +0 -13
  537. package/dist/sdk/authentication-jwt-bearer/flow-siwe.js.map +0 -1
  538. package/dist/sdk/authentication-jwt-bearer/flow-srp.js +0 -15
  539. package/dist/sdk/authentication-jwt-bearer/flow-srp.js.map +0 -1
  540. package/dist/sdk/authentication-jwt-bearer/services.js +0 -27
  541. package/dist/sdk/authentication-jwt-bearer/services.js.map +0 -1
  542. package/dist/sdk/authentication-jwt-bearer/types.js +0 -8
  543. package/dist/sdk/authentication-jwt-bearer/types.js.map +0 -1
  544. package/dist/sdk/authentication.js +0 -26
  545. package/dist/sdk/authentication.js.map +0 -1
  546. package/dist/sdk/encryption.js +0 -14
  547. package/dist/sdk/encryption.js.map +0 -1
  548. package/dist/sdk/env.js +0 -14
  549. package/dist/sdk/env.js.map +0 -1
  550. package/dist/sdk/errors.js +0 -20
  551. package/dist/sdk/errors.js.map +0 -1
  552. package/dist/sdk/index.js +0 -79
  553. package/dist/sdk/index.js.map +0 -1
  554. package/dist/sdk/user-storage.js +0 -18
  555. package/dist/sdk/user-storage.js.map +0 -1
  556. package/dist/sdk/utils/eip-6963-metamask-provider.js +0 -10
  557. package/dist/sdk/utils/eip-6963-metamask-provider.js.map +0 -1
  558. package/dist/sdk/utils/messaging-signing-snap-requests.js +0 -18
  559. package/dist/sdk/utils/messaging-signing-snap-requests.js.map +0 -1
  560. package/dist/sdk/utils/validate-login-response.js +0 -8
  561. package/dist/sdk/utils/validate-login-response.js.map +0 -1
  562. package/dist/tsconfig.build.tsbuildinfo +0 -1
  563. package/dist/types/controllers/authentication/AuthenticationController.d.ts.map +0 -1
  564. package/dist/types/controllers/authentication/__fixtures__/index.d.ts +0 -2
  565. package/dist/types/controllers/authentication/__fixtures__/index.d.ts.map +0 -1
  566. package/dist/types/controllers/authentication/__fixtures__/mockResponses.d.ts.map +0 -1
  567. package/dist/types/controllers/authentication/__fixtures__/mockServices.d.ts.map +0 -1
  568. package/dist/types/controllers/authentication/auth-snap-requests.d.ts.map +0 -1
  569. package/dist/types/controllers/authentication/index.d.ts +0 -7
  570. package/dist/types/controllers/authentication/index.d.ts.map +0 -1
  571. package/dist/types/controllers/authentication/services.d.ts.map +0 -1
  572. package/dist/types/controllers/index.d.ts +0 -3
  573. package/dist/types/controllers/index.d.ts.map +0 -1
  574. package/dist/types/controllers/user-storage/UserStorageController.d.ts.map +0 -1
  575. package/dist/types/controllers/user-storage/__fixtures__/index.d.ts +0 -3
  576. package/dist/types/controllers/user-storage/__fixtures__/index.d.ts.map +0 -1
  577. package/dist/types/controllers/user-storage/__fixtures__/mockAccounts.d.ts.map +0 -1
  578. package/dist/types/controllers/user-storage/__fixtures__/mockResponses.d.ts.map +0 -1
  579. package/dist/types/controllers/user-storage/__fixtures__/mockServices.d.ts.map +0 -1
  580. package/dist/types/controllers/user-storage/__fixtures__/mockStorage.d.ts.map +0 -1
  581. package/dist/types/controllers/user-storage/accounts/constants.d.ts.map +0 -1
  582. package/dist/types/controllers/user-storage/accounts/user-storage.d.ts.map +0 -1
  583. package/dist/types/controllers/user-storage/encryption/cache.d.ts.map +0 -1
  584. package/dist/types/controllers/user-storage/encryption/encryption.d.ts.map +0 -1
  585. package/dist/types/controllers/user-storage/encryption/index.d.ts +0 -5
  586. package/dist/types/controllers/user-storage/encryption/index.d.ts.map +0 -1
  587. package/dist/types/controllers/user-storage/encryption/utils.d.ts.map +0 -1
  588. package/dist/types/controllers/user-storage/index.d.ts +0 -8
  589. package/dist/types/controllers/user-storage/index.d.ts.map +0 -1
  590. package/dist/types/controllers/user-storage/schema.d.ts.map +0 -1
  591. package/dist/types/controllers/user-storage/services.d.ts.map +0 -1
  592. package/dist/types/index.d.ts +0 -4
  593. package/dist/types/index.d.ts.map +0 -1
  594. package/dist/types/sdk/__fixtures__/mock-auth.d.ts.map +0 -1
  595. package/dist/types/sdk/__fixtures__/mock-userstorage.d.ts.map +0 -1
  596. package/dist/types/sdk/__fixtures__/test-utils.d.ts.map +0 -1
  597. package/dist/types/sdk/authentication-jwt-bearer/flow-siwe.d.ts.map +0 -1
  598. package/dist/types/sdk/authentication-jwt-bearer/flow-srp.d.ts.map +0 -1
  599. package/dist/types/sdk/authentication-jwt-bearer/services.d.ts.map +0 -1
  600. package/dist/types/sdk/authentication-jwt-bearer/types.d.ts.map +0 -1
  601. package/dist/types/sdk/authentication.d.ts.map +0 -1
  602. package/dist/types/sdk/encryption.d.ts +0 -4
  603. package/dist/types/sdk/encryption.d.ts.map +0 -1
  604. package/dist/types/sdk/env.d.ts.map +0 -1
  605. package/dist/types/sdk/errors.d.ts.map +0 -1
  606. package/dist/types/sdk/index.d.ts +0 -7
  607. package/dist/types/sdk/index.d.ts.map +0 -1
  608. package/dist/types/sdk/user-storage.d.ts.map +0 -1
  609. package/dist/types/sdk/utils/eip-6963-metamask-provider.d.ts.map +0 -1
  610. package/dist/types/sdk/utils/messaging-signing-snap-requests.d.ts.map +0 -1
  611. package/dist/types/sdk/utils/validate-login-response.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"services.mjs","sourceRoot":"","sources":["../../../src/sdk/authentication-jwt-bearer/services.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,mBAAe;AACrD,OAAO,EACL,mBAAmB,EACnB,SAAS,EACT,WAAW,EACX,eAAe,EAChB,sBAAkB;AAEnB,OAAO,EAAE,QAAQ,EAAE,oBAAgB;AAEnC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAQ,EAAE,EAAE,CACpC,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,UAAU,eAAe,CAAC;AAE/C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAQ,EAAE,EAAE,CAC3C,GAAG,UAAU,C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,CAAC,UAAU;YACnC,OAAO,EAAE;gBACP,YAAY,EAAE,aAAa,CAAC,OAAO,CAAC,aAAa;gBACjD,aAAa,EAAE,aAAa,CAAC,OAAO,CAAC,cAAc;gBACnD,SAAS,EAAE,aAAa,CAAC,OAAO,CAAC,UAAU;aAC5C;SACF,CAAC;KACH;IAAC,OAAO,CAAC,EAAE;QACV,0BAA0B;QAC1B,MAAM,YAAY,GAChB,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QAC3D,MAAM,IAAI,WAAW,CAAC,gCAAgC,YAAY,EAAE,CAAC,CAAC;KACvE;AACH,CAAC","sourcesContent":["import type { Env, Platform } from '../env';\nimport { getEnvUrls, getOidcClientId } from '../env';\nimport {\n NonceRetrievalError,\n PairError,\n SignInError,\n ValidationError,\n} from '../errors';\nimport type { AccessToken, ErrorMessage, UserProfile } from './types';\nimport { AuthType } from './types';\n\nexport const NONCE_URL = (env: Env) =>\n `${getEnvUrls(env).authApiUrl}/api/v2/nonce`;\n\nexport const PAIR_IDENTIFIERS = (env: Env) =>\n `${getEnvUrls(env).authApiUrl}/api/v2/identifiers/pair`;\n\nexport const OIDC_TOKEN_URL = (env: Env) =>\n `${getEnvUrls(env).oidcApiUrl}/oauth2/token`;\n\nexport const SRP_LOGIN_URL = (env: Env) =>\n `${getEnvUrls(env).authApiUrl}/api/v2/srp/login`;\n\nexport const SIWE_LOGIN_URL = (env: Env) =>\n `${getEnvUrls(env).authApiUrl}/api/v2/siwe/login`;\n\nconst getAuthenticationUrl = (authType: AuthType, env: Env): string => {\n switch (authType) {\n case AuthType.SRP:\n return SRP_LOGIN_URL(env);\n case AuthType.SiWE:\n return SIWE_LOGIN_URL(env);\n /* istanbul ignore next */\n default:\n throw new ValidationError(\n `Invalid AuthType: ${authType as number} - unable to create Auth URL`,\n );\n }\n};\n\ntype NonceResponse = {\n nonce: string;\n identifier: string;\n expiresIn: number;\n};\n\ntype PairRequest = {\n signature: string;\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n raw_message: string;\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n encrypted_storage_key: string;\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n identifier_type: 'SIWE' | 'SRP';\n};\n\n/**\n * Pair multiple identifiers under a single profile\n *\n * @param nonce - session nonce\n * @param logins - pairing request payload\n * @param accessToken - JWT access token used to access protected resources\n * @param env - server environment\n * @returns void.\n */\nexport async function pairIdentifiers(\n nonce: string,\n logins: PairRequest[],\n accessToken: string,\n env: Env,\n): Promise<void> {\n const pairUrl = new URL(PAIR_IDENTIFIERS(env));\n\n try {\n const response = await fetch(pairUrl, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${accessToken}`,\n },\n body: JSON.stringify({\n nonce,\n logins,\n }),\n });\n\n if (!response.ok) {\n const responseBody = (await response.json()) as ErrorMessage;\n throw new Error(\n `HTTP error message: ${responseBody.message}, error: ${responseBody.error}`,\n );\n }\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n throw new PairError(`unable to pair identifiers: ${errorMessage}`);\n }\n}\n\n/**\n * Service to Get Nonce for JWT Bearer Flow\n *\n * @param id - identifier ID\n * @param env - server environment\n * @returns the nonce.\n */\nexport async function getNonce(id: string, env: Env): Promise<NonceResponse> {\n const nonceUrl = new URL(NONCE_URL(env));\n nonceUrl.searchParams.set('identifier', id);\n\n try {\n const nonceResponse = await fetch(nonceUrl.toString());\n if (!nonceResponse.ok) {\n const responseBody = (await nonceResponse.json()) as ErrorMessage;\n throw new Error(\n `HTTP error message: ${responseBody.message}, error: ${responseBody.error}`,\n );\n }\n\n const nonceJson = await nonceResponse.json();\n return {\n nonce: nonceJson.nonce,\n identifier: nonceJson.identifier,\n expiresIn: nonceJson.expires_in,\n };\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n throw new NonceRetrievalError(`failed to generate nonce: ${errorMessage}`);\n }\n}\n\n/**\n * Service to Authorize And perform OIDC Flow to get the Access Token\n *\n * @param jwtToken - The original token received from Authentication. This is traded for the Access Token. (the authentication token is single-use)\n * @param env - server environment\n * @param platform - SDK platform\n * @returns Access Token from Authorization server\n */\nexport async function authorizeOIDC(\n jwtToken: string,\n env: Env,\n platform: Platform,\n): Promise<AccessToken> {\n const grantType = 'urn:ietf:params:oauth:grant-type:jwt-bearer';\n const headers = new Headers({\n 'Content-Type': 'application/x-www-form-urlencoded',\n });\n\n const urlEncodedBody = new URLSearchParams();\n urlEncodedBody.append('grant_type', grantType);\n urlEncodedBody.append('client_id', getOidcClientId(env, platform));\n urlEncodedBody.append('assertion', jwtToken);\n\n try {\n const response = await fetch(OIDC_TOKEN_URL(env), {\n method: 'POST',\n headers,\n body: urlEncodedBody.toString(),\n });\n\n if (!response.ok) {\n const responseBody = (await response.json()) as {\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n error_description: string;\n error: string;\n };\n throw new Error(\n `HTTP error: ${responseBody.error_description}, error code: ${responseBody.error}`,\n );\n }\n\n const accessTokenResponse = await response.json();\n return {\n accessToken: accessTokenResponse.access_token,\n expiresIn: accessTokenResponse.expires_in,\n obtainedAt: Date.now(),\n };\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n throw new SignInError(`unable to get access token: ${errorMessage}`);\n }\n}\n\ntype Authentication = {\n token: string;\n expiresIn: number;\n profile: UserProfile;\n};\n/**\n * Service to Authenticate/Login a user via SIWE or SRP derived key.\n *\n * @param rawMessage - raw message for validation when authenticating\n * @param signature - signed raw message\n * @param authType - authentication type/flow used\n * @param env - server environment\n * @returns Authentication Token\n */\nexport async function authenticate(\n rawMessage: string,\n signature: string,\n authType: AuthType,\n env: Env,\n): Promise<Authentication> {\n const authenticationUrl = getAuthenticationUrl(authType, env);\n\n try {\n const response = await fetch(authenticationUrl, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n signature,\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n raw_message: rawMessage,\n }),\n });\n\n if (!response.ok) {\n const responseBody = (await response.json()) as ErrorMessage;\n throw new Error(\n `${authType} login HTTP error: ${responseBody.message}, error code: ${responseBody.error}`,\n );\n }\n\n const loginResponse = await response.json();\n return {\n token: loginResponse.token,\n expiresIn: loginResponse.expires_in,\n profile: {\n identifierId: loginResponse.profile.identifier_id,\n metaMetricsId: loginResponse.profile.metametrics_id,\n profileId: loginResponse.profile.profile_id,\n },\n };\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n throw new SignInError(`unable to perform SRP login: ${errorMessage}`);\n }\n}\n"]}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthType = void 0;
4
+ var AuthType;
5
+ (function (AuthType) {
6
+ /* sign in using a private key derived from your secret recovery phrase (SRP).
7
+ Uses message signing snap to perform this operation */
8
+ AuthType["SRP"] = "SRP";
9
+ /* sign in with Ethereum */
10
+ AuthType["SiWE"] = "SiWE";
11
+ })(AuthType || (exports.AuthType = AuthType = {}));
12
+ //# sourceMappingURL=types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../../src/sdk/authentication-jwt-bearer/types.ts"],"names":[],"mappings":";;;AAEA,IAAY,QAOX;AAPD,WAAY,QAAQ;IAClB;+DAC2D;IAC3D,uBAAW,CAAA;IAEX,2BAA2B;IAC3B,yBAAa,CAAA;AACf,CAAC,EAPW,QAAQ,wBAAR,QAAQ,QAOnB","sourcesContent":["import type { Env, Platform } from '../env';\n\nexport enum AuthType {\n /* sign in using a private key derived from your secret recovery phrase (SRP). \n Uses message signing snap to perform this operation */\n SRP = 'SRP',\n\n /* sign in with Ethereum */\n SiWE = 'SiWE',\n}\n\nexport type AuthConfig = {\n env: Env;\n platform: Platform;\n type: AuthType;\n};\n\nexport type AccessToken = {\n /**\n * The JWT Access Token\n */\n accessToken: string;\n /**\n * Expiration in seconds\n */\n expiresIn: number;\n /**\n * Date in milliseconds\n */\n obtainedAt: number;\n};\n\nexport type UserProfile = {\n /**\n * The \"Identifier\" used to log in with.\n */\n identifierId: string;\n /**\n * The Unique profile for a logged in user. A Profile can be logged in via multiple Identifiers\n */\n profileId: string;\n /**\n * Server MetaMetrics ID. Allows grouping of user events cross platform.\n */\n metaMetricsId: string;\n};\n\nexport type LoginResponse = {\n token: AccessToken;\n profile: UserProfile;\n};\n\nexport type IBaseAuth = {\n getAccessToken: () => Promise<string>;\n getUserProfile: () => Promise<UserProfile>;\n getIdentifier: () => Promise<string>;\n signMessage: (message: string) => Promise<string>;\n};\n\nexport type AuthStorageOptions = {\n getLoginResponse: () => Promise<LoginResponse | null>;\n setLoginResponse: (val: LoginResponse) => Promise<void>;\n};\n\nexport type AuthSigningOptions = {\n signMessage: (message: string) => Promise<string>;\n getIdentifier: () => Promise<string>;\n};\n\nexport type ErrorMessage = {\n message: string;\n error: string;\n};\n\nexport type Pair = {\n identifier: string;\n encryptedStorageKey: string;\n identifierType: 'SIWE' | 'SRP';\n signMessage: (message: string) => Promise<string>;\n};\n"]}
@@ -1,4 +1,4 @@
1
- import type { Env, Platform } from '../env';
1
+ import type { Env, Platform } from "../env.cjs";
2
2
  export declare enum AuthType {
3
3
  SRP = "SRP",
4
4
  SiWE = "SiWE"
@@ -64,4 +64,4 @@ export type Pair = {
64
64
  identifierType: 'SIWE' | 'SRP';
65
65
  signMessage: (message: string) => Promise<string>;
66
66
  };
67
- //# sourceMappingURL=types.d.ts.map
67
+ //# sourceMappingURL=types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../../src/sdk/authentication-jwt-bearer/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,mBAAe;AAE5C,oBAAY,QAAQ;IAGlB,GAAG,QAAQ;IAGX,IAAI,SAAS;CACd;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,GAAG,EAAE,GAAG,CAAC;IACT,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,WAAW,CAAC;IACnB,OAAO,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,cAAc,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IACtC,cAAc,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;IAC3C,aAAa,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IACrC,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CACnD,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,gBAAgB,EAAE,MAAM,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;IACtD,gBAAgB,EAAE,CAAC,GAAG,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACzD,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAClD,aAAa,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,cAAc,EAAE,MAAM,GAAG,KAAK,CAAC;IAC/B,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CACnD,CAAC"}
@@ -0,0 +1,67 @@
1
+ import type { Env, Platform } from "../env.mjs";
2
+ export declare enum AuthType {
3
+ SRP = "SRP",
4
+ SiWE = "SiWE"
5
+ }
6
+ export type AuthConfig = {
7
+ env: Env;
8
+ platform: Platform;
9
+ type: AuthType;
10
+ };
11
+ export type AccessToken = {
12
+ /**
13
+ * The JWT Access Token
14
+ */
15
+ accessToken: string;
16
+ /**
17
+ * Expiration in seconds
18
+ */
19
+ expiresIn: number;
20
+ /**
21
+ * Date in milliseconds
22
+ */
23
+ obtainedAt: number;
24
+ };
25
+ export type UserProfile = {
26
+ /**
27
+ * The "Identifier" used to log in with.
28
+ */
29
+ identifierId: string;
30
+ /**
31
+ * The Unique profile for a logged in user. A Profile can be logged in via multiple Identifiers
32
+ */
33
+ profileId: string;
34
+ /**
35
+ * Server MetaMetrics ID. Allows grouping of user events cross platform.
36
+ */
37
+ metaMetricsId: string;
38
+ };
39
+ export type LoginResponse = {
40
+ token: AccessToken;
41
+ profile: UserProfile;
42
+ };
43
+ export type IBaseAuth = {
44
+ getAccessToken: () => Promise<string>;
45
+ getUserProfile: () => Promise<UserProfile>;
46
+ getIdentifier: () => Promise<string>;
47
+ signMessage: (message: string) => Promise<string>;
48
+ };
49
+ export type AuthStorageOptions = {
50
+ getLoginResponse: () => Promise<LoginResponse | null>;
51
+ setLoginResponse: (val: LoginResponse) => Promise<void>;
52
+ };
53
+ export type AuthSigningOptions = {
54
+ signMessage: (message: string) => Promise<string>;
55
+ getIdentifier: () => Promise<string>;
56
+ };
57
+ export type ErrorMessage = {
58
+ message: string;
59
+ error: string;
60
+ };
61
+ export type Pair = {
62
+ identifier: string;
63
+ encryptedStorageKey: string;
64
+ identifierType: 'SIWE' | 'SRP';
65
+ signMessage: (message: string) => Promise<string>;
66
+ };
67
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../../src/sdk/authentication-jwt-bearer/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,mBAAe;AAE5C,oBAAY,QAAQ;IAGlB,GAAG,QAAQ;IAGX,IAAI,SAAS;CACd;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,GAAG,EAAE,GAAG,CAAC;IACT,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;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function (AuthType) {
3
+ /* sign in using a private key derived from your secret recovery phrase (SRP).
4
+ Uses message signing snap to perform this operation */
5
+ AuthType["SRP"] = "SRP";
6
+ /* sign in with Ethereum */
7
+ AuthType["SiWE"] = "SiWE";
8
+ })(AuthType || (AuthType = {}));
8
9
  //# sourceMappingURL=types.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../src/sdk/authentication-jwt-bearer/types.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,QAOX;AAPD,WAAY,QAAQ;IAClB;+DAC2D;IAC3D,uBAAW,CAAA;IAEX,2BAA2B;IAC3B,yBAAa,CAAA;AACf,CAAC,EAPW,QAAQ,KAAR,QAAQ,QAOnB","sourcesContent":["import type { Env, Platform } from '../env';\n\nexport enum AuthType {\n /* sign in using a private key derived from your secret recovery phrase (SRP). \n Uses message signing snap to perform this operation */\n SRP = 'SRP',\n\n /* sign in with Ethereum */\n SiWE = 'SiWE',\n}\n\nexport type AuthConfig = {\n env: Env;\n platform: Platform;\n type: AuthType;\n};\n\nexport type AccessToken = {\n /**\n * The JWT Access Token\n */\n accessToken: string;\n /**\n * Expiration in seconds\n */\n expiresIn: number;\n /**\n * Date in milliseconds\n */\n obtainedAt: number;\n};\n\nexport type UserProfile = {\n /**\n * The \"Identifier\" used to log in with.\n */\n identifierId: string;\n /**\n * The Unique profile for a logged in user. A Profile can be logged in via multiple Identifiers\n */\n profileId: string;\n /**\n * Server MetaMetrics ID. Allows grouping of user events cross platform.\n */\n metaMetricsId: string;\n};\n\nexport type LoginResponse = {\n token: AccessToken;\n profile: UserProfile;\n};\n\nexport type IBaseAuth = {\n getAccessToken: () => Promise<string>;\n getUserProfile: () => Promise<UserProfile>;\n getIdentifier: () => Promise<string>;\n signMessage: (message: string) => Promise<string>;\n};\n\nexport type AuthStorageOptions = {\n getLoginResponse: () => Promise<LoginResponse | null>;\n setLoginResponse: (val: LoginResponse) => Promise<void>;\n};\n\nexport type AuthSigningOptions = {\n signMessage: (message: string) => Promise<string>;\n getIdentifier: () => Promise<string>;\n};\n\nexport type ErrorMessage = {\n message: string;\n error: string;\n};\n\nexport type Pair = {\n identifier: string;\n encryptedStorageKey: string;\n identifierType: 'SIWE' | 'SRP';\n signMessage: (message: string) => Promise<string>;\n};\n"]}
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
17
+ if (kind === "m") throw new TypeError("Private method is not writable");
18
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
19
+ 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");
20
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
21
+ };
22
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
23
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
24
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
25
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
26
+ };
27
+ var _JwtBearerAuth_instances, _JwtBearerAuth_type, _JwtBearerAuth_env, _JwtBearerAuth_sdk, _JwtBearerAuth_assertSIWE, _JwtBearerAuth_assertSRP;
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.SRPJwtBearerAuth = exports.SIWEJwtBearerAuth = exports.JwtBearerAuth = void 0;
30
+ const flow_siwe_1 = require("./authentication-jwt-bearer/flow-siwe.cjs");
31
+ const flow_srp_1 = require("./authentication-jwt-bearer/flow-srp.cjs");
32
+ const services_1 = require("./authentication-jwt-bearer/services.cjs");
33
+ const types_1 = require("./authentication-jwt-bearer/types.cjs");
34
+ const errors_1 = require("./errors.cjs");
35
+ class JwtBearerAuth {
36
+ constructor(...args) {
37
+ _JwtBearerAuth_instances.add(this);
38
+ _JwtBearerAuth_type.set(this, void 0);
39
+ _JwtBearerAuth_env.set(this, void 0);
40
+ _JwtBearerAuth_sdk.set(this, void 0);
41
+ __classPrivateFieldSet(this, _JwtBearerAuth_type, args[0].type, "f");
42
+ __classPrivateFieldSet(this, _JwtBearerAuth_env, args[0].env, "f");
43
+ if (args[0].type === types_1.AuthType.SRP) {
44
+ __classPrivateFieldSet(this, _JwtBearerAuth_sdk, new flow_srp_1.SRPJwtBearerAuth(args[0], args[1]), "f");
45
+ return;
46
+ }
47
+ if (args[0].type === types_1.AuthType.SiWE) {
48
+ __classPrivateFieldSet(this, _JwtBearerAuth_sdk, new flow_siwe_1.SIWEJwtBearerAuth(args[0], args[1]), "f");
49
+ return;
50
+ }
51
+ throw new errors_1.UnsupportedAuthTypeError('unsupported auth type');
52
+ }
53
+ async getAccessToken() {
54
+ return await __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f").getAccessToken();
55
+ }
56
+ async connectSnap() {
57
+ __classPrivateFieldGet(this, _JwtBearerAuth_instances, "m", _JwtBearerAuth_assertSRP).call(this, __classPrivateFieldGet(this, _JwtBearerAuth_type, "f"), __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f"));
58
+ return __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f").connectSnap();
59
+ }
60
+ async isSnapConnected() {
61
+ __classPrivateFieldGet(this, _JwtBearerAuth_instances, "m", _JwtBearerAuth_assertSRP).call(this, __classPrivateFieldGet(this, _JwtBearerAuth_type, "f"), __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f"));
62
+ return __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f").isSnapConnected();
63
+ }
64
+ async getUserProfile() {
65
+ return await __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f").getUserProfile();
66
+ }
67
+ async getIdentifier() {
68
+ return await __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f").getIdentifier();
69
+ }
70
+ async signMessage(message) {
71
+ return await __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f").signMessage(message);
72
+ }
73
+ async pairIdentifiers(pairing) {
74
+ const profile = await this.getUserProfile();
75
+ const n = await (0, services_1.getNonce)(profile.profileId, __classPrivateFieldGet(this, _JwtBearerAuth_env, "f"));
76
+ const logins = await Promise.all(pairing.map(async (p) => {
77
+ try {
78
+ const raw = `metamask:${n.nonce}:${p.identifier}`;
79
+ const sig = await p.signMessage(raw);
80
+ return {
81
+ signature: sig,
82
+ // TODO: Either fix this lint violation or explain why it's necessary to ignore.
83
+ // eslint-disable-next-line @typescript-eslint/naming-convention
84
+ raw_message: raw,
85
+ // TODO: Either fix this lint violation or explain why it's necessary to ignore.
86
+ // eslint-disable-next-line @typescript-eslint/naming-convention
87
+ encrypted_storage_key: p.encryptedStorageKey,
88
+ // TODO: Either fix this lint violation or explain why it's necessary to ignore.
89
+ // eslint-disable-next-line @typescript-eslint/naming-convention
90
+ identifier_type: p.identifierType,
91
+ };
92
+ }
93
+ catch (e) {
94
+ /* istanbul ignore next */
95
+ const errorMessage = e instanceof Error ? e.message : JSON.stringify(e ?? '');
96
+ throw new errors_1.PairError(`failed to sign pairing message: ${errorMessage}`);
97
+ }
98
+ }));
99
+ const accessToken = await this.getAccessToken();
100
+ await (0, services_1.pairIdentifiers)(n.nonce, logins, accessToken, __classPrivateFieldGet(this, _JwtBearerAuth_env, "f"));
101
+ }
102
+ prepare(signer) {
103
+ __classPrivateFieldGet(this, _JwtBearerAuth_instances, "m", _JwtBearerAuth_assertSIWE).call(this, __classPrivateFieldGet(this, _JwtBearerAuth_type, "f"), __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f"));
104
+ __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f").prepare(signer);
105
+ }
106
+ }
107
+ exports.JwtBearerAuth = JwtBearerAuth;
108
+ _JwtBearerAuth_type = new WeakMap(), _JwtBearerAuth_env = new WeakMap(), _JwtBearerAuth_sdk = new WeakMap(), _JwtBearerAuth_instances = new WeakSet(), _JwtBearerAuth_assertSIWE = function _JwtBearerAuth_assertSIWE(type, _sdk) {
109
+ if (type === types_1.AuthType.SiWE) {
110
+ return;
111
+ }
112
+ throw new errors_1.UnsupportedAuthTypeError('This method is only available via SIWE auth type');
113
+ }, _JwtBearerAuth_assertSRP = function _JwtBearerAuth_assertSRP(type, _sdk) {
114
+ if (type === types_1.AuthType.SRP) {
115
+ return;
116
+ }
117
+ throw new errors_1.UnsupportedAuthTypeError('This method is only available via SRP auth type');
118
+ };
119
+ var flow_siwe_2 = require("./authentication-jwt-bearer/flow-siwe.cjs");
120
+ Object.defineProperty(exports, "SIWEJwtBearerAuth", { enumerable: true, get: function () { return flow_siwe_2.SIWEJwtBearerAuth; } });
121
+ var flow_srp_2 = require("./authentication-jwt-bearer/flow-srp.cjs");
122
+ Object.defineProperty(exports, "SRPJwtBearerAuth", { enumerable: true, get: function () { return flow_srp_2.SRPJwtBearerAuth; } });
123
+ __exportStar(require("./authentication-jwt-bearer/types.cjs"), exports);
124
+ //# sourceMappingURL=authentication.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authentication.cjs","sourceRoot":"","sources":["../../src/sdk/authentication.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;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AAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;gBAC3D,MAAM,IAAI,kBAAS,CACjB,mCAAmC,YAAY,EAAE,CAClD,CAAC;aACH;QACH,CAAC,CAAC,CACH,CAAC;QAEF,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAChD,MAAM,IAAA,0BAAe,EAAC,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,uBAAA,IAAI,0BAAK,CAAC,CAAC;IACjE,CAAC;IAED,OAAO,CAAC,MAKP;QACC,uBAAA,IAAI,2DAAY,MAAhB,IAAI,EAAa,uBAAA,IAAI,2BAAM,EAAE,uBAAA,IAAI,0BAAK,CAAC,CAAC;QACxC,uBAAA,IAAI,0BAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;CA2BF;AAzHD,sCAyHC;sNAxBG,IAAc,EACd,IAA0C;IAE1C,IAAI,IAAI,KAAK,gBAAQ,CAAC,IAAI,EAAE;QAC1B,OAAO;KACR;IAED,MAAM,IAAI,iCAAwB,CAChC,kDAAkD,CACnD,CAAC;AACJ,CAAC,+DAGC,IAAc,EACd,IAA0C;IAE1C,IAAI,IAAI,KAAK,gBAAQ,CAAC,GAAG,EAAE;QACzB,OAAO;KACR;IAED,MAAM,IAAI,iCAAwB,CAChC,iDAAiD,CAClD,CAAC;AACJ,CAAC;AAGH,uEAA0E;AAAjE,8GAAA,iBAAiB,OAAA;AAC1B,qEAAwE;AAA/D,4GAAA,gBAAgB,OAAA;AACzB,wEAAkD","sourcesContent":["import { SIWEJwtBearerAuth } from './authentication-jwt-bearer/flow-siwe';\nimport { SRPJwtBearerAuth } from './authentication-jwt-bearer/flow-srp';\nimport {\n getNonce,\n pairIdentifiers,\n} from './authentication-jwt-bearer/services';\nimport type { UserProfile, Pair } from './authentication-jwt-bearer/types';\nimport { AuthType } from './authentication-jwt-bearer/types';\nimport type { Env } from './env';\nimport { PairError, UnsupportedAuthTypeError } from './errors';\n\n// Computing the Classes, so we only get back the public methods for the interface.\n// TODO: Either fix this lint violation or explain why it's necessary to ignore.\n// eslint-disable-next-line @typescript-eslint/naming-convention\ntype Compute<T> = T extends infer U ? { [K in keyof U]: U[K] } : never;\ntype SIWEInterface = Compute<SIWEJwtBearerAuth>;\ntype SRPInterface = Compute<SRPJwtBearerAuth>;\n\ntype SiweParams = ConstructorParameters<typeof SIWEJwtBearerAuth>;\ntype SRPParams = ConstructorParameters<typeof SRPJwtBearerAuth>;\ntype JwtBearerAuthParams = SiweParams | SRPParams;\n\nexport class JwtBearerAuth implements SIWEInterface, SRPInterface {\n #type: AuthType;\n\n #env: Env;\n\n #sdk: SIWEJwtBearerAuth | SRPJwtBearerAuth;\n\n constructor(...args: JwtBearerAuthParams) {\n this.#type = args[0].type;\n this.#env = args[0].env;\n\n if (args[0].type === AuthType.SRP) {\n this.#sdk = new SRPJwtBearerAuth(args[0], args[1]);\n return;\n }\n\n if (args[0].type === AuthType.SiWE) {\n this.#sdk = new SIWEJwtBearerAuth(args[0], args[1]);\n return;\n }\n\n throw new UnsupportedAuthTypeError('unsupported auth type');\n }\n\n async getAccessToken(): Promise<string> {\n return await this.#sdk.getAccessToken();\n }\n\n async connectSnap(): Promise<string> {\n this.#assertSRP(this.#type, this.#sdk);\n return this.#sdk.connectSnap();\n }\n\n async isSnapConnected(): Promise<boolean> {\n this.#assertSRP(this.#type, this.#sdk);\n return this.#sdk.isSnapConnected();\n }\n\n async getUserProfile(): Promise<UserProfile> {\n return await this.#sdk.getUserProfile();\n }\n\n async getIdentifier(): Promise<string> {\n return await this.#sdk.getIdentifier();\n }\n\n async signMessage(message: string): Promise<string> {\n return await this.#sdk.signMessage(message);\n }\n\n async pairIdentifiers(pairing: Pair[]): Promise<void> {\n const profile = await this.getUserProfile();\n const n = await getNonce(profile.profileId, this.#env);\n\n const logins = await Promise.all(\n pairing.map(async (p) => {\n try {\n const raw = `metamask:${n.nonce}:${p.identifier}`;\n const sig = await p.signMessage(raw);\n return {\n signature: sig,\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n raw_message: raw,\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n encrypted_storage_key: p.encryptedStorageKey,\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n identifier_type: p.identifierType,\n };\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n throw new PairError(\n `failed to sign pairing message: ${errorMessage}`,\n );\n }\n }),\n );\n\n const accessToken = await this.getAccessToken();\n await pairIdentifiers(n.nonce, logins, accessToken, this.#env);\n }\n\n prepare(signer: {\n address: string;\n chainId: number;\n signMessage: (message: string) => Promise<string>;\n domain: string;\n }): void {\n this.#assertSIWE(this.#type, this.#sdk);\n this.#sdk.prepare(signer);\n }\n\n #assertSIWE(\n type: AuthType,\n _sdk: SIWEJwtBearerAuth | SRPJwtBearerAuth,\n ): asserts _sdk is SIWEJwtBearerAuth {\n if (type === AuthType.SiWE) {\n return;\n }\n\n throw new UnsupportedAuthTypeError(\n 'This method is only available via SIWE auth type',\n );\n }\n\n #assertSRP(\n type: AuthType,\n _sdk: SIWEJwtBearerAuth | SRPJwtBearerAuth,\n ): asserts _sdk is SRPJwtBearerAuth {\n if (type === AuthType.SRP) {\n return;\n }\n\n throw new UnsupportedAuthTypeError(\n 'This method is only available via SRP auth type',\n );\n }\n}\n\nexport { SIWEJwtBearerAuth } from './authentication-jwt-bearer/flow-siwe';\nexport { SRPJwtBearerAuth } from './authentication-jwt-bearer/flow-srp';\nexport * from './authentication-jwt-bearer/types';\n"]}
@@ -1,6 +1,6 @@
1
- import { SIWEJwtBearerAuth } from './authentication-jwt-bearer/flow-siwe';
2
- import { SRPJwtBearerAuth } from './authentication-jwt-bearer/flow-srp';
3
- import type { UserProfile, Pair } from './authentication-jwt-bearer/types';
1
+ import { SIWEJwtBearerAuth } from "./authentication-jwt-bearer/flow-siwe.cjs";
2
+ import { SRPJwtBearerAuth } from "./authentication-jwt-bearer/flow-srp.cjs";
3
+ import type { UserProfile, Pair } from "./authentication-jwt-bearer/types.cjs";
4
4
  type Compute<T> = T extends infer U ? {
5
5
  [K in keyof U]: U[K];
6
6
  } : never;
@@ -26,7 +26,7 @@ export declare class JwtBearerAuth implements SIWEInterface, SRPInterface {
26
26
  domain: string;
27
27
  }): void;
28
28
  }
29
- export { SIWEJwtBearerAuth } from './authentication-jwt-bearer/flow-siwe';
30
- export { SRPJwtBearerAuth } from './authentication-jwt-bearer/flow-srp';
31
- export * from './authentication-jwt-bearer/types';
32
- //# sourceMappingURL=authentication.d.ts.map
29
+ export { SIWEJwtBearerAuth } from "./authentication-jwt-bearer/flow-siwe.cjs";
30
+ export { SRPJwtBearerAuth } from "./authentication-jwt-bearer/flow-srp.cjs";
31
+ export * from "./authentication-jwt-bearer/types.cjs";
32
+ //# sourceMappingURL=authentication.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authentication.d.cts","sourceRoot":"","sources":["../../src/sdk/authentication.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,kDAA8C;AAC1E,OAAO,EAAE,gBAAgB,EAAE,iDAA6C;AAKxE,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,8CAA0C;AAQ3E,KAAK,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,CAAC,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG,KAAK,CAAC;AACvE,KAAK,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAChD,KAAK,YAAY,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAE9C,KAAK,UAAU,GAAG,qBAAqB,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAClE,KAAK,SAAS,GAAG,qBAAqB,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAChE,KAAK,mBAAmB,GAAG,UAAU,GAAG,SAAS,CAAC;AAElD,qBAAa,aAAc,YAAW,aAAa,EAAE,YAAY;;gBAOnD,GAAG,IAAI,EAAE,mBAAmB;IAiBlC,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;IAIjC,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAK9B,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IAKnC,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC;IAItC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAIhC,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI7C,eAAe,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAoCrD,OAAO,CAAC,MAAM,EAAE;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;QAClD,MAAM,EAAE,MAAM,CAAC;KAChB,GAAG,IAAI;CA8BT;AAED,OAAO,EAAE,iBAAiB,EAAE,kDAA8C;AAC1E,OAAO,EAAE,gBAAgB,EAAE,iDAA6C;AACxE,sDAAkD"}
@@ -0,0 +1,32 @@
1
+ import { SIWEJwtBearerAuth } from "./authentication-jwt-bearer/flow-siwe.mjs";
2
+ import { SRPJwtBearerAuth } from "./authentication-jwt-bearer/flow-srp.mjs";
3
+ import type { UserProfile, Pair } from "./authentication-jwt-bearer/types.mjs";
4
+ type Compute<T> = T extends infer U ? {
5
+ [K in keyof U]: U[K];
6
+ } : never;
7
+ type SIWEInterface = Compute<SIWEJwtBearerAuth>;
8
+ type SRPInterface = Compute<SRPJwtBearerAuth>;
9
+ type SiweParams = ConstructorParameters<typeof SIWEJwtBearerAuth>;
10
+ type SRPParams = ConstructorParameters<typeof SRPJwtBearerAuth>;
11
+ type JwtBearerAuthParams = SiweParams | SRPParams;
12
+ export declare class JwtBearerAuth implements SIWEInterface, SRPInterface {
13
+ #private;
14
+ constructor(...args: JwtBearerAuthParams);
15
+ getAccessToken(): Promise<string>;
16
+ connectSnap(): Promise<string>;
17
+ isSnapConnected(): Promise<boolean>;
18
+ getUserProfile(): Promise<UserProfile>;
19
+ getIdentifier(): Promise<string>;
20
+ signMessage(message: string): Promise<string>;
21
+ pairIdentifiers(pairing: Pair[]): Promise<void>;
22
+ prepare(signer: {
23
+ address: string;
24
+ chainId: number;
25
+ signMessage: (message: string) => Promise<string>;
26
+ domain: string;
27
+ }): void;
28
+ }
29
+ export { SIWEJwtBearerAuth } from "./authentication-jwt-bearer/flow-siwe.mjs";
30
+ export { SRPJwtBearerAuth } from "./authentication-jwt-bearer/flow-srp.mjs";
31
+ export * from "./authentication-jwt-bearer/types.mjs";
32
+ //# sourceMappingURL=authentication.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authentication.d.mts","sourceRoot":"","sources":["../../src/sdk/authentication.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,kDAA8C;AAC1E,OAAO,EAAE,gBAAgB,EAAE,iDAA6C;AAKxE,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,8CAA0C;AAQ3E,KAAK,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,CAAC,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG,KAAK,CAAC;AACvE,KAAK,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAChD,KAAK,YAAY,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAE9C,KAAK,UAAU,GAAG,qBAAqB,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAClE,KAAK,SAAS,GAAG,qBAAqB,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAChE,KAAK,mBAAmB,GAAG,UAAU,GAAG,SAAS,CAAC;AAElD,qBAAa,aAAc,YAAW,aAAa,EAAE,YAAY;;gBAOnD,GAAG,IAAI,EAAE,mBAAmB;IAiBlC,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;IAIjC,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAK9B,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IAKnC,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC;IAItC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAIhC,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI7C,eAAe,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAoCrD,OAAO,CAAC,MAAM,EAAE;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;QAClD,MAAM,EAAE,MAAM,CAAC;KAChB,GAAG,IAAI;CA8BT;AAED,OAAO,EAAE,iBAAiB,EAAE,kDAA8C;AAC1E,OAAO,EAAE,gBAAgB,EAAE,iDAA6C;AACxE,sDAAkD"}
@@ -1,26 +1,104 @@
1
- import {
2
- JwtBearerAuth
3
- } from "../chunk-PU7MAIST.mjs";
4
- import {
5
- SIWEJwtBearerAuth
6
- } from "../chunk-2CWF7ZTL.mjs";
7
- import {
8
- SRPJwtBearerAuth
9
- } from "../chunk-TP7SP3AG.mjs";
10
- import "../chunk-YLURF2PF.mjs";
11
- import {
12
- AuthType
13
- } from "../chunk-CAIIVJAO.mjs";
14
- import "../chunk-5XSXZTED.mjs";
15
- import "../chunk-UEWCUBMX.mjs";
16
- import "../chunk-QDGLIUUS.mjs";
17
- import "../chunk-KTCSRECK.mjs";
18
- import "../chunk-TFFQFIJV.mjs";
19
- import "../chunk-U5UIDVOO.mjs";
20
- export {
21
- AuthType,
22
- JwtBearerAuth,
23
- SIWEJwtBearerAuth,
24
- SRPJwtBearerAuth
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ 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");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
25
6
  };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _JwtBearerAuth_instances, _JwtBearerAuth_type, _JwtBearerAuth_env, _JwtBearerAuth_sdk, _JwtBearerAuth_assertSIWE, _JwtBearerAuth_assertSRP;
13
+ import { SIWEJwtBearerAuth } from "./authentication-jwt-bearer/flow-siwe.mjs";
14
+ import { SRPJwtBearerAuth } from "./authentication-jwt-bearer/flow-srp.mjs";
15
+ import { getNonce, pairIdentifiers } from "./authentication-jwt-bearer/services.mjs";
16
+ import { AuthType } from "./authentication-jwt-bearer/types.mjs";
17
+ import { PairError, UnsupportedAuthTypeError } from "./errors.mjs";
18
+ export class JwtBearerAuth {
19
+ constructor(...args) {
20
+ _JwtBearerAuth_instances.add(this);
21
+ _JwtBearerAuth_type.set(this, void 0);
22
+ _JwtBearerAuth_env.set(this, void 0);
23
+ _JwtBearerAuth_sdk.set(this, void 0);
24
+ __classPrivateFieldSet(this, _JwtBearerAuth_type, args[0].type, "f");
25
+ __classPrivateFieldSet(this, _JwtBearerAuth_env, args[0].env, "f");
26
+ if (args[0].type === AuthType.SRP) {
27
+ __classPrivateFieldSet(this, _JwtBearerAuth_sdk, new SRPJwtBearerAuth(args[0], args[1]), "f");
28
+ return;
29
+ }
30
+ if (args[0].type === AuthType.SiWE) {
31
+ __classPrivateFieldSet(this, _JwtBearerAuth_sdk, new SIWEJwtBearerAuth(args[0], args[1]), "f");
32
+ return;
33
+ }
34
+ throw new UnsupportedAuthTypeError('unsupported auth type');
35
+ }
36
+ async getAccessToken() {
37
+ return await __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f").getAccessToken();
38
+ }
39
+ async connectSnap() {
40
+ __classPrivateFieldGet(this, _JwtBearerAuth_instances, "m", _JwtBearerAuth_assertSRP).call(this, __classPrivateFieldGet(this, _JwtBearerAuth_type, "f"), __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f"));
41
+ return __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f").connectSnap();
42
+ }
43
+ async isSnapConnected() {
44
+ __classPrivateFieldGet(this, _JwtBearerAuth_instances, "m", _JwtBearerAuth_assertSRP).call(this, __classPrivateFieldGet(this, _JwtBearerAuth_type, "f"), __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f"));
45
+ return __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f").isSnapConnected();
46
+ }
47
+ async getUserProfile() {
48
+ return await __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f").getUserProfile();
49
+ }
50
+ async getIdentifier() {
51
+ return await __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f").getIdentifier();
52
+ }
53
+ async signMessage(message) {
54
+ return await __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f").signMessage(message);
55
+ }
56
+ async pairIdentifiers(pairing) {
57
+ const profile = await this.getUserProfile();
58
+ const n = await getNonce(profile.profileId, __classPrivateFieldGet(this, _JwtBearerAuth_env, "f"));
59
+ const logins = await Promise.all(pairing.map(async (p) => {
60
+ try {
61
+ const raw = `metamask:${n.nonce}:${p.identifier}`;
62
+ const sig = await p.signMessage(raw);
63
+ return {
64
+ signature: sig,
65
+ // TODO: Either fix this lint violation or explain why it's necessary to ignore.
66
+ // eslint-disable-next-line @typescript-eslint/naming-convention
67
+ raw_message: raw,
68
+ // TODO: Either fix this lint violation or explain why it's necessary to ignore.
69
+ // eslint-disable-next-line @typescript-eslint/naming-convention
70
+ encrypted_storage_key: p.encryptedStorageKey,
71
+ // TODO: Either fix this lint violation or explain why it's necessary to ignore.
72
+ // eslint-disable-next-line @typescript-eslint/naming-convention
73
+ identifier_type: p.identifierType,
74
+ };
75
+ }
76
+ catch (e) {
77
+ /* istanbul ignore next */
78
+ const errorMessage = e instanceof Error ? e.message : JSON.stringify(e ?? '');
79
+ throw new PairError(`failed to sign pairing message: ${errorMessage}`);
80
+ }
81
+ }));
82
+ const accessToken = await this.getAccessToken();
83
+ await pairIdentifiers(n.nonce, logins, accessToken, __classPrivateFieldGet(this, _JwtBearerAuth_env, "f"));
84
+ }
85
+ prepare(signer) {
86
+ __classPrivateFieldGet(this, _JwtBearerAuth_instances, "m", _JwtBearerAuth_assertSIWE).call(this, __classPrivateFieldGet(this, _JwtBearerAuth_type, "f"), __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f"));
87
+ __classPrivateFieldGet(this, _JwtBearerAuth_sdk, "f").prepare(signer);
88
+ }
89
+ }
90
+ _JwtBearerAuth_type = new WeakMap(), _JwtBearerAuth_env = new WeakMap(), _JwtBearerAuth_sdk = new WeakMap(), _JwtBearerAuth_instances = new WeakSet(), _JwtBearerAuth_assertSIWE = function _JwtBearerAuth_assertSIWE(type, _sdk) {
91
+ if (type === AuthType.SiWE) {
92
+ return;
93
+ }
94
+ throw new UnsupportedAuthTypeError('This method is only available via SIWE auth type');
95
+ }, _JwtBearerAuth_assertSRP = function _JwtBearerAuth_assertSRP(type, _sdk) {
96
+ if (type === AuthType.SRP) {
97
+ return;
98
+ }
99
+ throw new UnsupportedAuthTypeError('This method is only available via SRP auth type');
100
+ };
101
+ export { SIWEJwtBearerAuth } from "./authentication-jwt-bearer/flow-siwe.mjs";
102
+ export { SRPJwtBearerAuth } from "./authentication-jwt-bearer/flow-srp.mjs";
103
+ export * from "./authentication-jwt-bearer/types.mjs";
26
104
  //# sourceMappingURL=authentication.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"authentication.mjs","sourceRoot":"","sources":["../../src/sdk/authentication.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,iBAAiB,EAAE,kDAA8C;AAC1E,OAAO,EAAE,gBAAgB,EAAE,iDAA6C;AACxE,OAAO,EACL,QAAQ,EACR,eAAe,EAChB,iDAA6C;AAE9C,OAAO,EAAE,QAAQ,EAAE,8CAA0C;AAE7D,OAAO,EAAE,SAAS,EAAE,wBAAwB,EAAE,qBAAiB;AAa/D,MAAM,OAAO,aAAa;IAOxB,YAAY,GAAG,IAAyB;;QANxC,sCAAgB;QAEhB,qCAAU;QAEV,qCAA2C;QAGzC,uBAAA,IAAI,uBAAS,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,MAAA,CAAC;QAC1B,uBAAA,IAAI,sBAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,MAAA,CAAC;QAExB,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,GAAG,EAAE;YACjC,uBAAA,IAAI,sBAAQ,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,MAAA,CAAC;YACnD,OAAO;SACR;QAED,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,EAAE;YAClC,uBAAA,IAAI,sBAAQ,IAAI,iBAAiB,CAAC,IAAI,CAAC,C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,wBAAwB,CAChC,kDAAkD,CACnD,CAAC;AACJ,CAAC,+DAGC,IAAc,EACd,IAA0C;IAE1C,IAAI,IAAI,KAAK,QAAQ,CAAC,GAAG,EAAE;QACzB,OAAO;KACR;IAED,MAAM,IAAI,wBAAwB,CAChC,iDAAiD,CAClD,CAAC;AACJ,CAAC;AAGH,OAAO,EAAE,iBAAiB,EAAE,kDAA8C;AAC1E,OAAO,EAAE,gBAAgB,EAAE,iDAA6C;AACxE,sDAAkD","sourcesContent":["import { SIWEJwtBearerAuth } from './authentication-jwt-bearer/flow-siwe';\nimport { SRPJwtBearerAuth } from './authentication-jwt-bearer/flow-srp';\nimport {\n getNonce,\n pairIdentifiers,\n} from './authentication-jwt-bearer/services';\nimport type { UserProfile, Pair } from './authentication-jwt-bearer/types';\nimport { AuthType } from './authentication-jwt-bearer/types';\nimport type { Env } from './env';\nimport { PairError, UnsupportedAuthTypeError } from './errors';\n\n// Computing the Classes, so we only get back the public methods for the interface.\n// TODO: Either fix this lint violation or explain why it's necessary to ignore.\n// eslint-disable-next-line @typescript-eslint/naming-convention\ntype Compute<T> = T extends infer U ? { [K in keyof U]: U[K] } : never;\ntype SIWEInterface = Compute<SIWEJwtBearerAuth>;\ntype SRPInterface = Compute<SRPJwtBearerAuth>;\n\ntype SiweParams = ConstructorParameters<typeof SIWEJwtBearerAuth>;\ntype SRPParams = ConstructorParameters<typeof SRPJwtBearerAuth>;\ntype JwtBearerAuthParams = SiweParams | SRPParams;\n\nexport class JwtBearerAuth implements SIWEInterface, SRPInterface {\n #type: AuthType;\n\n #env: Env;\n\n #sdk: SIWEJwtBearerAuth | SRPJwtBearerAuth;\n\n constructor(...args: JwtBearerAuthParams) {\n this.#type = args[0].type;\n this.#env = args[0].env;\n\n if (args[0].type === AuthType.SRP) {\n this.#sdk = new SRPJwtBearerAuth(args[0], args[1]);\n return;\n }\n\n if (args[0].type === AuthType.SiWE) {\n this.#sdk = new SIWEJwtBearerAuth(args[0], args[1]);\n return;\n }\n\n throw new UnsupportedAuthTypeError('unsupported auth type');\n }\n\n async getAccessToken(): Promise<string> {\n return await this.#sdk.getAccessToken();\n }\n\n async connectSnap(): Promise<string> {\n this.#assertSRP(this.#type, this.#sdk);\n return this.#sdk.connectSnap();\n }\n\n async isSnapConnected(): Promise<boolean> {\n this.#assertSRP(this.#type, this.#sdk);\n return this.#sdk.isSnapConnected();\n }\n\n async getUserProfile(): Promise<UserProfile> {\n return await this.#sdk.getUserProfile();\n }\n\n async getIdentifier(): Promise<string> {\n return await this.#sdk.getIdentifier();\n }\n\n async signMessage(message: string): Promise<string> {\n return await this.#sdk.signMessage(message);\n }\n\n async pairIdentifiers(pairing: Pair[]): Promise<void> {\n const profile = await this.getUserProfile();\n const n = await getNonce(profile.profileId, this.#env);\n\n const logins = await Promise.all(\n pairing.map(async (p) => {\n try {\n const raw = `metamask:${n.nonce}:${p.identifier}`;\n const sig = await p.signMessage(raw);\n return {\n signature: sig,\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n raw_message: raw,\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n encrypted_storage_key: p.encryptedStorageKey,\n // TODO: Either fix this lint violation or explain why it's necessary to ignore.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n identifier_type: p.identifierType,\n };\n } catch (e) {\n /* istanbul ignore next */\n const errorMessage =\n e instanceof Error ? e.message : JSON.stringify(e ?? '');\n throw new PairError(\n `failed to sign pairing message: ${errorMessage}`,\n );\n }\n }),\n );\n\n const accessToken = await this.getAccessToken();\n await pairIdentifiers(n.nonce, logins, accessToken, this.#env);\n }\n\n prepare(signer: {\n address: string;\n chainId: number;\n signMessage: (message: string) => Promise<string>;\n domain: string;\n }): void {\n this.#assertSIWE(this.#type, this.#sdk);\n this.#sdk.prepare(signer);\n }\n\n #assertSIWE(\n type: AuthType,\n _sdk: SIWEJwtBearerAuth | SRPJwtBearerAuth,\n ): asserts _sdk is SIWEJwtBearerAuth {\n if (type === AuthType.SiWE) {\n return;\n }\n\n throw new UnsupportedAuthTypeError(\n 'This method is only available via SIWE auth type',\n );\n }\n\n #assertSRP(\n type: AuthType,\n _sdk: SIWEJwtBearerAuth | SRPJwtBearerAuth,\n ): asserts _sdk is SRPJwtBearerAuth {\n if (type === AuthType.SRP) {\n return;\n }\n\n throw new UnsupportedAuthTypeError(\n 'This method is only available via SRP auth type',\n );\n }\n}\n\nexport { SIWEJwtBearerAuth } from './authentication-jwt-bearer/flow-siwe';\nexport { SRPJwtBearerAuth } from './authentication-jwt-bearer/flow-srp';\nexport * from './authentication-jwt-bearer/types';\n"]}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ const encryption_1 = __importDefault(require("../controllers/user-storage/encryption/encryption.cjs"));
21
+ __exportStar(require("../controllers/user-storage/encryption/encryption.cjs"), exports);
22
+ exports.default = encryption_1.default;
23
+ //# sourceMappingURL=encryption.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encryption.cjs","sourceRoot":"","sources":["../../src/sdk/encryption.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,uGAA2E;AAE3E,wFAAkE;AAClE,kBAAe,oBAAU,CAAC","sourcesContent":["import encryption from '../controllers/user-storage/encryption/encryption';\n\nexport * from '../controllers/user-storage/encryption/encryption';\nexport default encryption;\n"]}
@@ -0,0 +1,4 @@
1
+ import encryption from "../controllers/user-storage/encryption/encryption.cjs";
2
+ export * from "../controllers/user-storage/encryption/encryption.cjs";
3
+ export default encryption;
4
+ //# sourceMappingURL=encryption.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encryption.d.cts","sourceRoot":"","sources":["../../src/sdk/encryption.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,8DAA0D;AAE3E,sEAAkE;AAClE,eAAe,UAAU,CAAC"}
@@ -0,0 +1,4 @@
1
+ import encryption from "../controllers/user-storage/encryption/encryption.mjs";
2
+ export * from "../controllers/user-storage/encryption/encryption.mjs";
3
+ export default encryption;
4
+ //# sourceMappingURL=encryption.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encryption.d.mts","sourceRoot":"","sources":["../../src/sdk/encryption.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,8DAA0D;AAE3E,sEAAkE;AAClE,eAAe,UAAU,CAAC"}
@@ -1,14 +1,4 @@
1
- import {
2
- encryption_default
3
- } from "../chunk-6DAK2U35.mjs";
4
- import {
5
- createSHA256Hash
6
- } from "../chunk-COBJUBZE.mjs";
7
- import "../chunk-H25EBXG5.mjs";
8
- import "../chunk-76VRE4BI.mjs";
9
- import "../chunk-U5UIDVOO.mjs";
10
- export {
11
- createSHA256Hash,
12
- encryption_default as default
13
- };
1
+ import encryption from "../controllers/user-storage/encryption/encryption.mjs";
2
+ export * from "../controllers/user-storage/encryption/encryption.mjs";
3
+ export default encryption;
14
4
  //# sourceMappingURL=encryption.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"encryption.mjs","sourceRoot":"","sources":["../../src/sdk/encryption.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,8DAA0D;AAE3E,sEAAkE;AAClE,eAAe,UAAU,CAAC","sourcesContent":["import encryption from '../controllers/user-storage/encryption/encryption';\n\nexport * from '../controllers/user-storage/encryption/encryption';\nexport default encryption;\n"]}