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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (548) hide show
  1. package/CHANGELOG.md +0 -1
  2. package/dist/controllers/authentication/AuthenticationController-method-action-types.cjs +7 -0
  3. package/dist/controllers/authentication/AuthenticationController-method-action-types.cjs.map +1 -0
  4. package/dist/controllers/authentication/{AuthenticationController-method-action-types.d.ts → AuthenticationController-method-action-types.d.cts} +2 -2
  5. package/dist/controllers/authentication/AuthenticationController-method-action-types.d.cts.map +1 -0
  6. package/dist/controllers/authentication/AuthenticationController-method-action-types.d.mts +102 -0
  7. package/dist/controllers/authentication/AuthenticationController-method-action-types.d.mts.map +1 -0
  8. package/dist/controllers/authentication/{AuthenticationController-method-action-types.js → AuthenticationController-method-action-types.mjs} +1 -1
  9. package/dist/controllers/authentication/AuthenticationController-method-action-types.mjs.map +1 -0
  10. package/dist/controllers/authentication/AuthenticationController.cjs +489 -0
  11. package/dist/controllers/authentication/AuthenticationController.cjs.map +1 -0
  12. package/dist/controllers/authentication/{AuthenticationController.d.ts → AuthenticationController.d.cts} +10 -10
  13. package/dist/controllers/authentication/AuthenticationController.d.cts.map +1 -0
  14. package/dist/controllers/authentication/AuthenticationController.d.mts +130 -0
  15. package/dist/controllers/authentication/AuthenticationController.d.mts.map +1 -0
  16. package/dist/controllers/authentication/AuthenticationController.mjs +485 -0
  17. package/dist/controllers/authentication/AuthenticationController.mjs.map +1 -0
  18. package/dist/controllers/authentication/index.cjs +35 -0
  19. package/dist/controllers/authentication/index.cjs.map +1 -0
  20. package/dist/controllers/authentication/{index.d.ts → index.d.cts} +5 -5
  21. package/dist/controllers/authentication/index.d.cts.map +1 -0
  22. package/dist/controllers/authentication/index.d.mts +7 -0
  23. package/dist/controllers/authentication/index.d.mts.map +1 -0
  24. package/dist/controllers/authentication/index.mjs +6 -0
  25. package/dist/controllers/authentication/index.mjs.map +1 -0
  26. package/dist/controllers/authentication/mocks/index.cjs +18 -0
  27. package/dist/controllers/authentication/mocks/index.cjs.map +1 -0
  28. package/dist/controllers/authentication/mocks/index.d.cts +2 -0
  29. package/dist/controllers/authentication/mocks/index.d.cts.map +1 -0
  30. package/dist/controllers/authentication/mocks/index.d.mts +2 -0
  31. package/dist/controllers/authentication/mocks/index.d.mts.map +1 -0
  32. package/dist/controllers/authentication/mocks/index.mjs +2 -0
  33. package/dist/controllers/authentication/mocks/index.mjs.map +1 -0
  34. package/dist/controllers/authentication/mocks/mockResponses.cjs +126 -0
  35. package/dist/controllers/authentication/mocks/mockResponses.cjs.map +1 -0
  36. package/dist/controllers/authentication/mocks/{mockResponses.d.ts → mockResponses.d.cts} +1 -1
  37. package/dist/controllers/authentication/mocks/mockResponses.d.cts.map +1 -0
  38. package/dist/controllers/authentication/mocks/mockResponses.d.mts +58 -0
  39. package/dist/controllers/authentication/mocks/mockResponses.d.mts.map +1 -0
  40. package/dist/controllers/authentication/mocks/{mockResponses.js → mockResponses.mjs} +2 -2
  41. package/dist/controllers/authentication/mocks/mockResponses.mjs.map +1 -0
  42. package/dist/controllers/index.cjs +29 -0
  43. package/dist/controllers/index.cjs.map +1 -0
  44. package/dist/controllers/index.d.cts +3 -0
  45. package/dist/controllers/index.d.cts.map +1 -0
  46. package/dist/controllers/index.d.mts +3 -0
  47. package/dist/controllers/index.d.mts.map +1 -0
  48. package/dist/controllers/index.mjs +3 -0
  49. package/dist/controllers/index.mjs.map +1 -0
  50. package/dist/controllers/user-storage/UserStorageController-method-action-types.cjs +7 -0
  51. package/dist/controllers/user-storage/UserStorageController-method-action-types.cjs.map +1 -0
  52. package/dist/controllers/user-storage/{UserStorageController-method-action-types.d.ts → UserStorageController-method-action-types.d.cts} +2 -2
  53. package/dist/controllers/user-storage/UserStorageController-method-action-types.d.cts.map +1 -0
  54. package/dist/controllers/user-storage/UserStorageController-method-action-types.d.mts +137 -0
  55. package/dist/controllers/user-storage/UserStorageController-method-action-types.d.mts.map +1 -0
  56. package/dist/controllers/user-storage/{UserStorageController-method-action-types.js → UserStorageController-method-action-types.mjs} +1 -1
  57. package/dist/controllers/user-storage/UserStorageController-method-action-types.mjs.map +1 -0
  58. package/dist/controllers/user-storage/UserStorageController.cjs +412 -0
  59. package/dist/controllers/user-storage/UserStorageController.cjs.map +1 -0
  60. package/dist/controllers/user-storage/{UserStorageController.d.ts → UserStorageController.d.cts} +14 -14
  61. package/dist/controllers/user-storage/UserStorageController.d.cts.map +1 -0
  62. package/dist/controllers/user-storage/UserStorageController.d.mts +182 -0
  63. package/dist/controllers/user-storage/UserStorageController.d.mts.map +1 -0
  64. package/dist/controllers/user-storage/UserStorageController.mjs +408 -0
  65. package/dist/controllers/user-storage/UserStorageController.mjs.map +1 -0
  66. package/dist/controllers/user-storage/constants.cjs +19 -0
  67. package/dist/controllers/user-storage/constants.cjs.map +1 -0
  68. package/dist/controllers/user-storage/constants.d.cts +15 -0
  69. package/dist/controllers/user-storage/constants.d.cts.map +1 -0
  70. package/dist/controllers/user-storage/constants.d.mts +15 -0
  71. package/dist/controllers/user-storage/constants.d.mts.map +1 -0
  72. package/dist/controllers/user-storage/{constants.js → constants.mjs} +1 -1
  73. package/dist/controllers/user-storage/constants.mjs.map +1 -0
  74. package/dist/controllers/user-storage/contact-syncing/constants.cjs +12 -0
  75. package/dist/controllers/user-storage/contact-syncing/constants.cjs.map +1 -0
  76. package/dist/controllers/user-storage/contact-syncing/{constants.d.ts → constants.d.cts} +1 -1
  77. package/dist/controllers/user-storage/contact-syncing/constants.d.cts.map +1 -0
  78. package/dist/controllers/user-storage/contact-syncing/constants.d.mts +9 -0
  79. package/dist/controllers/user-storage/contact-syncing/constants.d.mts.map +1 -0
  80. package/dist/controllers/user-storage/contact-syncing/{constants.js → constants.mjs} +1 -1
  81. package/dist/controllers/user-storage/contact-syncing/constants.mjs.map +1 -0
  82. package/dist/controllers/user-storage/contact-syncing/controller-integration.cjs +346 -0
  83. package/dist/controllers/user-storage/contact-syncing/controller-integration.cjs.map +1 -0
  84. package/dist/controllers/user-storage/contact-syncing/{controller-integration.d.ts → controller-integration.d.cts} +3 -3
  85. package/dist/controllers/user-storage/contact-syncing/controller-integration.d.cts.map +1 -0
  86. package/dist/controllers/user-storage/contact-syncing/controller-integration.d.mts +47 -0
  87. package/dist/controllers/user-storage/contact-syncing/controller-integration.d.mts.map +1 -0
  88. package/dist/controllers/user-storage/contact-syncing/{controller-integration.js → controller-integration.mjs} +6 -6
  89. package/dist/controllers/user-storage/contact-syncing/controller-integration.mjs.map +1 -0
  90. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.cjs +50 -0
  91. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.cjs.map +1 -0
  92. package/dist/controllers/user-storage/contact-syncing/{setup-subscriptions.d.ts → setup-subscriptions.d.cts} +2 -2
  93. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.cts.map +1 -0
  94. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.mts +8 -0
  95. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.mts.map +1 -0
  96. package/dist/controllers/user-storage/contact-syncing/{setup-subscriptions.js → setup-subscriptions.mjs} +4 -4
  97. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.mjs.map +1 -0
  98. package/dist/controllers/user-storage/contact-syncing/sync-utils.cjs +23 -0
  99. package/dist/controllers/user-storage/contact-syncing/sync-utils.cjs.map +1 -0
  100. package/dist/controllers/user-storage/contact-syncing/{sync-utils.d.ts → sync-utils.d.cts} +2 -2
  101. package/dist/controllers/user-storage/contact-syncing/sync-utils.d.cts.map +1 -0
  102. package/dist/controllers/user-storage/contact-syncing/sync-utils.d.mts +9 -0
  103. package/dist/controllers/user-storage/contact-syncing/sync-utils.d.mts.map +1 -0
  104. package/dist/controllers/user-storage/contact-syncing/{sync-utils.js → sync-utils.mjs} +1 -1
  105. package/dist/controllers/user-storage/contact-syncing/sync-utils.mjs.map +1 -0
  106. package/dist/controllers/user-storage/contact-syncing/types.cjs +3 -0
  107. package/dist/controllers/user-storage/contact-syncing/types.cjs.map +1 -0
  108. package/dist/controllers/user-storage/contact-syncing/{types.d.ts → types.d.cts} +6 -6
  109. package/dist/controllers/user-storage/contact-syncing/types.d.cts.map +1 -0
  110. package/dist/controllers/user-storage/contact-syncing/types.d.mts +37 -0
  111. package/dist/controllers/user-storage/contact-syncing/types.d.mts.map +1 -0
  112. package/dist/controllers/user-storage/contact-syncing/types.mjs +2 -0
  113. package/dist/controllers/user-storage/contact-syncing/types.mjs.map +1 -0
  114. package/dist/controllers/user-storage/contact-syncing/utils.cjs +64 -0
  115. package/dist/controllers/user-storage/contact-syncing/utils.cjs.map +1 -0
  116. package/dist/controllers/user-storage/contact-syncing/{utils.d.ts → utils.d.cts} +3 -3
  117. package/dist/controllers/user-storage/contact-syncing/utils.d.cts.map +1 -0
  118. package/dist/controllers/user-storage/contact-syncing/utils.d.mts +36 -0
  119. package/dist/controllers/user-storage/contact-syncing/utils.d.mts.map +1 -0
  120. package/dist/controllers/user-storage/contact-syncing/{utils.js → utils.mjs} +2 -2
  121. package/dist/controllers/user-storage/contact-syncing/utils.mjs.map +1 -0
  122. package/dist/controllers/user-storage/index.cjs +38 -0
  123. package/dist/controllers/user-storage/index.cjs.map +1 -0
  124. package/dist/controllers/user-storage/{index.d.ts → index.d.cts} +8 -8
  125. package/dist/controllers/user-storage/index.d.cts.map +1 -0
  126. package/dist/controllers/user-storage/index.d.mts +10 -0
  127. package/dist/controllers/user-storage/index.d.mts.map +1 -0
  128. package/dist/controllers/user-storage/index.mjs +9 -0
  129. package/dist/controllers/user-storage/index.mjs.map +1 -0
  130. package/dist/controllers/user-storage/mocks/index.cjs +19 -0
  131. package/dist/controllers/user-storage/mocks/index.cjs.map +1 -0
  132. package/dist/controllers/user-storage/mocks/index.d.cts +3 -0
  133. package/dist/controllers/user-storage/mocks/index.d.cts.map +1 -0
  134. package/dist/controllers/user-storage/mocks/index.d.mts +3 -0
  135. package/dist/controllers/user-storage/mocks/index.d.mts.map +1 -0
  136. package/dist/controllers/user-storage/mocks/index.mjs +3 -0
  137. package/dist/controllers/user-storage/mocks/index.mjs.map +1 -0
  138. package/dist/controllers/user-storage/mocks/mockResponses.cjs +113 -0
  139. package/dist/controllers/user-storage/mocks/mockResponses.cjs.map +1 -0
  140. package/dist/controllers/user-storage/mocks/{mockResponses.d.ts → mockResponses.d.cts} +3 -3
  141. package/dist/controllers/user-storage/mocks/mockResponses.d.cts.map +1 -0
  142. package/dist/controllers/user-storage/mocks/mockResponses.d.mts +66 -0
  143. package/dist/controllers/user-storage/mocks/mockResponses.d.mts.map +1 -0
  144. package/dist/controllers/user-storage/mocks/{mockResponses.js → mockResponses.mjs} +4 -4
  145. package/dist/controllers/user-storage/mocks/mockResponses.mjs.map +1 -0
  146. package/dist/controllers/user-storage/mocks/mockStorage.cjs +36 -0
  147. package/dist/controllers/user-storage/mocks/mockStorage.cjs.map +1 -0
  148. package/dist/controllers/user-storage/mocks/{mockStorage.d.ts → mockStorage.d.cts} +1 -1
  149. package/dist/controllers/user-storage/mocks/mockStorage.d.cts.map +1 -0
  150. package/dist/controllers/user-storage/mocks/mockStorage.d.mts +5 -0
  151. package/dist/controllers/user-storage/mocks/mockStorage.d.mts.map +1 -0
  152. package/dist/controllers/user-storage/mocks/{mockStorage.js → mockStorage.mjs} +3 -3
  153. package/dist/controllers/user-storage/mocks/mockStorage.mjs.map +1 -0
  154. package/dist/controllers/user-storage/types.cjs +3 -0
  155. package/dist/controllers/user-storage/types.cjs.map +1 -0
  156. package/dist/controllers/user-storage/{types.d.ts → types.d.cts} +3 -3
  157. package/dist/controllers/user-storage/types.d.cts.map +1 -0
  158. package/dist/controllers/user-storage/types.d.mts +23 -0
  159. package/dist/controllers/user-storage/types.d.mts.map +1 -0
  160. package/dist/controllers/user-storage/types.mjs +2 -0
  161. package/dist/controllers/user-storage/types.mjs.map +1 -0
  162. package/dist/controllers/user-storage/utils.cjs +32 -0
  163. package/dist/controllers/user-storage/utils.cjs.map +1 -0
  164. package/dist/controllers/user-storage/{utils.d.ts → utils.d.cts} +1 -1
  165. package/dist/controllers/user-storage/utils.d.cts.map +1 -0
  166. package/dist/controllers/user-storage/utils.d.mts +19 -0
  167. package/dist/controllers/user-storage/utils.d.mts.map +1 -0
  168. package/dist/controllers/user-storage/{utils.js → utils.mjs} +1 -1
  169. package/dist/controllers/user-storage/utils.mjs.map +1 -0
  170. package/dist/index.cjs +30 -0
  171. package/dist/index.cjs.map +1 -0
  172. package/dist/index.d.cts +4 -0
  173. package/dist/index.d.cts.map +1 -0
  174. package/dist/index.d.mts +4 -0
  175. package/dist/index.d.mts.map +1 -0
  176. package/dist/index.mjs +4 -0
  177. package/dist/index.mjs.map +1 -0
  178. package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs +114 -0
  179. package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs.map +1 -0
  180. package/dist/sdk/authentication-jwt-bearer/{flow-siwe.d.ts → flow-siwe.d.cts} +2 -2
  181. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.cts.map +1 -0
  182. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.mts +25 -0
  183. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.mts.map +1 -0
  184. package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs +110 -0
  185. package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs.map +1 -0
  186. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs +290 -0
  187. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs.map +1 -0
  188. package/dist/sdk/authentication-jwt-bearer/{flow-srp.d.ts → flow-srp.d.cts} +5 -5
  189. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts.map +1 -0
  190. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts +44 -0
  191. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts.map +1 -0
  192. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs +263 -0
  193. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs.map +1 -0
  194. package/dist/sdk/authentication-jwt-bearer/services.cjs +400 -0
  195. package/dist/sdk/authentication-jwt-bearer/services.cjs.map +1 -0
  196. package/dist/sdk/authentication-jwt-bearer/{services.d.ts → services.d.cts} +5 -5
  197. package/dist/sdk/authentication-jwt-bearer/services.d.cts.map +1 -0
  198. package/dist/sdk/authentication-jwt-bearer/services.d.mts +105 -0
  199. package/dist/sdk/authentication-jwt-bearer/services.d.mts.map +1 -0
  200. package/dist/sdk/authentication-jwt-bearer/{services.js → services.mjs} +6 -6
  201. package/dist/sdk/authentication-jwt-bearer/services.mjs.map +1 -0
  202. package/dist/sdk/authentication-jwt-bearer/types.cjs +12 -0
  203. package/dist/sdk/authentication-jwt-bearer/types.cjs.map +1 -0
  204. package/dist/sdk/authentication-jwt-bearer/{types.d.ts → types.d.cts} +2 -2
  205. package/dist/sdk/authentication-jwt-bearer/types.d.cts.map +1 -0
  206. package/dist/sdk/authentication-jwt-bearer/types.d.mts +114 -0
  207. package/dist/sdk/authentication-jwt-bearer/types.d.mts.map +1 -0
  208. package/dist/sdk/authentication-jwt-bearer/{types.js → types.mjs} +1 -1
  209. package/dist/sdk/authentication-jwt-bearer/types.mjs.map +1 -0
  210. package/dist/sdk/authentication-jwt-bearer/utils/identifier.cjs +27 -0
  211. package/dist/sdk/authentication-jwt-bearer/utils/identifier.cjs.map +1 -0
  212. package/dist/sdk/authentication-jwt-bearer/utils/{identifier.d.ts → identifier.d.cts} +2 -2
  213. package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.cts.map +1 -0
  214. package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.mts +13 -0
  215. package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.mts.map +1 -0
  216. package/dist/sdk/authentication-jwt-bearer/utils/{identifier.js → identifier.mjs} +2 -2
  217. package/dist/sdk/authentication-jwt-bearer/utils/identifier.mjs.map +1 -0
  218. package/dist/sdk/authentication-jwt-bearer/utils/time.cjs +17 -0
  219. package/dist/sdk/authentication-jwt-bearer/utils/time.cjs.map +1 -0
  220. package/dist/sdk/authentication-jwt-bearer/utils/{time.d.ts → time.d.cts} +1 -1
  221. package/dist/sdk/authentication-jwt-bearer/utils/time.d.cts.map +1 -0
  222. package/dist/sdk/authentication-jwt-bearer/utils/time.d.mts +8 -0
  223. package/dist/sdk/authentication-jwt-bearer/utils/time.d.mts.map +1 -0
  224. package/dist/sdk/authentication-jwt-bearer/utils/{time.js → time.mjs} +1 -1
  225. package/dist/sdk/authentication-jwt-bearer/utils/time.mjs.map +1 -0
  226. package/dist/sdk/authentication.cjs +132 -0
  227. package/dist/sdk/authentication.cjs.map +1 -0
  228. package/dist/sdk/{authentication.d.ts → authentication.d.cts} +9 -9
  229. package/dist/sdk/authentication.d.cts.map +1 -0
  230. package/dist/sdk/authentication.d.mts +38 -0
  231. package/dist/sdk/authentication.d.mts.map +1 -0
  232. package/dist/sdk/authentication.mjs +112 -0
  233. package/dist/sdk/authentication.mjs.map +1 -0
  234. package/dist/sdk/constants.cjs +7 -0
  235. package/dist/sdk/constants.cjs.map +1 -0
  236. package/dist/sdk/{constants.d.ts → constants.d.cts} +1 -1
  237. package/dist/sdk/constants.d.cts.map +1 -0
  238. package/dist/sdk/constants.d.mts +4 -0
  239. package/dist/sdk/constants.d.mts.map +1 -0
  240. package/dist/sdk/{constants.js → constants.mjs} +1 -1
  241. package/dist/sdk/constants.mjs.map +1 -0
  242. package/dist/sdk/errors.cjs +76 -0
  243. package/dist/sdk/errors.cjs.map +1 -0
  244. package/dist/sdk/{errors.d.ts → errors.d.cts} +1 -1
  245. package/dist/sdk/errors.d.cts.map +1 -0
  246. package/dist/sdk/errors.d.mts +34 -0
  247. package/dist/sdk/errors.d.mts.map +1 -0
  248. package/dist/sdk/{errors.js → errors.mjs} +3 -4
  249. package/dist/sdk/errors.mjs.map +1 -0
  250. package/dist/sdk/index.cjs +24 -0
  251. package/dist/sdk/index.cjs.map +1 -0
  252. package/dist/sdk/index.d.cts +8 -0
  253. package/dist/sdk/index.d.cts.map +1 -0
  254. package/dist/sdk/index.d.mts +8 -0
  255. package/dist/sdk/index.d.mts.map +1 -0
  256. package/dist/sdk/index.mjs +8 -0
  257. package/dist/sdk/index.mjs.map +1 -0
  258. package/dist/sdk/mocks/auth.cjs +82 -0
  259. package/dist/sdk/mocks/auth.cjs.map +1 -0
  260. package/dist/sdk/mocks/{auth.d.ts → auth.d.cts} +2 -2
  261. package/dist/sdk/mocks/auth.d.cts.map +1 -0
  262. package/dist/sdk/mocks/auth.d.mts +69 -0
  263. package/dist/sdk/mocks/auth.d.mts.map +1 -0
  264. package/dist/sdk/mocks/{auth.js → auth.mjs} +3 -3
  265. package/dist/sdk/mocks/auth.mjs.map +1 -0
  266. package/dist/sdk/mocks/userstorage.cjs +43 -0
  267. package/dist/sdk/mocks/userstorage.cjs.map +1 -0
  268. package/dist/sdk/mocks/{userstorage.d.ts → userstorage.d.cts} +1 -1
  269. package/dist/sdk/mocks/userstorage.d.cts.map +1 -0
  270. package/dist/sdk/mocks/userstorage.d.mts +10 -0
  271. package/dist/sdk/mocks/userstorage.d.mts.map +1 -0
  272. package/dist/sdk/mocks/{userstorage.js → userstorage.mjs} +5 -5
  273. package/dist/sdk/mocks/userstorage.mjs.map +1 -0
  274. package/dist/sdk/user-storage.cjs +386 -0
  275. package/dist/sdk/user-storage.cjs.map +1 -0
  276. package/dist/sdk/{user-storage.d.ts → user-storage.d.cts} +5 -5
  277. package/dist/sdk/user-storage.d.cts.map +1 -0
  278. package/dist/sdk/user-storage.d.mts +47 -0
  279. package/dist/sdk/user-storage.d.mts.map +1 -0
  280. package/dist/sdk/user-storage.mjs +358 -0
  281. package/dist/sdk/user-storage.mjs.map +1 -0
  282. package/dist/sdk/utils/eip-6963-metamask-provider.cjs +70 -0
  283. package/dist/sdk/utils/eip-6963-metamask-provider.cjs.map +1 -0
  284. package/dist/sdk/utils/{eip-6963-metamask-provider.d.ts → eip-6963-metamask-provider.d.cts} +2 -2
  285. package/dist/sdk/utils/eip-6963-metamask-provider.d.cts.map +1 -0
  286. package/dist/sdk/utils/eip-6963-metamask-provider.d.mts +25 -0
  287. package/dist/sdk/utils/eip-6963-metamask-provider.d.mts.map +1 -0
  288. package/dist/sdk/utils/{eip-6963-metamask-provider.js → eip-6963-metamask-provider.mjs} +1 -1
  289. package/dist/sdk/utils/eip-6963-metamask-provider.mjs.map +1 -0
  290. package/dist/sdk/utils/messaging-signing-snap-requests.cjs +96 -0
  291. package/dist/sdk/utils/messaging-signing-snap-requests.cjs.map +1 -0
  292. package/dist/sdk/utils/{messaging-signing-snap-requests.d.ts → messaging-signing-snap-requests.d.cts} +2 -2
  293. package/dist/sdk/utils/messaging-signing-snap-requests.d.cts.map +1 -0
  294. package/dist/sdk/utils/messaging-signing-snap-requests.d.mts +41 -0
  295. package/dist/sdk/utils/messaging-signing-snap-requests.d.mts.map +1 -0
  296. package/dist/sdk/utils/{messaging-signing-snap-requests.js → messaging-signing-snap-requests.mjs} +1 -1
  297. package/dist/sdk/utils/messaging-signing-snap-requests.mjs.map +1 -0
  298. package/dist/sdk/utils/validate-login-response.cjs +49 -0
  299. package/dist/sdk/utils/validate-login-response.cjs.map +1 -0
  300. package/dist/sdk/utils/{validate-login-response.d.ts → validate-login-response.d.cts} +2 -2
  301. package/dist/sdk/utils/validate-login-response.d.cts.map +1 -0
  302. package/dist/sdk/utils/validate-login-response.d.mts +14 -0
  303. package/dist/sdk/utils/validate-login-response.d.mts.map +1 -0
  304. package/dist/sdk/utils/{validate-login-response.js → validate-login-response.mjs} +1 -1
  305. package/dist/sdk/utils/validate-login-response.mjs.map +1 -0
  306. package/dist/sdk/utils/validate-pair-response.cjs +29 -0
  307. package/dist/sdk/utils/validate-pair-response.cjs.map +1 -0
  308. package/dist/sdk/utils/{validate-pair-response.d.ts → validate-pair-response.d.cts} +1 -1
  309. package/dist/sdk/utils/validate-pair-response.d.cts.map +1 -0
  310. package/dist/sdk/utils/validate-pair-response.d.mts +26 -0
  311. package/dist/sdk/utils/validate-pair-response.d.mts.map +1 -0
  312. package/dist/sdk/utils/{validate-pair-response.js → validate-pair-response.mjs} +1 -1
  313. package/dist/sdk/utils/validate-pair-response.mjs.map +1 -0
  314. package/dist/shared/encryption/cache.cjs +77 -0
  315. package/dist/shared/encryption/cache.cjs.map +1 -0
  316. package/dist/shared/encryption/{cache.d.ts → cache.d.cts} +1 -1
  317. package/dist/shared/encryption/cache.d.cts.map +1 -0
  318. package/dist/shared/encryption/cache.d.mts +32 -0
  319. package/dist/shared/encryption/cache.d.mts.map +1 -0
  320. package/dist/shared/encryption/{cache.js → cache.mjs} +4 -4
  321. package/dist/shared/encryption/cache.mjs.map +1 -0
  322. package/dist/shared/encryption/constants.cjs +17 -0
  323. package/dist/shared/encryption/constants.cjs.map +1 -0
  324. package/dist/shared/encryption/{constants.d.ts → constants.d.cts} +2 -2
  325. package/dist/shared/encryption/constants.d.cts.map +1 -0
  326. package/dist/shared/encryption/constants.d.mts +9 -0
  327. package/dist/shared/encryption/constants.d.mts.map +1 -0
  328. package/dist/shared/encryption/{constants.js → constants.mjs} +1 -1
  329. package/dist/shared/encryption/constants.mjs.map +1 -0
  330. package/dist/shared/encryption/encryption.cjs +209 -0
  331. package/dist/shared/encryption/encryption.cjs.map +1 -0
  332. package/dist/shared/encryption/{encryption.d.ts → encryption.d.cts} +3 -3
  333. package/dist/shared/encryption/encryption.d.cts.map +1 -0
  334. package/dist/shared/encryption/encryption.d.mts +30 -0
  335. package/dist/shared/encryption/encryption.d.mts.map +1 -0
  336. package/dist/shared/encryption/encryption.mjs +205 -0
  337. package/dist/shared/encryption/encryption.mjs.map +1 -0
  338. package/dist/shared/encryption/index.cjs +25 -0
  339. package/dist/shared/encryption/index.cjs.map +1 -0
  340. package/dist/shared/encryption/index.d.cts +5 -0
  341. package/dist/shared/encryption/index.d.cts.map +1 -0
  342. package/dist/shared/encryption/index.d.mts +5 -0
  343. package/dist/shared/encryption/index.d.mts.map +1 -0
  344. package/dist/shared/encryption/index.mjs +5 -0
  345. package/dist/shared/encryption/index.mjs.map +1 -0
  346. package/dist/shared/encryption/utils.cjs +21 -0
  347. package/dist/shared/encryption/utils.cjs.map +1 -0
  348. package/dist/shared/encryption/{utils.d.ts → utils.d.cts} +3 -3
  349. package/dist/shared/encryption/utils.d.cts.map +1 -0
  350. package/dist/shared/encryption/utils.d.mts +5 -0
  351. package/dist/shared/encryption/utils.d.mts.map +1 -0
  352. package/dist/shared/encryption/{utils.js → utils.mjs} +1 -1
  353. package/dist/shared/encryption/utils.mjs.map +1 -0
  354. package/dist/shared/env.cjs +85 -0
  355. package/dist/shared/env.cjs.map +1 -0
  356. package/dist/shared/{env.d.ts → env.d.cts} +1 -1
  357. package/dist/shared/env.d.cts.map +1 -0
  358. package/dist/shared/env.d.mts +34 -0
  359. package/dist/shared/env.d.mts.map +1 -0
  360. package/dist/shared/{env.js → env.mjs} +1 -1
  361. package/dist/shared/env.mjs.map +1 -0
  362. package/dist/shared/storage-schema.cjs +42 -0
  363. package/dist/shared/storage-schema.cjs.map +1 -0
  364. package/dist/shared/{storage-schema.d.ts → storage-schema.d.cts} +1 -1
  365. package/dist/shared/storage-schema.d.cts.map +1 -0
  366. package/dist/shared/storage-schema.d.mts +34 -0
  367. package/dist/shared/storage-schema.d.mts.map +1 -0
  368. package/dist/shared/{storage-schema.js → storage-schema.mjs} +2 -2
  369. package/dist/shared/storage-schema.mjs.map +1 -0
  370. package/dist/shared/types/encryption.cjs +3 -0
  371. package/dist/shared/types/encryption.cjs.map +1 -0
  372. package/dist/shared/types/{encryption.d.ts → encryption.d.cts} +1 -1
  373. package/dist/shared/types/encryption.d.cts.map +1 -0
  374. package/dist/shared/types/encryption.d.mts +2 -0
  375. package/dist/shared/types/encryption.d.mts.map +1 -0
  376. package/dist/shared/types/encryption.mjs +2 -0
  377. package/dist/shared/types/encryption.mjs.map +1 -0
  378. package/dist/shared/types/services.cjs +3 -0
  379. package/dist/shared/types/services.cjs.map +1 -0
  380. package/dist/shared/types/{services.d.ts → services.d.cts} +2 -2
  381. package/dist/shared/types/services.d.cts.map +1 -0
  382. package/dist/shared/types/services.d.mts +17 -0
  383. package/dist/shared/types/services.d.mts.map +1 -0
  384. package/dist/shared/types/services.mjs +2 -0
  385. package/dist/shared/types/services.mjs.map +1 -0
  386. package/dist/shared/utils/entropy-source.cjs +37 -0
  387. package/dist/shared/utils/entropy-source.cjs.map +1 -0
  388. package/dist/shared/utils/{entropy-source.d.ts → entropy-source.d.cts} +2 -2
  389. package/dist/shared/utils/entropy-source.d.cts.map +1 -0
  390. package/dist/shared/utils/entropy-source.d.mts +22 -0
  391. package/dist/shared/utils/entropy-source.d.mts.map +1 -0
  392. package/dist/shared/utils/{entropy-source.js → entropy-source.mjs} +2 -2
  393. package/dist/shared/utils/entropy-source.mjs.map +1 -0
  394. package/dist/shared/utils/event-queue.cjs +24 -0
  395. package/dist/shared/utils/event-queue.cjs.map +1 -0
  396. package/dist/shared/utils/{event-queue.d.ts → event-queue.d.cts} +1 -1
  397. package/dist/shared/utils/event-queue.d.cts.map +1 -0
  398. package/dist/shared/utils/event-queue.d.mts +6 -0
  399. package/dist/shared/utils/event-queue.d.mts.map +1 -0
  400. package/dist/shared/utils/{event-queue.js → event-queue.mjs} +4 -2
  401. package/dist/shared/utils/event-queue.mjs.map +1 -0
  402. package/dist/shared/utils/hd-keyring-seed.cjs +49 -0
  403. package/dist/shared/utils/hd-keyring-seed.cjs.map +1 -0
  404. package/dist/shared/utils/{hd-keyring-seed.d.ts → hd-keyring-seed.d.cts} +3 -3
  405. package/dist/shared/utils/hd-keyring-seed.d.cts.map +1 -0
  406. package/dist/shared/utils/hd-keyring-seed.d.mts +27 -0
  407. package/dist/shared/utils/hd-keyring-seed.d.mts.map +1 -0
  408. package/dist/shared/utils/{hd-keyring-seed.js → hd-keyring-seed.mjs} +1 -1
  409. package/dist/shared/utils/hd-keyring-seed.mjs.map +1 -0
  410. package/dist/shared/utils/message-signing.cjs +147 -0
  411. package/dist/shared/utils/message-signing.cjs.map +1 -0
  412. package/dist/shared/utils/{message-signing.d.ts → message-signing.d.cts} +1 -1
  413. package/dist/shared/utils/message-signing.d.cts.map +1 -0
  414. package/dist/shared/utils/message-signing.d.mts +73 -0
  415. package/dist/shared/utils/message-signing.d.mts.map +1 -0
  416. package/dist/shared/utils/{message-signing.js → message-signing.mjs} +7 -7
  417. package/dist/shared/utils/message-signing.mjs.map +1 -0
  418. package/package.json +56 -22
  419. package/dist/controllers/authentication/AuthenticationController-method-action-types.d.ts.map +0 -1
  420. package/dist/controllers/authentication/AuthenticationController-method-action-types.js.map +0 -1
  421. package/dist/controllers/authentication/AuthenticationController.d.ts.map +0 -1
  422. package/dist/controllers/authentication/AuthenticationController.js +0 -536
  423. package/dist/controllers/authentication/AuthenticationController.js.map +0 -1
  424. package/dist/controllers/authentication/index.d.ts.map +0 -1
  425. package/dist/controllers/authentication/index.js +0 -6
  426. package/dist/controllers/authentication/index.js.map +0 -1
  427. package/dist/controllers/authentication/mocks/index.d.ts +0 -2
  428. package/dist/controllers/authentication/mocks/index.d.ts.map +0 -1
  429. package/dist/controllers/authentication/mocks/index.js +0 -2
  430. package/dist/controllers/authentication/mocks/index.js.map +0 -1
  431. package/dist/controllers/authentication/mocks/mockResponses.d.ts.map +0 -1
  432. package/dist/controllers/authentication/mocks/mockResponses.js.map +0 -1
  433. package/dist/controllers/index.d.ts +0 -3
  434. package/dist/controllers/index.d.ts.map +0 -1
  435. package/dist/controllers/index.js +0 -3
  436. package/dist/controllers/index.js.map +0 -1
  437. package/dist/controllers/user-storage/UserStorageController-method-action-types.d.ts.map +0 -1
  438. package/dist/controllers/user-storage/UserStorageController-method-action-types.js.map +0 -1
  439. package/dist/controllers/user-storage/UserStorageController.d.ts.map +0 -1
  440. package/dist/controllers/user-storage/UserStorageController.js +0 -429
  441. package/dist/controllers/user-storage/UserStorageController.js.map +0 -1
  442. package/dist/controllers/user-storage/constants.d.ts +0 -15
  443. package/dist/controllers/user-storage/constants.d.ts.map +0 -1
  444. package/dist/controllers/user-storage/constants.js.map +0 -1
  445. package/dist/controllers/user-storage/contact-syncing/constants.d.ts.map +0 -1
  446. package/dist/controllers/user-storage/contact-syncing/constants.js.map +0 -1
  447. package/dist/controllers/user-storage/contact-syncing/controller-integration.d.ts.map +0 -1
  448. package/dist/controllers/user-storage/contact-syncing/controller-integration.js.map +0 -1
  449. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.ts.map +0 -1
  450. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.js.map +0 -1
  451. package/dist/controllers/user-storage/contact-syncing/sync-utils.d.ts.map +0 -1
  452. package/dist/controllers/user-storage/contact-syncing/sync-utils.js.map +0 -1
  453. package/dist/controllers/user-storage/contact-syncing/types.d.ts.map +0 -1
  454. package/dist/controllers/user-storage/contact-syncing/types.js +0 -2
  455. package/dist/controllers/user-storage/contact-syncing/types.js.map +0 -1
  456. package/dist/controllers/user-storage/contact-syncing/utils.d.ts.map +0 -1
  457. package/dist/controllers/user-storage/contact-syncing/utils.js.map +0 -1
  458. package/dist/controllers/user-storage/index.d.ts.map +0 -1
  459. package/dist/controllers/user-storage/index.js +0 -9
  460. package/dist/controllers/user-storage/index.js.map +0 -1
  461. package/dist/controllers/user-storage/mocks/index.d.ts +0 -3
  462. package/dist/controllers/user-storage/mocks/index.d.ts.map +0 -1
  463. package/dist/controllers/user-storage/mocks/index.js +0 -3
  464. package/dist/controllers/user-storage/mocks/index.js.map +0 -1
  465. package/dist/controllers/user-storage/mocks/mockResponses.d.ts.map +0 -1
  466. package/dist/controllers/user-storage/mocks/mockResponses.js.map +0 -1
  467. package/dist/controllers/user-storage/mocks/mockStorage.d.ts.map +0 -1
  468. package/dist/controllers/user-storage/mocks/mockStorage.js.map +0 -1
  469. package/dist/controllers/user-storage/types.d.ts.map +0 -1
  470. package/dist/controllers/user-storage/types.js +0 -2
  471. package/dist/controllers/user-storage/types.js.map +0 -1
  472. package/dist/controllers/user-storage/utils.d.ts.map +0 -1
  473. package/dist/controllers/user-storage/utils.js.map +0 -1
  474. package/dist/index.d.ts +0 -4
  475. package/dist/index.d.ts.map +0 -1
  476. package/dist/index.js +0 -4
  477. package/dist/index.js.map +0 -1
  478. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.ts.map +0 -1
  479. package/dist/sdk/authentication-jwt-bearer/flow-siwe.js +0 -99
  480. package/dist/sdk/authentication-jwt-bearer/flow-siwe.js.map +0 -1
  481. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.ts.map +0 -1
  482. package/dist/sdk/authentication-jwt-bearer/flow-srp.js +0 -255
  483. package/dist/sdk/authentication-jwt-bearer/flow-srp.js.map +0 -1
  484. package/dist/sdk/authentication-jwt-bearer/services.d.ts.map +0 -1
  485. package/dist/sdk/authentication-jwt-bearer/services.js.map +0 -1
  486. package/dist/sdk/authentication-jwt-bearer/types.d.ts.map +0 -1
  487. package/dist/sdk/authentication-jwt-bearer/types.js.map +0 -1
  488. package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.ts.map +0 -1
  489. package/dist/sdk/authentication-jwt-bearer/utils/identifier.js.map +0 -1
  490. package/dist/sdk/authentication-jwt-bearer/utils/time.d.ts.map +0 -1
  491. package/dist/sdk/authentication-jwt-bearer/utils/time.js.map +0 -1
  492. package/dist/sdk/authentication.d.ts.map +0 -1
  493. package/dist/sdk/authentication.js +0 -100
  494. package/dist/sdk/authentication.js.map +0 -1
  495. package/dist/sdk/constants.d.ts.map +0 -1
  496. package/dist/sdk/constants.js.map +0 -1
  497. package/dist/sdk/errors.d.ts.map +0 -1
  498. package/dist/sdk/errors.js.map +0 -1
  499. package/dist/sdk/index.d.ts +0 -8
  500. package/dist/sdk/index.d.ts.map +0 -1
  501. package/dist/sdk/index.js +0 -8
  502. package/dist/sdk/index.js.map +0 -1
  503. package/dist/sdk/mocks/auth.d.ts.map +0 -1
  504. package/dist/sdk/mocks/auth.js.map +0 -1
  505. package/dist/sdk/mocks/userstorage.d.ts.map +0 -1
  506. package/dist/sdk/mocks/userstorage.js.map +0 -1
  507. package/dist/sdk/user-storage.d.ts.map +0 -1
  508. package/dist/sdk/user-storage.js +0 -364
  509. package/dist/sdk/user-storage.js.map +0 -1
  510. package/dist/sdk/utils/eip-6963-metamask-provider.d.ts.map +0 -1
  511. package/dist/sdk/utils/eip-6963-metamask-provider.js.map +0 -1
  512. package/dist/sdk/utils/messaging-signing-snap-requests.d.ts.map +0 -1
  513. package/dist/sdk/utils/messaging-signing-snap-requests.js.map +0 -1
  514. package/dist/sdk/utils/validate-login-response.d.ts.map +0 -1
  515. package/dist/sdk/utils/validate-login-response.js.map +0 -1
  516. package/dist/sdk/utils/validate-pair-response.d.ts.map +0 -1
  517. package/dist/sdk/utils/validate-pair-response.js.map +0 -1
  518. package/dist/shared/encryption/cache.d.ts.map +0 -1
  519. package/dist/shared/encryption/cache.js.map +0 -1
  520. package/dist/shared/encryption/constants.d.ts.map +0 -1
  521. package/dist/shared/encryption/constants.js.map +0 -1
  522. package/dist/shared/encryption/encryption.d.ts.map +0 -1
  523. package/dist/shared/encryption/encryption.js +0 -202
  524. package/dist/shared/encryption/encryption.js.map +0 -1
  525. package/dist/shared/encryption/index.d.ts +0 -5
  526. package/dist/shared/encryption/index.d.ts.map +0 -1
  527. package/dist/shared/encryption/index.js +0 -5
  528. package/dist/shared/encryption/index.js.map +0 -1
  529. package/dist/shared/encryption/utils.d.ts.map +0 -1
  530. package/dist/shared/encryption/utils.js.map +0 -1
  531. package/dist/shared/env.d.ts.map +0 -1
  532. package/dist/shared/env.js.map +0 -1
  533. package/dist/shared/storage-schema.d.ts.map +0 -1
  534. package/dist/shared/storage-schema.js.map +0 -1
  535. package/dist/shared/types/encryption.d.ts.map +0 -1
  536. package/dist/shared/types/encryption.js +0 -2
  537. package/dist/shared/types/encryption.js.map +0 -1
  538. package/dist/shared/types/services.d.ts.map +0 -1
  539. package/dist/shared/types/services.js +0 -2
  540. package/dist/shared/types/services.js.map +0 -1
  541. package/dist/shared/utils/entropy-source.d.ts.map +0 -1
  542. package/dist/shared/utils/entropy-source.js.map +0 -1
  543. package/dist/shared/utils/event-queue.d.ts.map +0 -1
  544. package/dist/shared/utils/event-queue.js.map +0 -1
  545. package/dist/shared/utils/hd-keyring-seed.d.ts.map +0 -1
  546. package/dist/shared/utils/hd-keyring-seed.js.map +0 -1
  547. package/dist/shared/utils/message-signing.d.ts.map +0 -1
  548. package/dist/shared/utils/message-signing.js.map +0 -1
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMetaMaskProviderEIP6963 = exports.metamaskClientsRdns = void 0;
4
+ exports.metamaskClientsRdns = {
5
+ main: 'io.metamask',
6
+ flask: 'io.metamask.flask',
7
+ institutional: 'io.metamask.mmi',
8
+ };
9
+ // Cache, as when the function is recalled, we can reuse instead of continue waiting
10
+ const providerCache = {};
11
+ /**
12
+ * This uses EIP6963 to find all metamask accounts and returns the first matching provider
13
+ * the consumer requests (main, flask, institutional, or any)
14
+ *
15
+ * @param type - the MetaMask Wallet type (main, flask, institutional, or any)
16
+ * @returns a ethers provider so you can make requests to that specific wallet
17
+ */
18
+ function getMetaMaskProviderEIP6963(type = 'any') {
19
+ return new Promise((resolve) => {
20
+ if (type !== 'any' && exports.metamaskClientsRdns[type] === undefined) {
21
+ resolve(null);
22
+ return;
23
+ }
24
+ const cachedProvider = providerCache[type];
25
+ if (cachedProvider) {
26
+ resolve(cachedProvider);
27
+ return;
28
+ }
29
+ const providers = [];
30
+ const handleProviderEvent = (event) => {
31
+ const typedEvent = event;
32
+ const providerDetail = typedEvent?.detail;
33
+ if (providerDetail?.provider && providerDetail?.info?.rdns) {
34
+ providers.push({
35
+ rdns: providerDetail?.info?.rdns,
36
+ provider: providerDetail?.provider,
37
+ });
38
+ }
39
+ };
40
+ window.addEventListener('eip6963:announceProvider', handleProviderEvent);
41
+ window.dispatchEvent(new Event('eip6963:requestProvider'));
42
+ /**
43
+ * It may take some time for the events to be emitted from the different wallets.
44
+ * So waiting a small period of time before we use the collected events.
45
+ */
46
+ setTimeout(() => {
47
+ // remove attached listener
48
+ window.removeEventListener('eip6963:announceProvider', handleProviderEvent);
49
+ let provider;
50
+ if (type === 'any') {
51
+ // return the first MM client we find
52
+ const metamaskClients = Object.values(exports.metamaskClientsRdns);
53
+ provider =
54
+ providers.find((p) => metamaskClients.includes(p.rdns))?.provider ??
55
+ null;
56
+ }
57
+ else {
58
+ const metamaskRdns = exports.metamaskClientsRdns[type];
59
+ provider =
60
+ providers.find((p) => p.rdns === metamaskRdns)?.provider ?? null;
61
+ }
62
+ if (provider) {
63
+ providerCache[type] = provider;
64
+ }
65
+ return resolve(provider);
66
+ }, 100);
67
+ });
68
+ }
69
+ exports.getMetaMaskProviderEIP6963 = getMetaMaskProviderEIP6963;
70
+ //# sourceMappingURL=eip-6963-metamask-provider.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eip-6963-metamask-provider.cjs","sourceRoot":"","sources":["../../../src/sdk/utils/eip-6963-metamask-provider.ts"],"names":[],"mappings":";;;AASa,QAAA,mBAAmB,GAAG;IACjC,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE,mBAAmB;IAC1B,aAAa,EAAE,iBAAiB;CACjC,CAAC;AAMF,oFAAoF;AACpF,MAAM,aAAa,GAAyD,EAAE,CAAC;AAE/E;;;;;;GAMG;AACH,SAAgB,0BAA0B,CACxC,OAA2B,KAAK;IAEhC,OAAO,IAAI,OAAO,CAAyB,CAAC,OAAO,EAAE,EAAE;QACrD,IAAI,IAAI,KAAK,KAAK,IAAI,2BAAmB,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;YAC9D,OAAO,CAAC,IAAI,CAAC,CAAC;YACd,OAAO;QACT,CAAC;QAED,MAAM,cAAc,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,cAAc,EAAE,CAAC;YACnB,OAAO,CAAC,cAAc,CAAC,CAAC;YACxB,OAAO;QACT,CAAC;QAED,MAAM,SAAS,GAAkD,EAAE,CAAC;QAEpE,MAAM,mBAAmB,GAAG,CAAC,KAAc,EAAE,EAAE;YAC7C,MAAM,UAAU,GAAG,KAAiD,CAAC;YACrE,MAAM,cAAc,GAAG,UAAU,EAAE,MAAM,CAAC;YAC1C,IAAI,cAAc,EAAE,QAAQ,IAAI,cAAc,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;gBAC3D,SAAS,CAAC,IAAI,CAAC;oBACb,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI;oBAChC,QAAQ,EAAE,cAAc,EAAE,QAAQ;iBACnC,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC;QAEF,MAAM,CAAC,gBAAgB,CAAC,0BAA0B,EAAE,mBAAmB,CAAC,CAAC;QACzE,MAAM,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC,CAAC;QAE3D;;;WAGG;QACH,UAAU,CAAC,GAAG,EAAE;YACd,2BAA2B;YAC3B,MAAM,CAAC,mBAAmB,CACxB,0BAA0B,EAC1B,mBAAmB,CACpB,CAAC;YAEF,IAAI,QAAgC,CAAC;YACrC,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;gBACnB,qCAAqC;gBACrC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,2BAAmB,CAAC,CAAC;gBAC3D,QAAQ;oBACN,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,QAAQ;wBACjE,IAAI,CAAC;YACT,CAAC;iBAAM,CAAC;gBACN,MAAM,YAAY,GAAG,2BAAmB,CAAC,IAAI,CAAC,CAAC;gBAC/C,QAAQ;oBACN,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC,EAAE,QAAQ,IAAI,IAAI,CAAC;YACrE,CAAC;YAED,IAAI,QAAQ,EAAE,CAAC;gBACb,aAAa,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC;YACjC,CAAC;YACD,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC3B,CAAC,EAAE,GAAG,CAAC,CAAC;IACV,CAAC,CAAC,CAAC;AACL,CAAC;AA7DD,gEA6DC","sourcesContent":["import type { Eip1193Provider } from 'ethers';\n\n// We can isolate and create a metamask function/closure\nexport type AnnounceProviderEventDetail = {\n info?: { rdns?: string };\n provider?: Eip1193Provider;\n};\nexport type AnnounceProviderEvent = CustomEvent<AnnounceProviderEventDetail>;\n\nexport const metamaskClientsRdns = {\n main: 'io.metamask',\n flask: 'io.metamask.flask',\n institutional: 'io.metamask.mmi',\n};\n\nexport type MetamaskClientRdnsKey = keyof typeof metamaskClientsRdns;\n\ntype MetaMaskClientType = 'any' | MetamaskClientRdnsKey;\n\n// Cache, as when the function is recalled, we can reuse instead of continue waiting\nconst providerCache: Partial<Record<MetaMaskClientType, Eip1193Provider>> = {};\n\n/**\n * This uses EIP6963 to find all metamask accounts and returns the first matching provider\n * the consumer requests (main, flask, institutional, or any)\n *\n * @param type - the MetaMask Wallet type (main, flask, institutional, or any)\n * @returns a ethers provider so you can make requests to that specific wallet\n */\nexport function getMetaMaskProviderEIP6963(\n type: MetaMaskClientType = 'any',\n): Promise<Eip1193Provider | null> {\n return new Promise<Eip1193Provider | null>((resolve) => {\n if (type !== 'any' && metamaskClientsRdns[type] === undefined) {\n resolve(null);\n return;\n }\n\n const cachedProvider = providerCache[type];\n if (cachedProvider) {\n resolve(cachedProvider);\n return;\n }\n\n const providers: { rdns: string; provider: Eip1193Provider }[] = [];\n\n const handleProviderEvent = (event: unknown) => {\n const typedEvent = event as CustomEvent<AnnounceProviderEventDetail>;\n const providerDetail = typedEvent?.detail;\n if (providerDetail?.provider && providerDetail?.info?.rdns) {\n providers.push({\n rdns: providerDetail?.info?.rdns,\n provider: providerDetail?.provider,\n });\n }\n };\n\n window.addEventListener('eip6963:announceProvider', handleProviderEvent);\n window.dispatchEvent(new Event('eip6963:requestProvider'));\n\n /**\n * It may take some time for the events to be emitted from the different wallets.\n * So waiting a small period of time before we use the collected events.\n */\n setTimeout(() => {\n // remove attached listener\n window.removeEventListener(\n 'eip6963:announceProvider',\n handleProviderEvent,\n );\n\n let provider: Eip1193Provider | null;\n if (type === 'any') {\n // return the first MM client we find\n const metamaskClients = Object.values(metamaskClientsRdns);\n provider =\n providers.find((p) => metamaskClients.includes(p.rdns))?.provider ??\n null;\n } else {\n const metamaskRdns = metamaskClientsRdns[type];\n provider =\n providers.find((p) => p.rdns === metamaskRdns)?.provider ?? null;\n }\n\n if (provider) {\n providerCache[type] = provider;\n }\n return resolve(provider);\n }, 100);\n });\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { Eip1193Provider } from 'ethers';
1
+ import type { Eip1193Provider } from "ethers";
2
2
  export type AnnounceProviderEventDetail = {
3
3
  info?: {
4
4
  rdns?: string;
@@ -22,4 +22,4 @@ type MetaMaskClientType = 'any' | MetamaskClientRdnsKey;
22
22
  */
23
23
  export declare function getMetaMaskProviderEIP6963(type?: MetaMaskClientType): Promise<Eip1193Provider | null>;
24
24
  export {};
25
- //# sourceMappingURL=eip-6963-metamask-provider.d.ts.map
25
+ //# sourceMappingURL=eip-6963-metamask-provider.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eip-6963-metamask-provider.d.cts","sourceRoot":"","sources":["../../../src/sdk/utils/eip-6963-metamask-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe;AAG9C,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC5B,CAAC;AACF,MAAM,MAAM,qBAAqB,GAAG,WAAW,CAAC,2BAA2B,CAAC,CAAC;AAE7E,eAAO,MAAM,mBAAmB;;;;CAI/B,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,MAAM,OAAO,mBAAmB,CAAC;AAErE,KAAK,kBAAkB,GAAG,KAAK,GAAG,qBAAqB,CAAC;AAKxD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,GAAE,kBAA0B,GAC/B,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CA2DjC"}
@@ -0,0 +1,25 @@
1
+ import type { Eip1193Provider } from "ethers";
2
+ export type AnnounceProviderEventDetail = {
3
+ info?: {
4
+ rdns?: string;
5
+ };
6
+ provider?: Eip1193Provider;
7
+ };
8
+ export type AnnounceProviderEvent = CustomEvent<AnnounceProviderEventDetail>;
9
+ export declare const metamaskClientsRdns: {
10
+ main: string;
11
+ flask: string;
12
+ institutional: string;
13
+ };
14
+ export type MetamaskClientRdnsKey = keyof typeof metamaskClientsRdns;
15
+ type MetaMaskClientType = 'any' | MetamaskClientRdnsKey;
16
+ /**
17
+ * This uses EIP6963 to find all metamask accounts and returns the first matching provider
18
+ * the consumer requests (main, flask, institutional, or any)
19
+ *
20
+ * @param type - the MetaMask Wallet type (main, flask, institutional, or any)
21
+ * @returns a ethers provider so you can make requests to that specific wallet
22
+ */
23
+ export declare function getMetaMaskProviderEIP6963(type?: MetaMaskClientType): Promise<Eip1193Provider | null>;
24
+ export {};
25
+ //# sourceMappingURL=eip-6963-metamask-provider.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eip-6963-metamask-provider.d.mts","sourceRoot":"","sources":["../../../src/sdk/utils/eip-6963-metamask-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe;AAG9C,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC5B,CAAC;AACF,MAAM,MAAM,qBAAqB,GAAG,WAAW,CAAC,2BAA2B,CAAC,CAAC;AAE7E,eAAO,MAAM,mBAAmB;;;;CAI/B,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,MAAM,OAAO,mBAAmB,CAAC;AAErE,KAAK,kBAAkB,GAAG,KAAK,GAAG,qBAAqB,CAAC;AAKxD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,GAAE,kBAA0B,GAC/B,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CA2DjC"}
@@ -63,4 +63,4 @@ export function getMetaMaskProviderEIP6963(type = 'any') {
63
63
  }, 100);
64
64
  });
65
65
  }
66
- //# sourceMappingURL=eip-6963-metamask-provider.js.map
66
+ //# sourceMappingURL=eip-6963-metamask-provider.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eip-6963-metamask-provider.mjs","sourceRoot":"","sources":["../../../src/sdk/utils/eip-6963-metamask-provider.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE,mBAAmB;IAC1B,aAAa,EAAE,iBAAiB;CACjC,CAAC;AAMF,oFAAoF;AACpF,MAAM,aAAa,GAAyD,EAAE,CAAC;AAE/E;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CACxC,OAA2B,KAAK;IAEhC,OAAO,IAAI,OAAO,CAAyB,CAAC,OAAO,EAAE,EAAE;QACrD,IAAI,IAAI,KAAK,KAAK,IAAI,mBAAmB,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;YAC9D,OAAO,CAAC,IAAI,CAAC,CAAC;YACd,OAAO;QACT,CAAC;QAED,MAAM,cAAc,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,cAAc,EAAE,CAAC;YACnB,OAAO,CAAC,cAAc,CAAC,CAAC;YACxB,OAAO;QACT,CAAC;QAED,MAAM,SAAS,GAAkD,EAAE,CAAC;QAEpE,MAAM,mBAAmB,GAAG,CAAC,KAAc,EAAE,EAAE;YAC7C,MAAM,UAAU,GAAG,KAAiD,CAAC;YACrE,MAAM,cAAc,GAAG,UAAU,EAAE,MAAM,CAAC;YAC1C,IAAI,cAAc,EAAE,QAAQ,IAAI,cAAc,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;gBAC3D,SAAS,CAAC,IAAI,CAAC;oBACb,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI;oBAChC,QAAQ,EAAE,cAAc,EAAE,QAAQ;iBACnC,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC;QAEF,MAAM,CAAC,gBAAgB,CAAC,0BAA0B,EAAE,mBAAmB,CAAC,CAAC;QACzE,MAAM,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC,CAAC;QAE3D;;;WAGG;QACH,UAAU,CAAC,GAAG,EAAE;YACd,2BAA2B;YAC3B,MAAM,CAAC,mBAAmB,CACxB,0BAA0B,EAC1B,mBAAmB,CACpB,CAAC;YAEF,IAAI,QAAgC,CAAC;YACrC,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;gBACnB,qCAAqC;gBACrC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;gBAC3D,QAAQ;oBACN,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,QAAQ;wBACjE,IAAI,CAAC;YACT,CAAC;iBAAM,CAAC;gBACN,MAAM,YAAY,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;gBAC/C,QAAQ;oBACN,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC,EAAE,QAAQ,IAAI,IAAI,CAAC;YACrE,CAAC;YAED,IAAI,QAAQ,EAAE,CAAC;gBACb,aAAa,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC;YACjC,CAAC;YACD,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC3B,CAAC,EAAE,GAAG,CAAC,CAAC;IACV,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Eip1193Provider } from 'ethers';\n\n// We can isolate and create a metamask function/closure\nexport type AnnounceProviderEventDetail = {\n info?: { rdns?: string };\n provider?: Eip1193Provider;\n};\nexport type AnnounceProviderEvent = CustomEvent<AnnounceProviderEventDetail>;\n\nexport const metamaskClientsRdns = {\n main: 'io.metamask',\n flask: 'io.metamask.flask',\n institutional: 'io.metamask.mmi',\n};\n\nexport type MetamaskClientRdnsKey = keyof typeof metamaskClientsRdns;\n\ntype MetaMaskClientType = 'any' | MetamaskClientRdnsKey;\n\n// Cache, as when the function is recalled, we can reuse instead of continue waiting\nconst providerCache: Partial<Record<MetaMaskClientType, Eip1193Provider>> = {};\n\n/**\n * This uses EIP6963 to find all metamask accounts and returns the first matching provider\n * the consumer requests (main, flask, institutional, or any)\n *\n * @param type - the MetaMask Wallet type (main, flask, institutional, or any)\n * @returns a ethers provider so you can make requests to that specific wallet\n */\nexport function getMetaMaskProviderEIP6963(\n type: MetaMaskClientType = 'any',\n): Promise<Eip1193Provider | null> {\n return new Promise<Eip1193Provider | null>((resolve) => {\n if (type !== 'any' && metamaskClientsRdns[type] === undefined) {\n resolve(null);\n return;\n }\n\n const cachedProvider = providerCache[type];\n if (cachedProvider) {\n resolve(cachedProvider);\n return;\n }\n\n const providers: { rdns: string; provider: Eip1193Provider }[] = [];\n\n const handleProviderEvent = (event: unknown) => {\n const typedEvent = event as CustomEvent<AnnounceProviderEventDetail>;\n const providerDetail = typedEvent?.detail;\n if (providerDetail?.provider && providerDetail?.info?.rdns) {\n providers.push({\n rdns: providerDetail?.info?.rdns,\n provider: providerDetail?.provider,\n });\n }\n };\n\n window.addEventListener('eip6963:announceProvider', handleProviderEvent);\n window.dispatchEvent(new Event('eip6963:requestProvider'));\n\n /**\n * It may take some time for the events to be emitted from the different wallets.\n * So waiting a small period of time before we use the collected events.\n */\n setTimeout(() => {\n // remove attached listener\n window.removeEventListener(\n 'eip6963:announceProvider',\n handleProviderEvent,\n );\n\n let provider: Eip1193Provider | null;\n if (type === 'any') {\n // return the first MM client we find\n const metamaskClients = Object.values(metamaskClientsRdns);\n provider =\n providers.find((p) => metamaskClients.includes(p.rdns))?.provider ??\n null;\n } else {\n const metamaskRdns = metamaskClientsRdns[type];\n provider =\n providers.find((p) => p.rdns === metamaskRdns)?.provider ?? null;\n }\n\n if (provider) {\n providerCache[type] = provider;\n }\n return resolve(provider);\n }, 100);\n });\n}\n"]}
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertMessageStartsWithMetamask = exports.MESSAGE_SIGNING_SNAP = exports.isSnapConnected = exports.getSnaps = exports.connectSnap = exports.SNAP_ORIGIN = void 0;
4
+ exports.SNAP_ORIGIN = 'npm:@metamask/message-signing-snap';
5
+ /**
6
+ * Requests Connection to the Message Signing Snap
7
+ *
8
+ * @param provider - MetaMask Wallet Provider
9
+ * @returns snap connect result
10
+ */
11
+ async function connectSnap(provider) {
12
+ const result = await provider.request({
13
+ method: 'wallet_requestSnaps',
14
+ params: {
15
+ [exports.SNAP_ORIGIN]: {},
16
+ },
17
+ });
18
+ return result;
19
+ }
20
+ exports.connectSnap = connectSnap;
21
+ /**
22
+ * Gets Snaps from a MetaMask Wallet
23
+ *
24
+ * @param provider - MetaMask Wallet Provider
25
+ * @returns All currently installed snaps.
26
+ */
27
+ async function getSnaps(provider) {
28
+ const result = await provider.request({
29
+ method: 'wallet_getSnaps',
30
+ });
31
+ return result;
32
+ }
33
+ exports.getSnaps = getSnaps;
34
+ /**
35
+ * Check if snap is connected
36
+ *
37
+ * @param provider - MetaMask Wallet Provider
38
+ * @returns if snap is connected
39
+ */
40
+ async function isSnapConnected(provider) {
41
+ try {
42
+ const snaps = await getSnaps(provider);
43
+ if (!snaps) {
44
+ return false;
45
+ }
46
+ return Object.keys(snaps).includes(exports.SNAP_ORIGIN);
47
+ }
48
+ catch (e) {
49
+ console.error('Failed to determine if snap is connected', e);
50
+ return false;
51
+ }
52
+ }
53
+ exports.isSnapConnected = isSnapConnected;
54
+ exports.MESSAGE_SIGNING_SNAP = {
55
+ async getPublicKey(provider, entropySourceId) {
56
+ const publicKey = await provider.request({
57
+ method: 'wallet_invokeSnap',
58
+ params: {
59
+ snapId: exports.SNAP_ORIGIN,
60
+ request: {
61
+ method: 'getPublicKey',
62
+ ...(entropySourceId ? { params: { entropySourceId } } : {}),
63
+ },
64
+ },
65
+ });
66
+ return publicKey;
67
+ },
68
+ async signMessage(provider, message, entropySourceId) {
69
+ const signedMessage = await provider?.request({
70
+ method: 'wallet_invokeSnap',
71
+ params: {
72
+ snapId: exports.SNAP_ORIGIN,
73
+ request: {
74
+ method: 'signMessage',
75
+ params: {
76
+ message,
77
+ ...(entropySourceId ? { entropySourceId } : {}),
78
+ },
79
+ },
80
+ },
81
+ });
82
+ return signedMessage;
83
+ },
84
+ };
85
+ /**
86
+ * Asserts that a message starts with "metamask:"
87
+ *
88
+ * @param message - The message to check.
89
+ */
90
+ function assertMessageStartsWithMetamask(message) {
91
+ if (!message.startsWith('metamask:')) {
92
+ throw new Error('Message must start with "metamask:"');
93
+ }
94
+ }
95
+ exports.assertMessageStartsWithMetamask = assertMessageStartsWithMetamask;
96
+ //# sourceMappingURL=messaging-signing-snap-requests.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messaging-signing-snap-requests.cjs","sourceRoot":"","sources":["../../../src/sdk/utils/messaging-signing-snap-requests.ts"],"names":[],"mappings":";;;AAUa,QAAA,WAAW,GAAG,oCAAoC,CAAC;AAEhE;;;;;GAKG;AACI,KAAK,UAAU,WAAW,CAAC,QAAyB;IACzD,MAAM,MAAM,GAAW,MAAM,QAAQ,CAAC,OAAO,CAAC;QAC5C,MAAM,EAAE,qBAAqB;QAC7B,MAAM,EAAE;YACN,CAAC,mBAAW,CAAC,EAAE,EAAE;SAClB;KACF,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AATD,kCASC;AAED;;;;;GAKG;AACI,KAAK,UAAU,QAAQ,CAC5B,QAAyB;IAEzB,MAAM,MAAM,GAAqB,MAAM,QAAQ,CAAC,OAAO,CAAC;QACtD,MAAM,EAAE,iBAAiB;KAC1B,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AARD,4BAQC;AAED;;;;;GAKG;AACI,KAAK,UAAU,eAAe,CACnC,QAAyB;IAEzB,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACvC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,mBAAW,CAAC,CAAC;IAClD,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,0CAA0C,EAAE,CAAC,CAAC,CAAC;QAC7D,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAbD,0CAaC;AAEY,QAAA,oBAAoB,GAAG;IAClC,KAAK,CAAC,YAAY,CAAC,QAAyB,EAAE,eAAwB;QACpE,MAAM,SAAS,GAAW,MAAM,QAAQ,CAAC,OAAO,CAAC;YAC/C,MAAM,EAAE,mBAAmB;YAC3B,MAAM,EAAE;gBACN,MAAM,EAAE,mBAAW;gBACnB,OAAO,EAAE;oBACP,MAAM,EAAE,cAAc;oBACtB,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBAC5D;aACF;SACF,CAAC,CAAC;QAEH,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,WAAW,CACf,QAAyB,EACzB,OAA6B,EAC7B,eAAwB;QAExB,MAAM,aAAa,GAAW,MAAM,QAAQ,EAAE,OAAO,CAAC;YACpD,MAAM,EAAE,mBAAmB;YAC3B,MAAM,EAAE;gBACN,MAAM,EAAE,mBAAW;gBACnB,OAAO,EAAE;oBACP,MAAM,EAAE,aAAa;oBACrB,MAAM,EAAE;wBACN,OAAO;wBACP,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;qBAChD;iBACF;aACF;SACF,CAAC,CAAC;QAEH,OAAO,aAAa,CAAC;IACvB,CAAC;CACF,CAAC;AAEF;;;;GAIG;AACH,SAAgB,+BAA+B,CAC7C,OAAe;IAEf,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC;AACH,CAAC;AAND,0EAMC","sourcesContent":["import type { Eip1193Provider } from 'ethers';\n\nexport type Snap = {\n permissionName: string;\n id: string;\n version: string;\n initialPermissions: Record<string, unknown>;\n};\nexport type GetSnapsResponse = Record<string, Snap>;\n\nexport const SNAP_ORIGIN = 'npm:@metamask/message-signing-snap';\n\n/**\n * Requests Connection to the Message Signing Snap\n *\n * @param provider - MetaMask Wallet Provider\n * @returns snap connect result\n */\nexport async function connectSnap(provider: Eip1193Provider): Promise<string> {\n const result: string = await provider.request({\n method: 'wallet_requestSnaps',\n params: {\n [SNAP_ORIGIN]: {},\n },\n });\n\n return result;\n}\n\n/**\n * Gets Snaps from a MetaMask Wallet\n *\n * @param provider - MetaMask Wallet Provider\n * @returns All currently installed snaps.\n */\nexport async function getSnaps(\n provider: Eip1193Provider,\n): Promise<GetSnapsResponse> {\n const result: GetSnapsResponse = await provider.request({\n method: 'wallet_getSnaps',\n });\n\n return result;\n}\n\n/**\n * Check if snap is connected\n *\n * @param provider - MetaMask Wallet Provider\n * @returns if snap is connected\n */\nexport async function isSnapConnected(\n provider: Eip1193Provider,\n): Promise<boolean> {\n try {\n const snaps = await getSnaps(provider);\n if (!snaps) {\n return false;\n }\n return Object.keys(snaps).includes(SNAP_ORIGIN);\n } catch (e) {\n console.error('Failed to determine if snap is connected', e);\n return false;\n }\n}\n\nexport const MESSAGE_SIGNING_SNAP = {\n async getPublicKey(provider: Eip1193Provider, entropySourceId?: string) {\n const publicKey: string = await provider.request({\n method: 'wallet_invokeSnap',\n params: {\n snapId: SNAP_ORIGIN,\n request: {\n method: 'getPublicKey',\n ...(entropySourceId ? { params: { entropySourceId } } : {}),\n },\n },\n });\n\n return publicKey;\n },\n\n async signMessage(\n provider: Eip1193Provider,\n message: `metamask:${string}`,\n entropySourceId?: string,\n ) {\n const signedMessage: string = await provider?.request({\n method: 'wallet_invokeSnap',\n params: {\n snapId: SNAP_ORIGIN,\n request: {\n method: 'signMessage',\n params: {\n message,\n ...(entropySourceId ? { entropySourceId } : {}),\n },\n },\n },\n });\n\n return signedMessage;\n },\n};\n\n/**\n * Asserts that a message starts with \"metamask:\"\n *\n * @param message - The message to check.\n */\nexport function assertMessageStartsWithMetamask(\n message: string,\n): asserts message is `metamask:${string}` {\n if (!message.startsWith('metamask:')) {\n throw new Error('Message must start with \"metamask:\"');\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { Eip1193Provider } from 'ethers';
1
+ import type { Eip1193Provider } from "ethers";
2
2
  export type Snap = {
3
3
  permissionName: string;
4
4
  id: string;
@@ -38,4 +38,4 @@ export declare const MESSAGE_SIGNING_SNAP: {
38
38
  * @param message - The message to check.
39
39
  */
40
40
  export declare function assertMessageStartsWithMetamask(message: string): asserts message is `metamask:${string}`;
41
- //# sourceMappingURL=messaging-signing-snap-requests.d.ts.map
41
+ //# sourceMappingURL=messaging-signing-snap-requests.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messaging-signing-snap-requests.d.cts","sourceRoot":"","sources":["../../../src/sdk/utils/messaging-signing-snap-requests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe;AAE9C,MAAM,MAAM,IAAI,GAAG;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7C,CAAC;AACF,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAEpD,eAAO,MAAM,WAAW,uCAAuC,CAAC;AAEhE;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAS5E;AAED;;;;;GAKG;AACH,wBAAsB,QAAQ,CAC5B,QAAQ,EAAE,eAAe,GACxB,OAAO,CAAC,gBAAgB,CAAC,CAM3B;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,eAAe,GACxB,OAAO,CAAC,OAAO,CAAC,CAWlB;AAED,eAAO,MAAM,oBAAoB;2BACF,eAAe,oBAAoB,MAAM;0BAgB1D,eAAe,WAChB,YAAY,MAAM,EAAE,oBACX,MAAM;CAkB3B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,IAAI,YAAY,MAAM,EAAE,CAIzC"}
@@ -0,0 +1,41 @@
1
+ import type { Eip1193Provider } from "ethers";
2
+ export type Snap = {
3
+ permissionName: string;
4
+ id: string;
5
+ version: string;
6
+ initialPermissions: Record<string, unknown>;
7
+ };
8
+ export type GetSnapsResponse = Record<string, Snap>;
9
+ export declare const SNAP_ORIGIN = "npm:@metamask/message-signing-snap";
10
+ /**
11
+ * Requests Connection to the Message Signing Snap
12
+ *
13
+ * @param provider - MetaMask Wallet Provider
14
+ * @returns snap connect result
15
+ */
16
+ export declare function connectSnap(provider: Eip1193Provider): Promise<string>;
17
+ /**
18
+ * Gets Snaps from a MetaMask Wallet
19
+ *
20
+ * @param provider - MetaMask Wallet Provider
21
+ * @returns All currently installed snaps.
22
+ */
23
+ export declare function getSnaps(provider: Eip1193Provider): Promise<GetSnapsResponse>;
24
+ /**
25
+ * Check if snap is connected
26
+ *
27
+ * @param provider - MetaMask Wallet Provider
28
+ * @returns if snap is connected
29
+ */
30
+ export declare function isSnapConnected(provider: Eip1193Provider): Promise<boolean>;
31
+ export declare const MESSAGE_SIGNING_SNAP: {
32
+ getPublicKey(provider: Eip1193Provider, entropySourceId?: string): Promise<string>;
33
+ signMessage(provider: Eip1193Provider, message: `metamask:${string}`, entropySourceId?: string): Promise<string>;
34
+ };
35
+ /**
36
+ * Asserts that a message starts with "metamask:"
37
+ *
38
+ * @param message - The message to check.
39
+ */
40
+ export declare function assertMessageStartsWithMetamask(message: string): asserts message is `metamask:${string}`;
41
+ //# sourceMappingURL=messaging-signing-snap-requests.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messaging-signing-snap-requests.d.mts","sourceRoot":"","sources":["../../../src/sdk/utils/messaging-signing-snap-requests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe;AAE9C,MAAM,MAAM,IAAI,GAAG;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7C,CAAC;AACF,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAEpD,eAAO,MAAM,WAAW,uCAAuC,CAAC;AAEhE;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAS5E;AAED;;;;;GAKG;AACH,wBAAsB,QAAQ,CAC5B,QAAQ,EAAE,eAAe,GACxB,OAAO,CAAC,gBAAgB,CAAC,CAM3B;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,eAAe,GACxB,OAAO,CAAC,OAAO,CAAC,CAWlB;AAED,eAAO,MAAM,oBAAoB;2BACF,eAAe,oBAAoB,MAAM;0BAgB1D,eAAe,WAChB,YAAY,MAAM,EAAE,oBACX,MAAM;CAkB3B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,IAAI,YAAY,MAAM,EAAE,CAIzC"}
@@ -86,4 +86,4 @@ export function assertMessageStartsWithMetamask(message) {
86
86
  throw new Error('Message must start with "metamask:"');
87
87
  }
88
88
  }
89
- //# sourceMappingURL=messaging-signing-snap-requests.js.map
89
+ //# sourceMappingURL=messaging-signing-snap-requests.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messaging-signing-snap-requests.mjs","sourceRoot":"","sources":["../../../src/sdk/utils/messaging-signing-snap-requests.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,WAAW,GAAG,oCAAoC,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,QAAyB;IACzD,MAAM,MAAM,GAAW,MAAM,QAAQ,CAAC,OAAO,CAAC;QAC5C,MAAM,EAAE,qBAAqB;QAC7B,MAAM,EAAE;YACN,CAAC,WAAW,CAAC,EAAE,EAAE;SAClB;KACF,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,QAAyB;IAEzB,MAAM,MAAM,GAAqB,MAAM,QAAQ,CAAC,OAAO,CAAC;QACtD,MAAM,EAAE,iBAAiB;KAC1B,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,QAAyB;IAEzB,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACvC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAClD,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,0CAA0C,EAAE,CAAC,CAAC,CAAC;QAC7D,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,KAAK,CAAC,YAAY,CAAC,QAAyB,EAAE,eAAwB;QACpE,MAAM,SAAS,GAAW,MAAM,QAAQ,CAAC,OAAO,CAAC;YAC/C,MAAM,EAAE,mBAAmB;YAC3B,MAAM,EAAE;gBACN,MAAM,EAAE,WAAW;gBACnB,OAAO,EAAE;oBACP,MAAM,EAAE,cAAc;oBACtB,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,eAAe,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBAC5D;aACF;SACF,CAAC,CAAC;QAEH,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,WAAW,CACf,QAAyB,EACzB,OAA6B,EAC7B,eAAwB;QAExB,MAAM,aAAa,GAAW,MAAM,QAAQ,EAAE,OAAO,CAAC;YACpD,MAAM,EAAE,mBAAmB;YAC3B,MAAM,EAAE;gBACN,MAAM,EAAE,WAAW;gBACnB,OAAO,EAAE;oBACP,MAAM,EAAE,aAAa;oBACrB,MAAM,EAAE;wBACN,OAAO;wBACP,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;qBAChD;iBACF;aACF;SACF,CAAC,CAAC;QAEH,OAAO,aAAa,CAAC;IACvB,CAAC;CACF,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,+BAA+B,CAC7C,OAAe;IAEf,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC;AACH,CAAC","sourcesContent":["import type { Eip1193Provider } from 'ethers';\n\nexport type Snap = {\n permissionName: string;\n id: string;\n version: string;\n initialPermissions: Record<string, unknown>;\n};\nexport type GetSnapsResponse = Record<string, Snap>;\n\nexport const SNAP_ORIGIN = 'npm:@metamask/message-signing-snap';\n\n/**\n * Requests Connection to the Message Signing Snap\n *\n * @param provider - MetaMask Wallet Provider\n * @returns snap connect result\n */\nexport async function connectSnap(provider: Eip1193Provider): Promise<string> {\n const result: string = await provider.request({\n method: 'wallet_requestSnaps',\n params: {\n [SNAP_ORIGIN]: {},\n },\n });\n\n return result;\n}\n\n/**\n * Gets Snaps from a MetaMask Wallet\n *\n * @param provider - MetaMask Wallet Provider\n * @returns All currently installed snaps.\n */\nexport async function getSnaps(\n provider: Eip1193Provider,\n): Promise<GetSnapsResponse> {\n const result: GetSnapsResponse = await provider.request({\n method: 'wallet_getSnaps',\n });\n\n return result;\n}\n\n/**\n * Check if snap is connected\n *\n * @param provider - MetaMask Wallet Provider\n * @returns if snap is connected\n */\nexport async function isSnapConnected(\n provider: Eip1193Provider,\n): Promise<boolean> {\n try {\n const snaps = await getSnaps(provider);\n if (!snaps) {\n return false;\n }\n return Object.keys(snaps).includes(SNAP_ORIGIN);\n } catch (e) {\n console.error('Failed to determine if snap is connected', e);\n return false;\n }\n}\n\nexport const MESSAGE_SIGNING_SNAP = {\n async getPublicKey(provider: Eip1193Provider, entropySourceId?: string) {\n const publicKey: string = await provider.request({\n method: 'wallet_invokeSnap',\n params: {\n snapId: SNAP_ORIGIN,\n request: {\n method: 'getPublicKey',\n ...(entropySourceId ? { params: { entropySourceId } } : {}),\n },\n },\n });\n\n return publicKey;\n },\n\n async signMessage(\n provider: Eip1193Provider,\n message: `metamask:${string}`,\n entropySourceId?: string,\n ) {\n const signedMessage: string = await provider?.request({\n method: 'wallet_invokeSnap',\n params: {\n snapId: SNAP_ORIGIN,\n request: {\n method: 'signMessage',\n params: {\n message,\n ...(entropySourceId ? { entropySourceId } : {}),\n },\n },\n },\n });\n\n return signedMessage;\n },\n};\n\n/**\n * Asserts that a message starts with \"metamask:\"\n *\n * @param message - The message to check.\n */\nexport function assertMessageStartsWithMetamask(\n message: string,\n): asserts message is `metamask:${string}` {\n if (!message.startsWith('metamask:')) {\n throw new Error('Message must start with \"metamask:\"');\n }\n}\n"]}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateLoginResponse = void 0;
4
+ /**
5
+ * Validates that the input is a well-formed, non-expired LoginResponse.
6
+ *
7
+ * Checks structural shape (token + profile objects exist) and verifies
8
+ * the JWT access token's `exp` claim is still in the future. This acts
9
+ * as a hard guard against stale cached tokens regardless of client-side
10
+ * TTL tracking (obtainedAt / expiresIn), which can be corrupted.
11
+ *
12
+ * @param input - unknown/untyped input
13
+ * @returns boolean if input is a valid, non-expired LoginResponse
14
+ */
15
+ function validateLoginResponse(input) {
16
+ const assumedInput = input;
17
+ if (!assumedInput) {
18
+ return false;
19
+ }
20
+ if (!assumedInput?.token || !assumedInput?.profile) {
21
+ return false;
22
+ }
23
+ if (isJwtExpired(assumedInput.token.accessToken)) {
24
+ return false;
25
+ }
26
+ return true;
27
+ }
28
+ exports.validateLoginResponse = validateLoginResponse;
29
+ /**
30
+ * Checks whether a JWT has expired by decoding its `exp` claim.
31
+ *
32
+ * @param token - A JWT string.
33
+ * @returns true if the token is expired or cannot be decoded; false if still valid.
34
+ */
35
+ function isJwtExpired(token) {
36
+ try {
37
+ const parts = token.split('.');
38
+ if (parts.length !== 3) {
39
+ return true;
40
+ }
41
+ const base64 = parts[1].replace(/-/gu, '+').replace(/_/gu, '/');
42
+ const { exp } = JSON.parse(atob(base64));
43
+ return !Number.isInteger(exp) || exp * 1000 <= Date.now();
44
+ }
45
+ catch {
46
+ return true;
47
+ }
48
+ }
49
+ //# sourceMappingURL=validate-login-response.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-login-response.cjs","sourceRoot":"","sources":["../../../src/sdk/utils/validate-login-response.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;GAUG;AACH,SAAgB,qBAAqB,CAAC,KAAc;IAClD,MAAM,YAAY,GAAG,KAAsB,CAAC;IAE5C,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC,YAAY,EAAE,KAAK,IAAI,CAAC,YAAY,EAAE,OAAO,EAAE,CAAC;QACnD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC;QACjD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAhBD,sDAgBC;AAED;;;;;GAKG;AACH,SAAS,YAAY,CAAC,KAAa;IACjC,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAChE,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QACzC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,IAAI,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;IAC5D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import type { LoginResponse } from '../authentication.js';\n\n/**\n * Validates that the input is a well-formed, non-expired LoginResponse.\n *\n * Checks structural shape (token + profile objects exist) and verifies\n * the JWT access token's `exp` claim is still in the future. This acts\n * as a hard guard against stale cached tokens regardless of client-side\n * TTL tracking (obtainedAt / expiresIn), which can be corrupted.\n *\n * @param input - unknown/untyped input\n * @returns boolean if input is a valid, non-expired LoginResponse\n */\nexport function validateLoginResponse(input: unknown): input is LoginResponse {\n const assumedInput = input as LoginResponse;\n\n if (!assumedInput) {\n return false;\n }\n\n if (!assumedInput?.token || !assumedInput?.profile) {\n return false;\n }\n\n if (isJwtExpired(assumedInput.token.accessToken)) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Checks whether a JWT has expired by decoding its `exp` claim.\n *\n * @param token - A JWT string.\n * @returns true if the token is expired or cannot be decoded; false if still valid.\n */\nfunction isJwtExpired(token: string): boolean {\n try {\n const parts = token.split('.');\n if (parts.length !== 3) {\n return true;\n }\n const base64 = parts[1].replace(/-/gu, '+').replace(/_/gu, '/');\n const { exp } = JSON.parse(atob(base64));\n return !Number.isInteger(exp) || exp * 1000 <= Date.now();\n } catch {\n return true;\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { LoginResponse } from '../authentication.js';
1
+ import type { LoginResponse } from "../authentication.cjs";
2
2
  /**
3
3
  * Validates that the input is a well-formed, non-expired LoginResponse.
4
4
  *
@@ -11,4 +11,4 @@ import type { LoginResponse } from '../authentication.js';
11
11
  * @returns boolean if input is a valid, non-expired LoginResponse
12
12
  */
13
13
  export declare function validateLoginResponse(input: unknown): input is LoginResponse;
14
- //# sourceMappingURL=validate-login-response.d.ts.map
14
+ //# sourceMappingURL=validate-login-response.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-login-response.d.cts","sourceRoot":"","sources":["../../../src/sdk/utils/validate-login-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,8BAA6B;AAE1D;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAgB5E"}
@@ -0,0 +1,14 @@
1
+ import type { LoginResponse } from "../authentication.mjs";
2
+ /**
3
+ * Validates that the input is a well-formed, non-expired LoginResponse.
4
+ *
5
+ * Checks structural shape (token + profile objects exist) and verifies
6
+ * the JWT access token's `exp` claim is still in the future. This acts
7
+ * as a hard guard against stale cached tokens regardless of client-side
8
+ * TTL tracking (obtainedAt / expiresIn), which can be corrupted.
9
+ *
10
+ * @param input - unknown/untyped input
11
+ * @returns boolean if input is a valid, non-expired LoginResponse
12
+ */
13
+ export declare function validateLoginResponse(input: unknown): input is LoginResponse;
14
+ //# sourceMappingURL=validate-login-response.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-login-response.d.mts","sourceRoot":"","sources":["../../../src/sdk/utils/validate-login-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,8BAA6B;AAE1D;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAgB5E"}
@@ -42,4 +42,4 @@ function isJwtExpired(token) {
42
42
  return true;
43
43
  }
44
44
  }
45
- //# sourceMappingURL=validate-login-response.js.map
45
+ //# sourceMappingURL=validate-login-response.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-login-response.mjs","sourceRoot":"","sources":["../../../src/sdk/utils/validate-login-response.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAc;IAClD,MAAM,YAAY,GAAG,KAAsB,CAAC;IAE5C,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC,YAAY,EAAE,KAAK,IAAI,CAAC,YAAY,EAAE,OAAO,EAAE,CAAC;QACnD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC;QACjD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,SAAS,YAAY,CAAC,KAAa;IACjC,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAChE,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QACzC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,IAAI,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;IAC5D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import type { LoginResponse } from '../authentication.js';\n\n/**\n * Validates that the input is a well-formed, non-expired LoginResponse.\n *\n * Checks structural shape (token + profile objects exist) and verifies\n * the JWT access token's `exp` claim is still in the future. This acts\n * as a hard guard against stale cached tokens regardless of client-side\n * TTL tracking (obtainedAt / expiresIn), which can be corrupted.\n *\n * @param input - unknown/untyped input\n * @returns boolean if input is a valid, non-expired LoginResponse\n */\nexport function validateLoginResponse(input: unknown): input is LoginResponse {\n const assumedInput = input as LoginResponse;\n\n if (!assumedInput) {\n return false;\n }\n\n if (!assumedInput?.token || !assumedInput?.profile) {\n return false;\n }\n\n if (isJwtExpired(assumedInput.token.accessToken)) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Checks whether a JWT has expired by decoding its `exp` claim.\n *\n * @param token - A JWT string.\n * @returns true if the token is expired or cannot be decoded; false if still valid.\n */\nfunction isJwtExpired(token: string): boolean {\n try {\n const parts = token.split('.');\n if (parts.length !== 3) {\n return true;\n }\n const base64 = parts[1].replace(/-/gu, '+').replace(/_/gu, '/');\n const { exp } = JSON.parse(atob(base64));\n return !Number.isInteger(exp) || exp * 1000 <= Date.now();\n } catch {\n return true;\n }\n}\n"]}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ /* eslint-disable @typescript-eslint/naming-convention */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.validatePairResponse = void 0;
5
+ /**
6
+ * Asserts that the raw API response from the profile pairing endpoint has the
7
+ * expected shape before we attempt to map it into a `PairProfilesResponse`.
8
+ * Throws if the response is malformed.
9
+ *
10
+ * @param input - The raw JSON parsed from the pair endpoint response body.
11
+ */
12
+ function validatePairResponse(input) {
13
+ if (!input || typeof input !== 'object') {
14
+ throw new Error('validatePairResponse: input is not an object');
15
+ }
16
+ const assumed = input;
17
+ const profile = assumed.profile;
18
+ if (!profile || typeof profile !== 'object') {
19
+ throw new Error('validatePairResponse: profile is missing or not an object');
20
+ }
21
+ if (typeof profile.profile_id !== 'string' || !profile.profile_id) {
22
+ throw new Error('validatePairResponse: profile.profile_id is missing or empty');
23
+ }
24
+ if (typeof profile.identifier_id !== 'string' || !profile.identifier_id) {
25
+ throw new Error('validatePairResponse: profile.identifier_id is missing or empty');
26
+ }
27
+ }
28
+ exports.validatePairResponse = validatePairResponse;
29
+ //# sourceMappingURL=validate-pair-response.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-pair-response.cjs","sourceRoot":"","sources":["../../../src/sdk/utils/validate-pair-response.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAiBzD;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAClC,KAAc;IAEd,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IAED,MAAM,OAAO,GAAG,KAAgC,CAAC;IACjD,MAAM,OAAO,GAAG,OAAO,CAAC,OAA8C,CAAC;IACvE,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CACb,2DAA2D,CAC5D,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,OAAO,CAAC,UAAU,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QAClE,MAAM,IAAI,KAAK,CACb,8DAA8D,CAC/D,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,OAAO,CAAC,aAAa,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;QACxE,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;IACJ,CAAC;AACH,CAAC;AA1BD,oDA0BC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\n\ntype RawProfileAlias = {\n alias_profile_id: string;\n canonical_profile_id: string;\n identifier_ids: { id: string; type: string }[];\n};\n\nexport type RawPairResponse = {\n profile: {\n profile_id: string;\n identifier_id: string;\n metametrics_id?: string;\n };\n profile_aliases?: RawProfileAlias[];\n};\n\n/**\n * Asserts that the raw API response from the profile pairing endpoint has the\n * expected shape before we attempt to map it into a `PairProfilesResponse`.\n * Throws if the response is malformed.\n *\n * @param input - The raw JSON parsed from the pair endpoint response body.\n */\nexport function validatePairResponse(\n input: unknown,\n): asserts input is RawPairResponse {\n if (!input || typeof input !== 'object') {\n throw new Error('validatePairResponse: input is not an object');\n }\n\n const assumed = input as Record<string, unknown>;\n const profile = assumed.profile as Record<string, unknown> | undefined;\n if (!profile || typeof profile !== 'object') {\n throw new Error(\n 'validatePairResponse: profile is missing or not an object',\n );\n }\n\n if (typeof profile.profile_id !== 'string' || !profile.profile_id) {\n throw new Error(\n 'validatePairResponse: profile.profile_id is missing or empty',\n );\n }\n\n if (typeof profile.identifier_id !== 'string' || !profile.identifier_id) {\n throw new Error(\n 'validatePairResponse: profile.identifier_id is missing or empty',\n );\n }\n}\n"]}
@@ -23,4 +23,4 @@ export type RawPairResponse = {
23
23
  */
24
24
  export declare function validatePairResponse(input: unknown): asserts input is RawPairResponse;
25
25
  export {};
26
- //# sourceMappingURL=validate-pair-response.d.ts.map
26
+ //# sourceMappingURL=validate-pair-response.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-pair-response.d.cts","sourceRoot":"","sources":["../../../src/sdk/utils/validate-pair-response.ts"],"names":[],"mappings":"AAEA,KAAK,eAAe,GAAG;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,cAAc,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE;QACP,UAAU,EAAE,MAAM,CAAC;QACnB,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;IACF,eAAe,CAAC,EAAE,eAAe,EAAE,CAAC;CACrC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,KAAK,IAAI,eAAe,CAwBlC"}
@@ -0,0 +1,26 @@
1
+ type RawProfileAlias = {
2
+ alias_profile_id: string;
3
+ canonical_profile_id: string;
4
+ identifier_ids: {
5
+ id: string;
6
+ type: string;
7
+ }[];
8
+ };
9
+ export type RawPairResponse = {
10
+ profile: {
11
+ profile_id: string;
12
+ identifier_id: string;
13
+ metametrics_id?: string;
14
+ };
15
+ profile_aliases?: RawProfileAlias[];
16
+ };
17
+ /**
18
+ * Asserts that the raw API response from the profile pairing endpoint has the
19
+ * expected shape before we attempt to map it into a `PairProfilesResponse`.
20
+ * Throws if the response is malformed.
21
+ *
22
+ * @param input - The raw JSON parsed from the pair endpoint response body.
23
+ */
24
+ export declare function validatePairResponse(input: unknown): asserts input is RawPairResponse;
25
+ export {};
26
+ //# sourceMappingURL=validate-pair-response.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-pair-response.d.mts","sourceRoot":"","sources":["../../../src/sdk/utils/validate-pair-response.ts"],"names":[],"mappings":"AAEA,KAAK,eAAe,GAAG;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,cAAc,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE;QACP,UAAU,EAAE,MAAM,CAAC;QACnB,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;IACF,eAAe,CAAC,EAAE,eAAe,EAAE,CAAC;CACrC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,KAAK,IAAI,eAAe,CAwBlC"}
@@ -22,4 +22,4 @@ export function validatePairResponse(input) {
22
22
  throw new Error('validatePairResponse: profile.identifier_id is missing or empty');
23
23
  }
24
24
  }
25
- //# sourceMappingURL=validate-pair-response.js.map
25
+ //# sourceMappingURL=validate-pair-response.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-pair-response.mjs","sourceRoot":"","sources":["../../../src/sdk/utils/validate-pair-response.ts"],"names":[],"mappings":"AAAA,yDAAyD;AAiBzD;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAc;IAEd,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IAED,MAAM,OAAO,GAAG,KAAgC,CAAC;IACjD,MAAM,OAAO,GAAG,OAAO,CAAC,OAA8C,CAAC;IACvE,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CACb,2DAA2D,CAC5D,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,OAAO,CAAC,UAAU,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QAClE,MAAM,IAAI,KAAK,CACb,8DAA8D,CAC/D,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,OAAO,CAAC,aAAa,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;QACxE,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\n\ntype RawProfileAlias = {\n alias_profile_id: string;\n canonical_profile_id: string;\n identifier_ids: { id: string; type: string }[];\n};\n\nexport type RawPairResponse = {\n profile: {\n profile_id: string;\n identifier_id: string;\n metametrics_id?: string;\n };\n profile_aliases?: RawProfileAlias[];\n};\n\n/**\n * Asserts that the raw API response from the profile pairing endpoint has the\n * expected shape before we attempt to map it into a `PairProfilesResponse`.\n * Throws if the response is malformed.\n *\n * @param input - The raw JSON parsed from the pair endpoint response body.\n */\nexport function validatePairResponse(\n input: unknown,\n): asserts input is RawPairResponse {\n if (!input || typeof input !== 'object') {\n throw new Error('validatePairResponse: input is not an object');\n }\n\n const assumed = input as Record<string, unknown>;\n const profile = assumed.profile as Record<string, unknown> | undefined;\n if (!profile || typeof profile !== 'object') {\n throw new Error(\n 'validatePairResponse: profile is missing or not an object',\n );\n }\n\n if (typeof profile.profile_id !== 'string' || !profile.profile_id) {\n throw new Error(\n 'validatePairResponse: profile.profile_id is missing or empty',\n );\n }\n\n if (typeof profile.identifier_id !== 'string' || !profile.identifier_id) {\n throw new Error(\n 'validatePairResponse: profile.identifier_id is missing or empty',\n );\n }\n}\n"]}
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setCachedKey = exports.getCachedKeyGeneratedWithSharedSalt = exports.getCachedKeyBySalt = void 0;
4
+ const constants_js_1 = require("./constants.cjs");
5
+ const utils_js_1 = require("./utils.cjs");
6
+ const MAX_PASSWORD_CACHES = 100;
7
+ const MAX_SALT_CACHES = 100;
8
+ let inMemCachedKDF = {};
9
+ const getPasswordCache = (hashedPassword) => {
10
+ inMemCachedKDF[hashedPassword] ?? (inMemCachedKDF[hashedPassword] = new Map());
11
+ return inMemCachedKDF[hashedPassword];
12
+ };
13
+ /**
14
+ * Returns a given cached derived key from a hashed password and salt
15
+ *
16
+ * @param hashedPassword - hashed password for cache lookup
17
+ * @param salt - provide salt to receive cached key
18
+ * @returns cached key
19
+ */
20
+ function getCachedKeyBySalt(hashedPassword, salt) {
21
+ const cache = getPasswordCache(hashedPassword);
22
+ const base64Salt = (0, utils_js_1.byteArrayToBase64)(salt);
23
+ const cachedKey = cache.get(base64Salt);
24
+ if (!cachedKey) {
25
+ return undefined;
26
+ }
27
+ return {
28
+ salt,
29
+ base64Salt,
30
+ key: cachedKey,
31
+ };
32
+ }
33
+ exports.getCachedKeyBySalt = getCachedKeyBySalt;
34
+ /**
35
+ * Gets the cached key that was generated without a salt, if it exists.
36
+ * This is unique per hashed password.
37
+ *
38
+ * @param hashedPassword - hashed password for cache lookup
39
+ * @returns the cached key
40
+ */
41
+ function getCachedKeyGeneratedWithSharedSalt(hashedPassword) {
42
+ const cache = getPasswordCache(hashedPassword);
43
+ const base64Salt = (0, utils_js_1.byteArrayToBase64)(constants_js_1.SHARED_SALT);
44
+ const cachedKey = cache.get(base64Salt);
45
+ if (!cachedKey) {
46
+ return undefined;
47
+ }
48
+ return {
49
+ salt: constants_js_1.SHARED_SALT,
50
+ base64Salt,
51
+ key: cachedKey,
52
+ };
53
+ }
54
+ exports.getCachedKeyGeneratedWithSharedSalt = getCachedKeyGeneratedWithSharedSalt;
55
+ /**
56
+ * Sets a key to the in memory cache.
57
+ * We have set an arbitrary size of 10 cached keys per hashed password.
58
+ *
59
+ * @param hashedPassword - hashed password for cache lookup
60
+ * @param salt - salt to set new derived key
61
+ * @param key - derived key we are setting
62
+ */
63
+ function setCachedKey(hashedPassword, salt, key) {
64
+ // Max password caches
65
+ if (Object.keys(inMemCachedKDF).length > MAX_PASSWORD_CACHES) {
66
+ inMemCachedKDF = {};
67
+ }
68
+ const cache = getPasswordCache(hashedPassword);
69
+ const base64Salt = (0, utils_js_1.byteArrayToBase64)(salt);
70
+ // Max salt caches
71
+ if (cache.size > MAX_SALT_CACHES) {
72
+ cache.clear();
73
+ }
74
+ cache.set(base64Salt, key);
75
+ }
76
+ exports.setCachedKey = setCachedKey;
77
+ //# sourceMappingURL=cache.cjs.map