@hexclave/shared 1.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 (1144) hide show
  1. package/LICENSE +7 -0
  2. package/dist/ai/image-limits.d.ts +24 -0
  3. package/dist/ai/image-limits.d.ts.map +1 -0
  4. package/dist/ai/image-limits.js +61 -0
  5. package/dist/ai/image-limits.js.map +1 -0
  6. package/dist/ai/unified-prompts/reminders.d.ts +5 -0
  7. package/dist/ai/unified-prompts/reminders.d.ts.map +1 -0
  8. package/dist/ai/unified-prompts/reminders.js +33 -0
  9. package/dist/ai/unified-prompts/reminders.js.map +1 -0
  10. package/dist/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.d.ts +11 -0
  11. package/dist/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.d.ts.map +1 -0
  12. package/dist/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.js +851 -0
  13. package/dist/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.js.map +1 -0
  14. package/dist/ai/unified-prompts/skill-site-prompt-parts/brain.d.ts +5 -0
  15. package/dist/ai/unified-prompts/skill-site-prompt-parts/brain.d.ts.map +1 -0
  16. package/dist/ai/unified-prompts/skill-site-prompt-parts/brain.js +12 -0
  17. package/dist/ai/unified-prompts/skill-site-prompt-parts/brain.js.map +1 -0
  18. package/dist/ai/unified-prompts/skill-site-prompt-parts/cli-help.d.ts +5 -0
  19. package/dist/ai/unified-prompts/skill-site-prompt-parts/cli-help.d.ts.map +1 -0
  20. package/dist/ai/unified-prompts/skill-site-prompt-parts/cli-help.js +12 -0
  21. package/dist/ai/unified-prompts/skill-site-prompt-parts/cli-help.js.map +1 -0
  22. package/dist/ai/unified-prompts/skill-site-prompt-parts/config-docs.d.ts +5 -0
  23. package/dist/ai/unified-prompts/skill-site-prompt-parts/config-docs.d.ts.map +1 -0
  24. package/dist/ai/unified-prompts/skill-site-prompt-parts/config-docs.js +12 -0
  25. package/dist/ai/unified-prompts/skill-site-prompt-parts/config-docs.js.map +1 -0
  26. package/dist/ai/unified-prompts/skill-site-prompt-parts/custom-components-instructions.d.ts +5 -0
  27. package/dist/ai/unified-prompts/skill-site-prompt-parts/custom-components-instructions.d.ts.map +1 -0
  28. package/dist/ai/unified-prompts/skill-site-prompt-parts/custom-components-instructions.js +12 -0
  29. package/dist/ai/unified-prompts/skill-site-prompt-parts/custom-components-instructions.js.map +1 -0
  30. package/dist/ai/unified-prompts/skill-site-prompt-parts/dashboard-instructions.d.ts +5 -0
  31. package/dist/ai/unified-prompts/skill-site-prompt-parts/dashboard-instructions.d.ts.map +1 -0
  32. package/dist/ai/unified-prompts/skill-site-prompt-parts/dashboard-instructions.js +12 -0
  33. package/dist/ai/unified-prompts/skill-site-prompt-parts/dashboard-instructions.js.map +1 -0
  34. package/dist/ai/unified-prompts/skill-site-prompt-parts/docs-index.d.ts +5 -0
  35. package/dist/ai/unified-prompts/skill-site-prompt-parts/docs-index.d.ts.map +1 -0
  36. package/dist/ai/unified-prompts/skill-site-prompt-parts/docs-index.js +64 -0
  37. package/dist/ai/unified-prompts/skill-site-prompt-parts/docs-index.js.map +1 -0
  38. package/dist/ai/unified-prompts/skill-site-prompt-parts/openapi-specs.d.ts +5 -0
  39. package/dist/ai/unified-prompts/skill-site-prompt-parts/openapi-specs.d.ts.map +1 -0
  40. package/dist/ai/unified-prompts/skill-site-prompt-parts/openapi-specs.js +12 -0
  41. package/dist/ai/unified-prompts/skill-site-prompt-parts/openapi-specs.js.map +1 -0
  42. package/dist/ai/unified-prompts/skill-site-prompt-parts/sdk-interface-source.d.ts +5 -0
  43. package/dist/ai/unified-prompts/skill-site-prompt-parts/sdk-interface-source.d.ts.map +1 -0
  44. package/dist/ai/unified-prompts/skill-site-prompt-parts/sdk-interface-source.js +12 -0
  45. package/dist/ai/unified-prompts/skill-site-prompt-parts/sdk-interface-source.js.map +1 -0
  46. package/dist/ai/unified-prompts/skill-site-prompt.d.ts +5 -0
  47. package/dist/ai/unified-prompts/skill-site-prompt.d.ts.map +1 -0
  48. package/dist/ai/unified-prompts/skill-site-prompt.js +75 -0
  49. package/dist/ai/unified-prompts/skill-site-prompt.js.map +1 -0
  50. package/dist/apps/apps-config.d.ts +168 -0
  51. package/dist/apps/apps-config.d.ts.map +1 -0
  52. package/dist/apps/apps-config.js +157 -0
  53. package/dist/apps/apps-config.js.map +1 -0
  54. package/dist/apps/apps-ui.d.ts +45 -0
  55. package/dist/apps/apps-ui.d.ts.map +1 -0
  56. package/dist/apps/apps-ui.js +109 -0
  57. package/dist/apps/apps-ui.js.map +1 -0
  58. package/dist/chunk-BE-pF4vm.js +34 -0
  59. package/dist/config/db-sync-mappings.d.ts +193 -0
  60. package/dist/config/db-sync-mappings.d.ts.map +1 -0
  61. package/dist/config/db-sync-mappings.js +2255 -0
  62. package/dist/config/db-sync-mappings.js.map +1 -0
  63. package/dist/config/format.d.ts +61 -0
  64. package/dist/config/format.d.ts.map +1 -0
  65. package/dist/config/format.js +337 -0
  66. package/dist/config/format.js.map +1 -0
  67. package/dist/config/migrate-catalogs-to-product-lines.d.ts +14 -0
  68. package/dist/config/migrate-catalogs-to-product-lines.d.ts.map +1 -0
  69. package/dist/config/migrate-catalogs-to-product-lines.js +379 -0
  70. package/dist/config/migrate-catalogs-to-product-lines.js.map +1 -0
  71. package/dist/config/schema-fuzzer.test.d.ts +1 -0
  72. package/dist/config/schema-fuzzer.test.js +401 -0
  73. package/dist/config/schema-fuzzer.test.js.map +1 -0
  74. package/dist/config/schema.d.ts +2315 -0
  75. package/dist/config/schema.d.ts.map +1 -0
  76. package/dist/config/schema.js +1085 -0
  77. package/dist/config/schema.js.map +1 -0
  78. package/dist/config-authoring.d.ts +12 -0
  79. package/dist/config-authoring.d.ts.map +1 -0
  80. package/dist/config-authoring.js +12 -0
  81. package/dist/config-authoring.js.map +1 -0
  82. package/dist/config-authoring.test.d.ts +1 -0
  83. package/dist/config-authoring.test.js +29 -0
  84. package/dist/config-authoring.test.js.map +1 -0
  85. package/dist/config-rendering.d.ts +17 -0
  86. package/dist/config-rendering.d.ts.map +1 -0
  87. package/dist/config-rendering.js +114 -0
  88. package/dist/config-rendering.js.map +1 -0
  89. package/dist/crud.d.ts +98 -0
  90. package/dist/crud.d.ts.map +1 -0
  91. package/dist/crud.js +129 -0
  92. package/dist/crud.js.map +1 -0
  93. package/dist/esm/ai/image-limits.d.ts +24 -0
  94. package/dist/esm/ai/image-limits.d.ts.map +1 -0
  95. package/dist/esm/ai/image-limits.js +53 -0
  96. package/dist/esm/ai/image-limits.js.map +1 -0
  97. package/dist/esm/ai/unified-prompts/reminders.d.ts +5 -0
  98. package/dist/esm/ai/unified-prompts/reminders.d.ts.map +1 -0
  99. package/dist/esm/ai/unified-prompts/reminders.js +31 -0
  100. package/dist/esm/ai/unified-prompts/reminders.js.map +1 -0
  101. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.d.ts +11 -0
  102. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.d.ts.map +1 -0
  103. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.js +843 -0
  104. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.js.map +1 -0
  105. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/brain.d.ts +5 -0
  106. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/brain.d.ts.map +1 -0
  107. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/brain.js +10 -0
  108. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/brain.js.map +1 -0
  109. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/cli-help.d.ts +5 -0
  110. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/cli-help.d.ts.map +1 -0
  111. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/cli-help.js +10 -0
  112. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/cli-help.js.map +1 -0
  113. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/config-docs.d.ts +5 -0
  114. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/config-docs.d.ts.map +1 -0
  115. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/config-docs.js +10 -0
  116. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/config-docs.js.map +1 -0
  117. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/custom-components-instructions.d.ts +5 -0
  118. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/custom-components-instructions.d.ts.map +1 -0
  119. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/custom-components-instructions.js +10 -0
  120. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/custom-components-instructions.js.map +1 -0
  121. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/dashboard-instructions.d.ts +5 -0
  122. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/dashboard-instructions.d.ts.map +1 -0
  123. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/dashboard-instructions.js +10 -0
  124. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/dashboard-instructions.js.map +1 -0
  125. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/docs-index.d.ts +5 -0
  126. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/docs-index.d.ts.map +1 -0
  127. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/docs-index.js +61 -0
  128. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/docs-index.js.map +1 -0
  129. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/openapi-specs.d.ts +5 -0
  130. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/openapi-specs.d.ts.map +1 -0
  131. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/openapi-specs.js +10 -0
  132. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/openapi-specs.js.map +1 -0
  133. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/sdk-interface-source.d.ts +5 -0
  134. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/sdk-interface-source.d.ts.map +1 -0
  135. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/sdk-interface-source.js +10 -0
  136. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/sdk-interface-source.js.map +1 -0
  137. package/dist/esm/ai/unified-prompts/skill-site-prompt.d.ts +5 -0
  138. package/dist/esm/ai/unified-prompts/skill-site-prompt.d.ts.map +1 -0
  139. package/dist/esm/ai/unified-prompts/skill-site-prompt.js +73 -0
  140. package/dist/esm/ai/unified-prompts/skill-site-prompt.js.map +1 -0
  141. package/dist/esm/apps/apps-config.d.ts +168 -0
  142. package/dist/esm/apps/apps-config.d.ts.map +1 -0
  143. package/dist/esm/apps/apps-config.js +154 -0
  144. package/dist/esm/apps/apps-config.js.map +1 -0
  145. package/dist/esm/apps/apps-ui.d.ts +45 -0
  146. package/dist/esm/apps/apps-ui.d.ts.map +1 -0
  147. package/dist/esm/apps/apps-ui.js +104 -0
  148. package/dist/esm/apps/apps-ui.js.map +1 -0
  149. package/dist/esm/config/db-sync-mappings.d.ts +193 -0
  150. package/dist/esm/config/db-sync-mappings.d.ts.map +1 -0
  151. package/dist/esm/config/db-sync-mappings.js +2253 -0
  152. package/dist/esm/config/db-sync-mappings.js.map +1 -0
  153. package/dist/esm/config/format.d.ts +61 -0
  154. package/dist/esm/config/format.d.ts.map +1 -0
  155. package/dist/esm/config/format.js +327 -0
  156. package/dist/esm/config/format.js.map +1 -0
  157. package/dist/esm/config/migrate-catalogs-to-product-lines.d.ts +14 -0
  158. package/dist/esm/config/migrate-catalogs-to-product-lines.d.ts.map +1 -0
  159. package/dist/esm/config/migrate-catalogs-to-product-lines.js +377 -0
  160. package/dist/esm/config/migrate-catalogs-to-product-lines.js.map +1 -0
  161. package/dist/esm/config/schema-fuzzer.test.d.ts +1 -0
  162. package/dist/esm/config/schema-fuzzer.test.js +401 -0
  163. package/dist/esm/config/schema-fuzzer.test.js.map +1 -0
  164. package/dist/esm/config/schema.d.ts +2315 -0
  165. package/dist/esm/config/schema.d.ts.map +1 -0
  166. package/dist/esm/config/schema.js +1065 -0
  167. package/dist/esm/config/schema.js.map +1 -0
  168. package/dist/esm/config-authoring.d.ts +12 -0
  169. package/dist/esm/config-authoring.d.ts.map +1 -0
  170. package/dist/esm/config-authoring.js +9 -0
  171. package/dist/esm/config-authoring.js.map +1 -0
  172. package/dist/esm/config-authoring.test.d.ts +1 -0
  173. package/dist/esm/config-authoring.test.js +29 -0
  174. package/dist/esm/config-authoring.test.js.map +1 -0
  175. package/dist/esm/config-rendering.d.ts +17 -0
  176. package/dist/esm/config-rendering.d.ts.map +1 -0
  177. package/dist/esm/config-rendering.js +108 -0
  178. package/dist/esm/config-rendering.js.map +1 -0
  179. package/dist/esm/crud.d.ts +98 -0
  180. package/dist/esm/crud.d.ts.map +1 -0
  181. package/dist/esm/crud.js +127 -0
  182. package/dist/esm/crud.js.map +1 -0
  183. package/dist/esm/global.d.ts +1 -0
  184. package/dist/esm/helpers/emails.d.ts +69 -0
  185. package/dist/esm/helpers/emails.d.ts.map +1 -0
  186. package/dist/esm/helpers/emails.js +243 -0
  187. package/dist/esm/helpers/emails.js.map +1 -0
  188. package/dist/esm/helpers/init-prompt.d.ts +5 -0
  189. package/dist/esm/helpers/init-prompt.d.ts.map +1 -0
  190. package/dist/esm/helpers/init-prompt.js +40 -0
  191. package/dist/esm/helpers/init-prompt.js.map +1 -0
  192. package/dist/esm/helpers/password.d.ts +7 -0
  193. package/dist/esm/helpers/password.d.ts.map +1 -0
  194. package/dist/esm/helpers/password.js +13 -0
  195. package/dist/esm/helpers/password.js.map +1 -0
  196. package/dist/esm/helpers/production-mode.d.ts +11 -0
  197. package/dist/esm/helpers/production-mode.d.ts.map +1 -0
  198. package/dist/esm/helpers/production-mode.js +46 -0
  199. package/dist/esm/helpers/production-mode.js.map +1 -0
  200. package/dist/esm/helpers/support-sla.d.ts +48 -0
  201. package/dist/esm/helpers/support-sla.d.ts.map +1 -0
  202. package/dist/esm/helpers/support-sla.js +65 -0
  203. package/dist/esm/helpers/support-sla.js.map +1 -0
  204. package/dist/esm/helpers/support-sla.test.d.ts +1 -0
  205. package/dist/esm/helpers/support-sla.test.js +102 -0
  206. package/dist/esm/helpers/support-sla.test.js.map +1 -0
  207. package/dist/esm/helpers/vault/client-side.d.ts +16 -0
  208. package/dist/esm/helpers/vault/client-side.d.ts.map +1 -0
  209. package/dist/esm/helpers/vault/client-side.js +69 -0
  210. package/dist/esm/helpers/vault/client-side.js.map +1 -0
  211. package/dist/esm/helpers/vault/server-side.d.ts +9 -0
  212. package/dist/esm/helpers/vault/server-side.d.ts.map +1 -0
  213. package/dist/esm/helpers/vault/server-side.js +123 -0
  214. package/dist/esm/helpers/vault/server-side.js.map +1 -0
  215. package/dist/esm/hooks/use-async-callback.d.ts +8 -0
  216. package/dist/esm/hooks/use-async-callback.d.ts.map +1 -0
  217. package/dist/esm/hooks/use-async-callback.js +38 -0
  218. package/dist/esm/hooks/use-async-callback.js.map +1 -0
  219. package/dist/esm/hooks/use-async-external-store.d.ts +9 -0
  220. package/dist/esm/hooks/use-async-external-store.d.ts.map +1 -0
  221. package/dist/esm/hooks/use-async-external-store.js +20 -0
  222. package/dist/esm/hooks/use-async-external-store.js.map +1 -0
  223. package/dist/esm/hooks/use-hash.d.ts +5 -0
  224. package/dist/esm/hooks/use-hash.d.ts.map +1 -0
  225. package/dist/esm/hooks/use-hash.js +15 -0
  226. package/dist/esm/hooks/use-hash.js.map +1 -0
  227. package/dist/esm/hooks/use-hover.d.ts +8 -0
  228. package/dist/esm/hooks/use-hover.d.ts.map +1 -0
  229. package/dist/esm/hooks/use-hover.js +59 -0
  230. package/dist/esm/hooks/use-hover.js.map +1 -0
  231. package/dist/esm/hooks/use-strict-memo.d.ts +10 -0
  232. package/dist/esm/hooks/use-strict-memo.d.ts.map +1 -0
  233. package/dist/esm/hooks/use-strict-memo.js +119 -0
  234. package/dist/esm/hooks/use-strict-memo.js.map +1 -0
  235. package/dist/esm/index.d.ts +5 -0
  236. package/dist/esm/index.js +6 -0
  237. package/dist/esm/interface/admin-interface.d.ts +308 -0
  238. package/dist/esm/interface/admin-interface.d.ts.map +1 -0
  239. package/dist/esm/interface/admin-interface.js +463 -0
  240. package/dist/esm/interface/admin-interface.js.map +1 -0
  241. package/dist/esm/interface/admin-metrics.d.ts +597 -0
  242. package/dist/esm/interface/admin-metrics.d.ts.map +1 -0
  243. package/dist/esm/interface/admin-metrics.js +134 -0
  244. package/dist/esm/interface/admin-metrics.js.map +1 -0
  245. package/dist/esm/interface/client-interface.d.ts +447 -0
  246. package/dist/esm/interface/client-interface.d.ts.map +1 -0
  247. package/dist/esm/interface/client-interface.js +1946 -0
  248. package/dist/esm/interface/client-interface.js.map +1 -0
  249. package/dist/esm/interface/client-interface.test.d.ts +1 -0
  250. package/dist/esm/interface/client-interface.test.js +559 -0
  251. package/dist/esm/interface/client-interface.test.js.map +1 -0
  252. package/dist/esm/interface/conversations.d.ts +314 -0
  253. package/dist/esm/interface/conversations.d.ts.map +1 -0
  254. package/dist/esm/interface/conversations.js +108 -0
  255. package/dist/esm/interface/conversations.js.map +1 -0
  256. package/dist/esm/interface/crud/analytics.d.ts +14 -0
  257. package/dist/esm/interface/crud/analytics.d.ts.map +1 -0
  258. package/dist/esm/interface/crud/analytics.js +1 -0
  259. package/dist/esm/interface/crud/connected-accounts.d.ts +69 -0
  260. package/dist/esm/interface/crud/connected-accounts.d.ts.map +1 -0
  261. package/dist/esm/interface/crud/connected-accounts.js +35 -0
  262. package/dist/esm/interface/crud/connected-accounts.js.map +1 -0
  263. package/dist/esm/interface/crud/contact-channels.d.ts +182 -0
  264. package/dist/esm/interface/crud/contact-channels.d.ts.map +1 -0
  265. package/dist/esm/interface/crud/contact-channels.js +68 -0
  266. package/dist/esm/interface/crud/contact-channels.js.map +1 -0
  267. package/dist/esm/interface/crud/current-user.d.ts +286 -0
  268. package/dist/esm/interface/crud/current-user.d.ts.map +1 -0
  269. package/dist/esm/interface/crud/current-user.js +69 -0
  270. package/dist/esm/interface/crud/current-user.js.map +1 -0
  271. package/dist/esm/interface/crud/email-outbox.d.ts +1466 -0
  272. package/dist/esm/interface/crud/email-outbox.d.ts.map +1 -0
  273. package/dist/esm/interface/crud/email-outbox.js +190 -0
  274. package/dist/esm/interface/crud/email-outbox.js.map +1 -0
  275. package/dist/esm/interface/crud/email-templates.d.ts +86 -0
  276. package/dist/esm/interface/crud/email-templates.d.ts.map +1 -0
  277. package/dist/esm/interface/crud/email-templates.js +46 -0
  278. package/dist/esm/interface/crud/email-templates.js.map +1 -0
  279. package/dist/esm/interface/crud/emails.d.ts +42 -0
  280. package/dist/esm/interface/crud/emails.d.ts.map +1 -0
  281. package/dist/esm/interface/crud/emails.js +19 -0
  282. package/dist/esm/interface/crud/emails.js.map +1 -0
  283. package/dist/esm/interface/crud/internal-api-keys.d.ts +141 -0
  284. package/dist/esm/interface/crud/internal-api-keys.d.ts.map +1 -0
  285. package/dist/esm/interface/crud/internal-api-keys.js +49 -0
  286. package/dist/esm/interface/crud/internal-api-keys.js.map +1 -0
  287. package/dist/esm/interface/crud/invoices.d.ts +43 -0
  288. package/dist/esm/interface/crud/invoices.d.ts.map +1 -0
  289. package/dist/esm/interface/crud/invoices.js +25 -0
  290. package/dist/esm/interface/crud/invoices.js.map +1 -0
  291. package/dist/esm/interface/crud/items.d.ts +31 -0
  292. package/dist/esm/interface/crud/items.d.ts.map +1 -0
  293. package/dist/esm/interface/crud/items.js +23 -0
  294. package/dist/esm/interface/crud/items.js.map +1 -0
  295. package/dist/esm/interface/crud/notification-preferences.d.ts +39 -0
  296. package/dist/esm/interface/crud/notification-preferences.d.ts.map +1 -0
  297. package/dist/esm/interface/crud/notification-preferences.js +31 -0
  298. package/dist/esm/interface/crud/notification-preferences.js.map +1 -0
  299. package/dist/esm/interface/crud/oauth-providers.d.ts +187 -0
  300. package/dist/esm/interface/crud/oauth-providers.d.ts.map +1 -0
  301. package/dist/esm/interface/crud/oauth-providers.js +75 -0
  302. package/dist/esm/interface/crud/oauth-providers.js.map +1 -0
  303. package/dist/esm/interface/crud/products.d.ts +182 -0
  304. package/dist/esm/interface/crud/products.d.ts.map +1 -0
  305. package/dist/esm/interface/crud/products.js +29 -0
  306. package/dist/esm/interface/crud/products.js.map +1 -0
  307. package/dist/esm/interface/crud/project-api-keys.d.ts +204 -0
  308. package/dist/esm/interface/crud/project-api-keys.d.ts.map +1 -0
  309. package/dist/esm/interface/crud/project-api-keys.js +72 -0
  310. package/dist/esm/interface/crud/project-api-keys.js.map +1 -0
  311. package/dist/esm/interface/crud/project-permissions.d.ts +162 -0
  312. package/dist/esm/interface/crud/project-permissions.d.ts.map +1 -0
  313. package/dist/esm/interface/crud/project-permissions.js +104 -0
  314. package/dist/esm/interface/crud/project-permissions.js.map +1 -0
  315. package/dist/esm/interface/crud/projects.d.ts +852 -0
  316. package/dist/esm/interface/crud/projects.d.ts.map +1 -0
  317. package/dist/esm/interface/crud/projects.js +193 -0
  318. package/dist/esm/interface/crud/projects.js.map +1 -0
  319. package/dist/esm/interface/crud/session-replays.d.ts +83 -0
  320. package/dist/esm/interface/crud/session-replays.d.ts.map +1 -0
  321. package/dist/esm/interface/crud/session-replays.js +1 -0
  322. package/dist/esm/interface/crud/sessions.d.ts +151 -0
  323. package/dist/esm/interface/crud/sessions.d.ts.map +1 -0
  324. package/dist/esm/interface/crud/sessions.js +56 -0
  325. package/dist/esm/interface/crud/sessions.js.map +1 -0
  326. package/dist/esm/interface/crud/sign-up-rules.d.ts +15 -0
  327. package/dist/esm/interface/crud/sign-up-rules.d.ts.map +1 -0
  328. package/dist/esm/interface/crud/sign-up-rules.js +1 -0
  329. package/dist/esm/interface/crud/svix-token.d.ts +32 -0
  330. package/dist/esm/interface/crud/svix-token.d.ts.map +1 -0
  331. package/dist/esm/interface/crud/svix-token.js +18 -0
  332. package/dist/esm/interface/crud/svix-token.js.map +1 -0
  333. package/dist/esm/interface/crud/team-invitation-details.d.ts +32 -0
  334. package/dist/esm/interface/crud/team-invitation-details.d.ts.map +1 -0
  335. package/dist/esm/interface/crud/team-invitation-details.js +21 -0
  336. package/dist/esm/interface/crud/team-invitation-details.js.map +1 -0
  337. package/dist/esm/interface/crud/team-invitation.d.ts +55 -0
  338. package/dist/esm/interface/crud/team-invitation.d.ts.map +1 -0
  339. package/dist/esm/interface/crud/team-invitation.js +37 -0
  340. package/dist/esm/interface/crud/team-invitation.js.map +1 -0
  341. package/dist/esm/interface/crud/team-member-profiles.d.ts +287 -0
  342. package/dist/esm/interface/crud/team-member-profiles.d.ts.map +1 -0
  343. package/dist/esm/interface/crud/team-member-profiles.js +58 -0
  344. package/dist/esm/interface/crud/team-member-profiles.js.map +1 -0
  345. package/dist/esm/interface/crud/team-memberships.d.ts +76 -0
  346. package/dist/esm/interface/crud/team-memberships.d.ts.map +1 -0
  347. package/dist/esm/interface/crud/team-memberships.js +54 -0
  348. package/dist/esm/interface/crud/team-memberships.js.map +1 -0
  349. package/dist/esm/interface/crud/team-permissions.d.ts +170 -0
  350. package/dist/esm/interface/crud/team-permissions.d.ts.map +1 -0
  351. package/dist/esm/interface/crud/team-permissions.js +105 -0
  352. package/dist/esm/interface/crud/team-permissions.js.map +1 -0
  353. package/dist/esm/interface/crud/teams.d.ts +300 -0
  354. package/dist/esm/interface/crud/teams.d.ts.map +1 -0
  355. package/dist/esm/interface/crud/teams.js +129 -0
  356. package/dist/esm/interface/crud/teams.js.map +1 -0
  357. package/dist/esm/interface/crud/transactions.d.ts +183 -0
  358. package/dist/esm/interface/crud/transactions.d.ts.map +1 -0
  359. package/dist/esm/interface/crud/transactions.js +85 -0
  360. package/dist/esm/interface/crud/transactions.js.map +1 -0
  361. package/dist/esm/interface/crud/users.d.ts +654 -0
  362. package/dist/esm/interface/crud/users.d.ts.map +1 -0
  363. package/dist/esm/interface/crud/users.js +181 -0
  364. package/dist/esm/interface/crud/users.js.map +1 -0
  365. package/dist/esm/interface/handler-urls.d.ts +51 -0
  366. package/dist/esm/interface/handler-urls.d.ts.map +1 -0
  367. package/dist/esm/interface/handler-urls.js +3 -0
  368. package/dist/esm/interface/page-component-versions.d.ts +25 -0
  369. package/dist/esm/interface/page-component-versions.d.ts.map +1 -0
  370. package/dist/esm/interface/page-component-versions.js +1661 -0
  371. package/dist/esm/interface/page-component-versions.js.map +1 -0
  372. package/dist/esm/interface/server-interface.d.ts +255 -0
  373. package/dist/esm/interface/server-interface.d.ts.map +1 -0
  374. package/dist/esm/interface/server-interface.js +459 -0
  375. package/dist/esm/interface/server-interface.js.map +1 -0
  376. package/dist/esm/interface/webhooks.d.ts +326 -0
  377. package/dist/esm/interface/webhooks.d.ts.map +1 -0
  378. package/dist/esm/interface/webhooks.js +22 -0
  379. package/dist/esm/interface/webhooks.js.map +1 -0
  380. package/dist/esm/known-errors.d.ts +575 -0
  381. package/dist/esm/known-errors.d.ts.map +1 -0
  382. package/dist/esm/known-errors.js +791 -0
  383. package/dist/esm/known-errors.js.map +1 -0
  384. package/dist/esm/local-emulator.d.ts +6 -0
  385. package/dist/esm/local-emulator.d.ts.map +1 -0
  386. package/dist/esm/local-emulator.js +7 -0
  387. package/dist/esm/local-emulator.js.map +1 -0
  388. package/dist/esm/payments/payment-methods.d.ts +64 -0
  389. package/dist/esm/payments/payment-methods.d.ts.map +1 -0
  390. package/dist/esm/payments/payment-methods.js +205 -0
  391. package/dist/esm/payments/payment-methods.js.map +1 -0
  392. package/dist/esm/payments/stripe-limits.d.ts +17 -0
  393. package/dist/esm/payments/stripe-limits.d.ts.map +1 -0
  394. package/dist/esm/payments/stripe-limits.js +17 -0
  395. package/dist/esm/payments/stripe-limits.js.map +1 -0
  396. package/dist/esm/plans.d.ts +72 -0
  397. package/dist/esm/plans.d.ts.map +1 -0
  398. package/dist/esm/plans.js +81 -0
  399. package/dist/esm/plans.js.map +1 -0
  400. package/dist/esm/schema-fields.d.ts +472 -0
  401. package/dist/esm/schema-fields.d.ts.map +1 -0
  402. package/dist/esm/schema-fields.js +1009 -0
  403. package/dist/esm/schema-fields.js.map +1 -0
  404. package/dist/esm/sessions.d.ts +165 -0
  405. package/dist/esm/sessions.d.ts.map +1 -0
  406. package/dist/esm/sessions.js +226 -0
  407. package/dist/esm/sessions.js.map +1 -0
  408. package/dist/esm/stack-config-file.d.ts +15 -0
  409. package/dist/esm/stack-config-file.d.ts.map +1 -0
  410. package/dist/esm/stack-config-file.js +76 -0
  411. package/dist/esm/stack-config-file.js.map +1 -0
  412. package/dist/esm/utils/api-keys.d.ts +26 -0
  413. package/dist/esm/utils/api-keys.d.ts.map +1 -0
  414. package/dist/esm/utils/api-keys.js +77 -0
  415. package/dist/esm/utils/api-keys.js.map +1 -0
  416. package/dist/esm/utils/arrays.d.ts +25 -0
  417. package/dist/esm/utils/arrays.d.ts.map +1 -0
  418. package/dist/esm/utils/arrays.js +552 -0
  419. package/dist/esm/utils/arrays.js.map +1 -0
  420. package/dist/esm/utils/auth-methods.d.ts +6 -0
  421. package/dist/esm/utils/auth-methods.d.ts.map +1 -0
  422. package/dist/esm/utils/auth-methods.js +11 -0
  423. package/dist/esm/utils/auth-methods.js.map +1 -0
  424. package/dist/esm/utils/base64.d.ts +6 -0
  425. package/dist/esm/utils/base64.d.ts.map +1 -0
  426. package/dist/esm/utils/base64.js +25 -0
  427. package/dist/esm/utils/base64.js.map +1 -0
  428. package/dist/esm/utils/booleans.d.ts +8 -0
  429. package/dist/esm/utils/booleans.d.ts.map +1 -0
  430. package/dist/esm/utils/booleans.js +35 -0
  431. package/dist/esm/utils/booleans.js.map +1 -0
  432. package/dist/esm/utils/browser-compat.d.ts +10 -0
  433. package/dist/esm/utils/browser-compat.d.ts.map +1 -0
  434. package/dist/esm/utils/browser-compat.js +21 -0
  435. package/dist/esm/utils/browser-compat.js.map +1 -0
  436. package/dist/esm/utils/bytes.d.ts +17 -0
  437. package/dist/esm/utils/bytes.d.ts.map +1 -0
  438. package/dist/esm/utils/bytes.js +290 -0
  439. package/dist/esm/utils/bytes.js.map +1 -0
  440. package/dist/esm/utils/caches.d.ts +102 -0
  441. package/dist/esm/utils/caches.d.ts.map +1 -0
  442. package/dist/esm/utils/caches.js +185 -0
  443. package/dist/esm/utils/caches.js.map +1 -0
  444. package/dist/esm/utils/cel-fields.d.ts +23 -0
  445. package/dist/esm/utils/cel-fields.d.ts.map +1 -0
  446. package/dist/esm/utils/cel-fields.js +99 -0
  447. package/dist/esm/utils/cel-fields.js.map +1 -0
  448. package/dist/esm/utils/compile-time.d.ts +10 -0
  449. package/dist/esm/utils/compile-time.d.ts.map +1 -0
  450. package/dist/esm/utils/compile-time.js +14 -0
  451. package/dist/esm/utils/compile-time.js.map +1 -0
  452. package/dist/esm/utils/country-codes.d.ts +11 -0
  453. package/dist/esm/utils/country-codes.d.ts.map +1 -0
  454. package/dist/esm/utils/country-codes.js +36 -0
  455. package/dist/esm/utils/country-codes.js.map +1 -0
  456. package/dist/esm/utils/crypto.d.ts +48 -0
  457. package/dist/esm/utils/crypto.d.ts.map +1 -0
  458. package/dist/esm/utils/crypto.js +208 -0
  459. package/dist/esm/utils/crypto.js.map +1 -0
  460. package/dist/esm/utils/currencies.d.ts +8 -0
  461. package/dist/esm/utils/currencies.d.ts.map +1 -0
  462. package/dist/esm/utils/currencies.js +50 -0
  463. package/dist/esm/utils/currencies.js.map +1 -0
  464. package/dist/esm/utils/currency-constants.d.ts +39 -0
  465. package/dist/esm/utils/currency-constants.d.ts.map +1 -0
  466. package/dist/esm/utils/currency-constants.js +42 -0
  467. package/dist/esm/utils/currency-constants.js.map +1 -0
  468. package/dist/esm/utils/dates.d.ts +23 -0
  469. package/dist/esm/utils/dates.d.ts.map +1 -0
  470. package/dist/esm/utils/dates.js +167 -0
  471. package/dist/esm/utils/dates.js.map +1 -0
  472. package/dist/esm/utils/dev-env-state-path.d.ts +6 -0
  473. package/dist/esm/utils/dev-env-state-path.d.ts.map +1 -0
  474. package/dist/esm/utils/dev-env-state-path.js +15 -0
  475. package/dist/esm/utils/dev-env-state-path.js.map +1 -0
  476. package/dist/esm/utils/dom.d.ts +5 -0
  477. package/dist/esm/utils/dom.d.ts.map +1 -0
  478. package/dist/esm/utils/dom.js +11 -0
  479. package/dist/esm/utils/dom.js.map +1 -0
  480. package/dist/esm/utils/env.d.ts +25 -0
  481. package/dist/esm/utils/env.d.ts.map +1 -0
  482. package/dist/esm/utils/env.js +78 -0
  483. package/dist/esm/utils/env.js.map +1 -0
  484. package/dist/esm/utils/errors.d.ts +231 -0
  485. package/dist/esm/utils/errors.d.ts.map +1 -0
  486. package/dist/esm/utils/errors.js +385 -0
  487. package/dist/esm/utils/errors.js.map +1 -0
  488. package/dist/esm/utils/esbuild.d.ts +16 -0
  489. package/dist/esm/utils/esbuild.d.ts.map +1 -0
  490. package/dist/esm/utils/esbuild.js +182 -0
  491. package/dist/esm/utils/esbuild.js.map +1 -0
  492. package/dist/esm/utils/featurebase.d.ts +30 -0
  493. package/dist/esm/utils/featurebase.d.ts.map +1 -0
  494. package/dist/esm/utils/featurebase.js +166 -0
  495. package/dist/esm/utils/featurebase.js.map +1 -0
  496. package/dist/esm/utils/fs.d.ts +9 -0
  497. package/dist/esm/utils/fs.d.ts.map +1 -0
  498. package/dist/esm/utils/fs.js +25 -0
  499. package/dist/esm/utils/fs.js.map +1 -0
  500. package/dist/esm/utils/functions.d.ts +6 -0
  501. package/dist/esm/utils/functions.d.ts.map +1 -0
  502. package/dist/esm/utils/functions.js +34 -0
  503. package/dist/esm/utils/functions.js.map +1 -0
  504. package/dist/esm/utils/geo.d.ts +24 -0
  505. package/dist/esm/utils/geo.d.ts.map +1 -0
  506. package/dist/esm/utils/geo.js +16 -0
  507. package/dist/esm/utils/geo.js.map +1 -0
  508. package/dist/esm/utils/globals.d.ts +13 -0
  509. package/dist/esm/utils/globals.d.ts.map +1 -0
  510. package/dist/esm/utils/globals.js +34 -0
  511. package/dist/esm/utils/globals.js.map +1 -0
  512. package/dist/esm/utils/hashes.d.ts +9 -0
  513. package/dist/esm/utils/hashes.d.ts.map +1 -0
  514. package/dist/esm/utils/hashes.js +40 -0
  515. package/dist/esm/utils/hashes.js.map +1 -0
  516. package/dist/esm/utils/html.d.ts +7 -0
  517. package/dist/esm/utils/html.d.ts.map +1 -0
  518. package/dist/esm/utils/html.js +33 -0
  519. package/dist/esm/utils/html.js.map +1 -0
  520. package/dist/esm/utils/http.d.ts +45 -0
  521. package/dist/esm/utils/http.d.ts.map +1 -0
  522. package/dist/esm/utils/http.js +75 -0
  523. package/dist/esm/utils/http.js.map +1 -0
  524. package/dist/esm/utils/ips.d.ts +8 -0
  525. package/dist/esm/utils/ips.d.ts.map +1 -0
  526. package/dist/esm/utils/ips.js +36 -0
  527. package/dist/esm/utils/ips.js.map +1 -0
  528. package/dist/esm/utils/json.d.ts +15 -0
  529. package/dist/esm/utils/json.d.ts.map +1 -0
  530. package/dist/esm/utils/json.js +178 -0
  531. package/dist/esm/utils/json.js.map +1 -0
  532. package/dist/esm/utils/jsx-editable-transpiler.d.ts +68 -0
  533. package/dist/esm/utils/jsx-editable-transpiler.d.ts.map +1 -0
  534. package/dist/esm/utils/jsx-editable-transpiler.js +216 -0
  535. package/dist/esm/utils/jsx-editable-transpiler.js.map +1 -0
  536. package/dist/esm/utils/jsx-editable-transpiler.test.d.ts +1 -0
  537. package/dist/esm/utils/jsx-editable-transpiler.test.js +122 -0
  538. package/dist/esm/utils/jsx-editable-transpiler.test.js.map +1 -0
  539. package/dist/esm/utils/jwt.d.ts +79 -0
  540. package/dist/esm/utils/jwt.d.ts.map +1 -0
  541. package/dist/esm/utils/jwt.js +102 -0
  542. package/dist/esm/utils/jwt.js.map +1 -0
  543. package/dist/esm/utils/locks.d.ts +17 -0
  544. package/dist/esm/utils/locks.d.ts.map +1 -0
  545. package/dist/esm/utils/locks.js +54 -0
  546. package/dist/esm/utils/locks.js.map +1 -0
  547. package/dist/esm/utils/maps.d.ts +61 -0
  548. package/dist/esm/utils/maps.d.ts.map +1 -0
  549. package/dist/esm/utils/maps.js +297 -0
  550. package/dist/esm/utils/maps.js.map +1 -0
  551. package/dist/esm/utils/math.d.ts +8 -0
  552. package/dist/esm/utils/math.d.ts.map +1 -0
  553. package/dist/esm/utils/math.js +21 -0
  554. package/dist/esm/utils/math.js.map +1 -0
  555. package/dist/esm/utils/monkey-patch.d.ts +7 -0
  556. package/dist/esm/utils/monkey-patch.d.ts.map +1 -0
  557. package/dist/esm/utils/monkey-patch.js +21 -0
  558. package/dist/esm/utils/monkey-patch.js.map +1 -0
  559. package/dist/esm/utils/node-http.d.ts +17 -0
  560. package/dist/esm/utils/node-http.d.ts.map +1 -0
  561. package/dist/esm/utils/node-http.js +38 -0
  562. package/dist/esm/utils/node-http.js.map +1 -0
  563. package/dist/esm/utils/numbers.d.ts +7 -0
  564. package/dist/esm/utils/numbers.d.ts.map +1 -0
  565. package/dist/esm/utils/numbers.js +75 -0
  566. package/dist/esm/utils/numbers.js.map +1 -0
  567. package/dist/esm/utils/oauth.d.ts +11 -0
  568. package/dist/esm/utils/oauth.d.ts.map +1 -0
  569. package/dist/esm/utils/oauth.js +27 -0
  570. package/dist/esm/utils/oauth.js.map +1 -0
  571. package/dist/esm/utils/objects.d.ts +59 -0
  572. package/dist/esm/utils/objects.d.ts.map +1 -0
  573. package/dist/esm/utils/objects.js +818 -0
  574. package/dist/esm/utils/objects.js.map +1 -0
  575. package/dist/esm/utils/paginated-lists.d.ts +442 -0
  576. package/dist/esm/utils/paginated-lists.d.ts.map +1 -0
  577. package/dist/esm/utils/paginated-lists.js +411 -0
  578. package/dist/esm/utils/paginated-lists.js.map +1 -0
  579. package/dist/esm/utils/paginated-lists.test.d.ts +1 -0
  580. package/dist/esm/utils/paginated-lists.test.js +1304 -0
  581. package/dist/esm/utils/paginated-lists.test.js.map +1 -0
  582. package/dist/esm/utils/passkey.d.ts +2 -0
  583. package/dist/esm/utils/passkey.js +1 -0
  584. package/dist/esm/utils/promises.d.ts +80 -0
  585. package/dist/esm/utils/promises.d.ts.map +1 -0
  586. package/dist/esm/utils/promises.js +333 -0
  587. package/dist/esm/utils/promises.js.map +1 -0
  588. package/dist/esm/utils/proxies.d.ts +13 -0
  589. package/dist/esm/utils/proxies.d.ts.map +1 -0
  590. package/dist/esm/utils/proxies.js +197 -0
  591. package/dist/esm/utils/proxies.js.map +1 -0
  592. package/dist/esm/utils/react.d.ts +61 -0
  593. package/dist/esm/utils/react.d.ts.map +1 -0
  594. package/dist/esm/utils/react.js +229 -0
  595. package/dist/esm/utils/react.js.map +1 -0
  596. package/dist/esm/utils/redirect-urls.d.ts +30 -0
  597. package/dist/esm/utils/redirect-urls.d.ts.map +1 -0
  598. package/dist/esm/utils/redirect-urls.js +215 -0
  599. package/dist/esm/utils/redirect-urls.js.map +1 -0
  600. package/dist/esm/utils/regex.d.ts +5 -0
  601. package/dist/esm/utils/regex.d.ts.map +1 -0
  602. package/dist/esm/utils/regex.js +13 -0
  603. package/dist/esm/utils/regex.js.map +1 -0
  604. package/dist/esm/utils/results.d.ts +70 -0
  605. package/dist/esm/utils/results.d.ts.map +1 -0
  606. package/dist/esm/utils/results.js +339 -0
  607. package/dist/esm/utils/results.js.map +1 -0
  608. package/dist/esm/utils/sentry.d.ts +13 -0
  609. package/dist/esm/utils/sentry.d.ts.map +1 -0
  610. package/dist/esm/utils/sentry.js +14 -0
  611. package/dist/esm/utils/sentry.js.map +1 -0
  612. package/dist/esm/utils/stores.d.ts +104 -0
  613. package/dist/esm/utils/stores.d.ts.map +1 -0
  614. package/dist/esm/utils/stores.js +175 -0
  615. package/dist/esm/utils/stores.js.map +1 -0
  616. package/dist/esm/utils/strings.d.ts +76 -0
  617. package/dist/esm/utils/strings.d.ts.map +1 -0
  618. package/dist/esm/utils/strings.js +530 -0
  619. package/dist/esm/utils/strings.js.map +1 -0
  620. package/dist/esm/utils/strings.nicify.test.d.ts +1 -0
  621. package/dist/esm/utils/strings.nicify.test.js +243 -0
  622. package/dist/esm/utils/strings.nicify.test.js.map +1 -0
  623. package/dist/esm/utils/telemetry.d.ts +15 -0
  624. package/dist/esm/utils/telemetry.d.ts.map +1 -0
  625. package/dist/esm/utils/telemetry.js +31 -0
  626. package/dist/esm/utils/telemetry.js.map +1 -0
  627. package/dist/esm/utils/turnstile-browser.d.ts +32 -0
  628. package/dist/esm/utils/turnstile-browser.d.ts.map +1 -0
  629. package/dist/esm/utils/turnstile-browser.js +61 -0
  630. package/dist/esm/utils/turnstile-browser.js.map +1 -0
  631. package/dist/esm/utils/turnstile-flow.d.ts +29 -0
  632. package/dist/esm/utils/turnstile-flow.d.ts.map +1 -0
  633. package/dist/esm/utils/turnstile-flow.js +219 -0
  634. package/dist/esm/utils/turnstile-flow.js.map +1 -0
  635. package/dist/esm/utils/turnstile-flow.test.d.ts +1 -0
  636. package/dist/esm/utils/turnstile-flow.test.js +75 -0
  637. package/dist/esm/utils/turnstile-flow.test.js.map +1 -0
  638. package/dist/esm/utils/turnstile.d.ts +17 -0
  639. package/dist/esm/utils/turnstile.d.ts.map +1 -0
  640. package/dist/esm/utils/turnstile.js +25 -0
  641. package/dist/esm/utils/turnstile.js.map +1 -0
  642. package/dist/esm/utils/typed-arrays.d.ts +14 -0
  643. package/dist/esm/utils/typed-arrays.d.ts.map +1 -0
  644. package/dist/esm/utils/typed-arrays.js +20 -0
  645. package/dist/esm/utils/typed-arrays.js.map +1 -0
  646. package/dist/esm/utils/types.d.ts +77 -0
  647. package/dist/esm/utils/types.d.ts.map +1 -0
  648. package/dist/esm/utils/types.js +55 -0
  649. package/dist/esm/utils/types.js.map +1 -0
  650. package/dist/esm/utils/unicode.d.ts +5 -0
  651. package/dist/esm/utils/unicode.d.ts.map +1 -0
  652. package/dist/esm/utils/unicode.js +24 -0
  653. package/dist/esm/utils/unicode.js.map +1 -0
  654. package/dist/esm/utils/urls.d.ts +28 -0
  655. package/dist/esm/utils/urls.d.ts.map +1 -0
  656. package/dist/esm/utils/urls.js +259 -0
  657. package/dist/esm/utils/urls.js.map +1 -0
  658. package/dist/esm/utils/uuids.d.ts +6 -0
  659. package/dist/esm/utils/uuids.d.ts.map +1 -0
  660. package/dist/esm/utils/uuids.js +36 -0
  661. package/dist/esm/utils/uuids.js.map +1 -0
  662. package/dist/global.d.d.ts +0 -0
  663. package/dist/global.d.ts +1 -0
  664. package/dist/helpers/emails.d.ts +69 -0
  665. package/dist/helpers/emails.d.ts.map +1 -0
  666. package/dist/helpers/emails.js +252 -0
  667. package/dist/helpers/emails.js.map +1 -0
  668. package/dist/helpers/init-prompt.d.ts +5 -0
  669. package/dist/helpers/init-prompt.d.ts.map +1 -0
  670. package/dist/helpers/init-prompt.js +42 -0
  671. package/dist/helpers/init-prompt.js.map +1 -0
  672. package/dist/helpers/password.d.ts +6 -0
  673. package/dist/helpers/password.d.ts.map +1 -0
  674. package/dist/helpers/password.js +15 -0
  675. package/dist/helpers/password.js.map +1 -0
  676. package/dist/helpers/production-mode.d.ts +11 -0
  677. package/dist/helpers/production-mode.d.ts.map +1 -0
  678. package/dist/helpers/production-mode.js +48 -0
  679. package/dist/helpers/production-mode.js.map +1 -0
  680. package/dist/helpers/support-sla.d.ts +48 -0
  681. package/dist/helpers/support-sla.d.ts.map +1 -0
  682. package/dist/helpers/support-sla.js +72 -0
  683. package/dist/helpers/support-sla.js.map +1 -0
  684. package/dist/helpers/support-sla.test.d.ts +1 -0
  685. package/dist/helpers/support-sla.test.js +102 -0
  686. package/dist/helpers/support-sla.test.js.map +1 -0
  687. package/dist/helpers/vault/client-side.d.ts +16 -0
  688. package/dist/helpers/vault/client-side.d.ts.map +1 -0
  689. package/dist/helpers/vault/client-side.js +73 -0
  690. package/dist/helpers/vault/client-side.js.map +1 -0
  691. package/dist/helpers/vault/server-side.d.ts +9 -0
  692. package/dist/helpers/vault/server-side.d.ts.map +1 -0
  693. package/dist/helpers/vault/server-side.js +126 -0
  694. package/dist/helpers/vault/server-side.js.map +1 -0
  695. package/dist/hooks/use-async-callback.d.ts +8 -0
  696. package/dist/hooks/use-async-callback.d.ts.map +1 -0
  697. package/dist/hooks/use-async-callback.js +42 -0
  698. package/dist/hooks/use-async-callback.js.map +1 -0
  699. package/dist/hooks/use-async-external-store.d.ts +9 -0
  700. package/dist/hooks/use-async-external-store.d.ts.map +1 -0
  701. package/dist/hooks/use-async-external-store.js +22 -0
  702. package/dist/hooks/use-async-external-store.js.map +1 -0
  703. package/dist/hooks/use-hash.d.ts +5 -0
  704. package/dist/hooks/use-hash.d.ts.map +1 -0
  705. package/dist/hooks/use-hash.js +17 -0
  706. package/dist/hooks/use-hash.js.map +1 -0
  707. package/dist/hooks/use-hover.d.ts +8 -0
  708. package/dist/hooks/use-hover.d.ts.map +1 -0
  709. package/dist/hooks/use-hover.js +61 -0
  710. package/dist/hooks/use-hover.js.map +1 -0
  711. package/dist/hooks/use-strict-memo.d.ts +10 -0
  712. package/dist/hooks/use-strict-memo.d.ts.map +1 -0
  713. package/dist/hooks/use-strict-memo.js +121 -0
  714. package/dist/hooks/use-strict-memo.js.map +1 -0
  715. package/dist/index-D9ysacya.d.ts +153 -0
  716. package/dist/index-D9ysacya.d.ts.map +1 -0
  717. package/dist/index.d.ts +5 -0
  718. package/dist/index.js +37 -0
  719. package/dist/interface/admin-interface.d.ts +308 -0
  720. package/dist/interface/admin-interface.d.ts.map +1 -0
  721. package/dist/interface/admin-interface.js +465 -0
  722. package/dist/interface/admin-interface.js.map +1 -0
  723. package/dist/interface/admin-metrics.d.ts +597 -0
  724. package/dist/interface/admin-metrics.d.ts.map +1 -0
  725. package/dist/interface/admin-metrics.js +153 -0
  726. package/dist/interface/admin-metrics.js.map +1 -0
  727. package/dist/interface/client-interface.d.ts +447 -0
  728. package/dist/interface/client-interface.d.ts.map +1 -0
  729. package/dist/interface/client-interface.js +1948 -0
  730. package/dist/interface/client-interface.js.map +1 -0
  731. package/dist/interface/client-interface.test.d.ts +1 -0
  732. package/dist/interface/client-interface.test.js +559 -0
  733. package/dist/interface/client-interface.test.js.map +1 -0
  734. package/dist/interface/conversations.d.ts +314 -0
  735. package/dist/interface/conversations.d.ts.map +1 -0
  736. package/dist/interface/conversations.js +121 -0
  737. package/dist/interface/conversations.js.map +1 -0
  738. package/dist/interface/crud/analytics.d.ts +14 -0
  739. package/dist/interface/crud/analytics.d.ts.map +1 -0
  740. package/dist/interface/crud/analytics.js +0 -0
  741. package/dist/interface/crud/connected-accounts.d.ts +68 -0
  742. package/dist/interface/crud/connected-accounts.d.ts.map +1 -0
  743. package/dist/interface/crud/connected-accounts.js +41 -0
  744. package/dist/interface/crud/connected-accounts.js.map +1 -0
  745. package/dist/interface/crud/contact-channels.d.ts +181 -0
  746. package/dist/interface/crud/contact-channels.d.ts.map +1 -0
  747. package/dist/interface/crud/contact-channels.js +76 -0
  748. package/dist/interface/crud/contact-channels.js.map +1 -0
  749. package/dist/interface/crud/current-user.d.ts +285 -0
  750. package/dist/interface/crud/current-user.d.ts.map +1 -0
  751. package/dist/interface/crud/current-user.js +71 -0
  752. package/dist/interface/crud/current-user.js.map +1 -0
  753. package/dist/interface/crud/email-outbox.d.ts +1465 -0
  754. package/dist/interface/crud/email-outbox.d.ts.map +1 -0
  755. package/dist/interface/crud/email-outbox.js +195 -0
  756. package/dist/interface/crud/email-outbox.js.map +1 -0
  757. package/dist/interface/crud/email-templates.d.ts +85 -0
  758. package/dist/interface/crud/email-templates.d.ts.map +1 -0
  759. package/dist/interface/crud/email-templates.js +53 -0
  760. package/dist/interface/crud/email-templates.js.map +1 -0
  761. package/dist/interface/crud/emails.d.ts +41 -0
  762. package/dist/interface/crud/emails.d.ts.map +1 -0
  763. package/dist/interface/crud/emails.js +23 -0
  764. package/dist/interface/crud/emails.js.map +1 -0
  765. package/dist/interface/crud/internal-api-keys.d.ts +140 -0
  766. package/dist/interface/crud/internal-api-keys.d.ts.map +1 -0
  767. package/dist/interface/crud/internal-api-keys.js +56 -0
  768. package/dist/interface/crud/internal-api-keys.js.map +1 -0
  769. package/dist/interface/crud/invoices.d.ts +43 -0
  770. package/dist/interface/crud/invoices.d.ts.map +1 -0
  771. package/dist/interface/crud/invoices.js +28 -0
  772. package/dist/interface/crud/invoices.js.map +1 -0
  773. package/dist/interface/crud/items.d.ts +30 -0
  774. package/dist/interface/crud/items.d.ts.map +1 -0
  775. package/dist/interface/crud/items.js +25 -0
  776. package/dist/interface/crud/items.js.map +1 -0
  777. package/dist/interface/crud/notification-preferences.d.ts +38 -0
  778. package/dist/interface/crud/notification-preferences.d.ts.map +1 -0
  779. package/dist/interface/crud/notification-preferences.js +33 -0
  780. package/dist/interface/crud/notification-preferences.js.map +1 -0
  781. package/dist/interface/crud/oauth-providers.d.ts +186 -0
  782. package/dist/interface/crud/oauth-providers.d.ts.map +1 -0
  783. package/dist/interface/crud/oauth-providers.js +83 -0
  784. package/dist/interface/crud/oauth-providers.js.map +1 -0
  785. package/dist/interface/crud/products.d.ts +182 -0
  786. package/dist/interface/crud/products.d.ts.map +1 -0
  787. package/dist/interface/crud/products.js +32 -0
  788. package/dist/interface/crud/products.js.map +1 -0
  789. package/dist/interface/crud/project-api-keys.d.ts +203 -0
  790. package/dist/interface/crud/project-api-keys.d.ts.map +1 -0
  791. package/dist/interface/crud/project-api-keys.js +79 -0
  792. package/dist/interface/crud/project-api-keys.js.map +1 -0
  793. package/dist/interface/crud/project-permissions.d.ts +161 -0
  794. package/dist/interface/crud/project-permissions.d.ts.map +1 -0
  795. package/dist/interface/crud/project-permissions.js +116 -0
  796. package/dist/interface/crud/project-permissions.js.map +1 -0
  797. package/dist/interface/crud/projects.d.ts +851 -0
  798. package/dist/interface/crud/projects.d.ts.map +1 -0
  799. package/dist/interface/crud/projects.js +204 -0
  800. package/dist/interface/crud/projects.js.map +1 -0
  801. package/dist/interface/crud/session-replays.d.ts +83 -0
  802. package/dist/interface/crud/session-replays.d.ts.map +1 -0
  803. package/dist/interface/crud/session-replays.js +0 -0
  804. package/dist/interface/crud/sessions.d.ts +150 -0
  805. package/dist/interface/crud/sessions.d.ts.map +1 -0
  806. package/dist/interface/crud/sessions.js +62 -0
  807. package/dist/interface/crud/sessions.js.map +1 -0
  808. package/dist/interface/crud/sign-up-rules.d.ts +15 -0
  809. package/dist/interface/crud/sign-up-rules.d.ts.map +1 -0
  810. package/dist/interface/crud/sign-up-rules.js +0 -0
  811. package/dist/interface/crud/svix-token.d.ts +31 -0
  812. package/dist/interface/crud/svix-token.d.ts.map +1 -0
  813. package/dist/interface/crud/svix-token.js +22 -0
  814. package/dist/interface/crud/svix-token.js.map +1 -0
  815. package/dist/interface/crud/team-invitation-details.d.ts +31 -0
  816. package/dist/interface/crud/team-invitation-details.d.ts.map +1 -0
  817. package/dist/interface/crud/team-invitation-details.js +24 -0
  818. package/dist/interface/crud/team-invitation-details.js.map +1 -0
  819. package/dist/interface/crud/team-invitation.d.ts +54 -0
  820. package/dist/interface/crud/team-invitation.d.ts.map +1 -0
  821. package/dist/interface/crud/team-invitation.js +40 -0
  822. package/dist/interface/crud/team-invitation.js.map +1 -0
  823. package/dist/interface/crud/team-member-profiles.d.ts +286 -0
  824. package/dist/interface/crud/team-member-profiles.d.ts.map +1 -0
  825. package/dist/interface/crud/team-member-profiles.js +63 -0
  826. package/dist/interface/crud/team-member-profiles.js.map +1 -0
  827. package/dist/interface/crud/team-memberships.d.ts +75 -0
  828. package/dist/interface/crud/team-memberships.d.ts.map +1 -0
  829. package/dist/interface/crud/team-memberships.js +61 -0
  830. package/dist/interface/crud/team-memberships.js.map +1 -0
  831. package/dist/interface/crud/team-permissions.d.ts +169 -0
  832. package/dist/interface/crud/team-permissions.d.ts.map +1 -0
  833. package/dist/interface/crud/team-permissions.js +117 -0
  834. package/dist/interface/crud/team-permissions.js.map +1 -0
  835. package/dist/interface/crud/teams.d.ts +299 -0
  836. package/dist/interface/crud/teams.d.ts.map +1 -0
  837. package/dist/interface/crud/teams.js +142 -0
  838. package/dist/interface/crud/teams.js.map +1 -0
  839. package/dist/interface/crud/transactions.d.ts +183 -0
  840. package/dist/interface/crud/transactions.d.ts.map +1 -0
  841. package/dist/interface/crud/transactions.js +89 -0
  842. package/dist/interface/crud/transactions.js.map +1 -0
  843. package/dist/interface/crud/users.d.ts +653 -0
  844. package/dist/interface/crud/users.d.ts.map +1 -0
  845. package/dist/interface/crud/users.js +193 -0
  846. package/dist/interface/crud/users.js.map +1 -0
  847. package/dist/interface/handler-urls.d.ts +51 -0
  848. package/dist/interface/handler-urls.d.ts.map +1 -0
  849. package/dist/interface/handler-urls.js +16 -0
  850. package/dist/interface/page-component-versions.d.ts +25 -0
  851. package/dist/interface/page-component-versions.d.ts.map +1 -0
  852. package/dist/interface/page-component-versions.js +1664 -0
  853. package/dist/interface/page-component-versions.js.map +1 -0
  854. package/dist/interface/server-interface.d.ts +255 -0
  855. package/dist/interface/server-interface.d.ts.map +1 -0
  856. package/dist/interface/server-interface.js +461 -0
  857. package/dist/interface/server-interface.js.map +1 -0
  858. package/dist/interface/webhooks.d.ts +326 -0
  859. package/dist/interface/webhooks.d.ts.map +1 -0
  860. package/dist/interface/webhooks.js +24 -0
  861. package/dist/interface/webhooks.js.map +1 -0
  862. package/dist/known-errors.d.ts +575 -0
  863. package/dist/known-errors.d.ts.map +1 -0
  864. package/dist/known-errors.js +794 -0
  865. package/dist/known-errors.js.map +1 -0
  866. package/dist/local-emulator.d.ts +6 -0
  867. package/dist/local-emulator.d.ts.map +1 -0
  868. package/dist/local-emulator.js +10 -0
  869. package/dist/local-emulator.js.map +1 -0
  870. package/dist/payments/payment-methods.d.ts +64 -0
  871. package/dist/payments/payment-methods.d.ts.map +1 -0
  872. package/dist/payments/payment-methods.js +216 -0
  873. package/dist/payments/payment-methods.js.map +1 -0
  874. package/dist/payments/stripe-limits.d.ts +17 -0
  875. package/dist/payments/stripe-limits.d.ts.map +1 -0
  876. package/dist/payments/stripe-limits.js +20 -0
  877. package/dist/payments/stripe-limits.js.map +1 -0
  878. package/dist/plans.d.ts +72 -0
  879. package/dist/plans.d.ts.map +1 -0
  880. package/dist/plans.js +88 -0
  881. package/dist/plans.js.map +1 -0
  882. package/dist/schema-fields.d.ts +472 -0
  883. package/dist/schema-fields.d.ts.map +1 -0
  884. package/dist/schema-fields.js +1188 -0
  885. package/dist/schema-fields.js.map +1 -0
  886. package/dist/sessions.d.ts +165 -0
  887. package/dist/sessions.d.ts.map +1 -0
  888. package/dist/sessions.js +231 -0
  889. package/dist/sessions.js.map +1 -0
  890. package/dist/stack-config-file.d.ts +15 -0
  891. package/dist/stack-config-file.d.ts.map +1 -0
  892. package/dist/stack-config-file.js +82 -0
  893. package/dist/stack-config-file.js.map +1 -0
  894. package/dist/utils/api-keys.d.ts +26 -0
  895. package/dist/utils/api-keys.d.ts.map +1 -0
  896. package/dist/utils/api-keys.js +82 -0
  897. package/dist/utils/api-keys.js.map +1 -0
  898. package/dist/utils/arrays.d.ts +25 -0
  899. package/dist/utils/arrays.d.ts.map +1 -0
  900. package/dist/utils/arrays.js +569 -0
  901. package/dist/utils/arrays.js.map +1 -0
  902. package/dist/utils/auth-methods.d.ts +6 -0
  903. package/dist/utils/auth-methods.d.ts.map +1 -0
  904. package/dist/utils/auth-methods.js +13 -0
  905. package/dist/utils/auth-methods.js.map +1 -0
  906. package/dist/utils/base64.d.ts +6 -0
  907. package/dist/utils/base64.d.ts.map +1 -0
  908. package/dist/utils/base64.js +28 -0
  909. package/dist/utils/base64.js.map +1 -0
  910. package/dist/utils/booleans.d.ts +8 -0
  911. package/dist/utils/booleans.d.ts.map +1 -0
  912. package/dist/utils/booleans.js +38 -0
  913. package/dist/utils/booleans.js.map +1 -0
  914. package/dist/utils/browser-compat.d.ts +10 -0
  915. package/dist/utils/browser-compat.d.ts.map +1 -0
  916. package/dist/utils/browser-compat.js +23 -0
  917. package/dist/utils/browser-compat.js.map +1 -0
  918. package/dist/utils/bytes.d.ts +17 -0
  919. package/dist/utils/bytes.d.ts.map +1 -0
  920. package/dist/utils/bytes.js +304 -0
  921. package/dist/utils/bytes.js.map +1 -0
  922. package/dist/utils/caches.d.ts +102 -0
  923. package/dist/utils/caches.d.ts.map +1 -0
  924. package/dist/utils/caches.js +188 -0
  925. package/dist/utils/caches.js.map +1 -0
  926. package/dist/utils/cel-fields.d.ts +23 -0
  927. package/dist/utils/cel-fields.d.ts.map +1 -0
  928. package/dist/utils/cel-fields.js +108 -0
  929. package/dist/utils/cel-fields.js.map +1 -0
  930. package/dist/utils/compile-time.d.ts +10 -0
  931. package/dist/utils/compile-time.d.ts.map +1 -0
  932. package/dist/utils/compile-time.js +16 -0
  933. package/dist/utils/compile-time.js.map +1 -0
  934. package/dist/utils/country-codes.d.ts +11 -0
  935. package/dist/utils/country-codes.d.ts.map +1 -0
  936. package/dist/utils/country-codes.js +40 -0
  937. package/dist/utils/country-codes.js.map +1 -0
  938. package/dist/utils/crypto.d.ts +48 -0
  939. package/dist/utils/crypto.d.ts.map +1 -0
  940. package/dist/utils/crypto.js +215 -0
  941. package/dist/utils/crypto.js.map +1 -0
  942. package/dist/utils/currencies.d.ts +8 -0
  943. package/dist/utils/currencies.d.ts.map +1 -0
  944. package/dist/utils/currencies.js +52 -0
  945. package/dist/utils/currencies.js.map +1 -0
  946. package/dist/utils/currency-constants.d.ts +39 -0
  947. package/dist/utils/currency-constants.d.ts.map +1 -0
  948. package/dist/utils/currency-constants.js +44 -0
  949. package/dist/utils/currency-constants.js.map +1 -0
  950. package/dist/utils/dates.d.ts +23 -0
  951. package/dist/utils/dates.d.ts.map +1 -0
  952. package/dist/utils/dates.js +176 -0
  953. package/dist/utils/dates.js.map +1 -0
  954. package/dist/utils/dev-env-state-path.d.ts +6 -0
  955. package/dist/utils/dev-env-state-path.d.ts.map +1 -0
  956. package/dist/utils/dev-env-state-path.js +18 -0
  957. package/dist/utils/dev-env-state-path.js.map +1 -0
  958. package/dist/utils/dom.d.ts +5 -0
  959. package/dist/utils/dom.d.ts.map +1 -0
  960. package/dist/utils/dom.js +13 -0
  961. package/dist/utils/dom.js.map +1 -0
  962. package/dist/utils/env.d.ts +25 -0
  963. package/dist/utils/env.d.ts.map +1 -0
  964. package/dist/utils/env.js +85 -0
  965. package/dist/utils/env.js.map +1 -0
  966. package/dist/utils/errors.d.ts +231 -0
  967. package/dist/utils/errors.d.ts.map +1 -0
  968. package/dist/utils/errors.js +393 -0
  969. package/dist/utils/errors.js.map +1 -0
  970. package/dist/utils/esbuild.d.ts +16 -0
  971. package/dist/utils/esbuild.d.ts.map +1 -0
  972. package/dist/utils/esbuild.js +186 -0
  973. package/dist/utils/esbuild.js.map +1 -0
  974. package/dist/utils/featurebase.d.ts +30 -0
  975. package/dist/utils/featurebase.d.ts.map +1 -0
  976. package/dist/utils/featurebase.js +168 -0
  977. package/dist/utils/featurebase.js.map +1 -0
  978. package/dist/utils/fs.d.ts +9 -0
  979. package/dist/utils/fs.d.ts.map +1 -0
  980. package/dist/utils/fs.js +31 -0
  981. package/dist/utils/fs.js.map +1 -0
  982. package/dist/utils/functions.d.ts +6 -0
  983. package/dist/utils/functions.d.ts.map +1 -0
  984. package/dist/utils/functions.js +37 -0
  985. package/dist/utils/functions.js.map +1 -0
  986. package/dist/utils/geo.d.ts +24 -0
  987. package/dist/utils/geo.d.ts.map +1 -0
  988. package/dist/utils/geo.js +18 -0
  989. package/dist/utils/geo.js.map +1 -0
  990. package/dist/utils/globals.d.ts +13 -0
  991. package/dist/utils/globals.d.ts.map +1 -0
  992. package/dist/utils/globals.js +40 -0
  993. package/dist/utils/globals.js.map +1 -0
  994. package/dist/utils/hashes.d.ts +9 -0
  995. package/dist/utils/hashes.d.ts.map +1 -0
  996. package/dist/utils/hashes.js +47 -0
  997. package/dist/utils/hashes.js.map +1 -0
  998. package/dist/utils/html.d.ts +7 -0
  999. package/dist/utils/html.d.ts.map +1 -0
  1000. package/dist/utils/html.js +37 -0
  1001. package/dist/utils/html.js.map +1 -0
  1002. package/dist/utils/http.d.ts +45 -0
  1003. package/dist/utils/http.d.ts.map +1 -0
  1004. package/dist/utils/http.js +79 -0
  1005. package/dist/utils/http.js.map +1 -0
  1006. package/dist/utils/ips.d.ts +8 -0
  1007. package/dist/utils/ips.d.ts.map +1 -0
  1008. package/dist/utils/ips.js +40 -0
  1009. package/dist/utils/ips.js.map +1 -0
  1010. package/dist/utils/json.d.ts +15 -0
  1011. package/dist/utils/json.d.ts.map +1 -0
  1012. package/dist/utils/json.js +182 -0
  1013. package/dist/utils/json.js.map +1 -0
  1014. package/dist/utils/jsx-editable-transpiler.d.ts +68 -0
  1015. package/dist/utils/jsx-editable-transpiler.d.ts.map +1 -0
  1016. package/dist/utils/jsx-editable-transpiler.js +223 -0
  1017. package/dist/utils/jsx-editable-transpiler.js.map +1 -0
  1018. package/dist/utils/jsx-editable-transpiler.test.d.ts +1 -0
  1019. package/dist/utils/jsx-editable-transpiler.test.js +122 -0
  1020. package/dist/utils/jsx-editable-transpiler.test.js.map +1 -0
  1021. package/dist/utils/jwt.d.ts +79 -0
  1022. package/dist/utils/jwt.d.ts.map +1 -0
  1023. package/dist/utils/jwt.js +112 -0
  1024. package/dist/utils/jwt.js.map +1 -0
  1025. package/dist/utils/locks.d.ts +17 -0
  1026. package/dist/utils/locks.d.ts.map +1 -0
  1027. package/dist/utils/locks.js +56 -0
  1028. package/dist/utils/locks.js.map +1 -0
  1029. package/dist/utils/maps.d.ts +61 -0
  1030. package/dist/utils/maps.d.ts.map +1 -0
  1031. package/dist/utils/maps.js +302 -0
  1032. package/dist/utils/maps.js.map +1 -0
  1033. package/dist/utils/math.d.ts +8 -0
  1034. package/dist/utils/math.d.ts.map +1 -0
  1035. package/dist/utils/math.js +23 -0
  1036. package/dist/utils/math.js.map +1 -0
  1037. package/dist/utils/monkey-patch.d.ts +7 -0
  1038. package/dist/utils/monkey-patch.d.ts.map +1 -0
  1039. package/dist/utils/monkey-patch.js +25 -0
  1040. package/dist/utils/monkey-patch.js.map +1 -0
  1041. package/dist/utils/node-http.d.ts +17 -0
  1042. package/dist/utils/node-http.d.ts.map +1 -0
  1043. package/dist/utils/node-http.js +40 -0
  1044. package/dist/utils/node-http.js.map +1 -0
  1045. package/dist/utils/numbers.d.ts +7 -0
  1046. package/dist/utils/numbers.d.ts.map +1 -0
  1047. package/dist/utils/numbers.js +79 -0
  1048. package/dist/utils/numbers.js.map +1 -0
  1049. package/dist/utils/oauth.d.ts +11 -0
  1050. package/dist/utils/oauth.d.ts.map +1 -0
  1051. package/dist/utils/oauth.js +32 -0
  1052. package/dist/utils/oauth.js.map +1 -0
  1053. package/dist/utils/objects.d.ts +59 -0
  1054. package/dist/utils/objects.d.ts.map +1 -0
  1055. package/dist/utils/objects.js +846 -0
  1056. package/dist/utils/objects.js.map +1 -0
  1057. package/dist/utils/paginated-lists.d.ts +442 -0
  1058. package/dist/utils/paginated-lists.d.ts.map +1 -0
  1059. package/dist/utils/paginated-lists.js +414 -0
  1060. package/dist/utils/paginated-lists.js.map +1 -0
  1061. package/dist/utils/paginated-lists.test.d.ts +1 -0
  1062. package/dist/utils/paginated-lists.test.js +1304 -0
  1063. package/dist/utils/paginated-lists.test.js.map +1 -0
  1064. package/dist/utils/passkey.d.ts +2 -0
  1065. package/dist/utils/passkey.js +0 -0
  1066. package/dist/utils/promises.d.ts +80 -0
  1067. package/dist/utils/promises.d.ts.map +1 -0
  1068. package/dist/utils/promises.js +349 -0
  1069. package/dist/utils/promises.js.map +1 -0
  1070. package/dist/utils/proxies.d.ts +13 -0
  1071. package/dist/utils/proxies.d.ts.map +1 -0
  1072. package/dist/utils/proxies.js +201 -0
  1073. package/dist/utils/proxies.js.map +1 -0
  1074. package/dist/utils/react.d.ts +61 -0
  1075. package/dist/utils/react.d.ts.map +1 -0
  1076. package/dist/utils/react.js +243 -0
  1077. package/dist/utils/react.js.map +1 -0
  1078. package/dist/utils/redirect-urls.d.ts +30 -0
  1079. package/dist/utils/redirect-urls.d.ts.map +1 -0
  1080. package/dist/utils/redirect-urls.js +222 -0
  1081. package/dist/utils/redirect-urls.js.map +1 -0
  1082. package/dist/utils/regex.d.ts +5 -0
  1083. package/dist/utils/regex.d.ts.map +1 -0
  1084. package/dist/utils/regex.js +15 -0
  1085. package/dist/utils/regex.js.map +1 -0
  1086. package/dist/utils/results.d.ts +70 -0
  1087. package/dist/utils/results.d.ts.map +1 -0
  1088. package/dist/utils/results.js +342 -0
  1089. package/dist/utils/results.js.map +1 -0
  1090. package/dist/utils/sentry.d.ts +13 -0
  1091. package/dist/utils/sentry.d.ts.map +1 -0
  1092. package/dist/utils/sentry.js +16 -0
  1093. package/dist/utils/sentry.js.map +1 -0
  1094. package/dist/utils/stores.d.ts +104 -0
  1095. package/dist/utils/stores.d.ts.map +1 -0
  1096. package/dist/utils/stores.js +179 -0
  1097. package/dist/utils/stores.js.map +1 -0
  1098. package/dist/utils/strings.d.ts +76 -0
  1099. package/dist/utils/strings.d.ts.map +1 -0
  1100. package/dist/utils/strings.js +549 -0
  1101. package/dist/utils/strings.js.map +1 -0
  1102. package/dist/utils/strings.nicify.test.d.ts +1 -0
  1103. package/dist/utils/strings.nicify.test.js +243 -0
  1104. package/dist/utils/strings.nicify.test.js.map +1 -0
  1105. package/dist/utils/telemetry.d.ts +15 -0
  1106. package/dist/utils/telemetry.d.ts.map +1 -0
  1107. package/dist/utils/telemetry.js +35 -0
  1108. package/dist/utils/telemetry.js.map +1 -0
  1109. package/dist/utils/turnstile-browser.d.ts +32 -0
  1110. package/dist/utils/turnstile-browser.d.ts.map +1 -0
  1111. package/dist/utils/turnstile-browser.js +65 -0
  1112. package/dist/utils/turnstile-browser.js.map +1 -0
  1113. package/dist/utils/turnstile-flow.d.ts +29 -0
  1114. package/dist/utils/turnstile-flow.d.ts.map +1 -0
  1115. package/dist/utils/turnstile-flow.js +225 -0
  1116. package/dist/utils/turnstile-flow.js.map +1 -0
  1117. package/dist/utils/turnstile-flow.test.d.ts +1 -0
  1118. package/dist/utils/turnstile-flow.test.js +75 -0
  1119. package/dist/utils/turnstile-flow.test.js.map +1 -0
  1120. package/dist/utils/turnstile.d.ts +17 -0
  1121. package/dist/utils/turnstile.d.ts.map +1 -0
  1122. package/dist/utils/turnstile.js +31 -0
  1123. package/dist/utils/turnstile.js.map +1 -0
  1124. package/dist/utils/typed-arrays.d.ts +14 -0
  1125. package/dist/utils/typed-arrays.d.ts.map +1 -0
  1126. package/dist/utils/typed-arrays.js +22 -0
  1127. package/dist/utils/typed-arrays.js.map +1 -0
  1128. package/dist/utils/types.d.ts +77 -0
  1129. package/dist/utils/types.d.ts.map +1 -0
  1130. package/dist/utils/types.js +59 -0
  1131. package/dist/utils/types.js.map +1 -0
  1132. package/dist/utils/unicode.d.ts +5 -0
  1133. package/dist/utils/unicode.d.ts.map +1 -0
  1134. package/dist/utils/unicode.js +26 -0
  1135. package/dist/utils/unicode.js.map +1 -0
  1136. package/dist/utils/urls.d.ts +28 -0
  1137. package/dist/utils/urls.d.ts.map +1 -0
  1138. package/dist/utils/urls.js +274 -0
  1139. package/dist/utils/urls.js.map +1 -0
  1140. package/dist/utils/uuids.d.ts +6 -0
  1141. package/dist/utils/uuids.d.ts.map +1 -0
  1142. package/dist/utils/uuids.js +39 -0
  1143. package/dist/utils/uuids.js.map +1 -0
  1144. package/package.json +99 -0
@@ -0,0 +1,1948 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_chunk = require('../chunk-BE-pF4vm.js');
3
+ let ___utils_errors_js = require("../utils/errors.js");
4
+ let ___utils_objects_js = require("../utils/objects.js");
5
+ let ___utils_strings_js = require("../utils/strings.js");
6
+ let ___utils_oauth_js = require("../utils/oauth.js");
7
+ let ___utils_results_js = require("../utils/results.js");
8
+ let ___known_errors_js = require("../known-errors.js");
9
+ let ___utils_urls_js = require("../utils/urls.js");
10
+ let ___sessions_js = require("../sessions.js");
11
+ let ___utils_crypto_js = require("../utils/crypto.js");
12
+ let ___utils_globals_js = require("../utils/globals.js");
13
+ let ___utils_http_js = require("../utils/http.js");
14
+ let ___utils_promises_js = require("../utils/promises.js");
15
+
16
+ //#region ../../node_modules/.pnpm/oauth4webapi@3.8.3/node_modules/oauth4webapi/build/index.js
17
+ let USER_AGENT;
18
+ if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) USER_AGENT = `oauth4webapi/v3.8.3`;
19
+ function looseInstanceOf(input, expected) {
20
+ if (input == null) return false;
21
+ try {
22
+ return input instanceof expected || Object.getPrototypeOf(input)[Symbol.toStringTag] === expected.prototype[Symbol.toStringTag];
23
+ } catch {
24
+ return false;
25
+ }
26
+ }
27
+ const ERR_INVALID_ARG_VALUE = "ERR_INVALID_ARG_VALUE";
28
+ const ERR_INVALID_ARG_TYPE = "ERR_INVALID_ARG_TYPE";
29
+ function CodedTypeError(message, code, cause) {
30
+ const err = new TypeError(message, { cause });
31
+ Object.assign(err, { code });
32
+ return err;
33
+ }
34
+ const allowInsecureRequests = Symbol();
35
+ const clockSkew = Symbol();
36
+ const clockTolerance = Symbol();
37
+ const customFetch = Symbol();
38
+ const jweDecrypt = Symbol();
39
+ const encoder = new TextEncoder();
40
+ const decoder = new TextDecoder();
41
+ function buf(input) {
42
+ if (typeof input === "string") return encoder.encode(input);
43
+ return decoder.decode(input);
44
+ }
45
+ let encodeBase64Url;
46
+ if (Uint8Array.prototype.toBase64) encodeBase64Url = (input) => {
47
+ if (input instanceof ArrayBuffer) input = new Uint8Array(input);
48
+ return input.toBase64({
49
+ alphabet: "base64url",
50
+ omitPadding: true
51
+ });
52
+ };
53
+ else {
54
+ const CHUNK_SIZE = 32768;
55
+ encodeBase64Url = (input) => {
56
+ if (input instanceof ArrayBuffer) input = new Uint8Array(input);
57
+ const arr = [];
58
+ for (let i = 0; i < input.byteLength; i += CHUNK_SIZE) arr.push(String.fromCharCode.apply(null, input.subarray(i, i + CHUNK_SIZE)));
59
+ return btoa(arr.join("")).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
60
+ };
61
+ }
62
+ let decodeBase64Url;
63
+ if (Uint8Array.fromBase64) decodeBase64Url = (input) => {
64
+ try {
65
+ return Uint8Array.fromBase64(input, { alphabet: "base64url" });
66
+ } catch (cause) {
67
+ throw CodedTypeError("The input to be decoded is not correctly encoded.", ERR_INVALID_ARG_VALUE, cause);
68
+ }
69
+ };
70
+ else decodeBase64Url = (input) => {
71
+ try {
72
+ const binary = atob(input.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, ""));
73
+ const bytes = new Uint8Array(binary.length);
74
+ for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
75
+ return bytes;
76
+ } catch (cause) {
77
+ throw CodedTypeError("The input to be decoded is not correctly encoded.", ERR_INVALID_ARG_VALUE, cause);
78
+ }
79
+ };
80
+ function b64u(input) {
81
+ if (typeof input === "string") return decodeBase64Url(input);
82
+ return encodeBase64Url(input);
83
+ }
84
+ var UnsupportedOperationError = class extends Error {
85
+ code;
86
+ constructor(message, options) {
87
+ super(message, options);
88
+ this.name = this.constructor.name;
89
+ this.code = UNSUPPORTED_OPERATION;
90
+ Error.captureStackTrace?.(this, this.constructor);
91
+ }
92
+ };
93
+ var OperationProcessingError = class extends Error {
94
+ code;
95
+ constructor(message, options) {
96
+ super(message, options);
97
+ this.name = this.constructor.name;
98
+ if (options?.code) this.code = options?.code;
99
+ Error.captureStackTrace?.(this, this.constructor);
100
+ }
101
+ };
102
+ function OPE(message, code, cause) {
103
+ return new OperationProcessingError(message, {
104
+ code,
105
+ cause
106
+ });
107
+ }
108
+ function isJsonObject(input) {
109
+ if (input === null || typeof input !== "object" || Array.isArray(input)) return false;
110
+ return true;
111
+ }
112
+ function prepareHeaders(input) {
113
+ if (looseInstanceOf(input, Headers)) input = Object.fromEntries(input.entries());
114
+ const headers = new Headers(input ?? {});
115
+ if (USER_AGENT && !headers.has("user-agent")) headers.set("user-agent", USER_AGENT);
116
+ if (headers.has("authorization")) throw CodedTypeError("\"options.headers\" must not include the \"authorization\" header name", ERR_INVALID_ARG_VALUE);
117
+ return headers;
118
+ }
119
+ function signal(url, value) {
120
+ if (value !== void 0) {
121
+ if (typeof value === "function") value = value(url.href);
122
+ if (!(value instanceof AbortSignal)) throw CodedTypeError("\"options.signal\" must return or be an instance of AbortSignal", ERR_INVALID_ARG_TYPE);
123
+ return value;
124
+ }
125
+ }
126
+ function assertNumber(input, allow0, it, code, cause) {
127
+ try {
128
+ if (typeof input !== "number" || !Number.isFinite(input)) throw CodedTypeError(`${it} must be a number`, ERR_INVALID_ARG_TYPE, cause);
129
+ if (input > 0) return;
130
+ if (allow0) {
131
+ if (input !== 0) throw CodedTypeError(`${it} must be a non-negative number`, ERR_INVALID_ARG_VALUE, cause);
132
+ return;
133
+ }
134
+ throw CodedTypeError(`${it} must be a positive number`, ERR_INVALID_ARG_VALUE, cause);
135
+ } catch (err) {
136
+ if (code) throw OPE(err.message, code, cause);
137
+ throw err;
138
+ }
139
+ }
140
+ function assertString(input, it, code, cause) {
141
+ try {
142
+ if (typeof input !== "string") throw CodedTypeError(`${it} must be a string`, ERR_INVALID_ARG_TYPE, cause);
143
+ if (input.length === 0) throw CodedTypeError(`${it} must not be empty`, ERR_INVALID_ARG_VALUE, cause);
144
+ } catch (err) {
145
+ if (code) throw OPE(err.message, code, cause);
146
+ throw err;
147
+ }
148
+ }
149
+ function assertApplicationJson(response) {
150
+ assertContentType(response, "application/json");
151
+ }
152
+ function notJson(response, ...types) {
153
+ let msg = "\"response\" content-type must be ";
154
+ if (types.length > 2) {
155
+ const last = types.pop();
156
+ msg += `${types.join(", ")}, or ${last}`;
157
+ } else if (types.length === 2) msg += `${types[0]} or ${types[1]}`;
158
+ else msg += types[0];
159
+ return OPE(msg, RESPONSE_IS_NOT_JSON, response);
160
+ }
161
+ function assertContentType(response, contentType) {
162
+ if (getContentType(response) !== contentType) throw notJson(response, contentType);
163
+ }
164
+ function getClockSkew(client) {
165
+ const skew = client?.[clockSkew];
166
+ return typeof skew === "number" && Number.isFinite(skew) ? skew : 0;
167
+ }
168
+ function getClockTolerance(client) {
169
+ const tolerance = client?.[clockTolerance];
170
+ return typeof tolerance === "number" && Number.isFinite(tolerance) && Math.sign(tolerance) !== -1 ? tolerance : 30;
171
+ }
172
+ function epochTime() {
173
+ return Math.floor(Date.now() / 1e3);
174
+ }
175
+ function assertAs(as) {
176
+ if (typeof as !== "object" || as === null) throw CodedTypeError("\"as\" must be an object", ERR_INVALID_ARG_TYPE);
177
+ assertString(as.issuer, "\"as.issuer\"");
178
+ }
179
+ function assertClient(client) {
180
+ if (typeof client !== "object" || client === null) throw CodedTypeError("\"client\" must be an object", ERR_INVALID_ARG_TYPE);
181
+ assertString(client.client_id, "\"client.client_id\"");
182
+ }
183
+ function ClientSecretPost(clientSecret) {
184
+ assertString(clientSecret, "\"clientSecret\"");
185
+ return (_as, client, body, _headers) => {
186
+ body.set("client_id", client.client_id);
187
+ body.set("client_secret", clientSecret);
188
+ };
189
+ }
190
+ const URLParse = URL.parse ? (url, base) => URL.parse(url, base) : (url, base) => {
191
+ try {
192
+ return new URL(url, base);
193
+ } catch {
194
+ return null;
195
+ }
196
+ };
197
+ function checkProtocol(url, enforceHttps) {
198
+ if (enforceHttps && url.protocol !== "https:") throw OPE("only requests to HTTPS are allowed", HTTP_REQUEST_FORBIDDEN, url);
199
+ if (url.protocol !== "https:" && url.protocol !== "http:") throw OPE("only HTTP and HTTPS requests are allowed", REQUEST_PROTOCOL_FORBIDDEN, url);
200
+ }
201
+ function validateEndpoint(value, endpoint, useMtlsAlias, enforceHttps) {
202
+ let url;
203
+ if (typeof value !== "string" || !(url = URLParse(value))) throw OPE(`authorization server metadata does not contain a valid ${useMtlsAlias ? `"as.mtls_endpoint_aliases.${endpoint}"` : `"as.${endpoint}"`}`, value === void 0 ? MISSING_SERVER_METADATA : INVALID_SERVER_METADATA, { attribute: useMtlsAlias ? `mtls_endpoint_aliases.${endpoint}` : endpoint });
204
+ checkProtocol(url, enforceHttps);
205
+ return url;
206
+ }
207
+ function resolveEndpoint(as, endpoint, useMtlsAlias, enforceHttps) {
208
+ if (useMtlsAlias && as.mtls_endpoint_aliases && endpoint in as.mtls_endpoint_aliases) return validateEndpoint(as.mtls_endpoint_aliases[endpoint], endpoint, useMtlsAlias, enforceHttps);
209
+ return validateEndpoint(as[endpoint], endpoint, useMtlsAlias, enforceHttps);
210
+ }
211
+ var ResponseBodyError = class extends Error {
212
+ cause;
213
+ code;
214
+ error;
215
+ status;
216
+ error_description;
217
+ response;
218
+ constructor(message, options) {
219
+ super(message, options);
220
+ this.name = this.constructor.name;
221
+ this.code = RESPONSE_BODY_ERROR;
222
+ this.cause = options.cause;
223
+ this.error = options.cause.error;
224
+ this.status = options.response.status;
225
+ this.error_description = options.cause.error_description;
226
+ Object.defineProperty(this, "response", {
227
+ enumerable: false,
228
+ value: options.response
229
+ });
230
+ Error.captureStackTrace?.(this, this.constructor);
231
+ }
232
+ };
233
+ var AuthorizationResponseError = class extends Error {
234
+ cause;
235
+ code;
236
+ error;
237
+ error_description;
238
+ constructor(message, options) {
239
+ super(message, options);
240
+ this.name = this.constructor.name;
241
+ this.code = AUTHORIZATION_RESPONSE_ERROR;
242
+ this.cause = options.cause;
243
+ this.error = options.cause.get("error");
244
+ this.error_description = options.cause.get("error_description") ?? void 0;
245
+ Error.captureStackTrace?.(this, this.constructor);
246
+ }
247
+ };
248
+ var WWWAuthenticateChallengeError = class extends Error {
249
+ cause;
250
+ code;
251
+ response;
252
+ status;
253
+ constructor(message, options) {
254
+ super(message, options);
255
+ this.name = this.constructor.name;
256
+ this.code = WWW_AUTHENTICATE_CHALLENGE;
257
+ this.cause = options.cause;
258
+ this.status = options.response.status;
259
+ this.response = options.response;
260
+ Object.defineProperty(this, "response", { enumerable: false });
261
+ Error.captureStackTrace?.(this, this.constructor);
262
+ }
263
+ };
264
+ const tokenMatch = "[a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+";
265
+ const token68Match = "[a-zA-Z0-9\\-\\._\\~\\+\\/]+={0,2}";
266
+ const quotedParamMatcher = "(" + tokenMatch + ")\\s*=\\s*\"((?:[^\"\\\\]|\\\\[\\s\\S])*)\"";
267
+ const paramMatcher = "(" + tokenMatch + ")\\s*=\\s*([a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+)";
268
+ const schemeRE = new RegExp("^[,\\s]*(" + tokenMatch + ")");
269
+ const quotedParamRE = new RegExp("^[,\\s]*" + quotedParamMatcher + "[,\\s]*(.*)");
270
+ const unquotedParamRE = new RegExp("^[,\\s]*" + paramMatcher + "[,\\s]*(.*)");
271
+ const token68ParamRE = new RegExp("^(" + token68Match + ")(?:$|[,\\s])(.*)");
272
+ function parseWwwAuthenticateChallenges(response) {
273
+ if (!looseInstanceOf(response, Response)) throw CodedTypeError("\"response\" must be an instance of Response", ERR_INVALID_ARG_TYPE);
274
+ const header = response.headers.get("www-authenticate");
275
+ if (header === null) return;
276
+ const challenges = [];
277
+ let rest = header;
278
+ while (rest) {
279
+ let match = rest.match(schemeRE);
280
+ const scheme = match?.["1"].toLowerCase();
281
+ if (!scheme) return;
282
+ const afterScheme = rest.substring(match[0].length);
283
+ if (afterScheme && !afterScheme.match(/^[\s,]/)) return;
284
+ const spaceMatch = afterScheme.match(/^\s+(.*)$/);
285
+ const hasParameters = !!spaceMatch;
286
+ rest = spaceMatch ? spaceMatch[1] : void 0;
287
+ const parameters = {};
288
+ let token68;
289
+ if (hasParameters) while (rest) {
290
+ let key;
291
+ let value;
292
+ if (match = rest.match(quotedParamRE)) {
293
+ [, key, value, rest] = match;
294
+ if (value.includes("\\")) try {
295
+ value = JSON.parse(`"${value}"`);
296
+ } catch {}
297
+ parameters[key.toLowerCase()] = value;
298
+ continue;
299
+ }
300
+ if (match = rest.match(unquotedParamRE)) {
301
+ [, key, value, rest] = match;
302
+ parameters[key.toLowerCase()] = value;
303
+ continue;
304
+ }
305
+ if (match = rest.match(token68ParamRE)) {
306
+ if (Object.keys(parameters).length) break;
307
+ [, token68, rest] = match;
308
+ break;
309
+ }
310
+ return;
311
+ }
312
+ else rest = afterScheme || void 0;
313
+ const challenge = {
314
+ scheme,
315
+ parameters
316
+ };
317
+ if (token68) challenge.token68 = token68;
318
+ challenges.push(challenge);
319
+ }
320
+ if (!challenges.length) return;
321
+ return challenges;
322
+ }
323
+ async function parseOAuthResponseErrorBody(response) {
324
+ if (response.status > 399 && response.status < 500) {
325
+ assertReadableResponse(response);
326
+ assertApplicationJson(response);
327
+ try {
328
+ const json = await response.clone().json();
329
+ if (isJsonObject(json) && typeof json.error === "string" && json.error.length) return json;
330
+ } catch {}
331
+ }
332
+ }
333
+ async function checkOAuthBodyError(response, expected, label) {
334
+ if (response.status !== expected) {
335
+ checkAuthenticationChallenges(response);
336
+ let err;
337
+ if (err = await parseOAuthResponseErrorBody(response)) {
338
+ await response.body?.cancel();
339
+ throw new ResponseBodyError("server responded with an error in the response body", {
340
+ cause: err,
341
+ response
342
+ });
343
+ }
344
+ throw OPE(`"response" is not a conform ${label} response (unexpected HTTP status code)`, RESPONSE_IS_NOT_CONFORM, response);
345
+ }
346
+ }
347
+ function assertDPoP(option) {
348
+ if (!branded.has(option)) throw CodedTypeError("\"options.DPoP\" is not a valid DPoPHandle", ERR_INVALID_ARG_VALUE);
349
+ }
350
+ function getContentType(input) {
351
+ return input.headers.get("content-type")?.split(";")[0];
352
+ }
353
+ async function authenticatedRequest(as, client, clientAuthentication, url, body, headers, options) {
354
+ await clientAuthentication(as, client, body, headers);
355
+ headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8");
356
+ return (options?.[customFetch] || fetch)(url.href, {
357
+ body,
358
+ headers: Object.fromEntries(headers.entries()),
359
+ method: "POST",
360
+ redirect: "manual",
361
+ signal: signal(url, options?.signal)
362
+ });
363
+ }
364
+ async function tokenEndpointRequest(as, client, clientAuthentication, grantType, parameters, options) {
365
+ const url = resolveEndpoint(as, "token_endpoint", client.use_mtls_endpoint_aliases, options?.[allowInsecureRequests] !== true);
366
+ parameters.set("grant_type", grantType);
367
+ const headers = prepareHeaders(options?.headers);
368
+ headers.set("accept", "application/json");
369
+ if (options?.DPoP !== void 0) {
370
+ assertDPoP(options.DPoP);
371
+ await options.DPoP.addProof(url, headers, "POST");
372
+ }
373
+ const response = await authenticatedRequest(as, client, clientAuthentication, url, parameters, headers, options);
374
+ options?.DPoP?.cacheNonce(response, url);
375
+ return response;
376
+ }
377
+ async function refreshTokenGrantRequest(as, client, clientAuthentication, refreshToken, options) {
378
+ assertAs(as);
379
+ assertClient(client);
380
+ assertString(refreshToken, "\"refreshToken\"");
381
+ const parameters = new URLSearchParams(options?.additionalParameters);
382
+ parameters.set("refresh_token", refreshToken);
383
+ return tokenEndpointRequest(as, client, clientAuthentication, "refresh_token", parameters, options);
384
+ }
385
+ const idTokenClaims = /* @__PURE__ */ new WeakMap();
386
+ const jwtRefs = /* @__PURE__ */ new WeakMap();
387
+ function getValidatedIdTokenClaims(ref) {
388
+ if (!ref.id_token) return;
389
+ const claims = idTokenClaims.get(ref);
390
+ if (!claims) throw CodedTypeError("\"ref\" was already garbage collected or did not resolve from the proper sources", ERR_INVALID_ARG_VALUE);
391
+ return claims;
392
+ }
393
+ async function processGenericAccessTokenResponse(as, client, response, additionalRequiredIdTokenClaims, decryptFn, recognizedTokenTypes) {
394
+ assertAs(as);
395
+ assertClient(client);
396
+ if (!looseInstanceOf(response, Response)) throw CodedTypeError("\"response\" must be an instance of Response", ERR_INVALID_ARG_TYPE);
397
+ await checkOAuthBodyError(response, 200, "Token Endpoint");
398
+ assertReadableResponse(response);
399
+ const json = await getResponseJsonBody(response);
400
+ assertString(json.access_token, "\"response\" body \"access_token\" property", INVALID_RESPONSE, { body: json });
401
+ assertString(json.token_type, "\"response\" body \"token_type\" property", INVALID_RESPONSE, { body: json });
402
+ json.token_type = json.token_type.toLowerCase();
403
+ if (json.expires_in !== void 0) {
404
+ let expiresIn = typeof json.expires_in !== "number" ? parseFloat(json.expires_in) : json.expires_in;
405
+ assertNumber(expiresIn, true, "\"response\" body \"expires_in\" property", INVALID_RESPONSE, { body: json });
406
+ json.expires_in = expiresIn;
407
+ }
408
+ if (json.refresh_token !== void 0) assertString(json.refresh_token, "\"response\" body \"refresh_token\" property", INVALID_RESPONSE, { body: json });
409
+ if (json.scope !== void 0 && typeof json.scope !== "string") throw OPE("\"response\" body \"scope\" property must be a string", INVALID_RESPONSE, { body: json });
410
+ if (json.id_token !== void 0) {
411
+ assertString(json.id_token, "\"response\" body \"id_token\" property", INVALID_RESPONSE, { body: json });
412
+ const requiredClaims = [
413
+ "aud",
414
+ "exp",
415
+ "iat",
416
+ "iss",
417
+ "sub"
418
+ ];
419
+ if (client.require_auth_time === true) requiredClaims.push("auth_time");
420
+ if (client.default_max_age !== void 0) {
421
+ assertNumber(client.default_max_age, true, "\"client.default_max_age\"");
422
+ requiredClaims.push("auth_time");
423
+ }
424
+ if (additionalRequiredIdTokenClaims?.length) requiredClaims.push(...additionalRequiredIdTokenClaims);
425
+ const { claims, jwt } = await validateJwt(json.id_token, checkSigningAlgorithm.bind(void 0, client.id_token_signed_response_alg, as.id_token_signing_alg_values_supported, "RS256"), getClockSkew(client), getClockTolerance(client), decryptFn).then(validatePresence.bind(void 0, requiredClaims)).then(validateIssuer.bind(void 0, as)).then(validateAudience.bind(void 0, client.client_id));
426
+ if (Array.isArray(claims.aud) && claims.aud.length !== 1) {
427
+ if (claims.azp === void 0) throw OPE("ID Token \"aud\" (audience) claim includes additional untrusted audiences", JWT_CLAIM_COMPARISON, {
428
+ claims,
429
+ claim: "aud"
430
+ });
431
+ if (claims.azp !== client.client_id) throw OPE("unexpected ID Token \"azp\" (authorized party) claim value", JWT_CLAIM_COMPARISON, {
432
+ expected: client.client_id,
433
+ claims,
434
+ claim: "azp"
435
+ });
436
+ }
437
+ if (claims.auth_time !== void 0) assertNumber(claims.auth_time, true, "ID Token \"auth_time\" (authentication time)", INVALID_RESPONSE, { claims });
438
+ jwtRefs.set(response, jwt);
439
+ idTokenClaims.set(json, claims);
440
+ }
441
+ if (recognizedTokenTypes?.[json.token_type] !== void 0) recognizedTokenTypes[json.token_type](response, json);
442
+ else if (json.token_type !== "dpop" && json.token_type !== "bearer") throw new UnsupportedOperationError("unsupported `token_type` value", { cause: { body: json } });
443
+ return json;
444
+ }
445
+ function checkAuthenticationChallenges(response) {
446
+ let challenges;
447
+ if (challenges = parseWwwAuthenticateChallenges(response)) throw new WWWAuthenticateChallengeError("server responded with a challenge in the WWW-Authenticate HTTP Header", {
448
+ cause: challenges,
449
+ response
450
+ });
451
+ }
452
+ async function processRefreshTokenResponse(as, client, response, options) {
453
+ return processGenericAccessTokenResponse(as, client, response, void 0, options?.[jweDecrypt], options?.recognizedTokenTypes);
454
+ }
455
+ function validateAudience(expected, result) {
456
+ if (Array.isArray(result.claims.aud)) {
457
+ if (!result.claims.aud.includes(expected)) throw OPE("unexpected JWT \"aud\" (audience) claim value", JWT_CLAIM_COMPARISON, {
458
+ expected,
459
+ claims: result.claims,
460
+ claim: "aud"
461
+ });
462
+ } else if (result.claims.aud !== expected) throw OPE("unexpected JWT \"aud\" (audience) claim value", JWT_CLAIM_COMPARISON, {
463
+ expected,
464
+ claims: result.claims,
465
+ claim: "aud"
466
+ });
467
+ return result;
468
+ }
469
+ function validateIssuer(as, result) {
470
+ const expected = as[_expectedIssuer]?.(result) ?? as.issuer;
471
+ if (result.claims.iss !== expected) throw OPE("unexpected JWT \"iss\" (issuer) claim value", JWT_CLAIM_COMPARISON, {
472
+ expected,
473
+ claims: result.claims,
474
+ claim: "iss"
475
+ });
476
+ return result;
477
+ }
478
+ const branded = /* @__PURE__ */ new WeakSet();
479
+ function brand(searchParams) {
480
+ branded.add(searchParams);
481
+ return searchParams;
482
+ }
483
+ const nopkce = Symbol();
484
+ async function authorizationCodeGrantRequest(as, client, clientAuthentication, callbackParameters, redirectUri, codeVerifier, options) {
485
+ assertAs(as);
486
+ assertClient(client);
487
+ if (!branded.has(callbackParameters)) throw CodedTypeError("\"callbackParameters\" must be an instance of URLSearchParams obtained from \"validateAuthResponse()\", or \"validateJwtAuthResponse()", ERR_INVALID_ARG_VALUE);
488
+ assertString(redirectUri, "\"redirectUri\"");
489
+ const code = getURLSearchParameter(callbackParameters, "code");
490
+ if (!code) throw OPE("no authorization code in \"callbackParameters\"", INVALID_RESPONSE);
491
+ const parameters = new URLSearchParams(options?.additionalParameters);
492
+ parameters.set("redirect_uri", redirectUri);
493
+ parameters.set("code", code);
494
+ if (codeVerifier !== nopkce) {
495
+ assertString(codeVerifier, "\"codeVerifier\"");
496
+ parameters.set("code_verifier", codeVerifier);
497
+ }
498
+ return tokenEndpointRequest(as, client, clientAuthentication, "authorization_code", parameters, options);
499
+ }
500
+ const jwtClaimNames = {
501
+ aud: "audience",
502
+ c_hash: "code hash",
503
+ client_id: "client id",
504
+ exp: "expiration time",
505
+ iat: "issued at",
506
+ iss: "issuer",
507
+ jti: "jwt id",
508
+ nonce: "nonce",
509
+ s_hash: "state hash",
510
+ sub: "subject",
511
+ ath: "access token hash",
512
+ htm: "http method",
513
+ htu: "http uri",
514
+ cnf: "confirmation",
515
+ auth_time: "authentication time"
516
+ };
517
+ function validatePresence(required, result) {
518
+ for (const claim of required) if (result.claims[claim] === void 0) throw OPE(`JWT "${claim}" (${jwtClaimNames[claim]}) claim missing`, INVALID_RESPONSE, { claims: result.claims });
519
+ return result;
520
+ }
521
+ const expectNoNonce = Symbol();
522
+ const skipAuthTimeCheck = Symbol();
523
+ async function processAuthorizationCodeResponse(as, client, response, options) {
524
+ if (typeof options?.expectedNonce === "string" || typeof options?.maxAge === "number" || options?.requireIdToken) return processAuthorizationCodeOpenIDResponse(as, client, response, options.expectedNonce, options.maxAge, options[jweDecrypt], options.recognizedTokenTypes);
525
+ return processAuthorizationCodeOAuth2Response(as, client, response, options?.[jweDecrypt], options?.recognizedTokenTypes);
526
+ }
527
+ async function processAuthorizationCodeOpenIDResponse(as, client, response, expectedNonce, maxAge, decryptFn, recognizedTokenTypes) {
528
+ const additionalRequiredClaims = [];
529
+ switch (expectedNonce) {
530
+ case void 0:
531
+ expectedNonce = expectNoNonce;
532
+ break;
533
+ case expectNoNonce: break;
534
+ default:
535
+ assertString(expectedNonce, "\"expectedNonce\" argument");
536
+ additionalRequiredClaims.push("nonce");
537
+ }
538
+ maxAge ??= client.default_max_age;
539
+ switch (maxAge) {
540
+ case void 0:
541
+ maxAge = skipAuthTimeCheck;
542
+ break;
543
+ case skipAuthTimeCheck: break;
544
+ default:
545
+ assertNumber(maxAge, true, "\"maxAge\" argument");
546
+ additionalRequiredClaims.push("auth_time");
547
+ }
548
+ const result = await processGenericAccessTokenResponse(as, client, response, additionalRequiredClaims, decryptFn, recognizedTokenTypes);
549
+ assertString(result.id_token, "\"response\" body \"id_token\" property", INVALID_RESPONSE, { body: result });
550
+ const claims = getValidatedIdTokenClaims(result);
551
+ if (maxAge !== skipAuthTimeCheck) {
552
+ const now = epochTime() + getClockSkew(client);
553
+ const tolerance = getClockTolerance(client);
554
+ if (claims.auth_time + maxAge < now - tolerance) throw OPE("too much time has elapsed since the last End-User authentication", JWT_TIMESTAMP_CHECK, {
555
+ claims,
556
+ now,
557
+ tolerance,
558
+ claim: "auth_time"
559
+ });
560
+ }
561
+ if (expectedNonce === expectNoNonce) {
562
+ if (claims.nonce !== void 0) throw OPE("unexpected ID Token \"nonce\" claim value", JWT_CLAIM_COMPARISON, {
563
+ expected: void 0,
564
+ claims,
565
+ claim: "nonce"
566
+ });
567
+ } else if (claims.nonce !== expectedNonce) throw OPE("unexpected ID Token \"nonce\" claim value", JWT_CLAIM_COMPARISON, {
568
+ expected: expectedNonce,
569
+ claims,
570
+ claim: "nonce"
571
+ });
572
+ return result;
573
+ }
574
+ async function processAuthorizationCodeOAuth2Response(as, client, response, decryptFn, recognizedTokenTypes) {
575
+ const result = await processGenericAccessTokenResponse(as, client, response, void 0, decryptFn, recognizedTokenTypes);
576
+ const claims = getValidatedIdTokenClaims(result);
577
+ if (claims) {
578
+ if (client.default_max_age !== void 0) {
579
+ assertNumber(client.default_max_age, true, "\"client.default_max_age\"");
580
+ const now = epochTime() + getClockSkew(client);
581
+ const tolerance = getClockTolerance(client);
582
+ if (claims.auth_time + client.default_max_age < now - tolerance) throw OPE("too much time has elapsed since the last End-User authentication", JWT_TIMESTAMP_CHECK, {
583
+ claims,
584
+ now,
585
+ tolerance,
586
+ claim: "auth_time"
587
+ });
588
+ }
589
+ if (claims.nonce !== void 0) throw OPE("unexpected ID Token \"nonce\" claim value", JWT_CLAIM_COMPARISON, {
590
+ expected: void 0,
591
+ claims,
592
+ claim: "nonce"
593
+ });
594
+ }
595
+ return result;
596
+ }
597
+ const WWW_AUTHENTICATE_CHALLENGE = "OAUTH_WWW_AUTHENTICATE_CHALLENGE";
598
+ const RESPONSE_BODY_ERROR = "OAUTH_RESPONSE_BODY_ERROR";
599
+ const UNSUPPORTED_OPERATION = "OAUTH_UNSUPPORTED_OPERATION";
600
+ const AUTHORIZATION_RESPONSE_ERROR = "OAUTH_AUTHORIZATION_RESPONSE_ERROR";
601
+ const PARSE_ERROR = "OAUTH_PARSE_ERROR";
602
+ const INVALID_RESPONSE = "OAUTH_INVALID_RESPONSE";
603
+ const RESPONSE_IS_NOT_JSON = "OAUTH_RESPONSE_IS_NOT_JSON";
604
+ const RESPONSE_IS_NOT_CONFORM = "OAUTH_RESPONSE_IS_NOT_CONFORM";
605
+ const HTTP_REQUEST_FORBIDDEN = "OAUTH_HTTP_REQUEST_FORBIDDEN";
606
+ const REQUEST_PROTOCOL_FORBIDDEN = "OAUTH_REQUEST_PROTOCOL_FORBIDDEN";
607
+ const JWT_TIMESTAMP_CHECK = "OAUTH_JWT_TIMESTAMP_CHECK_FAILED";
608
+ const JWT_CLAIM_COMPARISON = "OAUTH_JWT_CLAIM_COMPARISON_FAILED";
609
+ const MISSING_SERVER_METADATA = "OAUTH_MISSING_SERVER_METADATA";
610
+ const INVALID_SERVER_METADATA = "OAUTH_INVALID_SERVER_METADATA";
611
+ function assertReadableResponse(response) {
612
+ if (response.bodyUsed) throw CodedTypeError("\"response\" body has been used already", ERR_INVALID_ARG_VALUE);
613
+ }
614
+ async function validateJwt(jws, checkAlg, clockSkew, clockTolerance, decryptJwt) {
615
+ let { 0: protectedHeader, 1: payload, length } = jws.split(".");
616
+ if (length === 5) if (decryptJwt !== void 0) {
617
+ jws = await decryptJwt(jws);
618
+ ({0: protectedHeader, 1: payload, length} = jws.split("."));
619
+ } else throw new UnsupportedOperationError("JWE decryption is not configured", { cause: jws });
620
+ if (length !== 3) throw OPE("Invalid JWT", INVALID_RESPONSE, jws);
621
+ let header;
622
+ try {
623
+ header = JSON.parse(buf(b64u(protectedHeader)));
624
+ } catch (cause) {
625
+ throw OPE("failed to parse JWT Header body as base64url encoded JSON", PARSE_ERROR, cause);
626
+ }
627
+ if (!isJsonObject(header)) throw OPE("JWT Header must be a top level object", INVALID_RESPONSE, jws);
628
+ checkAlg(header);
629
+ if (header.crit !== void 0) throw new UnsupportedOperationError("no JWT \"crit\" header parameter extensions are supported", { cause: { header } });
630
+ let claims;
631
+ try {
632
+ claims = JSON.parse(buf(b64u(payload)));
633
+ } catch (cause) {
634
+ throw OPE("failed to parse JWT Payload body as base64url encoded JSON", PARSE_ERROR, cause);
635
+ }
636
+ if (!isJsonObject(claims)) throw OPE("JWT Payload must be a top level object", INVALID_RESPONSE, jws);
637
+ const now = epochTime() + clockSkew;
638
+ if (claims.exp !== void 0) {
639
+ if (typeof claims.exp !== "number") throw OPE("unexpected JWT \"exp\" (expiration time) claim type", INVALID_RESPONSE, { claims });
640
+ if (claims.exp <= now - clockTolerance) throw OPE("unexpected JWT \"exp\" (expiration time) claim value, expiration is past current timestamp", JWT_TIMESTAMP_CHECK, {
641
+ claims,
642
+ now,
643
+ tolerance: clockTolerance,
644
+ claim: "exp"
645
+ });
646
+ }
647
+ if (claims.iat !== void 0) {
648
+ if (typeof claims.iat !== "number") throw OPE("unexpected JWT \"iat\" (issued at) claim type", INVALID_RESPONSE, { claims });
649
+ }
650
+ if (claims.iss !== void 0) {
651
+ if (typeof claims.iss !== "string") throw OPE("unexpected JWT \"iss\" (issuer) claim type", INVALID_RESPONSE, { claims });
652
+ }
653
+ if (claims.nbf !== void 0) {
654
+ if (typeof claims.nbf !== "number") throw OPE("unexpected JWT \"nbf\" (not before) claim type", INVALID_RESPONSE, { claims });
655
+ if (claims.nbf > now + clockTolerance) throw OPE("unexpected JWT \"nbf\" (not before) claim value", JWT_TIMESTAMP_CHECK, {
656
+ claims,
657
+ now,
658
+ tolerance: clockTolerance,
659
+ claim: "nbf"
660
+ });
661
+ }
662
+ if (claims.aud !== void 0) {
663
+ if (typeof claims.aud !== "string" && !Array.isArray(claims.aud)) throw OPE("unexpected JWT \"aud\" (audience) claim type", INVALID_RESPONSE, { claims });
664
+ }
665
+ return {
666
+ header,
667
+ claims,
668
+ jwt: jws
669
+ };
670
+ }
671
+ function checkSigningAlgorithm(client, issuer, fallback, header) {
672
+ if (client !== void 0) {
673
+ if (typeof client === "string" ? header.alg !== client : !client.includes(header.alg)) throw OPE("unexpected JWT \"alg\" header parameter", INVALID_RESPONSE, {
674
+ header,
675
+ expected: client,
676
+ reason: "client configuration"
677
+ });
678
+ return;
679
+ }
680
+ if (Array.isArray(issuer)) {
681
+ if (!issuer.includes(header.alg)) throw OPE("unexpected JWT \"alg\" header parameter", INVALID_RESPONSE, {
682
+ header,
683
+ expected: issuer,
684
+ reason: "authorization server metadata"
685
+ });
686
+ return;
687
+ }
688
+ if (fallback !== void 0) {
689
+ if (typeof fallback === "string" ? header.alg !== fallback : typeof fallback === "function" ? !fallback(header.alg) : !fallback.includes(header.alg)) throw OPE("unexpected JWT \"alg\" header parameter", INVALID_RESPONSE, {
690
+ header,
691
+ expected: fallback,
692
+ reason: "default value"
693
+ });
694
+ return;
695
+ }
696
+ throw OPE("missing client or server configuration to verify used JWT \"alg\" header parameter", void 0, {
697
+ client,
698
+ issuer,
699
+ fallback
700
+ });
701
+ }
702
+ function getURLSearchParameter(parameters, name) {
703
+ const { 0: value, length } = parameters.getAll(name);
704
+ if (length > 1) throw OPE(`"${name}" parameter must be provided only once`, INVALID_RESPONSE);
705
+ return value;
706
+ }
707
+ const skipStateCheck = Symbol();
708
+ const expectNoState = Symbol();
709
+ function validateAuthResponse(as, client, parameters, expectedState) {
710
+ assertAs(as);
711
+ assertClient(client);
712
+ if (parameters instanceof URL) parameters = parameters.searchParams;
713
+ if (!(parameters instanceof URLSearchParams)) throw CodedTypeError("\"parameters\" must be an instance of URLSearchParams, or URL", ERR_INVALID_ARG_TYPE);
714
+ if (getURLSearchParameter(parameters, "response")) throw OPE("\"parameters\" contains a JARM response, use validateJwtAuthResponse() instead of validateAuthResponse()", INVALID_RESPONSE, { parameters });
715
+ const iss = getURLSearchParameter(parameters, "iss");
716
+ const state = getURLSearchParameter(parameters, "state");
717
+ if (!iss && as.authorization_response_iss_parameter_supported) throw OPE("response parameter \"iss\" (issuer) missing", INVALID_RESPONSE, { parameters });
718
+ if (iss && iss !== as.issuer) throw OPE("unexpected \"iss\" (issuer) response parameter value", INVALID_RESPONSE, {
719
+ expected: as.issuer,
720
+ parameters
721
+ });
722
+ switch (expectedState) {
723
+ case void 0:
724
+ case expectNoState:
725
+ if (state !== void 0) throw OPE("unexpected \"state\" response parameter encountered", INVALID_RESPONSE, {
726
+ expected: void 0,
727
+ parameters
728
+ });
729
+ break;
730
+ case skipStateCheck: break;
731
+ default:
732
+ assertString(expectedState, "\"expectedState\" argument");
733
+ if (state !== expectedState) throw OPE(state === void 0 ? "response parameter \"state\" missing" : "unexpected \"state\" response parameter value", INVALID_RESPONSE, {
734
+ expected: expectedState,
735
+ parameters
736
+ });
737
+ }
738
+ if (getURLSearchParameter(parameters, "error")) throw new AuthorizationResponseError("authorization response from the server is an error", { cause: parameters });
739
+ const id_token = getURLSearchParameter(parameters, "id_token");
740
+ const token = getURLSearchParameter(parameters, "token");
741
+ if (id_token !== void 0 || token !== void 0) throw new UnsupportedOperationError("implicit and hybrid flows are not supported");
742
+ return brand(new URLSearchParams(parameters));
743
+ }
744
+ async function getResponseJsonBody(response, check = assertApplicationJson) {
745
+ let json;
746
+ try {
747
+ json = await response.json();
748
+ } catch (cause) {
749
+ check(response);
750
+ throw OPE("failed to parse \"response\" body as JSON", PARSE_ERROR, cause);
751
+ }
752
+ if (!isJsonObject(json)) throw OPE("\"response\" body must be a top level object", INVALID_RESPONSE, { body: json });
753
+ return json;
754
+ }
755
+ const _expectedIssuer = Symbol();
756
+
757
+ //#endregion
758
+ //#region src/interface/client-interface.ts
759
+ const botChallengeKnownErrors = [___known_errors_js.KnownErrors.BotChallengeRequired, ___known_errors_js.KnownErrors.BotChallengeFailed];
760
+ function isBotChallengeKnownError(error) {
761
+ return ___known_errors_js.KnownErrors.BotChallengeRequired.isInstance(error) || ___known_errors_js.KnownErrors.BotChallengeFailed.isInstance(error);
762
+ }
763
+ function getBotChallengeRequestFields(botChallenge, context) {
764
+ if (botChallenge?.unavailable) {
765
+ if (botChallenge.token != null || botChallenge.phase != null) throw new ___utils_errors_js.HexclaveAssertionError(`${context} bot challenge unavailability cannot be combined with a token or phase.`);
766
+ return { bot_challenge_unavailable: "true" };
767
+ }
768
+ const challengeToken = botChallenge?.token?.trim() || void 0;
769
+ if (botChallenge?.phase === "visible") {
770
+ if (challengeToken == null) return { bot_challenge_unavailable: "true" };
771
+ return {
772
+ bot_challenge_token: challengeToken,
773
+ bot_challenge_phase: "visible"
774
+ };
775
+ }
776
+ if (challengeToken == null) {
777
+ if (botChallenge?.phase != null) throw new ___utils_errors_js.HexclaveAssertionError(`${context} bot challenge phase options require a token.`);
778
+ return {};
779
+ }
780
+ if (botChallenge?.phase == null) return { bot_challenge_token: challengeToken };
781
+ return {
782
+ bot_challenge_token: challengeToken,
783
+ bot_challenge_phase: "invisible"
784
+ };
785
+ }
786
+ async function encodeAnalyticsBody(jsonBody, options) {
787
+ if (options.keepalive) return {
788
+ body: jsonBody,
789
+ contentType: "application/json"
790
+ };
791
+ const CompressionStreamCtor = ___utils_globals_js.globalVar.CompressionStream;
792
+ if (typeof CompressionStreamCtor !== "function" || typeof Blob === "undefined" || typeof Response === "undefined") return {
793
+ body: jsonBody,
794
+ contentType: "application/json"
795
+ };
796
+ try {
797
+ const stream = new Blob([jsonBody]).stream().pipeThrough(new CompressionStreamCtor("gzip"));
798
+ const buffer = await new Response(stream).arrayBuffer();
799
+ return {
800
+ body: new Uint8Array(buffer),
801
+ contentType: "application/octet-stream"
802
+ };
803
+ } catch {
804
+ return {
805
+ body: jsonBody,
806
+ contentType: "application/json"
807
+ };
808
+ }
809
+ }
810
+ var HexclaveClientInterface = class {
811
+ constructor(options) {
812
+ this.options = options;
813
+ this._requestListeners = /* @__PURE__ */ new Set();
814
+ this._sticky = null;
815
+ this._initialProbeRate = options.probeRate ?? .3;
816
+ }
817
+ addRequestListener(listener) {
818
+ this._requestListeners.add(listener);
819
+ return () => {
820
+ this._requestListeners.delete(listener);
821
+ };
822
+ }
823
+ get projectId() {
824
+ return this.options.projectId;
825
+ }
826
+ getApiUrl() {
827
+ return this.options.getBaseUrl() + "/api/v1";
828
+ }
829
+ getApiUrls() {
830
+ return this.options.getApiUrls().map((u) => u + "/api/v1");
831
+ }
832
+ /**
833
+ * Returns the best-known-good API URL: the sticky fallback if we're in
834
+ * fallback mode, otherwise the primary. Use for browser-navigated URLs
835
+ * (e.g. OAuth authorize) where _withFallback can't help.
836
+ */
837
+ getBestApiUrl() {
838
+ const apiUrls = this.getApiUrls();
839
+ if (this._sticky && apiUrls[this._sticky.index]) return apiUrls[this._sticky.index];
840
+ return apiUrls[0];
841
+ }
842
+ /**
843
+ * Routes a request through an ordered URL list with automatic failover.
844
+ *
845
+ * The URL list is [primary, ...fallbacks]. The logic has two modes:
846
+ *
847
+ * **Normal mode** (`_sticky` is null) — try each URL in order. If a
848
+ * non-primary URL succeeds, enter sticky mode on that index.
849
+ *
850
+ * **Sticky mode** — a previous request already failed over. We remember
851
+ * which URL worked and go there directly. Occasionally (controlled by a
852
+ * decaying probe rate) we probe the primary to see if it recovered:
853
+ * - Probe succeeds → exit sticky mode, use result.
854
+ * - Probe fails → halve probe rate, use sticky URL.
855
+ * - Sticky URL fails → exit sticky mode, do a full iteration.
856
+ *
857
+ * In both modes, a full iteration tries every URL once per pass for 2
858
+ * passes before giving up. KnownErrors and 4xx API responses (except 429)
859
+ * are never retried (they're application-level, not network-level).
860
+ *
861
+ * Single-URL lists skip all of this and use 5-retry behavior directly.
862
+ */
863
+ async _withFallback(cb) {
864
+ const apiUrls = this.getApiUrls();
865
+ if (apiUrls.length <= 1) return await cb(apiUrls[0], {
866
+ maxAttempts: 5,
867
+ skipDiagnostics: false
868
+ });
869
+ if (this._sticky) {
870
+ const result = await this._tryStickyUrl(apiUrls, cb);
871
+ if (result !== void 0) return result;
872
+ }
873
+ return await this._iterateUrls(apiUrls, cb);
874
+ }
875
+ _shouldSkipFallback(error) {
876
+ return error instanceof ___known_errors_js.KnownError || this._isNonRetryableApiResponseError(error);
877
+ }
878
+ _isNonRetryableApiResponseError(error) {
879
+ const response = this._getApiResponseFromError(error);
880
+ return response != null && response.status >= 400 && response.status < 500;
881
+ }
882
+ _getApiResponseFromError(error, seenErrors = /* @__PURE__ */ new Set()) {
883
+ if (error instanceof Response) return error;
884
+ if (!(error instanceof Error) || seenErrors.has(error)) return null;
885
+ seenErrors.add(error);
886
+ return this._getApiResponseFromError(error.cause, seenErrors);
887
+ }
888
+ /**
889
+ * Attempts the sticky URL, optionally probing primary first.
890
+ * Returns the result on success, or `undefined` if we should fall through to full iteration.
891
+ */
892
+ async _tryStickyUrl(apiUrls, cb) {
893
+ const sticky = this._sticky;
894
+ if (Math.random() < sticky.probeRate) try {
895
+ const result = await cb(apiUrls[0], {
896
+ maxAttempts: 1,
897
+ skipDiagnostics: true
898
+ });
899
+ this._sticky = null;
900
+ return result;
901
+ } catch (e) {
902
+ if (this._shouldSkipFallback(e)) throw e;
903
+ sticky.probeRate = Math.max(sticky.probeRate * .5, .01);
904
+ }
905
+ try {
906
+ return await cb(apiUrls[sticky.index], {
907
+ maxAttempts: 1,
908
+ skipDiagnostics: true
909
+ });
910
+ } catch (e) {
911
+ if (this._shouldSkipFallback(e)) throw e;
912
+ this._sticky = null;
913
+ return;
914
+ }
915
+ }
916
+ /**
917
+ * Tries every URL in order for up to 2 passes.
918
+ * If a non-primary URL (index > 0) succeeds, enters sticky mode on it.
919
+ */
920
+ async _iterateUrls(apiUrls, cb) {
921
+ let lastError;
922
+ for (let pass = 0; pass < 2; pass++) for (let i = 0; i < apiUrls.length; i++) try {
923
+ const result = await cb(apiUrls[i], {
924
+ maxAttempts: 1,
925
+ skipDiagnostics: true
926
+ });
927
+ if (i > 0) this._sticky = {
928
+ index: i,
929
+ probeRate: this._initialProbeRate
930
+ };
931
+ return result;
932
+ } catch (e) {
933
+ if (this._shouldSkipFallback(e)) throw e;
934
+ lastError = e instanceof Error ? e : new Error(String(e));
935
+ }
936
+ throw lastError;
937
+ }
938
+ getAnalyticsApiUrl() {
939
+ return (this.options.getAnalyticsBaseUrl ?? this.options.getBaseUrl)() + "/api/v1";
940
+ }
941
+ async runNetworkDiagnostics(session, requestType) {
942
+ if (this.pendingNetworkDiagnostics) return await this.pendingNetworkDiagnostics;
943
+ this.pendingNetworkDiagnostics = this._runNetworkDiagnosticsInner(session, requestType);
944
+ try {
945
+ return await this.pendingNetworkDiagnostics;
946
+ } finally {
947
+ this.pendingNetworkDiagnostics = void 0;
948
+ }
949
+ }
950
+ async _runNetworkDiagnosticsInner(session, requestType) {
951
+ const tryRequest = async (cb) => {
952
+ try {
953
+ await cb();
954
+ return "OK";
955
+ } catch (e) {
956
+ return `${e}`;
957
+ }
958
+ };
959
+ const cfTrace = await tryRequest(async () => {
960
+ const res = await fetch("https://1.1.1.1/cdn-cgi/trace");
961
+ if (!res.ok) throw new Error(`${res.status} ${res.statusText}: ${await res.text()}`);
962
+ });
963
+ const baseUrlBackend = await tryRequest(async () => {
964
+ const res = await fetch(new URL("/health", this.getApiUrl()));
965
+ if (!res.ok) throw new Error(`${res.status} ${res.statusText}: ${await res.text()}`);
966
+ });
967
+ const prodDashboard = await tryRequest(async () => {
968
+ const res = await fetch("https://app.hexclave.com/health");
969
+ if (!res.ok) throw new Error(`${res.status} ${res.statusText}: ${await res.text()}`);
970
+ });
971
+ const prodBackend = await tryRequest(async () => {
972
+ const res = await fetch("https://api.hexclave.com/health");
973
+ if (!res.ok) throw new Error(`${res.status} ${res.statusText}: ${await res.text()}`);
974
+ });
975
+ return {
976
+ "navigator?.onLine": ___utils_globals_js.globalVar.navigator?.onLine,
977
+ cfTrace,
978
+ baseUrlBackend,
979
+ prodDashboard,
980
+ prodBackend
981
+ };
982
+ }
983
+ async _createNetworkError(cause, session, requestType) {
984
+ return new Error(___utils_strings_js.deindent`
985
+ Hexclave is unable to connect to the server. Please check your internet connection and try again.
986
+
987
+ If the problem persists, please contact support and provide a screenshot of your entire browser console.
988
+
989
+ ${cause}
990
+
991
+ ${JSON.stringify(await this.runNetworkDiagnostics(session, requestType), null, 2)}
992
+ `, { cause });
993
+ }
994
+ async _networkRetry(cb, session, requestType, options) {
995
+ const retriedResult = await ___utils_results_js.Result.retry(cb, options?.maxAttempts ?? 5, { exponentialDelayBase: 1e3 });
996
+ if (retriedResult.status === "error") {
997
+ if (___utils_globals_js.globalVar.navigator && ___utils_globals_js.globalVar.navigator.onLine === false) throw new Error("You are offline. Please check your internet connection and try again. (window.navigator.onLine is false)", { cause: retriedResult.error });
998
+ if (options?.skipDiagnostics) throw retriedResult.error;
999
+ throw await this._createNetworkError(retriedResult.error, session, requestType);
1000
+ }
1001
+ return retriedResult.data;
1002
+ }
1003
+ async _networkRetryException(cb, session, requestType, options) {
1004
+ return await this._networkRetry(async () => await ___utils_results_js.Result.fromThrowingAsync(cb), session, requestType, options);
1005
+ }
1006
+ async fetchNewAccessToken(refreshToken) {
1007
+ if ("projectOwnerSession" in this.options) throw new Error("Admin session token is currently not supported for fetching new access token. Did you try to log in on a StackApp initiated with the admin session?");
1008
+ const clientSecret = this.options.publishableClientKey ?? ___utils_oauth_js.publishableClientKeyNotNecessarySentinel;
1009
+ return await this._withFallback(async (apiUrl, retryOptions) => {
1010
+ return await this._fetchNewAccessTokenInner(refreshToken, clientSecret, apiUrl, retryOptions);
1011
+ });
1012
+ }
1013
+ async _fetchNewAccessTokenInner(refreshToken, clientSecret, apiUrl, retryOptions) {
1014
+ const tokenEndpoint = apiUrl + "/auth/oauth/token";
1015
+ const as = {
1016
+ issuer: this.options.getBaseUrl(),
1017
+ algorithm: "oauth2",
1018
+ token_endpoint: tokenEndpoint
1019
+ };
1020
+ const client = {
1021
+ client_id: this.projectId,
1022
+ client_secret: clientSecret
1023
+ };
1024
+ const clientAuthentication = ClientSecretPost(clientSecret);
1025
+ const allowInsecure = tokenEndpoint.startsWith("http://");
1026
+ const response = await this._networkRetryException(async () => {
1027
+ const rawResponse = await refreshTokenGrantRequest(as, client, clientAuthentication, refreshToken.token, allowInsecure ? { [allowInsecureRequests]: true } : void 0);
1028
+ const response = await this._processResponse(rawResponse);
1029
+ if (response.status === "error") {
1030
+ const error = response.error;
1031
+ if (___known_errors_js.KnownErrors.RefreshTokenError.isInstance(error)) return null;
1032
+ throw error;
1033
+ }
1034
+ if (!response.data.ok) {
1035
+ const body = await response.data.text();
1036
+ throw new Error(`Failed to send refresh token request: ${response.status} ${body}`, { cause: response.data });
1037
+ }
1038
+ return response.data;
1039
+ }, void 0, void 0, retryOptions);
1040
+ if (!response) return null;
1041
+ let result;
1042
+ try {
1043
+ result = await processRefreshTokenResponse(as, client, response);
1044
+ } catch (e) {
1045
+ if (e instanceof ResponseBodyError) throw new ___utils_errors_js.HexclaveAssertionError("ResponseBodyError when processing refresh token response", {
1046
+ cause: e.cause,
1047
+ code: e.code,
1048
+ error: e.error
1049
+ });
1050
+ throw new ___utils_errors_js.HexclaveAssertionError("Unexpected error when processing refresh token response", { cause: e });
1051
+ }
1052
+ if (!result.access_token) throw new ___utils_errors_js.HexclaveAssertionError("Access token not found in token endpoint response, this is weird!");
1053
+ return ___sessions_js.AccessToken.createIfValid(result.access_token) ?? (0, ___utils_errors_js.throwErr)("Access token in fetchNewAccessToken is invalid, looks like the backend is returning an invalid token!", { result });
1054
+ }
1055
+ async sendClientRequest(path, requestOptions, session, requestType = "client", apiUrlOverride, retryOptions) {
1056
+ session ??= this.createSession({ refreshToken: null });
1057
+ if (apiUrlOverride) return await this._networkRetry(() => this.sendClientRequestInner(path, requestOptions, session, requestType, apiUrlOverride, retryOptions), session, requestType, retryOptions);
1058
+ return await this._withFallback(async (apiUrl, fallbackRetryOptions) => {
1059
+ return await this._networkRetry(() => this.sendClientRequestInner(path, requestOptions, session, requestType, apiUrl, retryOptions), session, requestType, {
1060
+ ...fallbackRetryOptions,
1061
+ ...retryOptions
1062
+ });
1063
+ });
1064
+ }
1065
+ createSession(options) {
1066
+ return new ___sessions_js.InternalSession({
1067
+ refreshAccessTokenCallback: async (refreshToken) => await this.fetchNewAccessToken(refreshToken),
1068
+ ...options
1069
+ });
1070
+ }
1071
+ async sendSessionReplayBatch(body, session, options) {
1072
+ try {
1073
+ const response = await this.sendClientRequest("/session-replays/batch", {
1074
+ method: "POST",
1075
+ headers: { "Content-Type": "application/json" },
1076
+ body,
1077
+ keepalive: options.keepalive
1078
+ }, session, "client", this.getAnalyticsApiUrl(), {
1079
+ maxAttempts: 1,
1080
+ skipDiagnostics: true
1081
+ });
1082
+ return ___utils_results_js.Result.ok(response);
1083
+ } catch (e) {
1084
+ return ___utils_results_js.Result.error(e instanceof Error ? e : new Error(String(e)));
1085
+ }
1086
+ }
1087
+ async sendAnalyticsEventBatch(body, session, options) {
1088
+ try {
1089
+ const encoded = await encodeAnalyticsBody(body, { keepalive: options.keepalive });
1090
+ const response = await this.sendClientRequest("/analytics/events/batch", {
1091
+ method: "POST",
1092
+ headers: { "Content-Type": encoded.contentType },
1093
+ body: encoded.body,
1094
+ keepalive: options.keepalive
1095
+ }, session, "client", this.getAnalyticsApiUrl(), {
1096
+ maxAttempts: 1,
1097
+ skipDiagnostics: true
1098
+ });
1099
+ return ___utils_results_js.Result.ok(response);
1100
+ } catch (e) {
1101
+ return ___utils_results_js.Result.error(e instanceof Error ? e : new Error(String(e)));
1102
+ }
1103
+ }
1104
+ async sendClientRequestAndCatchKnownError(path, requestOptions, tokenStoreOrNull, errorsToCatch) {
1105
+ try {
1106
+ return ___utils_results_js.Result.ok(await this.sendClientRequest(path, requestOptions, tokenStoreOrNull));
1107
+ } catch (e) {
1108
+ for (const errorType of errorsToCatch) if (errorType.isInstance(e)) return ___utils_results_js.Result.error(e);
1109
+ throw e;
1110
+ }
1111
+ }
1112
+ async sendClientRequestInner(path, options, session, requestType, apiUrlOverride, innerOptions) {
1113
+ /**
1114
+ * `tokenObj === null` means the session is invalid/not logged in
1115
+ */
1116
+ let tokenObj = await session.getOrFetchLikelyValidTokens(2e4, null);
1117
+ let adminSession = null;
1118
+ let adminTokenObj = null;
1119
+ if ("projectOwnerSession" in this.options) {
1120
+ const projectOwnerSession = this.options.projectOwnerSession;
1121
+ if (typeof projectOwnerSession === "function") {
1122
+ const accessTokenString = await projectOwnerSession();
1123
+ if (accessTokenString) {
1124
+ const accessToken = ___sessions_js.AccessToken.createIfValid(accessTokenString);
1125
+ if (accessToken) adminTokenObj = {
1126
+ accessToken,
1127
+ refreshToken: null
1128
+ };
1129
+ }
1130
+ } else {
1131
+ adminSession = projectOwnerSession;
1132
+ adminTokenObj = await projectOwnerSession.getOrFetchLikelyValidTokens(2e4, null);
1133
+ }
1134
+ }
1135
+ await this.options.prepareRequest?.();
1136
+ let url = (apiUrlOverride ?? this.getApiUrl()) + path;
1137
+ if (url.endsWith("/")) url = url.slice(0, -1);
1138
+ const params = {
1139
+ ..."WebSocketPair" in ___utils_globals_js.globalVar ? {} : { credentials: "omit" },
1140
+ ...options,
1141
+ headers: {
1142
+ "X-Hexclave-Override-Error-Status": "true",
1143
+ "X-Hexclave-Project-Id": this.projectId,
1144
+ "X-Hexclave-Access-Type": requestType,
1145
+ "X-Hexclave-Client-Version": this.options.clientVersion,
1146
+ ...tokenObj ? { "X-Hexclave-Access-Token": tokenObj.accessToken.token } : {},
1147
+ ...tokenObj?.refreshToken ? { "X-Hexclave-Refresh-Token": tokenObj.refreshToken.token } : {},
1148
+ "X-Hexclave-Allow-Anonymous-User": "true",
1149
+ ..."publishableClientKey" in this.options && this.options.publishableClientKey ? { "X-Hexclave-Publishable-Client-Key": this.options.publishableClientKey } : {},
1150
+ ...adminTokenObj ? { "X-Hexclave-Admin-Access-Token": adminTokenObj.accessToken.token } : {},
1151
+ "X-Hexclave-Random-Nonce": (0, ___utils_crypto_js.generateSecureRandomString)(),
1152
+ "ngrok-skip-browser-warning": "true",
1153
+ ...this.options.extraRequestHeaders,
1154
+ ...options.headers
1155
+ },
1156
+ ..."WebSocketPair" in ___utils_globals_js.globalVar ? {} : { cache: "no-store" }
1157
+ };
1158
+ const startTime = performance.now();
1159
+ let rawRes;
1160
+ try {
1161
+ rawRes = await fetch(url, params);
1162
+ } catch (e) {
1163
+ if (this._requestListeners.size > 0) {
1164
+ const entry = {
1165
+ path,
1166
+ method: (params.method ?? "GET").toUpperCase(),
1167
+ duration: Math.round(performance.now() - startTime),
1168
+ error: e instanceof Error ? e.message : "Network error"
1169
+ };
1170
+ this._requestListeners.forEach((l) => l(entry));
1171
+ }
1172
+ if (e instanceof TypeError) if (___utils_http_js.HTTP_METHODS[params.method ?? "GET"].idempotent) return ___utils_results_js.Result.error(e);
1173
+ else if (innerOptions?.skipDiagnostics) throw e;
1174
+ else throw await this._createNetworkError(e, session, requestType);
1175
+ throw e;
1176
+ }
1177
+ const preprocessedRes = await this._preprocessResponse(rawRes);
1178
+ if (this._requestListeners.size > 0) {
1179
+ const entry = {
1180
+ path,
1181
+ method: (params.method ?? "GET").toUpperCase(),
1182
+ status: preprocessedRes.status,
1183
+ duration: Math.round(performance.now() - startTime)
1184
+ };
1185
+ this._requestListeners.forEach((l) => l(entry));
1186
+ }
1187
+ const processedRes = await this._processResponse(preprocessedRes);
1188
+ if (processedRes.status === "error") {
1189
+ if (___known_errors_js.KnownErrors.InvalidAccessToken.isInstance(processedRes.error)) {
1190
+ if (!tokenObj) throw new ___utils_errors_js.HexclaveAssertionError("Received invalid access token, but session is not logged in", {
1191
+ tokenObj,
1192
+ processedRes
1193
+ });
1194
+ session.markAccessTokenExpired(tokenObj.accessToken);
1195
+ return ___utils_results_js.Result.error(processedRes.error);
1196
+ }
1197
+ if (adminSession && (___known_errors_js.KnownErrors.InvalidAdminAccessToken.isInstance(processedRes.error) || ___known_errors_js.KnownErrors.ApiKeyNotFound.isInstance(processedRes.error))) {
1198
+ if (!adminTokenObj) throw new ___utils_errors_js.HexclaveAssertionError("Received invalid admin access token, but admin session is not logged in", {
1199
+ adminTokenObj,
1200
+ processedRes
1201
+ });
1202
+ adminSession.markAccessTokenExpired(adminTokenObj.accessToken);
1203
+ return ___utils_results_js.Result.error(processedRes.error);
1204
+ }
1205
+ throw processedRes.error;
1206
+ }
1207
+ const res = Object.assign(processedRes.data, { usedTokens: tokenObj });
1208
+ if (res.ok) return ___utils_results_js.Result.ok(res);
1209
+ else if (res.status === 429) {
1210
+ const retryAfter = res.headers.get("Retry-After");
1211
+ if (retryAfter !== null) {
1212
+ console.log(`Rate limited while sending request to ${url}. Will retry after ${retryAfter} seconds...`);
1213
+ await (0, ___utils_promises_js.wait)(Number(retryAfter) * 1e3);
1214
+ return ___utils_results_js.Result.error(/* @__PURE__ */ new Error(`Rate limited, retrying after ${retryAfter} seconds`));
1215
+ }
1216
+ console.log(`Rate limited while sending request to ${url}, no retry-after header received. Retrying...`);
1217
+ return ___utils_results_js.Result.error(/* @__PURE__ */ new Error("Rate limited, no retry-after header received"));
1218
+ } else {
1219
+ const error = await res.text();
1220
+ if (res.status >= 400 && res.status < 500) throw new Error(`Failed to send request to ${url}: ${res.status} ${error}`, { cause: res });
1221
+ const errorObj = new ___utils_errors_js.HexclaveAssertionError(`Failed to send request to ${url}: ${res.status} ${error}`, {
1222
+ request: params,
1223
+ res,
1224
+ path
1225
+ });
1226
+ if (res.status === 508 && error.includes("INFINITE_LOOP_DETECTED")) return ___utils_results_js.Result.error(errorObj);
1227
+ throw errorObj;
1228
+ }
1229
+ }
1230
+ async _preprocessResponse(rawRes) {
1231
+ let res = rawRes;
1232
+ if (rawRes.headers.has("x-hexclave-actual-status") || rawRes.headers.has("x-stack-actual-status")) {
1233
+ const actualStatus = Number(rawRes.headers.get("x-hexclave-actual-status") ?? rawRes.headers.get("x-stack-actual-status"));
1234
+ res = new Response(rawRes.body, {
1235
+ status: actualStatus,
1236
+ statusText: rawRes.statusText,
1237
+ headers: rawRes.headers
1238
+ });
1239
+ }
1240
+ return res;
1241
+ }
1242
+ async _processResponse(res) {
1243
+ if (res.headers.has("x-hexclave-known-error") || res.headers.has("x-stack-known-error")) {
1244
+ const errorJson = await res.json();
1245
+ if ((res.headers.get("x-hexclave-known-error") ?? res.headers.get("x-stack-known-error")) !== errorJson.code) throw new ___utils_errors_js.HexclaveAssertionError("Mismatch between x-hexclave-known-error/x-stack-known-error header and error code in body; the server's response is invalid");
1246
+ const error = ___known_errors_js.KnownError.fromJson(errorJson);
1247
+ return ___utils_results_js.Result.error(error);
1248
+ }
1249
+ return ___utils_results_js.Result.ok(res);
1250
+ }
1251
+ async checkFeatureSupport(options) {
1252
+ throw new ___utils_errors_js.HexclaveAssertionError(await (await this.sendClientRequest("/check-feature-support", {
1253
+ method: "POST",
1254
+ headers: { "Content-Type": "application/json" },
1255
+ body: JSON.stringify(options)
1256
+ }, null)).text());
1257
+ }
1258
+ async sendForgotPasswordEmail(email, callbackUrl) {
1259
+ const res = await this.sendClientRequestAndCatchKnownError("/auth/password/send-reset-code", {
1260
+ method: "POST",
1261
+ headers: { "Content-Type": "application/json" },
1262
+ body: JSON.stringify({
1263
+ email,
1264
+ callback_url: callbackUrl
1265
+ })
1266
+ }, null, [___known_errors_js.KnownErrors.UserNotFound]);
1267
+ if (res.status === "error") return ___utils_results_js.Result.error(res.error);
1268
+ else return ___utils_results_js.Result.ok(void 0);
1269
+ }
1270
+ async sendVerificationEmail(email, callbackUrl, session) {
1271
+ const res = await this.sendClientRequestAndCatchKnownError("/contact-channels/send-verification-code", {
1272
+ method: "POST",
1273
+ headers: { "Content-Type": "application/json" },
1274
+ body: JSON.stringify({
1275
+ email,
1276
+ callback_url: callbackUrl
1277
+ })
1278
+ }, session, [___known_errors_js.KnownErrors.EmailAlreadyVerified]);
1279
+ if (res.status === "error") return res.error;
1280
+ }
1281
+ async sendMagicLinkEmail(email, callbackUrl, botChallenge) {
1282
+ const res = await this.sendClientRequestAndCatchKnownError("/auth/otp/send-sign-in-code", {
1283
+ method: "POST",
1284
+ headers: { "Content-Type": "application/json" },
1285
+ body: JSON.stringify({
1286
+ email,
1287
+ callback_url: callbackUrl,
1288
+ ...getBotChallengeRequestFields(botChallenge, "Magic link sign-in")
1289
+ })
1290
+ }, null, [___known_errors_js.KnownErrors.RedirectUrlNotWhitelisted, ...botChallengeKnownErrors]);
1291
+ if (res.status === "error") return ___utils_results_js.Result.error(res.error);
1292
+ else return ___utils_results_js.Result.ok(await res.data.json());
1293
+ }
1294
+ async resetPassword(options) {
1295
+ const res = await this.sendClientRequestAndCatchKnownError("onlyVerifyCode" in options ? "/auth/password/reset/check-code" : "/auth/password/reset", {
1296
+ method: "POST",
1297
+ headers: { "Content-Type": "application/json" },
1298
+ body: JSON.stringify({
1299
+ code: options.code,
1300
+ ..."password" in options ? { password: options.password } : {}
1301
+ })
1302
+ }, null, [___known_errors_js.KnownErrors.VerificationCodeError]);
1303
+ if (res.status === "error") return ___utils_results_js.Result.error(res.error);
1304
+ else return ___utils_results_js.Result.ok(void 0);
1305
+ }
1306
+ async updatePassword(options, session) {
1307
+ const res = await this.sendClientRequestAndCatchKnownError("/auth/password/update", {
1308
+ method: "POST",
1309
+ headers: { "Content-Type": "application/json" },
1310
+ body: JSON.stringify({
1311
+ old_password: options.oldPassword,
1312
+ new_password: options.newPassword
1313
+ })
1314
+ }, session, [___known_errors_js.KnownErrors.PasswordConfirmationMismatch, ___known_errors_js.KnownErrors.PasswordRequirementsNotMet]);
1315
+ if (res.status === "error") return res.error;
1316
+ }
1317
+ async setPassword(options, session) {
1318
+ const res = await this.sendClientRequestAndCatchKnownError("/auth/password/set", {
1319
+ method: "POST",
1320
+ headers: { "Content-Type": "application/json" },
1321
+ body: JSON.stringify(options)
1322
+ }, session, [___known_errors_js.KnownErrors.PasswordRequirementsNotMet]);
1323
+ if (res.status === "error") return res.error;
1324
+ }
1325
+ async verifyPasswordResetCode(code) {
1326
+ const res = await this.resetPassword({
1327
+ code,
1328
+ onlyVerifyCode: true
1329
+ });
1330
+ if (res.status === "error") return ___utils_results_js.Result.error(res.error);
1331
+ else return ___utils_results_js.Result.ok(void 0);
1332
+ }
1333
+ async verifyEmail(code) {
1334
+ const res = await this.sendClientRequestAndCatchKnownError("/contact-channels/verify", {
1335
+ method: "POST",
1336
+ headers: { "Content-Type": "application/json" },
1337
+ body: JSON.stringify({ code })
1338
+ }, null, [___known_errors_js.KnownErrors.VerificationCodeError]);
1339
+ if (res.status === "error") return ___utils_results_js.Result.error(res.error);
1340
+ else return ___utils_results_js.Result.ok(void 0);
1341
+ }
1342
+ async initiatePasskeyRegistration(options, session) {
1343
+ const res = await this.sendClientRequestAndCatchKnownError("/auth/passkey/initiate-passkey-registration", {
1344
+ method: "POST",
1345
+ headers: { "Content-Type": "application/json" },
1346
+ body: JSON.stringify(options)
1347
+ }, session, []);
1348
+ if (res.status === "error") return ___utils_results_js.Result.error(res.error);
1349
+ return ___utils_results_js.Result.ok(await res.data.json());
1350
+ }
1351
+ async registerPasskey(options, session) {
1352
+ const res = await this.sendClientRequestAndCatchKnownError("/auth/passkey/register", {
1353
+ method: "POST",
1354
+ headers: { "Content-Type": "application/json" },
1355
+ body: JSON.stringify(options)
1356
+ }, session, [___known_errors_js.KnownErrors.PasskeyRegistrationFailed]);
1357
+ if (res.status === "error") return ___utils_results_js.Result.error(res.error);
1358
+ return ___utils_results_js.Result.ok(void 0);
1359
+ }
1360
+ async initiatePasskeyAuthentication(options, session) {
1361
+ const res = await this.sendClientRequestAndCatchKnownError("/auth/passkey/initiate-passkey-authentication", {
1362
+ method: "POST",
1363
+ headers: { "Content-Type": "application/json" },
1364
+ body: JSON.stringify(options)
1365
+ }, session, []);
1366
+ if (res.status === "error") return ___utils_results_js.Result.error(res.error);
1367
+ return ___utils_results_js.Result.ok(await res.data.json());
1368
+ }
1369
+ async sendTeamInvitation(options) {
1370
+ await this.sendClientRequest("/team-invitations/send-code", {
1371
+ method: "POST",
1372
+ headers: { "Content-Type": "application/json" },
1373
+ body: JSON.stringify({
1374
+ email: options.email,
1375
+ team_id: options.teamId,
1376
+ callback_url: options.callbackUrl
1377
+ })
1378
+ }, options.session);
1379
+ }
1380
+ async acceptTeamInvitation(options) {
1381
+ const res = await this.sendClientRequestAndCatchKnownError(options.type === "check" ? "/team-invitations/accept/check-code" : options.type === "details" ? "/team-invitations/accept/details" : "/team-invitations/accept", {
1382
+ method: "POST",
1383
+ headers: { "Content-Type": "application/json" },
1384
+ body: JSON.stringify({ code: options.code })
1385
+ }, options.session, [___known_errors_js.KnownErrors.VerificationCodeError, ___known_errors_js.KnownErrors.TeamInvitationEmailMismatch]);
1386
+ if (res.status === "error") return ___utils_results_js.Result.error(res.error);
1387
+ else return ___utils_results_js.Result.ok(await res.data.json());
1388
+ }
1389
+ async totpMfa(attemptCode, totp, session) {
1390
+ const result = await (await this.sendClientRequest("/auth/mfa/sign-in", {
1391
+ method: "POST",
1392
+ headers: { "Content-Type": "application/json" },
1393
+ body: JSON.stringify({
1394
+ code: attemptCode,
1395
+ type: "totp",
1396
+ totp
1397
+ })
1398
+ }, session)).json();
1399
+ return {
1400
+ accessToken: result.access_token,
1401
+ refreshToken: result.refresh_token,
1402
+ newUser: result.is_new_user
1403
+ };
1404
+ }
1405
+ async signInWithCredential(email, password, session) {
1406
+ const res = await this.sendClientRequestAndCatchKnownError("/auth/password/sign-in", {
1407
+ method: "POST",
1408
+ headers: { "Content-Type": "application/json" },
1409
+ body: JSON.stringify({
1410
+ email,
1411
+ password
1412
+ })
1413
+ }, session, [___known_errors_js.KnownErrors.EmailPasswordMismatch]);
1414
+ if (res.status === "error") return ___utils_results_js.Result.error(res.error);
1415
+ const result = await res.data.json();
1416
+ return ___utils_results_js.Result.ok({
1417
+ accessToken: result.access_token,
1418
+ refreshToken: result.refresh_token
1419
+ });
1420
+ }
1421
+ async signUpWithCredential(email, password, emailVerificationRedirectUrl, session, botChallenge) {
1422
+ const res = await this.sendClientRequestAndCatchKnownError("/auth/password/sign-up", {
1423
+ headers: { "Content-Type": "application/json" },
1424
+ method: "POST",
1425
+ body: JSON.stringify({
1426
+ email,
1427
+ password,
1428
+ verification_callback_url: emailVerificationRedirectUrl,
1429
+ ...getBotChallengeRequestFields(botChallenge, "Credential sign-up")
1430
+ })
1431
+ }, session, [
1432
+ ___known_errors_js.KnownErrors.UserWithEmailAlreadyExists,
1433
+ ___known_errors_js.KnownErrors.PasswordRequirementsNotMet,
1434
+ ...botChallengeKnownErrors
1435
+ ]);
1436
+ if (res.status === "error") return ___utils_results_js.Result.error(res.error);
1437
+ const result = await res.data.json();
1438
+ return ___utils_results_js.Result.ok({
1439
+ accessToken: result.access_token,
1440
+ refreshToken: result.refresh_token
1441
+ });
1442
+ }
1443
+ async signUpAnonymously(session) {
1444
+ const res = await this.sendClientRequestAndCatchKnownError("/auth/anonymous/sign-up", { method: "POST" }, session, []);
1445
+ if (res.status === "error") return ___utils_results_js.Result.error(res.error);
1446
+ const result = await res.data.json();
1447
+ return ___utils_results_js.Result.ok({
1448
+ accessToken: result.access_token,
1449
+ refreshToken: result.refresh_token
1450
+ });
1451
+ }
1452
+ async signInWithMagicLink(code, session) {
1453
+ const res = await this.sendClientRequestAndCatchKnownError("/auth/otp/sign-in", {
1454
+ method: "POST",
1455
+ headers: { "Content-Type": "application/json" },
1456
+ body: JSON.stringify({ code })
1457
+ }, session, [___known_errors_js.KnownErrors.VerificationCodeError]);
1458
+ if (res.status === "error") return ___utils_results_js.Result.error(res.error);
1459
+ const result = await res.data.json();
1460
+ return ___utils_results_js.Result.ok({
1461
+ accessToken: result.access_token,
1462
+ refreshToken: result.refresh_token,
1463
+ newUser: result.is_new_user
1464
+ });
1465
+ }
1466
+ async signInWithMfa(totp, code, session) {
1467
+ const res = await this.sendClientRequestAndCatchKnownError("/auth/mfa/sign-in", {
1468
+ method: "POST",
1469
+ headers: { "Content-Type": "application/json" },
1470
+ body: JSON.stringify({
1471
+ type: "totp",
1472
+ totp,
1473
+ code
1474
+ })
1475
+ }, session, [___known_errors_js.KnownErrors.VerificationCodeError]);
1476
+ if (res.status === "error") return ___utils_results_js.Result.error(res.error);
1477
+ const result = await res.data.json();
1478
+ return ___utils_results_js.Result.ok({
1479
+ accessToken: result.access_token,
1480
+ refreshToken: result.refresh_token,
1481
+ newUser: result.is_new_user
1482
+ });
1483
+ }
1484
+ async signInWithPasskey(body, session) {
1485
+ const res = await this.sendClientRequestAndCatchKnownError("/auth/passkey/sign-in", {
1486
+ method: "POST",
1487
+ headers: { "Content-Type": "application/json" },
1488
+ body: JSON.stringify(body)
1489
+ }, session, [___known_errors_js.KnownErrors.PasskeyAuthenticationFailed]);
1490
+ if (res.status === "error") return ___utils_results_js.Result.error(res.error);
1491
+ const result = await res.data.json();
1492
+ return ___utils_results_js.Result.ok({
1493
+ accessToken: result.access_token,
1494
+ refreshToken: result.refresh_token
1495
+ });
1496
+ }
1497
+ async getOAuthUrl(options) {
1498
+ const updatedRedirectUrl = new URL(options.redirectUrl);
1499
+ for (const key of ["code", "state"]) {
1500
+ if (updatedRedirectUrl.searchParams.has(key)) console.warn("Redirect URL already contains " + key + " parameter, removing it as it will be overwritten by the OAuth callback");
1501
+ updatedRedirectUrl.searchParams.delete(key);
1502
+ }
1503
+ if ("projectOwnerSession" in this.options) throw new Error("Admin session token is currently not supported for OAuth");
1504
+ const clientSecret = this.options.publishableClientKey ?? ___utils_oauth_js.publishableClientKeyNotNecessarySentinel;
1505
+ const url = new URL(this.getBestApiUrl() + "/auth/oauth/authorize/" + options.provider.toLowerCase());
1506
+ url.searchParams.set("client_id", this.projectId);
1507
+ url.searchParams.set("client_secret", clientSecret);
1508
+ url.searchParams.set("redirect_uri", updatedRedirectUrl.toString());
1509
+ url.searchParams.set("scope", "legacy");
1510
+ url.searchParams.set("state", options.state);
1511
+ url.searchParams.set("grant_type", "authorization_code");
1512
+ url.searchParams.set("code_challenge", options.codeChallenge);
1513
+ url.searchParams.set("code_challenge_method", "S256");
1514
+ url.searchParams.set("response_type", "code");
1515
+ url.searchParams.set("type", options.type);
1516
+ url.searchParams.set("error_redirect_url", options.errorRedirectUrl);
1517
+ const tokens = await options.session.getOrFetchLikelyValidTokens(45e3, 6e4);
1518
+ if (tokens) url.searchParams.set("token", tokens.accessToken.token);
1519
+ if (options.afterCallbackRedirectUrl) url.searchParams.set("after_callback_redirect_url", options.afterCallbackRedirectUrl);
1520
+ if (options.providerScope) url.searchParams.set("provider_scope", options.providerScope);
1521
+ for (const [key, value] of Object.entries(getBotChallengeRequestFields(options.botChallenge, `OAuth ${options.type}`))) url.searchParams.set(key, value);
1522
+ return url.toString();
1523
+ }
1524
+ async authorizeOAuth(options) {
1525
+ if (typeof window === "undefined") throw new ___utils_errors_js.HexclaveAssertionError("authorizeOAuth can currently only be called in a browser environment");
1526
+ await this.options.prepareRequest?.();
1527
+ const url = new URL(await this.getOAuthUrl(options));
1528
+ url.searchParams.set("hexclave_response_mode", "json");
1529
+ url.searchParams.set("stack_response_mode", "json");
1530
+ let rawRes;
1531
+ try {
1532
+ rawRes = await fetch(url, { method: "GET" });
1533
+ } catch (error) {
1534
+ if (error instanceof TypeError) throw await this._createNetworkError(error, options.session, "client");
1535
+ throw error;
1536
+ }
1537
+ const processedResponse = await this._processResponse(rawRes);
1538
+ if (processedResponse.status === "error") {
1539
+ if (isBotChallengeKnownError(processedResponse.error)) return ___utils_results_js.Result.error(processedResponse.error);
1540
+ throw processedResponse.error;
1541
+ }
1542
+ if (processedResponse.data.status !== 200) throw new ___utils_errors_js.HexclaveAssertionError(`OAuth authorize returned an unexpected status: ${processedResponse.data.status}`);
1543
+ const body = await processedResponse.data.json();
1544
+ if (body == null || typeof body !== "object" || Array.isArray(body)) throw new ___utils_errors_js.HexclaveAssertionError("OAuth authorize response body must be an object", { body });
1545
+ const location = body.location;
1546
+ if (typeof location !== "string") throw new ___utils_errors_js.HexclaveAssertionError("OAuth authorize response is missing a redirect location", { body });
1547
+ return ___utils_results_js.Result.ok(location);
1548
+ }
1549
+ async callOAuthCallback(options) {
1550
+ if ("projectOwnerSession" in this.options) throw new Error("Admin session token is currently not supported for OAuth");
1551
+ const clientSecret = this.options.publishableClientKey ?? ___utils_oauth_js.publishableClientKeyNotNecessarySentinel;
1552
+ return await this._withFallback(async (apiUrl) => {
1553
+ return await this._callOAuthCallbackInner(options, clientSecret, apiUrl);
1554
+ });
1555
+ }
1556
+ async _callOAuthCallbackInner(options, clientSecret, apiUrl) {
1557
+ const tokenEndpoint = apiUrl + "/auth/oauth/token";
1558
+ const as = {
1559
+ issuer: this.options.getBaseUrl(),
1560
+ algorithm: "oauth2",
1561
+ token_endpoint: tokenEndpoint
1562
+ };
1563
+ const client = {
1564
+ client_id: this.projectId,
1565
+ client_secret: clientSecret
1566
+ };
1567
+ const clientAuthentication = ClientSecretPost(clientSecret);
1568
+ const allowInsecure = tokenEndpoint.startsWith("http://");
1569
+ let params;
1570
+ try {
1571
+ params = validateAuthResponse(as, client, options.oauthParams, options.state);
1572
+ } catch (e) {
1573
+ if (e instanceof AuthorizationResponseError) throw new ___utils_errors_js.HexclaveAssertionError("Authorization response error when validating outer OAuth response", {
1574
+ cause: Object.fromEntries(e.cause),
1575
+ code: e.code,
1576
+ error: e.error
1577
+ });
1578
+ throw new ___utils_errors_js.HexclaveAssertionError("Unexpected error when validating outer OAuth response", { cause: e });
1579
+ }
1580
+ const response = await authorizationCodeGrantRequest(as, client, clientAuthentication, params, options.redirectUri, options.codeVerifier, allowInsecure ? { [allowInsecureRequests]: true } : void 0);
1581
+ let result;
1582
+ try {
1583
+ result = await processAuthorizationCodeResponse(as, client, response);
1584
+ } catch (e) {
1585
+ if (e instanceof ResponseBodyError) {
1586
+ if (e.cause.code === "MULTI_FACTOR_AUTHENTICATION_REQUIRED") throw new ___known_errors_js.KnownErrors.MultiFactorAuthenticationRequired(e.cause.details.attempt_code);
1587
+ throw new ___utils_errors_js.HexclaveAssertionError("Outer OAuth error during authorization code response", {
1588
+ cause: e.cause,
1589
+ code: e.code,
1590
+ error: e.error
1591
+ });
1592
+ }
1593
+ throw new ___utils_errors_js.HexclaveAssertionError("Unexpected error when processing authorization code response", { cause: e });
1594
+ }
1595
+ return {
1596
+ newUser: result.is_new_user,
1597
+ afterCallbackRedirectUrl: result.after_callback_redirect_url,
1598
+ accessToken: result.access_token,
1599
+ refreshToken: result.refresh_token ?? (0, ___utils_errors_js.throwErr)("Refresh token not found in outer OAuth response")
1600
+ };
1601
+ }
1602
+ async signOut(session) {
1603
+ if (await session.getOrFetchLikelyValidTokens(2e4, null)) {
1604
+ const resOrError = await this.sendClientRequestAndCatchKnownError("/auth/sessions/current", {
1605
+ method: "DELETE",
1606
+ headers: { "Content-Type": "application/json" },
1607
+ body: JSON.stringify({})
1608
+ }, session, [___known_errors_js.KnownErrors.RefreshTokenError]);
1609
+ if (resOrError.status === "error") if (___known_errors_js.KnownErrors.RefreshTokenError.isInstance(resOrError.error)) {} else throw new ___utils_errors_js.HexclaveAssertionError("Unexpected error", { cause: resOrError.error });
1610
+ }
1611
+ session.markInvalid();
1612
+ }
1613
+ async getClientUserByToken(session) {
1614
+ const responseOrError = await this.sendClientRequestAndCatchKnownError("/users/me", {}, session, [___known_errors_js.KnownErrors.CannotGetOwnUserWithoutUser]);
1615
+ if (responseOrError.status === "error") if (___known_errors_js.KnownErrors.CannotGetOwnUserWithoutUser.isInstance(responseOrError.error)) return null;
1616
+ else throw new ___utils_errors_js.HexclaveAssertionError("Unexpected uncaught error", { cause: responseOrError.error });
1617
+ const user = await responseOrError.data.json();
1618
+ if (!user) throw new ___utils_errors_js.HexclaveAssertionError("User endpoint returned null; this should never happen");
1619
+ return user;
1620
+ }
1621
+ async listTeamInvitations(options, session) {
1622
+ return (await (await this.sendClientRequest("/team-invitations?" + new URLSearchParams({ team_id: options.teamId }), {}, session)).json()).items;
1623
+ }
1624
+ async listCurrentUserTeamInvitations(session) {
1625
+ return (await (await this.sendClientRequest("/team-invitations?" + new URLSearchParams({ user_id: "me" }), {}, session)).json()).items;
1626
+ }
1627
+ async acceptTeamInvitationById(invitationId, session) {
1628
+ await this.sendClientRequest(___utils_urls_js.urlString`/team-invitations/${invitationId}/accept` + "?" + new URLSearchParams({ user_id: "me" }), { method: "POST" }, session);
1629
+ }
1630
+ async revokeTeamInvitation(invitationId, teamId, session) {
1631
+ await this.sendClientRequest(`/team-invitations/${invitationId}?team_id=${teamId}`, { method: "DELETE" }, session);
1632
+ }
1633
+ async listTeamMemberProfiles(options, session) {
1634
+ return (await (await this.sendClientRequest("/team-member-profiles?" + new URLSearchParams((0, ___utils_objects_js.filterUndefined)({
1635
+ team_id: options.teamId,
1636
+ user_id: options.userId
1637
+ })), {}, session)).json()).items;
1638
+ }
1639
+ async getTeamMemberProfile(options, session) {
1640
+ return await (await this.sendClientRequest(`/team-member-profiles/${options.teamId}/${options.userId}`, {}, session)).json();
1641
+ }
1642
+ async leaveTeam(teamId, session) {
1643
+ await this.sendClientRequest(`/team-memberships/${teamId}/me`, {
1644
+ method: "DELETE",
1645
+ headers: { "content-type": "application/json" },
1646
+ body: JSON.stringify({})
1647
+ }, session);
1648
+ }
1649
+ async updateTeamMemberProfile(options, session) {
1650
+ await this.sendClientRequest(`/team-member-profiles/${options.teamId}/${options.userId}`, {
1651
+ method: "PATCH",
1652
+ headers: { "content-type": "application/json" },
1653
+ body: JSON.stringify(options.profile)
1654
+ }, session);
1655
+ }
1656
+ async updateTeam(options, session) {
1657
+ await this.sendClientRequest(`/teams/${options.teamId}`, {
1658
+ method: "PATCH",
1659
+ headers: { "content-type": "application/json" },
1660
+ body: JSON.stringify(options.data)
1661
+ }, session);
1662
+ }
1663
+ async listCurrentUserTeamPermissions(options, session) {
1664
+ return (await (await this.sendClientRequest(`/team-permissions?team_id=${options.teamId}&user_id=me&recursive=${options.recursive}`, {}, session)).json()).items;
1665
+ }
1666
+ async listCurrentUserProjectPermissions(options, session) {
1667
+ return (await (await this.sendClientRequest(`/project-permissions?user_id=me&recursive=${options.recursive}`, {}, session)).json()).items;
1668
+ }
1669
+ async listCurrentUserTeams(session) {
1670
+ return (await (await this.sendClientRequest("/teams?user_id=me", {}, session)).json()).items;
1671
+ }
1672
+ async getClientProject() {
1673
+ const responseOrError = await this.sendClientRequestAndCatchKnownError("/projects/current", {}, null, [___known_errors_js.KnownErrors.ProjectNotFound]);
1674
+ if (responseOrError.status === "error") return ___utils_results_js.Result.error(responseOrError.error);
1675
+ const project = await responseOrError.data.json();
1676
+ return ___utils_results_js.Result.ok(project);
1677
+ }
1678
+ async updateClientUser(update, session) {
1679
+ await this.sendClientRequest("/users/me", {
1680
+ method: "PATCH",
1681
+ headers: { "content-type": "application/json" },
1682
+ body: JSON.stringify(update)
1683
+ }, session);
1684
+ }
1685
+ async listProjects(session) {
1686
+ const response = await this.sendClientRequest("/internal/projects", {}, session);
1687
+ if (!response.ok) throw new Error("Failed to list projects: " + response.status + " " + await response.text());
1688
+ return (await response.json()).items;
1689
+ }
1690
+ async createProject(project, session) {
1691
+ const fetchResponse = await this.sendClientRequest("/internal/projects", {
1692
+ method: "POST",
1693
+ headers: { "content-type": "application/json" },
1694
+ body: JSON.stringify(project)
1695
+ }, session);
1696
+ if (!fetchResponse.ok) throw new Error("Failed to create project: " + fetchResponse.status + " " + await fetchResponse.text());
1697
+ return await fetchResponse.json();
1698
+ }
1699
+ async createProviderAccessToken(provider, scope, session) {
1700
+ return await (await this.sendClientRequest(`/connected-accounts/me/${provider}/access-token`, {
1701
+ method: "POST",
1702
+ headers: { "content-type": "application/json" },
1703
+ body: JSON.stringify({ scope })
1704
+ }, session)).json();
1705
+ }
1706
+ /**
1707
+ * Get access token for a specific connected account by provider ID and provider account ID.
1708
+ * This is the preferred method when dealing with multiple accounts of the same provider.
1709
+ */
1710
+ async createProviderAccessTokenByAccount(providerId, providerAccountId, scope, session) {
1711
+ return await (await this.sendClientRequest(`/connected-accounts/me/${encodeURIComponent(providerId)}/${encodeURIComponent(providerAccountId)}/access-token`, {
1712
+ method: "POST",
1713
+ headers: { "content-type": "application/json" },
1714
+ body: JSON.stringify({ scope })
1715
+ }, session)).json();
1716
+ }
1717
+ /**
1718
+ * List all connected accounts for the current user.
1719
+ */
1720
+ async listConnectedAccounts(session) {
1721
+ return await (await this.sendClientRequest(`/connected-accounts/me`, { method: "GET" }, session)).json();
1722
+ }
1723
+ async createClientTeam(data, session) {
1724
+ return await (await this.sendClientRequest("/teams", {
1725
+ method: "POST",
1726
+ headers: { "content-type": "application/json" },
1727
+ body: JSON.stringify(data)
1728
+ }, session)).json();
1729
+ }
1730
+ async deleteTeam(teamId, session) {
1731
+ await this.sendClientRequest(`/teams/${teamId}`, { method: "DELETE" }, session);
1732
+ }
1733
+ async deleteCurrentUser(session) {
1734
+ await this.sendClientRequest("/users/me", { method: "DELETE" }, session);
1735
+ }
1736
+ async createClientContactChannel(data, session) {
1737
+ return await (await this.sendClientRequest("/contact-channels", {
1738
+ method: "POST",
1739
+ headers: { "content-type": "application/json" },
1740
+ body: JSON.stringify(data)
1741
+ }, session)).json();
1742
+ }
1743
+ async updateClientContactChannel(id, data, session) {
1744
+ return await (await this.sendClientRequest(`/contact-channels/me/${id}`, {
1745
+ method: "PATCH",
1746
+ headers: { "content-type": "application/json" },
1747
+ body: JSON.stringify(data)
1748
+ }, session)).json();
1749
+ }
1750
+ async deleteClientContactChannel(id, session) {
1751
+ await this.sendClientRequest(`/contact-channels/me/${id}`, { method: "DELETE" }, session);
1752
+ }
1753
+ async deleteSession(sessionId, session) {
1754
+ await this.sendClientRequest(`/auth/sessions/${sessionId}?user_id=me`, { method: "DELETE" }, session);
1755
+ }
1756
+ async listSessions(session) {
1757
+ return await (await this.sendClientRequest("/auth/sessions?user_id=me", { method: "GET" }, session)).json();
1758
+ }
1759
+ async listClientContactChannels(session) {
1760
+ return (await (await this.sendClientRequest("/contact-channels?user_id=me", { method: "GET" }, session)).json()).items;
1761
+ }
1762
+ async sendCurrentUserContactChannelVerificationEmail(contactChannelId, callbackUrl, session) {
1763
+ const responseOrError = await this.sendClientRequestAndCatchKnownError(`/contact-channels/me/${contactChannelId}/send-verification-code`, {
1764
+ method: "POST",
1765
+ headers: { "content-type": "application/json" },
1766
+ body: JSON.stringify({ callback_url: callbackUrl })
1767
+ }, session, [___known_errors_js.KnownErrors.EmailAlreadyVerified]);
1768
+ if (responseOrError.status === "error") return ___utils_results_js.Result.error(responseOrError.error);
1769
+ return ___utils_results_js.Result.ok(void 0);
1770
+ }
1771
+ async cliLogin(loginCode, refreshToken, session) {
1772
+ const responseOrError = await this.sendClientRequestAndCatchKnownError("/auth/cli/complete", {
1773
+ method: "POST",
1774
+ headers: { "Content-Type": "application/json" },
1775
+ body: JSON.stringify({
1776
+ login_code: loginCode,
1777
+ refresh_token: refreshToken
1778
+ })
1779
+ }, session, [___known_errors_js.KnownErrors.SchemaError]);
1780
+ if (responseOrError.status === "error") return ___utils_results_js.Result.error(responseOrError.error);
1781
+ return ___utils_results_js.Result.ok(void 0);
1782
+ }
1783
+ async _getApiKeyRequestInfo(options) {
1784
+ if ("user_id" in options && "team_id" in options) throw new ___utils_errors_js.HexclaveAssertionError("Cannot specify both user_id and team_id in _getApiKeyRequestInfo");
1785
+ return {
1786
+ endpoint: "team_id" in options ? "/team-api-keys" : "/user-api-keys",
1787
+ queryParams: new URLSearchParams((0, ___utils_objects_js.filterUndefinedOrNull)(options))
1788
+ };
1789
+ }
1790
+ async listProjectApiKeys(options, session, requestType) {
1791
+ const sendRequest = (requestType === "client" ? this.sendClientRequest : this.sendServerRequest).bind(this);
1792
+ const { endpoint, queryParams } = await this._getApiKeyRequestInfo(options);
1793
+ return (await (await sendRequest(`${endpoint}?${queryParams.toString()}`, { method: "GET" }, session, requestType)).json()).items;
1794
+ }
1795
+ async createProjectApiKey(data, session, requestType) {
1796
+ const sendRequest = (requestType === "client" ? this.sendClientRequest : this.sendServerRequest).bind(this);
1797
+ const { endpoint } = await this._getApiKeyRequestInfo(data);
1798
+ return await (await sendRequest(`${endpoint}`, {
1799
+ method: "POST",
1800
+ headers: { "content-type": "application/json" },
1801
+ body: JSON.stringify(data)
1802
+ }, session, requestType)).json();
1803
+ }
1804
+ async getProjectApiKey(options, keyId, session, requestType) {
1805
+ const sendRequest = (requestType === "client" ? this.sendClientRequest : this.sendServerRequest).bind(this);
1806
+ const { endpoint, queryParams } = await this._getApiKeyRequestInfo(options);
1807
+ return await (await sendRequest(`${endpoint}/${keyId}?${queryParams.toString()}`, { method: "GET" }, session, requestType)).json();
1808
+ }
1809
+ async updateProjectApiKey(options, keyId, data, session, requestType) {
1810
+ const sendRequest = (requestType === "client" ? this.sendClientRequest : this.sendServerRequest).bind(this);
1811
+ const { endpoint, queryParams } = await this._getApiKeyRequestInfo(options);
1812
+ return await (await sendRequest(`${endpoint}/${keyId}?${queryParams.toString()}`, {
1813
+ method: "PATCH",
1814
+ headers: { "content-type": "application/json" },
1815
+ body: JSON.stringify(data)
1816
+ }, session, requestType)).json();
1817
+ }
1818
+ async checkProjectApiKey(type, apiKey, session, requestType) {
1819
+ const result = await (requestType === "client" ? this.sendClientRequestAndCatchKnownError : this.sendServerRequestAndCatchKnownError).bind(this)(`/${type}-api-keys/check`, {
1820
+ method: "POST",
1821
+ headers: { "content-type": "application/json" },
1822
+ body: JSON.stringify({ api_key: apiKey })
1823
+ }, session, [___known_errors_js.KnownErrors.ApiKeyNotValid]);
1824
+ if (result.status === "error") return null;
1825
+ return await result.data.json();
1826
+ }
1827
+ async listNotificationCategories(session) {
1828
+ return (await (await this.sendClientRequest(`/emails/notification-preference/me`, {}, session)).json()).items;
1829
+ }
1830
+ async setNotificationsEnabled(notificationCategoryId, enabled, session) {
1831
+ await this.sendClientRequest(`/emails/notification-preference/me/${notificationCategoryId}`, {
1832
+ method: "PATCH",
1833
+ headers: { "content-type": "application/json" },
1834
+ body: JSON.stringify({ enabled })
1835
+ }, session);
1836
+ }
1837
+ async getOAuthProvider(userId, providerId, session) {
1838
+ return await (await this.sendClientRequest(`/oauth-providers/${userId}/${providerId}`, { method: "GET" }, session)).json();
1839
+ }
1840
+ async updateOAuthProvider(userId, providerId, data, session) {
1841
+ return await (await this.sendClientRequest(`/oauth-providers/${userId}/${providerId}`, {
1842
+ method: "PATCH",
1843
+ headers: { "content-type": "application/json" },
1844
+ body: JSON.stringify(data)
1845
+ }, session)).json();
1846
+ }
1847
+ async listOAuthProviders(options = {}, session) {
1848
+ const queryParams = new URLSearchParams((0, ___utils_objects_js.filterUndefined)(options));
1849
+ return (await (await this.sendClientRequest(`/oauth-providers${queryParams.toString() ? `?${queryParams.toString()}` : ""}`, { method: "GET" }, session)).json()).items;
1850
+ }
1851
+ async deleteOAuthProvider(userId, providerId, session) {
1852
+ return await (await this.sendClientRequest(`/oauth-providers/${userId}/${providerId}`, { method: "DELETE" }, session)).json();
1853
+ }
1854
+ async getItem(options, session, requestType = "client") {
1855
+ let customerType;
1856
+ let customerId;
1857
+ if ("userId" in options) {
1858
+ customerType = "user";
1859
+ customerId = options.userId;
1860
+ } else if ("teamId" in options) {
1861
+ customerType = "team";
1862
+ customerId = options.teamId;
1863
+ } else if ("customCustomerId" in options) {
1864
+ customerType = "custom";
1865
+ customerId = options.customCustomerId;
1866
+ } else throw new ___utils_errors_js.HexclaveAssertionError("getItem requires one of userId, teamId, or customCustomerId");
1867
+ return await (await (requestType === "client" ? this.sendClientRequest : this.sendServerRequest).bind(this)(___utils_urls_js.urlString`/payments/items/${customerType}/${customerId}/${options.itemId}`, {}, session, requestType)).json();
1868
+ }
1869
+ async listProducts(options, session, requestType = "client") {
1870
+ const queryParams = new URLSearchParams((0, ___utils_objects_js.filterUndefined)({
1871
+ cursor: options.cursor,
1872
+ limit: options.limit !== void 0 ? options.limit.toString() : void 0
1873
+ }));
1874
+ const path = ___utils_urls_js.urlString`/payments/products/${options.customer_type}/${options.customer_id}`;
1875
+ return await (await (requestType === "client" ? this.sendClientRequest : this.sendServerRequest).bind(this)(`${path}${queryParams.toString() ? `?${queryParams.toString()}` : ""}`, {}, session, requestType)).json();
1876
+ }
1877
+ async listInvoices(options, session) {
1878
+ const queryParams = new URLSearchParams((0, ___utils_objects_js.filterUndefined)({
1879
+ cursor: options.cursor,
1880
+ limit: options.limit !== void 0 ? options.limit.toString() : void 0
1881
+ }));
1882
+ const path = ___utils_urls_js.urlString`/payments/invoices/${options.customer_type}/${options.customer_id}`;
1883
+ return await (await this.sendClientRequest(`${path}${queryParams.toString() ? `?${queryParams.toString()}` : ""}`, {}, session)).json();
1884
+ }
1885
+ async cancelSubscription(options, session) {
1886
+ const queryParams = new URLSearchParams((0, ___utils_objects_js.filterUndefined)({ subscription_id: options.subscription_id }));
1887
+ const path = ___utils_urls_js.urlString`/payments/products/${options.customer_type}/${options.customer_id}/${options.product_id}`;
1888
+ await this.sendClientRequest(`${path}${queryParams.toString() ? `?${queryParams.toString()}` : ""}`, { method: "DELETE" }, session);
1889
+ }
1890
+ async switchSubscription(options, session) {
1891
+ await this.sendClientRequest(___utils_urls_js.urlString`/payments/products/${options.customer_type}/${options.customer_id}/switch`, {
1892
+ method: "POST",
1893
+ headers: { "content-type": "application/json" },
1894
+ body: JSON.stringify({
1895
+ from_product_id: options.from_product_id,
1896
+ to_product_id: options.to_product_id,
1897
+ price_id: options.price_id,
1898
+ quantity: options.quantity
1899
+ })
1900
+ }, session);
1901
+ }
1902
+ async createCheckoutUrl(customer_type, customer_id, productIdOrInline, session, returnUrl, requestType = "client") {
1903
+ const productBody = typeof productIdOrInline === "string" ? { product_id: productIdOrInline } : { product_inline: productIdOrInline };
1904
+ const { url } = await (await (requestType === "client" ? this.sendClientRequest : this.sendServerRequest).bind(this)("/payments/purchases/create-purchase-url", {
1905
+ method: "POST",
1906
+ headers: { "content-type": "application/json" },
1907
+ body: JSON.stringify({
1908
+ customer_type,
1909
+ customer_id,
1910
+ ...productBody,
1911
+ return_url: returnUrl
1912
+ })
1913
+ }, session, requestType)).json();
1914
+ return url;
1915
+ }
1916
+ async getCustomerBilling(customerType, customerId, session) {
1917
+ return await (await this.sendClientRequest(___utils_urls_js.urlString`/payments/billing/${customerType}/${customerId}`, {}, session)).json();
1918
+ }
1919
+ async createCustomerPaymentMethodSetupIntent(customerType, customerId, session) {
1920
+ return await (await this.sendClientRequest(___utils_urls_js.urlString`/payments/payment-method/${customerType}/${customerId}/setup-intent`, {
1921
+ method: "POST",
1922
+ headers: { "content-type": "application/json" },
1923
+ body: JSON.stringify({})
1924
+ }, session)).json();
1925
+ }
1926
+ async setDefaultCustomerPaymentMethodFromSetupIntent(customerType, customerId, setupIntentId, session) {
1927
+ return await (await this.sendClientRequest(___utils_urls_js.urlString`/payments/payment-method/${customerType}/${customerId}/set-default`, {
1928
+ method: "POST",
1929
+ headers: { "content-type": "application/json" },
1930
+ body: JSON.stringify({ setup_intent_id: setupIntentId })
1931
+ }, session)).json();
1932
+ }
1933
+ async transferProject(internalProjectSession, projectIdToTransfer, newTeamId) {
1934
+ if (this.options.projectId !== "internal") throw new ___utils_errors_js.HexclaveAssertionError("HexclaveClientInterface.transferProject() is only available for internal projects (please specify the project ID in the constructor)");
1935
+ await this.sendClientRequest("/internal/projects/transfer", {
1936
+ method: "POST",
1937
+ headers: { "content-type": "application/json" },
1938
+ body: JSON.stringify({
1939
+ project_id: projectIdToTransfer,
1940
+ new_team_id: newTeamId
1941
+ })
1942
+ }, internalProjectSession);
1943
+ }
1944
+ };
1945
+
1946
+ //#endregion
1947
+ exports.HexclaveClientInterface = HexclaveClientInterface;
1948
+ //# sourceMappingURL=client-interface.js.map