@metamask/profile-sync-controller 30.0.0 → 32.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (547) hide show
  1. package/CHANGELOG.md +33 -1
  2. package/dist/controllers/authentication/{AuthenticationController-method-action-types.d.mts → AuthenticationController-method-action-types.d.ts} +11 -3
  3. package/dist/controllers/authentication/AuthenticationController-method-action-types.d.ts.map +1 -0
  4. package/dist/controllers/authentication/{AuthenticationController-method-action-types.mjs → AuthenticationController-method-action-types.js} +1 -1
  5. package/dist/controllers/authentication/AuthenticationController-method-action-types.js.map +1 -0
  6. package/dist/controllers/authentication/{AuthenticationController.d.mts → AuthenticationController.d.ts} +15 -10
  7. package/dist/controllers/authentication/AuthenticationController.d.ts.map +1 -0
  8. package/dist/controllers/authentication/AuthenticationController.js +666 -0
  9. package/dist/controllers/authentication/AuthenticationController.js.map +1 -0
  10. package/dist/controllers/authentication/{index.d.cts → index.d.ts} +5 -5
  11. package/dist/controllers/authentication/index.d.ts.map +1 -0
  12. package/dist/controllers/authentication/index.js +6 -0
  13. package/dist/controllers/authentication/index.js.map +1 -0
  14. package/dist/controllers/authentication/mocks/index.d.ts +2 -0
  15. package/dist/controllers/authentication/mocks/index.d.ts.map +1 -0
  16. package/dist/controllers/authentication/mocks/index.js +2 -0
  17. package/dist/controllers/authentication/mocks/index.js.map +1 -0
  18. package/dist/controllers/authentication/mocks/{mockResponses.d.mts → mockResponses.d.ts} +1 -1
  19. package/dist/controllers/authentication/mocks/mockResponses.d.ts.map +1 -0
  20. package/dist/controllers/authentication/mocks/{mockResponses.mjs → mockResponses.js} +2 -2
  21. package/dist/controllers/authentication/mocks/mockResponses.js.map +1 -0
  22. package/dist/controllers/index.d.ts +3 -0
  23. package/dist/controllers/index.d.ts.map +1 -0
  24. package/dist/controllers/index.js +3 -0
  25. package/dist/controllers/index.js.map +1 -0
  26. package/dist/controllers/user-storage/{UserStorageController-method-action-types.d.mts → UserStorageController-method-action-types.d.ts} +2 -2
  27. package/dist/controllers/user-storage/UserStorageController-method-action-types.d.ts.map +1 -0
  28. package/dist/controllers/user-storage/{UserStorageController-method-action-types.mjs → UserStorageController-method-action-types.js} +1 -1
  29. package/dist/controllers/user-storage/UserStorageController-method-action-types.js.map +1 -0
  30. package/dist/controllers/user-storage/{UserStorageController.d.mts → UserStorageController.d.ts} +18 -14
  31. package/dist/controllers/user-storage/UserStorageController.d.ts.map +1 -0
  32. package/dist/controllers/user-storage/UserStorageController.js +439 -0
  33. package/dist/controllers/user-storage/UserStorageController.js.map +1 -0
  34. package/dist/controllers/user-storage/constants.d.ts +16 -0
  35. package/dist/controllers/user-storage/constants.d.ts.map +1 -0
  36. package/dist/controllers/user-storage/{constants.mjs → constants.js} +2 -1
  37. package/dist/controllers/user-storage/constants.js.map +1 -0
  38. package/dist/controllers/user-storage/contact-syncing/{constants.d.cts → constants.d.ts} +1 -1
  39. package/dist/controllers/user-storage/contact-syncing/constants.d.ts.map +1 -0
  40. package/dist/controllers/user-storage/contact-syncing/{constants.mjs → constants.js} +1 -1
  41. package/dist/controllers/user-storage/contact-syncing/constants.js.map +1 -0
  42. package/dist/controllers/user-storage/contact-syncing/{controller-integration.d.cts → controller-integration.d.ts} +3 -3
  43. package/dist/controllers/user-storage/contact-syncing/controller-integration.d.ts.map +1 -0
  44. package/dist/controllers/user-storage/contact-syncing/{controller-integration.mjs → controller-integration.js} +6 -6
  45. package/dist/controllers/user-storage/contact-syncing/controller-integration.js.map +1 -0
  46. package/dist/controllers/user-storage/contact-syncing/{setup-subscriptions.d.cts → setup-subscriptions.d.ts} +2 -2
  47. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.ts.map +1 -0
  48. package/dist/controllers/user-storage/contact-syncing/{setup-subscriptions.mjs → setup-subscriptions.js} +4 -4
  49. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.js.map +1 -0
  50. package/dist/controllers/user-storage/contact-syncing/{sync-utils.d.cts → sync-utils.d.ts} +2 -2
  51. package/dist/controllers/user-storage/contact-syncing/sync-utils.d.ts.map +1 -0
  52. package/dist/controllers/user-storage/contact-syncing/{sync-utils.mjs → sync-utils.js} +1 -1
  53. package/dist/controllers/user-storage/contact-syncing/sync-utils.js.map +1 -0
  54. package/dist/controllers/user-storage/contact-syncing/{types.d.mts → types.d.ts} +6 -6
  55. package/dist/controllers/user-storage/contact-syncing/types.d.ts.map +1 -0
  56. package/dist/controllers/user-storage/contact-syncing/types.js +2 -0
  57. package/dist/controllers/user-storage/contact-syncing/types.js.map +1 -0
  58. package/dist/controllers/user-storage/contact-syncing/{utils.d.mts → utils.d.ts} +3 -3
  59. package/dist/controllers/user-storage/contact-syncing/utils.d.ts.map +1 -0
  60. package/dist/controllers/user-storage/contact-syncing/{utils.mjs → utils.js} +2 -2
  61. package/dist/controllers/user-storage/contact-syncing/utils.js.map +1 -0
  62. package/dist/controllers/user-storage/{index.d.cts → index.d.ts} +8 -8
  63. package/dist/controllers/user-storage/index.d.ts.map +1 -0
  64. package/dist/controllers/user-storage/index.js +9 -0
  65. package/dist/controllers/user-storage/index.js.map +1 -0
  66. package/dist/controllers/user-storage/mocks/index.d.ts +3 -0
  67. package/dist/controllers/user-storage/mocks/index.d.ts.map +1 -0
  68. package/dist/controllers/user-storage/mocks/index.js +3 -0
  69. package/dist/controllers/user-storage/mocks/index.js.map +1 -0
  70. package/dist/controllers/user-storage/mocks/{mockResponses.d.mts → mockResponses.d.ts} +3 -3
  71. package/dist/controllers/user-storage/mocks/mockResponses.d.ts.map +1 -0
  72. package/dist/controllers/user-storage/mocks/{mockResponses.mjs → mockResponses.js} +4 -4
  73. package/dist/controllers/user-storage/mocks/mockResponses.js.map +1 -0
  74. package/dist/controllers/user-storage/mocks/{mockStorage.d.cts → mockStorage.d.ts} +1 -1
  75. package/dist/controllers/user-storage/mocks/mockStorage.d.ts.map +1 -0
  76. package/dist/controllers/user-storage/mocks/{mockStorage.mjs → mockStorage.js} +3 -3
  77. package/dist/controllers/user-storage/mocks/mockStorage.js.map +1 -0
  78. package/dist/controllers/user-storage/{types.d.cts → types.d.ts} +3 -3
  79. package/dist/controllers/user-storage/types.d.ts.map +1 -0
  80. package/dist/controllers/user-storage/types.js +2 -0
  81. package/dist/controllers/user-storage/types.js.map +1 -0
  82. package/dist/controllers/user-storage/{utils.d.cts → utils.d.ts} +1 -1
  83. package/dist/controllers/user-storage/utils.d.ts.map +1 -0
  84. package/dist/controllers/user-storage/{utils.mjs → utils.js} +1 -1
  85. package/dist/controllers/user-storage/utils.js.map +1 -0
  86. package/dist/index.d.ts +4 -0
  87. package/dist/index.d.ts.map +1 -0
  88. package/dist/index.js +4 -0
  89. package/dist/index.js.map +1 -0
  90. package/dist/sdk/authentication-jwt-bearer/{flow-siwe.d.cts → flow-siwe.d.ts} +2 -2
  91. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.ts.map +1 -0
  92. package/dist/sdk/authentication-jwt-bearer/flow-siwe.js +99 -0
  93. package/dist/sdk/authentication-jwt-bearer/flow-siwe.js.map +1 -0
  94. package/dist/sdk/authentication-jwt-bearer/{flow-srp.d.mts → flow-srp.d.ts} +5 -5
  95. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.ts.map +1 -0
  96. package/dist/sdk/authentication-jwt-bearer/flow-srp.js +258 -0
  97. package/dist/sdk/authentication-jwt-bearer/flow-srp.js.map +1 -0
  98. package/dist/sdk/authentication-jwt-bearer/{services.d.cts → services.d.ts} +5 -5
  99. package/dist/sdk/authentication-jwt-bearer/services.d.ts.map +1 -0
  100. package/dist/sdk/authentication-jwt-bearer/{services.mjs → services.js} +6 -6
  101. package/dist/sdk/authentication-jwt-bearer/{services.cjs.map → services.js.map} +1 -1
  102. package/dist/sdk/authentication-jwt-bearer/{types.d.cts → types.d.ts} +2 -2
  103. package/dist/sdk/authentication-jwt-bearer/types.d.ts.map +1 -0
  104. package/dist/sdk/authentication-jwt-bearer/{types.mjs → types.js} +1 -1
  105. package/dist/sdk/authentication-jwt-bearer/types.js.map +1 -0
  106. package/dist/sdk/authentication-jwt-bearer/utils/{identifier.d.cts → identifier.d.ts} +2 -2
  107. package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.ts.map +1 -0
  108. package/dist/sdk/authentication-jwt-bearer/utils/{identifier.mjs → identifier.js} +2 -2
  109. package/dist/sdk/authentication-jwt-bearer/utils/identifier.js.map +1 -0
  110. package/dist/sdk/authentication-jwt-bearer/utils/{time.d.cts → time.d.ts} +1 -1
  111. package/dist/sdk/authentication-jwt-bearer/utils/time.d.ts.map +1 -0
  112. package/dist/sdk/authentication-jwt-bearer/utils/{time.mjs → time.js} +1 -1
  113. package/dist/sdk/authentication-jwt-bearer/utils/time.js.map +1 -0
  114. package/dist/sdk/{authentication.d.cts → authentication.d.ts} +9 -9
  115. package/dist/sdk/authentication.d.ts.map +1 -0
  116. package/dist/sdk/authentication.js +104 -0
  117. package/dist/sdk/authentication.js.map +1 -0
  118. package/dist/sdk/{constants.d.cts → constants.d.ts} +1 -1
  119. package/dist/sdk/constants.d.ts.map +1 -0
  120. package/dist/sdk/{constants.mjs → constants.js} +1 -1
  121. package/dist/sdk/constants.js.map +1 -0
  122. package/dist/sdk/{errors.d.cts → errors.d.ts} +1 -1
  123. package/dist/sdk/errors.d.ts.map +1 -0
  124. package/dist/sdk/{errors.mjs → errors.js} +5 -4
  125. package/dist/sdk/errors.js.map +1 -0
  126. package/dist/sdk/index.d.ts +8 -0
  127. package/dist/sdk/index.d.ts.map +1 -0
  128. package/dist/sdk/index.js +8 -0
  129. package/dist/sdk/index.js.map +1 -0
  130. package/dist/sdk/mocks/{auth.d.cts → auth.d.ts} +2 -2
  131. package/dist/sdk/mocks/auth.d.ts.map +1 -0
  132. package/dist/sdk/mocks/{auth.mjs → auth.js} +3 -3
  133. package/dist/sdk/mocks/auth.js.map +1 -0
  134. package/dist/sdk/mocks/{userstorage.d.cts → userstorage.d.ts} +1 -1
  135. package/dist/sdk/mocks/userstorage.d.ts.map +1 -0
  136. package/dist/sdk/mocks/{userstorage.mjs → userstorage.js} +5 -5
  137. package/dist/sdk/mocks/userstorage.js.map +1 -0
  138. package/dist/sdk/{user-storage.d.mts → user-storage.d.ts} +5 -5
  139. package/dist/sdk/user-storage.d.ts.map +1 -0
  140. package/dist/sdk/user-storage.js +364 -0
  141. package/dist/sdk/user-storage.js.map +1 -0
  142. package/dist/sdk/utils/{eip-6963-metamask-provider.d.cts → eip-6963-metamask-provider.d.ts} +2 -2
  143. package/dist/sdk/utils/eip-6963-metamask-provider.d.ts.map +1 -0
  144. package/dist/sdk/utils/{eip-6963-metamask-provider.mjs → eip-6963-metamask-provider.js} +1 -1
  145. package/dist/sdk/utils/eip-6963-metamask-provider.js.map +1 -0
  146. package/dist/sdk/utils/{messaging-signing-snap-requests.d.cts → messaging-signing-snap-requests.d.ts} +2 -2
  147. package/dist/sdk/utils/messaging-signing-snap-requests.d.ts.map +1 -0
  148. package/dist/sdk/utils/{messaging-signing-snap-requests.mjs → messaging-signing-snap-requests.js} +1 -1
  149. package/dist/sdk/utils/messaging-signing-snap-requests.js.map +1 -0
  150. package/dist/sdk/utils/{validate-login-response.d.mts → validate-login-response.d.ts} +2 -2
  151. package/dist/sdk/utils/validate-login-response.d.ts.map +1 -0
  152. package/dist/sdk/utils/{validate-login-response.mjs → validate-login-response.js} +1 -1
  153. package/dist/sdk/utils/validate-login-response.js.map +1 -0
  154. package/dist/sdk/utils/{validate-pair-response.d.cts → validate-pair-response.d.ts} +1 -1
  155. package/dist/sdk/utils/validate-pair-response.d.ts.map +1 -0
  156. package/dist/sdk/utils/{validate-pair-response.mjs → validate-pair-response.js} +1 -1
  157. package/dist/sdk/utils/validate-pair-response.js.map +1 -0
  158. package/dist/shared/encryption/{cache.d.cts → cache.d.ts} +1 -1
  159. package/dist/shared/encryption/cache.d.ts.map +1 -0
  160. package/dist/shared/encryption/{cache.mjs → cache.js} +4 -4
  161. package/dist/shared/encryption/cache.js.map +1 -0
  162. package/dist/shared/encryption/{constants.d.cts → constants.d.ts} +2 -2
  163. package/dist/shared/encryption/constants.d.ts.map +1 -0
  164. package/dist/shared/encryption/{constants.mjs → constants.js} +1 -1
  165. package/dist/shared/encryption/constants.js.map +1 -0
  166. package/dist/shared/encryption/{encryption.d.cts → encryption.d.ts} +3 -3
  167. package/dist/shared/encryption/encryption.d.ts.map +1 -0
  168. package/dist/shared/encryption/encryption.js +202 -0
  169. package/dist/shared/encryption/encryption.js.map +1 -0
  170. package/dist/shared/encryption/index.d.ts +5 -0
  171. package/dist/shared/encryption/index.d.ts.map +1 -0
  172. package/dist/shared/encryption/index.js +5 -0
  173. package/dist/shared/encryption/index.js.map +1 -0
  174. package/dist/shared/encryption/{utils.d.cts → utils.d.ts} +3 -3
  175. package/dist/shared/encryption/utils.d.ts.map +1 -0
  176. package/dist/shared/encryption/{utils.mjs → utils.js} +1 -1
  177. package/dist/shared/encryption/utils.js.map +1 -0
  178. package/dist/shared/{env.d.cts → env.d.ts} +1 -1
  179. package/dist/shared/env.d.ts.map +1 -0
  180. package/dist/shared/{env.mjs → env.js} +1 -1
  181. package/dist/shared/env.js.map +1 -0
  182. package/dist/shared/{storage-schema.d.mts → storage-schema.d.ts} +1 -1
  183. package/dist/shared/storage-schema.d.ts.map +1 -0
  184. package/dist/shared/{storage-schema.mjs → storage-schema.js} +2 -2
  185. package/dist/shared/storage-schema.js.map +1 -0
  186. package/dist/shared/types/{encryption.d.cts → encryption.d.ts} +1 -1
  187. package/dist/shared/types/encryption.d.ts.map +1 -0
  188. package/dist/shared/types/encryption.js +2 -0
  189. package/dist/shared/types/encryption.js.map +1 -0
  190. package/dist/shared/types/{services.d.cts → services.d.ts} +2 -2
  191. package/dist/shared/types/services.d.ts.map +1 -0
  192. package/dist/shared/types/services.js +2 -0
  193. package/dist/shared/types/services.js.map +1 -0
  194. package/dist/shared/utils/{entropy-source.d.cts → entropy-source.d.ts} +2 -2
  195. package/dist/shared/utils/entropy-source.d.ts.map +1 -0
  196. package/dist/shared/utils/{entropy-source.mjs → entropy-source.js} +2 -2
  197. package/dist/shared/utils/entropy-source.js.map +1 -0
  198. package/dist/shared/utils/{event-queue.d.cts → event-queue.d.ts} +1 -1
  199. package/dist/shared/utils/event-queue.d.ts.map +1 -0
  200. package/dist/shared/utils/{event-queue.mjs → event-queue.js} +2 -4
  201. package/dist/shared/utils/event-queue.js.map +1 -0
  202. package/dist/shared/utils/{hd-keyring-seed.d.mts → hd-keyring-seed.d.ts} +3 -3
  203. package/dist/shared/utils/hd-keyring-seed.d.ts.map +1 -0
  204. package/dist/shared/utils/{hd-keyring-seed.mjs → hd-keyring-seed.js} +1 -1
  205. package/dist/shared/utils/hd-keyring-seed.js.map +1 -0
  206. package/dist/shared/utils/{message-signing.d.mts → message-signing.d.ts} +1 -1
  207. package/dist/shared/utils/message-signing.d.ts.map +1 -0
  208. package/dist/shared/utils/{message-signing.mjs → message-signing.js} +7 -7
  209. package/dist/shared/utils/message-signing.js.map +1 -0
  210. package/package.json +29 -63
  211. package/dist/controllers/authentication/AuthenticationController-method-action-types.cjs +0 -7
  212. package/dist/controllers/authentication/AuthenticationController-method-action-types.cjs.map +0 -1
  213. package/dist/controllers/authentication/AuthenticationController-method-action-types.d.cts +0 -102
  214. package/dist/controllers/authentication/AuthenticationController-method-action-types.d.cts.map +0 -1
  215. package/dist/controllers/authentication/AuthenticationController-method-action-types.d.mts.map +0 -1
  216. package/dist/controllers/authentication/AuthenticationController-method-action-types.mjs.map +0 -1
  217. package/dist/controllers/authentication/AuthenticationController.cjs +0 -596
  218. package/dist/controllers/authentication/AuthenticationController.cjs.map +0 -1
  219. package/dist/controllers/authentication/AuthenticationController.d.cts +0 -149
  220. package/dist/controllers/authentication/AuthenticationController.d.cts.map +0 -1
  221. package/dist/controllers/authentication/AuthenticationController.d.mts.map +0 -1
  222. package/dist/controllers/authentication/AuthenticationController.mjs +0 -592
  223. package/dist/controllers/authentication/AuthenticationController.mjs.map +0 -1
  224. package/dist/controllers/authentication/index.cjs +0 -35
  225. package/dist/controllers/authentication/index.cjs.map +0 -1
  226. package/dist/controllers/authentication/index.d.cts.map +0 -1
  227. package/dist/controllers/authentication/index.d.mts +0 -7
  228. package/dist/controllers/authentication/index.d.mts.map +0 -1
  229. package/dist/controllers/authentication/index.mjs +0 -6
  230. package/dist/controllers/authentication/index.mjs.map +0 -1
  231. package/dist/controllers/authentication/mocks/index.cjs +0 -18
  232. package/dist/controllers/authentication/mocks/index.cjs.map +0 -1
  233. package/dist/controllers/authentication/mocks/index.d.cts +0 -2
  234. package/dist/controllers/authentication/mocks/index.d.cts.map +0 -1
  235. package/dist/controllers/authentication/mocks/index.d.mts +0 -2
  236. package/dist/controllers/authentication/mocks/index.d.mts.map +0 -1
  237. package/dist/controllers/authentication/mocks/index.mjs +0 -2
  238. package/dist/controllers/authentication/mocks/index.mjs.map +0 -1
  239. package/dist/controllers/authentication/mocks/mockResponses.cjs +0 -135
  240. package/dist/controllers/authentication/mocks/mockResponses.cjs.map +0 -1
  241. package/dist/controllers/authentication/mocks/mockResponses.d.cts +0 -69
  242. package/dist/controllers/authentication/mocks/mockResponses.d.cts.map +0 -1
  243. package/dist/controllers/authentication/mocks/mockResponses.d.mts.map +0 -1
  244. package/dist/controllers/authentication/mocks/mockResponses.mjs.map +0 -1
  245. package/dist/controllers/index.cjs +0 -29
  246. package/dist/controllers/index.cjs.map +0 -1
  247. package/dist/controllers/index.d.cts +0 -3
  248. package/dist/controllers/index.d.cts.map +0 -1
  249. package/dist/controllers/index.d.mts +0 -3
  250. package/dist/controllers/index.d.mts.map +0 -1
  251. package/dist/controllers/index.mjs +0 -3
  252. package/dist/controllers/index.mjs.map +0 -1
  253. package/dist/controllers/user-storage/UserStorageController-method-action-types.cjs +0 -7
  254. package/dist/controllers/user-storage/UserStorageController-method-action-types.cjs.map +0 -1
  255. package/dist/controllers/user-storage/UserStorageController-method-action-types.d.cts +0 -137
  256. package/dist/controllers/user-storage/UserStorageController-method-action-types.d.cts.map +0 -1
  257. package/dist/controllers/user-storage/UserStorageController-method-action-types.d.mts.map +0 -1
  258. package/dist/controllers/user-storage/UserStorageController-method-action-types.mjs.map +0 -1
  259. package/dist/controllers/user-storage/UserStorageController.cjs +0 -412
  260. package/dist/controllers/user-storage/UserStorageController.cjs.map +0 -1
  261. package/dist/controllers/user-storage/UserStorageController.d.cts +0 -182
  262. package/dist/controllers/user-storage/UserStorageController.d.cts.map +0 -1
  263. package/dist/controllers/user-storage/UserStorageController.d.mts.map +0 -1
  264. package/dist/controllers/user-storage/UserStorageController.mjs +0 -408
  265. package/dist/controllers/user-storage/UserStorageController.mjs.map +0 -1
  266. package/dist/controllers/user-storage/constants.cjs +0 -19
  267. package/dist/controllers/user-storage/constants.cjs.map +0 -1
  268. package/dist/controllers/user-storage/constants.d.cts +0 -15
  269. package/dist/controllers/user-storage/constants.d.cts.map +0 -1
  270. package/dist/controllers/user-storage/constants.d.mts +0 -15
  271. package/dist/controllers/user-storage/constants.d.mts.map +0 -1
  272. package/dist/controllers/user-storage/constants.mjs.map +0 -1
  273. package/dist/controllers/user-storage/contact-syncing/constants.cjs +0 -12
  274. package/dist/controllers/user-storage/contact-syncing/constants.cjs.map +0 -1
  275. package/dist/controllers/user-storage/contact-syncing/constants.d.cts.map +0 -1
  276. package/dist/controllers/user-storage/contact-syncing/constants.d.mts +0 -9
  277. package/dist/controllers/user-storage/contact-syncing/constants.d.mts.map +0 -1
  278. package/dist/controllers/user-storage/contact-syncing/constants.mjs.map +0 -1
  279. package/dist/controllers/user-storage/contact-syncing/controller-integration.cjs +0 -346
  280. package/dist/controllers/user-storage/contact-syncing/controller-integration.cjs.map +0 -1
  281. package/dist/controllers/user-storage/contact-syncing/controller-integration.d.cts.map +0 -1
  282. package/dist/controllers/user-storage/contact-syncing/controller-integration.d.mts +0 -47
  283. package/dist/controllers/user-storage/contact-syncing/controller-integration.d.mts.map +0 -1
  284. package/dist/controllers/user-storage/contact-syncing/controller-integration.mjs.map +0 -1
  285. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.cjs +0 -50
  286. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.cjs.map +0 -1
  287. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.cts.map +0 -1
  288. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.mts +0 -8
  289. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.d.mts.map +0 -1
  290. package/dist/controllers/user-storage/contact-syncing/setup-subscriptions.mjs.map +0 -1
  291. package/dist/controllers/user-storage/contact-syncing/sync-utils.cjs +0 -23
  292. package/dist/controllers/user-storage/contact-syncing/sync-utils.cjs.map +0 -1
  293. package/dist/controllers/user-storage/contact-syncing/sync-utils.d.cts.map +0 -1
  294. package/dist/controllers/user-storage/contact-syncing/sync-utils.d.mts +0 -9
  295. package/dist/controllers/user-storage/contact-syncing/sync-utils.d.mts.map +0 -1
  296. package/dist/controllers/user-storage/contact-syncing/sync-utils.mjs.map +0 -1
  297. package/dist/controllers/user-storage/contact-syncing/types.cjs +0 -3
  298. package/dist/controllers/user-storage/contact-syncing/types.cjs.map +0 -1
  299. package/dist/controllers/user-storage/contact-syncing/types.d.cts +0 -37
  300. package/dist/controllers/user-storage/contact-syncing/types.d.cts.map +0 -1
  301. package/dist/controllers/user-storage/contact-syncing/types.d.mts.map +0 -1
  302. package/dist/controllers/user-storage/contact-syncing/types.mjs +0 -2
  303. package/dist/controllers/user-storage/contact-syncing/types.mjs.map +0 -1
  304. package/dist/controllers/user-storage/contact-syncing/utils.cjs +0 -64
  305. package/dist/controllers/user-storage/contact-syncing/utils.cjs.map +0 -1
  306. package/dist/controllers/user-storage/contact-syncing/utils.d.cts +0 -36
  307. package/dist/controllers/user-storage/contact-syncing/utils.d.cts.map +0 -1
  308. package/dist/controllers/user-storage/contact-syncing/utils.d.mts.map +0 -1
  309. package/dist/controllers/user-storage/contact-syncing/utils.mjs.map +0 -1
  310. package/dist/controllers/user-storage/index.cjs +0 -38
  311. package/dist/controllers/user-storage/index.cjs.map +0 -1
  312. package/dist/controllers/user-storage/index.d.cts.map +0 -1
  313. package/dist/controllers/user-storage/index.d.mts +0 -10
  314. package/dist/controllers/user-storage/index.d.mts.map +0 -1
  315. package/dist/controllers/user-storage/index.mjs +0 -9
  316. package/dist/controllers/user-storage/index.mjs.map +0 -1
  317. package/dist/controllers/user-storage/mocks/index.cjs +0 -19
  318. package/dist/controllers/user-storage/mocks/index.cjs.map +0 -1
  319. package/dist/controllers/user-storage/mocks/index.d.cts +0 -3
  320. package/dist/controllers/user-storage/mocks/index.d.cts.map +0 -1
  321. package/dist/controllers/user-storage/mocks/index.d.mts +0 -3
  322. package/dist/controllers/user-storage/mocks/index.d.mts.map +0 -1
  323. package/dist/controllers/user-storage/mocks/index.mjs +0 -3
  324. package/dist/controllers/user-storage/mocks/index.mjs.map +0 -1
  325. package/dist/controllers/user-storage/mocks/mockResponses.cjs +0 -113
  326. package/dist/controllers/user-storage/mocks/mockResponses.cjs.map +0 -1
  327. package/dist/controllers/user-storage/mocks/mockResponses.d.cts +0 -66
  328. package/dist/controllers/user-storage/mocks/mockResponses.d.cts.map +0 -1
  329. package/dist/controllers/user-storage/mocks/mockResponses.d.mts.map +0 -1
  330. package/dist/controllers/user-storage/mocks/mockResponses.mjs.map +0 -1
  331. package/dist/controllers/user-storage/mocks/mockStorage.cjs +0 -36
  332. package/dist/controllers/user-storage/mocks/mockStorage.cjs.map +0 -1
  333. package/dist/controllers/user-storage/mocks/mockStorage.d.cts.map +0 -1
  334. package/dist/controllers/user-storage/mocks/mockStorage.d.mts +0 -5
  335. package/dist/controllers/user-storage/mocks/mockStorage.d.mts.map +0 -1
  336. package/dist/controllers/user-storage/mocks/mockStorage.mjs.map +0 -1
  337. package/dist/controllers/user-storage/types.cjs +0 -3
  338. package/dist/controllers/user-storage/types.cjs.map +0 -1
  339. package/dist/controllers/user-storage/types.d.cts.map +0 -1
  340. package/dist/controllers/user-storage/types.d.mts +0 -23
  341. package/dist/controllers/user-storage/types.d.mts.map +0 -1
  342. package/dist/controllers/user-storage/types.mjs +0 -2
  343. package/dist/controllers/user-storage/types.mjs.map +0 -1
  344. package/dist/controllers/user-storage/utils.cjs +0 -32
  345. package/dist/controllers/user-storage/utils.cjs.map +0 -1
  346. package/dist/controllers/user-storage/utils.d.cts.map +0 -1
  347. package/dist/controllers/user-storage/utils.d.mts +0 -19
  348. package/dist/controllers/user-storage/utils.d.mts.map +0 -1
  349. package/dist/controllers/user-storage/utils.mjs.map +0 -1
  350. package/dist/index.cjs +0 -30
  351. package/dist/index.cjs.map +0 -1
  352. package/dist/index.d.cts +0 -4
  353. package/dist/index.d.cts.map +0 -1
  354. package/dist/index.d.mts +0 -4
  355. package/dist/index.d.mts.map +0 -1
  356. package/dist/index.mjs +0 -4
  357. package/dist/index.mjs.map +0 -1
  358. package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs +0 -114
  359. package/dist/sdk/authentication-jwt-bearer/flow-siwe.cjs.map +0 -1
  360. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.cts.map +0 -1
  361. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.mts +0 -25
  362. package/dist/sdk/authentication-jwt-bearer/flow-siwe.d.mts.map +0 -1
  363. package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs +0 -110
  364. package/dist/sdk/authentication-jwt-bearer/flow-siwe.mjs.map +0 -1
  365. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs +0 -293
  366. package/dist/sdk/authentication-jwt-bearer/flow-srp.cjs.map +0 -1
  367. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts +0 -45
  368. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.cts.map +0 -1
  369. package/dist/sdk/authentication-jwt-bearer/flow-srp.d.mts.map +0 -1
  370. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs +0 -266
  371. package/dist/sdk/authentication-jwt-bearer/flow-srp.mjs.map +0 -1
  372. package/dist/sdk/authentication-jwt-bearer/services.cjs +0 -443
  373. package/dist/sdk/authentication-jwt-bearer/services.d.cts.map +0 -1
  374. package/dist/sdk/authentication-jwt-bearer/services.d.mts +0 -120
  375. package/dist/sdk/authentication-jwt-bearer/services.d.mts.map +0 -1
  376. package/dist/sdk/authentication-jwt-bearer/services.mjs.map +0 -1
  377. package/dist/sdk/authentication-jwt-bearer/types.cjs +0 -12
  378. package/dist/sdk/authentication-jwt-bearer/types.cjs.map +0 -1
  379. package/dist/sdk/authentication-jwt-bearer/types.d.cts.map +0 -1
  380. package/dist/sdk/authentication-jwt-bearer/types.d.mts +0 -133
  381. package/dist/sdk/authentication-jwt-bearer/types.d.mts.map +0 -1
  382. package/dist/sdk/authentication-jwt-bearer/types.mjs.map +0 -1
  383. package/dist/sdk/authentication-jwt-bearer/utils/identifier.cjs +0 -27
  384. package/dist/sdk/authentication-jwt-bearer/utils/identifier.cjs.map +0 -1
  385. package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.cts.map +0 -1
  386. package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.mts +0 -13
  387. package/dist/sdk/authentication-jwt-bearer/utils/identifier.d.mts.map +0 -1
  388. package/dist/sdk/authentication-jwt-bearer/utils/identifier.mjs.map +0 -1
  389. package/dist/sdk/authentication-jwt-bearer/utils/time.cjs +0 -17
  390. package/dist/sdk/authentication-jwt-bearer/utils/time.cjs.map +0 -1
  391. package/dist/sdk/authentication-jwt-bearer/utils/time.d.cts.map +0 -1
  392. package/dist/sdk/authentication-jwt-bearer/utils/time.d.mts +0 -8
  393. package/dist/sdk/authentication-jwt-bearer/utils/time.d.mts.map +0 -1
  394. package/dist/sdk/authentication-jwt-bearer/utils/time.mjs.map +0 -1
  395. package/dist/sdk/authentication.cjs +0 -136
  396. package/dist/sdk/authentication.cjs.map +0 -1
  397. package/dist/sdk/authentication.d.cts.map +0 -1
  398. package/dist/sdk/authentication.d.mts +0 -39
  399. package/dist/sdk/authentication.d.mts.map +0 -1
  400. package/dist/sdk/authentication.mjs +0 -116
  401. package/dist/sdk/authentication.mjs.map +0 -1
  402. package/dist/sdk/constants.cjs +0 -8
  403. package/dist/sdk/constants.cjs.map +0 -1
  404. package/dist/sdk/constants.d.cts.map +0 -1
  405. package/dist/sdk/constants.d.mts +0 -5
  406. package/dist/sdk/constants.d.mts.map +0 -1
  407. package/dist/sdk/constants.mjs.map +0 -1
  408. package/dist/sdk/errors.cjs +0 -89
  409. package/dist/sdk/errors.cjs.map +0 -1
  410. package/dist/sdk/errors.d.cts.map +0 -1
  411. package/dist/sdk/errors.d.mts +0 -43
  412. package/dist/sdk/errors.d.mts.map +0 -1
  413. package/dist/sdk/errors.mjs.map +0 -1
  414. package/dist/sdk/index.cjs +0 -24
  415. package/dist/sdk/index.cjs.map +0 -1
  416. package/dist/sdk/index.d.cts +0 -8
  417. package/dist/sdk/index.d.cts.map +0 -1
  418. package/dist/sdk/index.d.mts +0 -8
  419. package/dist/sdk/index.d.mts.map +0 -1
  420. package/dist/sdk/index.mjs +0 -8
  421. package/dist/sdk/index.mjs.map +0 -1
  422. package/dist/sdk/mocks/auth.cjs +0 -93
  423. package/dist/sdk/mocks/auth.cjs.map +0 -1
  424. package/dist/sdk/mocks/auth.d.cts.map +0 -1
  425. package/dist/sdk/mocks/auth.d.mts +0 -80
  426. package/dist/sdk/mocks/auth.d.mts.map +0 -1
  427. package/dist/sdk/mocks/auth.mjs.map +0 -1
  428. package/dist/sdk/mocks/userstorage.cjs +0 -43
  429. package/dist/sdk/mocks/userstorage.cjs.map +0 -1
  430. package/dist/sdk/mocks/userstorage.d.cts.map +0 -1
  431. package/dist/sdk/mocks/userstorage.d.mts +0 -10
  432. package/dist/sdk/mocks/userstorage.d.mts.map +0 -1
  433. package/dist/sdk/mocks/userstorage.mjs.map +0 -1
  434. package/dist/sdk/user-storage.cjs +0 -386
  435. package/dist/sdk/user-storage.cjs.map +0 -1
  436. package/dist/sdk/user-storage.d.cts +0 -47
  437. package/dist/sdk/user-storage.d.cts.map +0 -1
  438. package/dist/sdk/user-storage.d.mts.map +0 -1
  439. package/dist/sdk/user-storage.mjs +0 -358
  440. package/dist/sdk/user-storage.mjs.map +0 -1
  441. package/dist/sdk/utils/eip-6963-metamask-provider.cjs +0 -70
  442. package/dist/sdk/utils/eip-6963-metamask-provider.cjs.map +0 -1
  443. package/dist/sdk/utils/eip-6963-metamask-provider.d.cts.map +0 -1
  444. package/dist/sdk/utils/eip-6963-metamask-provider.d.mts +0 -25
  445. package/dist/sdk/utils/eip-6963-metamask-provider.d.mts.map +0 -1
  446. package/dist/sdk/utils/eip-6963-metamask-provider.mjs.map +0 -1
  447. package/dist/sdk/utils/messaging-signing-snap-requests.cjs +0 -96
  448. package/dist/sdk/utils/messaging-signing-snap-requests.cjs.map +0 -1
  449. package/dist/sdk/utils/messaging-signing-snap-requests.d.cts.map +0 -1
  450. package/dist/sdk/utils/messaging-signing-snap-requests.d.mts +0 -41
  451. package/dist/sdk/utils/messaging-signing-snap-requests.d.mts.map +0 -1
  452. package/dist/sdk/utils/messaging-signing-snap-requests.mjs.map +0 -1
  453. package/dist/sdk/utils/validate-login-response.cjs +0 -49
  454. package/dist/sdk/utils/validate-login-response.cjs.map +0 -1
  455. package/dist/sdk/utils/validate-login-response.d.cts +0 -14
  456. package/dist/sdk/utils/validate-login-response.d.cts.map +0 -1
  457. package/dist/sdk/utils/validate-login-response.d.mts.map +0 -1
  458. package/dist/sdk/utils/validate-login-response.mjs.map +0 -1
  459. package/dist/sdk/utils/validate-pair-response.cjs +0 -29
  460. package/dist/sdk/utils/validate-pair-response.cjs.map +0 -1
  461. package/dist/sdk/utils/validate-pair-response.d.cts.map +0 -1
  462. package/dist/sdk/utils/validate-pair-response.d.mts +0 -26
  463. package/dist/sdk/utils/validate-pair-response.d.mts.map +0 -1
  464. package/dist/sdk/utils/validate-pair-response.mjs.map +0 -1
  465. package/dist/shared/encryption/cache.cjs +0 -77
  466. package/dist/shared/encryption/cache.cjs.map +0 -1
  467. package/dist/shared/encryption/cache.d.cts.map +0 -1
  468. package/dist/shared/encryption/cache.d.mts +0 -32
  469. package/dist/shared/encryption/cache.d.mts.map +0 -1
  470. package/dist/shared/encryption/cache.mjs.map +0 -1
  471. package/dist/shared/encryption/constants.cjs +0 -17
  472. package/dist/shared/encryption/constants.cjs.map +0 -1
  473. package/dist/shared/encryption/constants.d.cts.map +0 -1
  474. package/dist/shared/encryption/constants.d.mts +0 -9
  475. package/dist/shared/encryption/constants.d.mts.map +0 -1
  476. package/dist/shared/encryption/constants.mjs.map +0 -1
  477. package/dist/shared/encryption/encryption.cjs +0 -209
  478. package/dist/shared/encryption/encryption.cjs.map +0 -1
  479. package/dist/shared/encryption/encryption.d.cts.map +0 -1
  480. package/dist/shared/encryption/encryption.d.mts +0 -30
  481. package/dist/shared/encryption/encryption.d.mts.map +0 -1
  482. package/dist/shared/encryption/encryption.mjs +0 -205
  483. package/dist/shared/encryption/encryption.mjs.map +0 -1
  484. package/dist/shared/encryption/index.cjs +0 -25
  485. package/dist/shared/encryption/index.cjs.map +0 -1
  486. package/dist/shared/encryption/index.d.cts +0 -5
  487. package/dist/shared/encryption/index.d.cts.map +0 -1
  488. package/dist/shared/encryption/index.d.mts +0 -5
  489. package/dist/shared/encryption/index.d.mts.map +0 -1
  490. package/dist/shared/encryption/index.mjs +0 -5
  491. package/dist/shared/encryption/index.mjs.map +0 -1
  492. package/dist/shared/encryption/utils.cjs +0 -21
  493. package/dist/shared/encryption/utils.cjs.map +0 -1
  494. package/dist/shared/encryption/utils.d.cts.map +0 -1
  495. package/dist/shared/encryption/utils.d.mts +0 -5
  496. package/dist/shared/encryption/utils.d.mts.map +0 -1
  497. package/dist/shared/encryption/utils.mjs.map +0 -1
  498. package/dist/shared/env.cjs +0 -85
  499. package/dist/shared/env.cjs.map +0 -1
  500. package/dist/shared/env.d.cts.map +0 -1
  501. package/dist/shared/env.d.mts +0 -34
  502. package/dist/shared/env.d.mts.map +0 -1
  503. package/dist/shared/env.mjs.map +0 -1
  504. package/dist/shared/storage-schema.cjs +0 -42
  505. package/dist/shared/storage-schema.cjs.map +0 -1
  506. package/dist/shared/storage-schema.d.cts +0 -34
  507. package/dist/shared/storage-schema.d.cts.map +0 -1
  508. package/dist/shared/storage-schema.d.mts.map +0 -1
  509. package/dist/shared/storage-schema.mjs.map +0 -1
  510. package/dist/shared/types/encryption.cjs +0 -3
  511. package/dist/shared/types/encryption.cjs.map +0 -1
  512. package/dist/shared/types/encryption.d.cts.map +0 -1
  513. package/dist/shared/types/encryption.d.mts +0 -2
  514. package/dist/shared/types/encryption.d.mts.map +0 -1
  515. package/dist/shared/types/encryption.mjs +0 -2
  516. package/dist/shared/types/encryption.mjs.map +0 -1
  517. package/dist/shared/types/services.cjs +0 -3
  518. package/dist/shared/types/services.cjs.map +0 -1
  519. package/dist/shared/types/services.d.cts.map +0 -1
  520. package/dist/shared/types/services.d.mts +0 -17
  521. package/dist/shared/types/services.d.mts.map +0 -1
  522. package/dist/shared/types/services.mjs +0 -2
  523. package/dist/shared/types/services.mjs.map +0 -1
  524. package/dist/shared/utils/entropy-source.cjs +0 -37
  525. package/dist/shared/utils/entropy-source.cjs.map +0 -1
  526. package/dist/shared/utils/entropy-source.d.cts.map +0 -1
  527. package/dist/shared/utils/entropy-source.d.mts +0 -22
  528. package/dist/shared/utils/entropy-source.d.mts.map +0 -1
  529. package/dist/shared/utils/entropy-source.mjs.map +0 -1
  530. package/dist/shared/utils/event-queue.cjs +0 -24
  531. package/dist/shared/utils/event-queue.cjs.map +0 -1
  532. package/dist/shared/utils/event-queue.d.cts.map +0 -1
  533. package/dist/shared/utils/event-queue.d.mts +0 -6
  534. package/dist/shared/utils/event-queue.d.mts.map +0 -1
  535. package/dist/shared/utils/event-queue.mjs.map +0 -1
  536. package/dist/shared/utils/hd-keyring-seed.cjs +0 -49
  537. package/dist/shared/utils/hd-keyring-seed.cjs.map +0 -1
  538. package/dist/shared/utils/hd-keyring-seed.d.cts +0 -27
  539. package/dist/shared/utils/hd-keyring-seed.d.cts.map +0 -1
  540. package/dist/shared/utils/hd-keyring-seed.d.mts.map +0 -1
  541. package/dist/shared/utils/hd-keyring-seed.mjs.map +0 -1
  542. package/dist/shared/utils/message-signing.cjs +0 -147
  543. package/dist/shared/utils/message-signing.cjs.map +0 -1
  544. package/dist/shared/utils/message-signing.d.cts +0 -73
  545. package/dist/shared/utils/message-signing.d.cts.map +0 -1
  546. package/dist/shared/utils/message-signing.d.mts.map +0 -1
  547. package/dist/shared/utils/message-signing.mjs.map +0 -1
@@ -1,443 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCustomerServiceToken = exports.getUserProfileLineage = exports.authenticate = exports.authorizeOIDC = exports.getNonce = exports.pairSocialIdentifier = exports.pairProfiles = exports.pairIdentifiers = exports.CUSTOMER_SERVICE_TOKEN_URL = exports.PROFILE_LINEAGE_URL = exports.PAIR_SOCIAL_IDENTIFIER_URL = exports.PAIR_PROFILES_URL = exports.SIWE_LOGIN_URL = exports.SRP_LOGIN_URL = exports.OIDC_TOKEN_URL = exports.PAIR_IDENTIFIERS = exports.NONCE_URL = void 0;
4
- const env_js_1 = require("../../shared/env.cjs");
5
- const constants_js_1 = require("../constants.cjs");
6
- const errors_js_1 = require("../errors.cjs");
7
- const validate_pair_response_js_1 = require("../utils/validate-pair-response.cjs");
8
- const types_js_1 = require("./types.cjs");
9
- /**
10
- * Parse Retry-After header into milliseconds if possible.
11
- * Supports seconds or HTTP-date formats.
12
- *
13
- * @param retryAfterHeader - The Retry-After header value (seconds or HTTP-date)
14
- * @returns The retry delay in milliseconds, or null if parsing fails
15
- */
16
- function parseRetryAfter(retryAfterHeader) {
17
- if (!retryAfterHeader) {
18
- return null;
19
- }
20
- const seconds = Number(retryAfterHeader);
21
- if (!Number.isNaN(seconds)) {
22
- return seconds * 1000;
23
- }
24
- const date = Date.parse(retryAfterHeader);
25
- if (!Number.isNaN(date)) {
26
- const diff = date - Date.now();
27
- return diff > 0 ? diff : null;
28
- }
29
- return null;
30
- }
31
- /**
32
- * Extracts error details from a Response object.
33
- *
34
- * @param response - The HTTP response object
35
- * @returns Formatted error message with HTTP status and response body
36
- */
37
- async function getResponseErrorMessage(response) {
38
- const { status } = response;
39
- const clonedResponse = response.clone();
40
- let message = 'Unknown error';
41
- let error = 'unknown';
42
- try {
43
- const responseBody = (await response.json());
44
- message =
45
- 'message' in responseBody
46
- ? responseBody.message
47
- : responseBody.error_description;
48
- error = responseBody.error ?? 'unknown';
49
- }
50
- catch {
51
- try {
52
- const textContent = await clonedResponse.text();
53
- message = textContent
54
- ? textContent.slice(0, 150)
55
- : 'Non-JSON error response';
56
- error = 'non_json_response';
57
- }
58
- catch {
59
- message = 'Unable to parse error response';
60
- error = 'unparseable_response';
61
- }
62
- }
63
- return `HTTP ${status} - ${message} (error: ${error})`;
64
- }
65
- /**
66
- * Type guard to check if an object is a Response-like object.
67
- *
68
- * @param obj - The object to check
69
- * @returns True if the object is a Response-like object, false otherwise
70
- */
71
- const isErrorResponse = (obj) => typeof obj === 'object' &&
72
- obj !== null &&
73
- 'status' in obj &&
74
- 'headers' in obj;
75
- /**
76
- * Throws a domain-specific error for service failures.
77
- * Handles both HTTP error responses and regular errors (network failures, etc.).
78
- * For HTTP 429, throws RateLimitedError with Retry-After header parsing.
79
- *
80
- * @param error - The error (Response object or caught error)
81
- * @param errorPrefix - Context prefix for the error message
82
- * @param ErrorClass - The domain-specific error class to throw
83
- * @throws RateLimitedError for 429, otherwise ErrorClass
84
- */
85
- async function throwServiceError(error, errorPrefix, ErrorClass) {
86
- // Re-throw RateLimitedError or matching ErrorClass as-is (don't double-wrap)
87
- if (error instanceof errors_js_1.RateLimitedError || error instanceof ErrorClass) {
88
- throw error;
89
- }
90
- // Not a Response-like object - handle as regular error
91
- if (!isErrorResponse(error)) {
92
- const errorMessage = error instanceof Error ? error.message : String(error);
93
- throw new ErrorClass(`${errorPrefix}: ${errorMessage}`);
94
- }
95
- // Handle HTTP error response
96
- const response = error;
97
- const { status } = response;
98
- const responseMessage = await getResponseErrorMessage(response);
99
- if (status === constants_js_1.HTTP_STATUS_CODES.TOO_MANY_REQUESTS) {
100
- const retryAfterHeader = response.headers.get('Retry-After');
101
- const retryAfterMs = parseRetryAfter(retryAfterHeader);
102
- throw new errors_js_1.RateLimitedError(`${errorPrefix}: ${responseMessage}`, retryAfterMs ?? undefined);
103
- }
104
- throw new ErrorClass(`${errorPrefix}: ${responseMessage}`);
105
- }
106
- const NONCE_URL = (env) => `${(0, env_js_1.getEnvUrls)(env).authApiUrl}/api/v2/nonce`;
107
- exports.NONCE_URL = NONCE_URL;
108
- const PAIR_IDENTIFIERS = (env) => `${(0, env_js_1.getEnvUrls)(env).authApiUrl}/api/v2/identifiers/pair`;
109
- exports.PAIR_IDENTIFIERS = PAIR_IDENTIFIERS;
110
- const OIDC_TOKEN_URL = (env) => `${(0, env_js_1.getEnvUrls)(env).oidcApiUrl}/oauth2/token`;
111
- exports.OIDC_TOKEN_URL = OIDC_TOKEN_URL;
112
- const SRP_LOGIN_URL = (env) => `${(0, env_js_1.getEnvUrls)(env).authApiUrl}/api/v2/srp/login`;
113
- exports.SRP_LOGIN_URL = SRP_LOGIN_URL;
114
- const SIWE_LOGIN_URL = (env) => `${(0, env_js_1.getEnvUrls)(env).authApiUrl}/api/v2/siwe/login`;
115
- exports.SIWE_LOGIN_URL = SIWE_LOGIN_URL;
116
- const PAIR_PROFILES_URL = (env) => `${(0, env_js_1.getEnvUrls)(env).authApiUrl}/api/v2/profile/pair`;
117
- exports.PAIR_PROFILES_URL = PAIR_PROFILES_URL;
118
- const PAIR_SOCIAL_IDENTIFIER_URL = (env) => `${(0, env_js_1.getEnvUrls)(env).authApiUrl}/api/v2/profile/pair/identifier`;
119
- exports.PAIR_SOCIAL_IDENTIFIER_URL = PAIR_SOCIAL_IDENTIFIER_URL;
120
- const PROFILE_LINEAGE_URL = (env) => `${(0, env_js_1.getEnvUrls)(env).authApiUrl}/api/v2/profile/lineage`;
121
- exports.PROFILE_LINEAGE_URL = PROFILE_LINEAGE_URL;
122
- const CUSTOMER_SERVICE_TOKEN_URL = (env) => `${(0, env_js_1.getEnvUrls)(env).authApiUrl}/api/v2/customer-service/token`;
123
- exports.CUSTOMER_SERVICE_TOKEN_URL = CUSTOMER_SERVICE_TOKEN_URL;
124
- const getAuthenticationUrl = (authType, env) => {
125
- switch (authType) {
126
- case types_js_1.AuthType.SRP:
127
- return (0, exports.SRP_LOGIN_URL)(env);
128
- case types_js_1.AuthType.SiWE:
129
- return (0, exports.SIWE_LOGIN_URL)(env);
130
- /* istanbul ignore next */
131
- default:
132
- throw new errors_js_1.ValidationError(`Invalid AuthType: ${authType} - unable to create Auth URL`);
133
- }
134
- };
135
- const parseProfileAliases = (raw) => {
136
- return raw.map((alias) => ({
137
- aliasProfileId: alias.alias_profile_id,
138
- canonicalProfileId: alias.canonical_profile_id,
139
- identifierIds: alias.identifier_ids ?? [],
140
- }));
141
- };
142
- /**
143
- * Pair multiple identifiers under a single profile
144
- *
145
- * @param nonce - session nonce
146
- * @param logins - pairing request payload
147
- * @param accessToken - JWT access token used to access protected resources
148
- * @param env - server environment
149
- * @returns void.
150
- */
151
- async function pairIdentifiers(nonce, logins, accessToken, env) {
152
- const pairUrl = new URL((0, exports.PAIR_IDENTIFIERS)(env));
153
- try {
154
- const response = await fetch(pairUrl, {
155
- method: 'POST',
156
- headers: {
157
- 'Content-Type': 'application/json',
158
- Authorization: `Bearer ${accessToken}`,
159
- },
160
- body: JSON.stringify({
161
- nonce,
162
- logins,
163
- }),
164
- });
165
- if (!response.ok) {
166
- return await throwServiceError(response, 'Failed to pair identifiers', errors_js_1.PairError);
167
- }
168
- return undefined;
169
- }
170
- catch (error) {
171
- return await throwServiceError(error, 'Failed to pair identifiers', errors_js_1.PairError);
172
- }
173
- }
174
- exports.pairIdentifiers = pairIdentifiers;
175
- /**
176
- * Pair multiple profiles using their OIDC access tokens.
177
- * Idempotent — calling with already-paired tokens is a no-op.
178
- *
179
- * @param accessTokens - Two or more OIDC access tokens to pair
180
- * @param authAccessToken - A valid access token for the Authorization header
181
- * @param env - server environment
182
- * @returns The pair response containing the canonical profile and aliases
183
- */
184
- async function pairProfiles(accessTokens, authAccessToken, env) {
185
- const pairUrl = new URL((0, exports.PAIR_PROFILES_URL)(env));
186
- try {
187
- const response = await fetch(pairUrl, {
188
- method: 'POST',
189
- headers: {
190
- 'Content-Type': 'application/json',
191
- Authorization: `Bearer ${authAccessToken}`,
192
- },
193
- body: JSON.stringify({
194
- jwts: accessTokens,
195
- }),
196
- });
197
- if (!response.ok) {
198
- return await throwServiceError(response, 'Failed to pair profiles', errors_js_1.PairError);
199
- }
200
- const pairResponse = await response.json();
201
- (0, validate_pair_response_js_1.validatePairResponse)(pairResponse);
202
- return {
203
- profile: {
204
- identifierId: pairResponse.profile.identifier_id,
205
- metaMetricsId: pairResponse.profile.metametrics_id ?? '',
206
- profileId: pairResponse.profile.profile_id,
207
- canonicalProfileId: pairResponse.profile.profile_id,
208
- },
209
- profileAliases: parseProfileAliases(pairResponse.profile_aliases ?? []),
210
- };
211
- }
212
- catch (error) {
213
- return await throwServiceError(error, 'Failed to pair profiles', errors_js_1.PairError);
214
- }
215
- }
216
- exports.pairProfiles = pairProfiles;
217
- /**
218
- * Attach a Google/Apple/Telegram social identifier to the profile that
219
- * owns `authAccessToken` (`POST /api/v2/profile/pair/identifier`).
220
- *
221
- * `email` is omitted from the body when undefined. 409 Conflict throws
222
- * {@link PairConflictError} so callers can treat it as terminal. The
223
- * response body (new token + profile) is not consumed: a 2xx status is the
224
- * only success signal.
225
- *
226
- * @param params - Social identifier type, social JWT, and optional email
227
- * @param authAccessToken - Bearer token of the canonical (primary SRP) profile
228
- * @param env - server environment
229
- */
230
- async function pairSocialIdentifier(params, authAccessToken, env) {
231
- const pairUrl = new URL((0, exports.PAIR_SOCIAL_IDENTIFIER_URL)(env));
232
- const errorPrefix = 'Failed to pair social identifier';
233
- try {
234
- const response = await fetch(pairUrl, {
235
- method: 'POST',
236
- headers: {
237
- 'Content-Type': 'application/json',
238
- Authorization: `Bearer ${authAccessToken}`,
239
- },
240
- body: JSON.stringify({
241
- identifier_type: params.identifierType,
242
- social_jwt: params.socialJwt,
243
- ...(params.email === undefined ? {} : { email: params.email }),
244
- }),
245
- });
246
- if (!response.ok) {
247
- if (response.status === constants_js_1.HTTP_STATUS_CODES.CONFLICT) {
248
- await throwServiceError(response, errorPrefix, errors_js_1.PairConflictError);
249
- }
250
- await throwServiceError(response, errorPrefix, errors_js_1.PairError);
251
- }
252
- }
253
- catch (error) {
254
- await throwServiceError(error, errorPrefix, errors_js_1.PairError);
255
- }
256
- }
257
- exports.pairSocialIdentifier = pairSocialIdentifier;
258
- /**
259
- * Service to Get Nonce for JWT Bearer Flow
260
- *
261
- * @param id - identifier ID
262
- * @param env - server environment
263
- * @returns the nonce.
264
- */
265
- async function getNonce(id, env) {
266
- const nonceUrl = new URL((0, exports.NONCE_URL)(env));
267
- nonceUrl.searchParams.set('identifier', id);
268
- try {
269
- const nonceResponse = await fetch(nonceUrl.toString());
270
- if (!nonceResponse.ok) {
271
- return await throwServiceError(nonceResponse, 'Failed to get nonce', errors_js_1.NonceRetrievalError);
272
- }
273
- const nonceJson = await nonceResponse.json();
274
- return {
275
- nonce: nonceJson.nonce,
276
- identifier: nonceJson.identifier,
277
- expiresIn: nonceJson.expires_in,
278
- };
279
- }
280
- catch (error) {
281
- return await throwServiceError(error, 'Failed to get nonce', errors_js_1.NonceRetrievalError);
282
- }
283
- }
284
- exports.getNonce = getNonce;
285
- /**
286
- * Service to Authorize And perform OIDC Flow to get the Access Token
287
- *
288
- * @param jwtToken - The original token received from Authentication. This is traded for the Access Token. (the authentication token is single-use)
289
- * @param env - server environment
290
- * @param platform - SDK platform
291
- * @returns Access Token from Authorization server
292
- */
293
- async function authorizeOIDC(jwtToken, env, platform) {
294
- const grantType = 'urn:ietf:params:oauth:grant-type:jwt-bearer';
295
- const headers = {
296
- 'Content-Type': 'application/x-www-form-urlencoded',
297
- };
298
- const urlEncodedBody = new URLSearchParams();
299
- urlEncodedBody.append('grant_type', grantType);
300
- urlEncodedBody.append('client_id', (0, env_js_1.getOidcClientId)(env, platform));
301
- urlEncodedBody.append('assertion', jwtToken);
302
- try {
303
- const response = await fetch((0, exports.OIDC_TOKEN_URL)(env), {
304
- method: 'POST',
305
- headers,
306
- body: urlEncodedBody.toString(),
307
- });
308
- if (!response.ok) {
309
- return await throwServiceError(response, 'Failed to get access token', errors_js_1.SignInError);
310
- }
311
- const accessTokenResponse = await response.json();
312
- return {
313
- accessToken: accessTokenResponse.access_token,
314
- expiresIn: accessTokenResponse.expires_in,
315
- obtainedAt: Date.now(),
316
- };
317
- }
318
- catch (error) {
319
- return await throwServiceError(error, 'Failed to get access token', errors_js_1.SignInError);
320
- }
321
- }
322
- exports.authorizeOIDC = authorizeOIDC;
323
- /**
324
- * Service to Authenticate/Login a user via SIWE or SRP derived key.
325
- *
326
- * @param rawMessage - raw message for validation when authenticating
327
- * @param signature - signed raw message
328
- * @param authType - authentication type/flow used
329
- * @param env - server environment
330
- * @param metametrics - optional metametrics
331
- * @param identifierType - login identifier type included in metametrics
332
- * (defaults to `SRP` when metametrics is present)
333
- * @returns Authentication Token
334
- */
335
- async function authenticate(rawMessage, signature, authType, env, metametrics, identifierType = 'SRP') {
336
- const authenticationUrl = getAuthenticationUrl(authType, env);
337
- try {
338
- const response = await fetch(authenticationUrl, {
339
- method: 'POST',
340
- headers: {
341
- 'Content-Type': 'application/json',
342
- ...(authType === types_js_1.AuthType.SRP
343
- ? { 'X-MetaMask-Profile-Pairing': 'enabled' }
344
- : {}),
345
- },
346
- body: JSON.stringify({
347
- signature,
348
- raw_message: rawMessage,
349
- ...(metametrics
350
- ? {
351
- metametrics: {
352
- metametrics_id: await metametrics.getMetaMetricsId(),
353
- agent: metametrics.agent,
354
- app_version: await metametrics.getAppVersion?.(),
355
- identifier_type: identifierType,
356
- },
357
- }
358
- : {}),
359
- }),
360
- });
361
- if (!response.ok) {
362
- return await throwServiceError(response, `Failed to login with ${authType}`, errors_js_1.SignInError);
363
- }
364
- const loginResponse = await response.json();
365
- return {
366
- token: loginResponse.token,
367
- expiresIn: loginResponse.expires_in,
368
- profile: {
369
- identifierId: loginResponse.profile.identifier_id,
370
- metaMetricsId: loginResponse.profile.metametrics_id,
371
- profileId: loginResponse.profile.profile_id,
372
- canonicalProfileId: loginResponse.profile.profile_id,
373
- },
374
- profileAliases: parseProfileAliases(loginResponse.profile_aliases ?? []),
375
- };
376
- }
377
- catch (error) {
378
- return await throwServiceError(error, `Failed to login with ${authType}`, errors_js_1.SignInError);
379
- }
380
- }
381
- exports.authenticate = authenticate;
382
- /**
383
- * Service to get the Profile Lineage
384
- *
385
- * @param env - server environment
386
- * @param accessToken - JWT access token used to access protected resources
387
- * @returns Profile Lineage information.
388
- */
389
- async function getUserProfileLineage(env, accessToken) {
390
- const profileLineageUrl = new URL((0, exports.PROFILE_LINEAGE_URL)(env));
391
- try {
392
- const response = await fetch(profileLineageUrl, {
393
- method: 'GET',
394
- headers: {
395
- Authorization: `Bearer ${accessToken}`,
396
- },
397
- });
398
- if (!response.ok) {
399
- return await throwServiceError(response, 'Failed to get profile lineage', errors_js_1.SignInError);
400
- }
401
- const profileJson = await response.json();
402
- return profileJson;
403
- }
404
- catch (error) {
405
- return await throwServiceError(error, 'Failed to get profile lineage', errors_js_1.SignInError);
406
- }
407
- }
408
- exports.getUserProfileLineage = getUserProfileLineage;
409
- /**
410
- * Service to get a Customer Service specific access token.
411
- *
412
- * Exchanges a valid OIDC access token for a short-lived token scoped to the
413
- * customer-service audience, which Customer Service tooling consumes to
414
- * identify and authenticate the user.
415
- *
416
- * @param env - server environment
417
- * @param accessToken - JWT access token used to access protected resources
418
- * @returns The customer-service access token.
419
- */
420
- async function getCustomerServiceToken(env, accessToken) {
421
- const customerServiceTokenUrl = new URL((0, exports.CUSTOMER_SERVICE_TOKEN_URL)(env));
422
- try {
423
- const response = await fetch(customerServiceTokenUrl, {
424
- method: 'POST',
425
- headers: {
426
- Authorization: `Bearer ${accessToken}`,
427
- },
428
- });
429
- if (!response.ok) {
430
- return await throwServiceError(response, 'Failed to get customer service token', errors_js_1.SignInError);
431
- }
432
- const tokenResponse = await response.json();
433
- if (typeof tokenResponse?.access_token !== 'string') {
434
- throw new errors_js_1.SignInError('Failed to get customer service token: missing access_token');
435
- }
436
- return tokenResponse.access_token;
437
- }
438
- catch (error) {
439
- return await throwServiceError(error, 'Failed to get customer service token', errors_js_1.SignInError);
440
- }
441
- }
442
- exports.getCustomerServiceToken = getCustomerServiceToken;
443
- //# sourceMappingURL=services.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"services.d.cts","sourceRoot":"","sources":["../../../src/sdk/authentication-jwt-bearer/services.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,6BAA4B;AAEzD,OAAO,KAAK,EAAE,eAAe,EAAE,wCAAuC;AAWtE,OAAO,KAAK,EACV,WAAW,EAEX,mBAAmB,EACnB,0BAA0B,EAC1B,YAAY,EACZ,WAAW,EACX,kBAAkB,EACnB,oBAAmB;AACpB,OAAO,EAAE,QAAQ,EAAE,oBAAmB;AAwHtC,eAAO,MAAM,SAAS,QAAS,GAAG,KAAG,MACS,CAAC;AAE/C,eAAO,MAAM,gBAAgB,QAAS,GAAG,KAAG,MACa,CAAC;AAE1D,eAAO,MAAM,cAAc,QAAS,GAAG,KAAG,MACI,CAAC;AAE/C,eAAO,MAAM,aAAa,QAAS,GAAG,KAAG,MACS,CAAC;AAEnD,eAAO,MAAM,cAAc,QAAS,GAAG,KAAG,MACS,CAAC;AAEpD,eAAO,MAAM,iBAAiB,QAAS,GAAG,KAAG,MACQ,CAAC;AAEtD,eAAO,MAAM,0BAA0B,QAAS,GAAG,KAAG,MACU,CAAC;AAEjE,eAAO,MAAM,mBAAmB,QAAS,GAAG,KAAG,MACS,CAAC;AAEzD,eAAO,MAAM,0BAA0B,QAAS,GAAG,KAAG,MACS,CAAC;AAgBhE,KAAK,aAAa,GAAG;IACnB,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B,OAAO,EAAE,WAAW,CAAC;IACrB,cAAc,EAAE,YAAY,EAAE,CAAC;CAChC,CAAC;AACF;;;;;;;;;;;GAWG;AACH,wBAAsB,YAAY,CAChC,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,EACR,WAAW,CAAC,EAAE,eAAe,EAC7B,cAAc,GAAE,mBAA2B,GAC1C,OAAO,CAAC,cAAc,CAAC,CAwDzB;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,kBAAkB,CAAC,CA4B7B;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,CAiCjB"}
@@ -1,120 +0,0 @@
1
- import type { Env, Platform } from "../../shared/env.mjs";
2
- import type { MetaMetricsAuth } from "../../shared/types/services.mjs";
3
- import type { AccessToken, LoginIdentifierType, PairSocialIdentifierParams, ProfileAlias, UserProfile, UserProfileLineage } from "./types.mjs";
4
- import { AuthType } from "./types.mjs";
5
- export declare const NONCE_URL: (env: Env) => string;
6
- export declare const PAIR_IDENTIFIERS: (env: Env) => string;
7
- export declare const OIDC_TOKEN_URL: (env: Env) => string;
8
- export declare const SRP_LOGIN_URL: (env: Env) => string;
9
- export declare const SIWE_LOGIN_URL: (env: Env) => string;
10
- export declare const PAIR_PROFILES_URL: (env: Env) => string;
11
- export declare const PAIR_SOCIAL_IDENTIFIER_URL: (env: Env) => string;
12
- export declare const PROFILE_LINEAGE_URL: (env: Env) => string;
13
- export declare const CUSTOMER_SERVICE_TOKEN_URL: (env: Env) => string;
14
- type NonceResponse = {
15
- nonce: string;
16
- identifier: string;
17
- expiresIn: number;
18
- };
19
- type PairRequest = {
20
- signature: string;
21
- raw_message: string;
22
- encrypted_storage_key: string;
23
- identifier_type: 'SIWE' | 'SRP';
24
- };
25
- /**
26
- * Pair multiple identifiers under a single profile
27
- *
28
- * @param nonce - session nonce
29
- * @param logins - pairing request payload
30
- * @param accessToken - JWT access token used to access protected resources
31
- * @param env - server environment
32
- * @returns void.
33
- */
34
- export declare function pairIdentifiers(nonce: string, logins: PairRequest[], accessToken: string, env: Env): Promise<void>;
35
- export type PairProfilesResponse = {
36
- profile: UserProfile;
37
- profileAliases: ProfileAlias[];
38
- };
39
- /**
40
- * Pair multiple profiles using their OIDC access tokens.
41
- * Idempotent — calling with already-paired tokens is a no-op.
42
- *
43
- * @param accessTokens - Two or more OIDC access tokens to pair
44
- * @param authAccessToken - A valid access token for the Authorization header
45
- * @param env - server environment
46
- * @returns The pair response containing the canonical profile and aliases
47
- */
48
- export declare function pairProfiles(accessTokens: string[], authAccessToken: string, env: Env): Promise<PairProfilesResponse>;
49
- /**
50
- * Attach a Google/Apple/Telegram social identifier to the profile that
51
- * owns `authAccessToken` (`POST /api/v2/profile/pair/identifier`).
52
- *
53
- * `email` is omitted from the body when undefined. 409 Conflict throws
54
- * {@link PairConflictError} so callers can treat it as terminal. The
55
- * response body (new token + profile) is not consumed: a 2xx status is the
56
- * only success signal.
57
- *
58
- * @param params - Social identifier type, social JWT, and optional email
59
- * @param authAccessToken - Bearer token of the canonical (primary SRP) profile
60
- * @param env - server environment
61
- */
62
- export declare function pairSocialIdentifier(params: PairSocialIdentifierParams, authAccessToken: string, env: Env): Promise<void>;
63
- /**
64
- * Service to Get Nonce for JWT Bearer Flow
65
- *
66
- * @param id - identifier ID
67
- * @param env - server environment
68
- * @returns the nonce.
69
- */
70
- export declare function getNonce(id: string, env: Env): Promise<NonceResponse>;
71
- /**
72
- * Service to Authorize And perform OIDC Flow to get the Access Token
73
- *
74
- * @param jwtToken - The original token received from Authentication. This is traded for the Access Token. (the authentication token is single-use)
75
- * @param env - server environment
76
- * @param platform - SDK platform
77
- * @returns Access Token from Authorization server
78
- */
79
- export declare function authorizeOIDC(jwtToken: string, env: Env, platform: Platform): Promise<AccessToken>;
80
- type Authentication = {
81
- token: string;
82
- expiresIn: number;
83
- profile: UserProfile;
84
- profileAliases: ProfileAlias[];
85
- };
86
- /**
87
- * Service to Authenticate/Login a user via SIWE or SRP derived key.
88
- *
89
- * @param rawMessage - raw message for validation when authenticating
90
- * @param signature - signed raw message
91
- * @param authType - authentication type/flow used
92
- * @param env - server environment
93
- * @param metametrics - optional metametrics
94
- * @param identifierType - login identifier type included in metametrics
95
- * (defaults to `SRP` when metametrics is present)
96
- * @returns Authentication Token
97
- */
98
- export declare function authenticate(rawMessage: string, signature: string, authType: AuthType, env: Env, metametrics?: MetaMetricsAuth, identifierType?: LoginIdentifierType): Promise<Authentication>;
99
- /**
100
- * Service to get the Profile Lineage
101
- *
102
- * @param env - server environment
103
- * @param accessToken - JWT access token used to access protected resources
104
- * @returns Profile Lineage information.
105
- */
106
- export declare function getUserProfileLineage(env: Env, accessToken: string): Promise<UserProfileLineage>;
107
- /**
108
- * Service to get a Customer Service specific access token.
109
- *
110
- * Exchanges a valid OIDC access token for a short-lived token scoped to the
111
- * customer-service audience, which Customer Service tooling consumes to
112
- * identify and authenticate the user.
113
- *
114
- * @param env - server environment
115
- * @param accessToken - JWT access token used to access protected resources
116
- * @returns The customer-service access token.
117
- */
118
- export declare function getCustomerServiceToken(env: Env, accessToken: string): Promise<string>;
119
- export {};
120
- //# sourceMappingURL=services.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"services.d.mts","sourceRoot":"","sources":["../../../src/sdk/authentication-jwt-bearer/services.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,6BAA4B;AAEzD,OAAO,KAAK,EAAE,eAAe,EAAE,wCAAuC;AAWtE,OAAO,KAAK,EACV,WAAW,EAEX,mBAAmB,EACnB,0BAA0B,EAC1B,YAAY,EACZ,WAAW,EACX,kBAAkB,EACnB,oBAAmB;AACpB,OAAO,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AAG,GACP,OAAO,CAAC,oBAAoB,CAAC,CAsC/B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,0BAA0B,EAClC,eAAe,EAAE,MAAM,EACvB,GAAG,EAAE,GAAG,GACP,OAAO,CAAC,IAAI,CAAC,CA2Bf;AAED;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,aAAa,CAAC,CA2B3E;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,WAAW,CAAC,CAuCtB;AAED,KAAK,cAAc,GAAG;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,WAAW,CAAC;IACrB,cAAc,EAAE,YAAY,EAAE,CAAC;CAChC,CAAC;AACF;;;;;;;;;;;GAWG;AACH,wBAAsB,YAAY,CAChC,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,GAAG,EACR,WAAW,CAAC,EAAE,eAAe,EAC7B,cAAc,GAAE,mBAA2B,GAC1C,OAAO,CAAC,cAAc,CAAC,CAwDzB;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,kBAAkB,CAAC,CA4B7B;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,CAiCjB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"services.mjs","sourceRoot":"","sources":["../../../src/sdk/authentication-jwt-bearer/services.ts"],"names":[],"mappings":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AC,0BAA0B,CAAC,GAAG,CAAC,CAAC,CAAC;IAEzE,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,uBAAuB,EAAE;YACpD,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,WAAW,EAAE;aACvC;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,OAAO,MAAM,iBAAiB,CAC5B,QAAQ,EACR,sCAAsC,EACtC,WAAW,CACZ,CAAC;QACJ,CAAC;QAED,MAAM,aAAa,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC5C,IAAI,OAAO,aAAa,EAAE,YAAY,KAAK,QAAQ,EAAE,CAAC;YACpD,MAAM,IAAI,WAAW,CACnB,4DAA4D,CAC7D,CAAC;QACJ,CAAC;QACD,OAAO,aAAa,CAAC,YAAY,CAAC;IACpC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,MAAM,iBAAiB,CAC5B,KAAK,EACL,sCAAsC,EACtC,WAAW,CACZ,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import type { Env, Platform } from '../../shared/env.js';\nimport { getEnvUrls, getOidcClientId } from '../../shared/env.js';\nimport type { MetaMetricsAuth } from '../../shared/types/services.js';\nimport { HTTP_STATUS_CODES } from '../constants.js';\nimport {\n NonceRetrievalError,\n PairConflictError,\n PairError,\n SignInError,\n ValidationError,\n RateLimitedError,\n} from '../errors.js';\nimport { validatePairResponse } from '../utils/validate-pair-response.js';\nimport type {\n AccessToken,\n ErrorMessage,\n LoginIdentifierType,\n PairSocialIdentifierParams,\n ProfileAlias,\n UserProfile,\n UserProfileLineage,\n} from './types.js';\nimport { AuthType } from './types.js';\n\n/**\n * Parse Retry-After header into milliseconds if possible.\n * Supports seconds or HTTP-date formats.\n *\n * @param retryAfterHeader - The Retry-After header value (seconds or HTTP-date)\n * @returns The retry delay in milliseconds, or null if parsing fails\n */\nfunction parseRetryAfter(retryAfterHeader: string | null): number | null {\n if (!retryAfterHeader) {\n return null;\n }\n const seconds = Number(retryAfterHeader);\n if (!Number.isNaN(seconds)) {\n return seconds * 1000;\n }\n const date = Date.parse(retryAfterHeader);\n if (!Number.isNaN(date)) {\n const diff = date - Date.now();\n return diff > 0 ? diff : null;\n }\n return null;\n}\n\n/**\n * Extracts error details from a Response object.\n *\n * @param response - The HTTP response object\n * @returns Formatted error message with HTTP status and response body\n */\nasync function getResponseErrorMessage(response: Response): Promise<string> {\n const { status } = response;\n const clonedResponse = response.clone();\n\n let message = 'Unknown error';\n let error = 'unknown';\n\n try {\n const responseBody = (await response.json()) as\n | ErrorMessage\n // eslint-disable-next-line @typescript-eslint/naming-convention\n | { error_description: string; error: string };\n\n message =\n 'message' in responseBody\n ? responseBody.message\n : responseBody.error_description;\n error = responseBody.error ?? 'unknown';\n } catch {\n try {\n const textContent = await clonedResponse.text();\n message = textContent\n ? textContent.slice(0, 150)\n : 'Non-JSON error response';\n error = 'non_json_response';\n } catch {\n message = 'Unable to parse error response';\n error = 'unparseable_response';\n }\n }\n\n return `HTTP ${status} - ${message} (error: ${error})`;\n}\n\n/**\n * Type guard to check if an object is a Response-like object.\n *\n * @param obj - The object to check\n * @returns True if the object is a Response-like object, false otherwise\n */\nconst isErrorResponse = (obj: unknown): obj is Response =>\n typeof obj === 'object' &&\n obj !== null &&\n 'status' in obj &&\n 'headers' in obj;\n\n/**\n * Throws a domain-specific error for service failures.\n * Handles both HTTP error responses and regular errors (network failures, etc.).\n * For HTTP 429, throws RateLimitedError with Retry-After header parsing.\n *\n * @param error - The error (Response object or caught error)\n * @param errorPrefix - Context prefix for the error message\n * @param ErrorClass - The domain-specific error class to throw\n * @throws RateLimitedError for 429, otherwise ErrorClass\n */\nasync function throwServiceError(\n error: unknown,\n errorPrefix: string,\n ErrorClass: new (message: string) => Error,\n): Promise<never> {\n // Re-throw RateLimitedError or matching ErrorClass as-is (don't double-wrap)\n if (error instanceof RateLimitedError || error instanceof ErrorClass) {\n throw error;\n }\n\n // Not a Response-like object - handle as regular error\n if (!isErrorResponse(error)) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n throw new ErrorClass(`${errorPrefix}: ${errorMessage}`);\n }\n\n // Handle HTTP error response\n const response = error;\n const { status } = response;\n const responseMessage = await getResponseErrorMessage(response);\n\n if (status === HTTP_STATUS_CODES.TOO_MANY_REQUESTS) {\n const retryAfterHeader = response.headers.get('Retry-After');\n const retryAfterMs = parseRetryAfter(retryAfterHeader);\n throw new RateLimitedError(\n `${errorPrefix}: ${responseMessage}`,\n retryAfterMs ?? undefined,\n );\n }\n\n throw new ErrorClass(`${errorPrefix}: ${responseMessage}`);\n}\n\nexport const NONCE_URL = (env: Env): string =>\n `${getEnvUrls(env).authApiUrl}/api/v2/nonce`;\n\nexport const PAIR_IDENTIFIERS = (env: Env): string =>\n `${getEnvUrls(env).authApiUrl}/api/v2/identifiers/pair`;\n\nexport const OIDC_TOKEN_URL = (env: Env): string =>\n `${getEnvUrls(env).oidcApiUrl}/oauth2/token`;\n\nexport const SRP_LOGIN_URL = (env: Env): string =>\n `${getEnvUrls(env).authApiUrl}/api/v2/srp/login`;\n\nexport const SIWE_LOGIN_URL = (env: Env): string =>\n `${getEnvUrls(env).authApiUrl}/api/v2/siwe/login`;\n\nexport const PAIR_PROFILES_URL = (env: Env): string =>\n `${getEnvUrls(env).authApiUrl}/api/v2/profile/pair`;\n\nexport const PAIR_SOCIAL_IDENTIFIER_URL = (env: Env): string =>\n `${getEnvUrls(env).authApiUrl}/api/v2/profile/pair/identifier`;\n\nexport const PROFILE_LINEAGE_URL = (env: Env): string =>\n `${getEnvUrls(env).authApiUrl}/api/v2/profile/lineage`;\n\nexport const CUSTOMER_SERVICE_TOKEN_URL = (env: Env): string =>\n `${getEnvUrls(env).authApiUrl}/api/v2/customer-service/token`;\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 RawProfileAlias = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n alias_profile_id: string;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n canonical_profile_id: string;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n identifier_ids: { id: string; type: string }[];\n};\n\nconst parseProfileAliases = (raw: RawProfileAlias[]): ProfileAlias[] => {\n return raw.map((alias) => ({\n aliasProfileId: alias.alias_profile_id,\n canonicalProfileId: alias.canonical_profile_id,\n identifierIds: alias.identifier_ids ?? [],\n }));\n};\n\ntype PairRequest = {\n signature: string;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n raw_message: string;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n encrypted_storage_key: string;\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 return await throwServiceError(\n response,\n 'Failed to pair identifiers',\n PairError,\n );\n }\n return undefined;\n } catch (error) {\n return await throwServiceError(\n error,\n 'Failed to pair identifiers',\n PairError,\n );\n }\n}\n\nexport type PairProfilesResponse = {\n profile: UserProfile;\n profileAliases: ProfileAlias[];\n};\n\n/**\n * Pair multiple profiles using their OIDC access tokens.\n * Idempotent — calling with already-paired tokens is a no-op.\n *\n * @param accessTokens - Two or more OIDC access tokens to pair\n * @param authAccessToken - A valid access token for the Authorization header\n * @param env - server environment\n * @returns The pair response containing the canonical profile and aliases\n */\nexport async function pairProfiles(\n accessTokens: string[],\n authAccessToken: string,\n env: Env,\n): Promise<PairProfilesResponse> {\n const pairUrl = new URL(PAIR_PROFILES_URL(env));\n\n try {\n const response = await fetch(pairUrl, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${authAccessToken}`,\n },\n body: JSON.stringify({\n jwts: accessTokens,\n }),\n });\n\n if (!response.ok) {\n return await throwServiceError(\n response,\n 'Failed to pair profiles',\n PairError,\n );\n }\n\n const pairResponse: unknown = await response.json();\n validatePairResponse(pairResponse);\n\n return {\n profile: {\n identifierId: pairResponse.profile.identifier_id,\n metaMetricsId: pairResponse.profile.metametrics_id ?? '',\n profileId: pairResponse.profile.profile_id,\n canonicalProfileId: pairResponse.profile.profile_id,\n },\n profileAliases: parseProfileAliases(pairResponse.profile_aliases ?? []),\n };\n } catch (error) {\n return await throwServiceError(error, 'Failed to pair profiles', PairError);\n }\n}\n\n/**\n * Attach a Google/Apple/Telegram social identifier to the profile that\n * owns `authAccessToken` (`POST /api/v2/profile/pair/identifier`).\n *\n * `email` is omitted from the body when undefined. 409 Conflict throws\n * {@link PairConflictError} so callers can treat it as terminal. The\n * response body (new token + profile) is not consumed: a 2xx status is the\n * only success signal.\n *\n * @param params - Social identifier type, social JWT, and optional email\n * @param authAccessToken - Bearer token of the canonical (primary SRP) profile\n * @param env - server environment\n */\nexport async function pairSocialIdentifier(\n params: PairSocialIdentifierParams,\n authAccessToken: string,\n env: Env,\n): Promise<void> {\n const pairUrl = new URL(PAIR_SOCIAL_IDENTIFIER_URL(env));\n const errorPrefix = 'Failed to pair social identifier';\n\n try {\n const response = await fetch(pairUrl, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${authAccessToken}`,\n },\n body: JSON.stringify({\n identifier_type: params.identifierType,\n social_jwt: params.socialJwt,\n ...(params.email === undefined ? {} : { email: params.email }),\n }),\n });\n\n if (!response.ok) {\n if (response.status === HTTP_STATUS_CODES.CONFLICT) {\n await throwServiceError(response, errorPrefix, PairConflictError);\n }\n await throwServiceError(response, errorPrefix, PairError);\n }\n } catch (error) {\n await throwServiceError(error, errorPrefix, PairError);\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 return await throwServiceError(\n nonceResponse,\n 'Failed to get nonce',\n NonceRetrievalError,\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 (error) {\n return await throwServiceError(\n error,\n 'Failed to get nonce',\n NonceRetrievalError,\n );\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 = {\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 return await throwServiceError(\n response,\n 'Failed to get access token',\n SignInError,\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 (error) {\n return await throwServiceError(\n error,\n 'Failed to get access token',\n SignInError,\n );\n }\n}\n\ntype Authentication = {\n token: string;\n expiresIn: number;\n profile: UserProfile;\n profileAliases: ProfileAlias[];\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 * @param metametrics - optional metametrics\n * @param identifierType - login identifier type included in metametrics\n * (defaults to `SRP` when metametrics is present)\n * @returns Authentication Token\n */\nexport async function authenticate(\n rawMessage: string,\n signature: string,\n authType: AuthType,\n env: Env,\n metametrics?: MetaMetricsAuth,\n identifierType: LoginIdentifierType = 'SRP',\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 ...(authType === AuthType.SRP\n ? { 'X-MetaMask-Profile-Pairing': 'enabled' }\n : {}),\n },\n body: JSON.stringify({\n signature,\n raw_message: rawMessage,\n ...(metametrics\n ? {\n metametrics: {\n metametrics_id: await metametrics.getMetaMetricsId(),\n agent: metametrics.agent,\n app_version: await metametrics.getAppVersion?.(),\n identifier_type: identifierType,\n },\n }\n : {}),\n }),\n });\n\n if (!response.ok) {\n return await throwServiceError(\n response,\n `Failed to login with ${authType}`,\n SignInError,\n );\n }\n\n const loginResponse = await response.json();\n\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 canonicalProfileId: loginResponse.profile.profile_id,\n },\n profileAliases: parseProfileAliases(loginResponse.profile_aliases ?? []),\n };\n } catch (error) {\n return await throwServiceError(\n error,\n `Failed to login with ${authType}`,\n SignInError,\n );\n }\n}\n\n/**\n * Service to get the Profile Lineage\n *\n * @param env - server environment\n * @param accessToken - JWT access token used to access protected resources\n * @returns Profile Lineage information.\n */\nexport async function getUserProfileLineage(\n env: Env,\n accessToken: string,\n): Promise<UserProfileLineage> {\n const profileLineageUrl = new URL(PROFILE_LINEAGE_URL(env));\n\n try {\n const response = await fetch(profileLineageUrl, {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${accessToken}`,\n },\n });\n\n if (!response.ok) {\n return await throwServiceError(\n response,\n 'Failed to get profile lineage',\n SignInError,\n );\n }\n\n const profileJson: UserProfileLineage = await response.json();\n return profileJson;\n } catch (error) {\n return await throwServiceError(\n error,\n 'Failed to get profile lineage',\n SignInError,\n );\n }\n}\n\n/**\n * Service to get a Customer Service specific access token.\n *\n * Exchanges a valid OIDC access token for a short-lived token scoped to the\n * customer-service audience, which Customer Service tooling consumes to\n * identify and authenticate the user.\n *\n * @param env - server environment\n * @param accessToken - JWT access token used to access protected resources\n * @returns The customer-service access token.\n */\nexport async function getCustomerServiceToken(\n env: Env,\n accessToken: string,\n): Promise<string> {\n const customerServiceTokenUrl = new URL(CUSTOMER_SERVICE_TOKEN_URL(env));\n\n try {\n const response = await fetch(customerServiceTokenUrl, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${accessToken}`,\n },\n });\n\n if (!response.ok) {\n return await throwServiceError(\n response,\n 'Failed to get customer service token',\n SignInError,\n );\n }\n\n const tokenResponse = await response.json();\n if (typeof tokenResponse?.access_token !== 'string') {\n throw new SignInError(\n 'Failed to get customer service token: missing access_token',\n );\n }\n return tokenResponse.access_token;\n } catch (error) {\n return await throwServiceError(\n error,\n 'Failed to get customer service token',\n SignInError,\n );\n }\n}\n"]}
@@ -1,12 +0,0 @@
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