@hexclave/shared 1.0.41 → 1.0.42

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 (1066) hide show
  1. package/dist/admin-interface-Y9EZqwD6.d.ts +379 -0
  2. package/dist/admin-interface-Y9EZqwD6.d.ts.map +1 -0
  3. package/dist/admin-metrics-bsOkw4YQ.d.ts +807 -0
  4. package/dist/admin-metrics-bsOkw4YQ.d.ts.map +1 -0
  5. package/dist/ai/image-limits.d.ts.map +1 -1
  6. package/dist/ai/image-limits.js +6 -7
  7. package/dist/ai/image-limits.js.map +1 -1
  8. package/dist/ai/llms/llms.d.ts.map +1 -1
  9. package/dist/ai/llms/llms.js +2 -4
  10. package/dist/ai/llms/llms.js.map +1 -1
  11. package/dist/ai/unified-prompts/reminders.js +3 -6
  12. package/dist/ai/unified-prompts/reminders.js.map +1 -1
  13. package/dist/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.d.ts.map +1 -1
  14. package/dist/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.js +2 -5
  15. package/dist/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.js.map +1 -1
  16. package/dist/ai/unified-prompts/skill-site-prompt-parts/brain.js +3 -6
  17. package/dist/ai/unified-prompts/skill-site-prompt-parts/brain.js.map +1 -1
  18. package/dist/ai/unified-prompts/skill-site-prompt-parts/cli-help.js +3 -6
  19. package/dist/ai/unified-prompts/skill-site-prompt-parts/cli-help.js.map +1 -1
  20. package/dist/ai/unified-prompts/skill-site-prompt-parts/config-docs.js +3 -6
  21. package/dist/ai/unified-prompts/skill-site-prompt-parts/config-docs.js.map +1 -1
  22. package/dist/ai/unified-prompts/skill-site-prompt-parts/custom-components-instructions.js +3 -6
  23. package/dist/ai/unified-prompts/skill-site-prompt-parts/custom-components-instructions.js.map +1 -1
  24. package/dist/ai/unified-prompts/skill-site-prompt-parts/dashboard-instructions.js +3 -6
  25. package/dist/ai/unified-prompts/skill-site-prompt-parts/dashboard-instructions.js.map +1 -1
  26. package/dist/ai/unified-prompts/skill-site-prompt-parts/docs-index.d.ts.map +1 -1
  27. package/dist/ai/unified-prompts/skill-site-prompt-parts/docs-index.js +5 -6
  28. package/dist/ai/unified-prompts/skill-site-prompt-parts/docs-index.js.map +1 -1
  29. package/dist/ai/unified-prompts/skill-site-prompt-parts/docs-json.generated.js +1 -2
  30. package/dist/ai/unified-prompts/skill-site-prompt-parts/docs-json.generated.js.map +1 -1
  31. package/dist/ai/unified-prompts/skill-site-prompt-parts/openapi-specs.js +3 -6
  32. package/dist/ai/unified-prompts/skill-site-prompt-parts/openapi-specs.js.map +1 -1
  33. package/dist/ai/unified-prompts/skill-site-prompt-parts/sdk-interface-source.js +3 -6
  34. package/dist/ai/unified-prompts/skill-site-prompt-parts/sdk-interface-source.js.map +1 -1
  35. package/dist/ai/unified-prompts/skill-site-prompt.d.ts.map +1 -1
  36. package/dist/ai/unified-prompts/skill-site-prompt.js +2 -4
  37. package/dist/ai/unified-prompts/skill-site-prompt.js.map +1 -1
  38. package/dist/analytics-IjkAsefy.d.ts +14 -0
  39. package/dist/analytics-IjkAsefy.d.ts.map +1 -0
  40. package/dist/apps/apps-config.d.ts.map +1 -1
  41. package/dist/apps/apps-config.js +2 -3
  42. package/dist/apps/apps-config.js.map +1 -1
  43. package/dist/apps/apps-ui.d.ts +1 -2
  44. package/dist/apps/apps-ui.d.ts.map +1 -1
  45. package/dist/apps/apps-ui.js +4 -5
  46. package/dist/apps/apps-ui.js.map +1 -1
  47. package/dist/client-interface-iIw4nU5k.d.ts +447 -0
  48. package/dist/client-interface-iIw4nU5k.d.ts.map +1 -0
  49. package/dist/config/db-sync-mappings.js +2 -3
  50. package/dist/config/db-sync-mappings.js.map +1 -1
  51. package/dist/config/format.d.ts +2 -61
  52. package/dist/config/format.js +2 -192
  53. package/dist/config/format.js.map +1 -1
  54. package/dist/config/migrate-catalogs-to-product-lines.d.ts.map +1 -1
  55. package/dist/config/migrate-catalogs-to-product-lines.js +2 -196
  56. package/dist/config/migrate-catalogs-to-product-lines.js.map +1 -1
  57. package/dist/config/schema-fuzzer.test.js +18 -172
  58. package/dist/config/schema-fuzzer.test.js.map +1 -1
  59. package/dist/config/schema.d.ts +2 -2328
  60. package/dist/config/schema.js +6 -351
  61. package/dist/config/schema.js.map +1 -1
  62. package/dist/config-authoring.d.ts +1 -1
  63. package/dist/config-authoring.d.ts.map +1 -1
  64. package/dist/config-authoring.js +2 -3
  65. package/dist/config-authoring.js.map +1 -1
  66. package/dist/config-authoring.test.js +1 -3
  67. package/dist/config-authoring.test.js.map +1 -1
  68. package/dist/config-eval.d.ts.map +1 -1
  69. package/dist/config-eval.js +4 -46
  70. package/dist/config-eval.js.map +1 -1
  71. package/dist/config-rendering.d.ts.map +1 -1
  72. package/dist/config-rendering.js +2 -48
  73. package/dist/config-rendering.js.map +1 -1
  74. package/dist/connected-accounts-D5CKe50A.d.ts +67 -0
  75. package/dist/connected-accounts-D5CKe50A.d.ts.map +1 -0
  76. package/dist/contact-channels-DW8yQxlc.d.ts +180 -0
  77. package/dist/contact-channels-DW8yQxlc.d.ts.map +1 -0
  78. package/dist/country-codes-CRWDroBE.d.ts +11 -0
  79. package/dist/country-codes-CRWDroBE.d.ts.map +1 -0
  80. package/dist/crud-CqmEW9s6.d.ts +98 -0
  81. package/dist/crud-CqmEW9s6.d.ts.map +1 -0
  82. package/dist/crud.d.ts +2 -98
  83. package/dist/crud.js +3 -71
  84. package/dist/crud.js.map +1 -1
  85. package/dist/currency-constants-Cq_q8twn.d.ts +45 -0
  86. package/dist/currency-constants-Cq_q8twn.d.ts.map +1 -0
  87. package/dist/current-user-BBoN3hsn.d.ts +284 -0
  88. package/dist/current-user-BBoN3hsn.d.ts.map +1 -0
  89. package/dist/dates-B6ne9iOR.d.ts +23 -0
  90. package/dist/dates-B6ne9iOR.d.ts.map +1 -0
  91. package/dist/email-outbox-B1wmVPRG.d.ts +1464 -0
  92. package/dist/{interface/crud/email-outbox.d.ts.map → email-outbox-B1wmVPRG.d.ts.map} +1 -1
  93. package/dist/emails-Ba4yEaCS.d.ts +40 -0
  94. package/dist/emails-Ba4yEaCS.d.ts.map +1 -0
  95. package/dist/errors-Cl-RUyed.d.ts +238 -0
  96. package/dist/errors-Cl-RUyed.d.ts.map +1 -0
  97. package/dist/esm/ai/image-limits.d.ts.map +1 -1
  98. package/dist/esm/ai/image-limits.js +5 -5
  99. package/dist/esm/ai/image-limits.js.map +1 -1
  100. package/dist/esm/ai/llms/llms.d.ts +1 -1
  101. package/dist/esm/ai/llms/llms.d.ts.map +1 -1
  102. package/dist/esm/ai/llms/llms.js +1 -2
  103. package/dist/esm/ai/llms/llms.js.map +1 -1
  104. package/dist/esm/ai/unified-prompts/reminders.js +2 -3
  105. package/dist/esm/ai/unified-prompts/reminders.js.map +1 -1
  106. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.d.ts.map +1 -1
  107. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.js +25 -28
  108. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.js.map +1 -1
  109. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/brain.js +1 -2
  110. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/brain.js.map +1 -1
  111. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/cli-help.js +1 -2
  112. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/cli-help.js.map +1 -1
  113. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/config-docs.js +1 -2
  114. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/config-docs.js.map +1 -1
  115. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/custom-components-instructions.js +1 -2
  116. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/custom-components-instructions.js.map +1 -1
  117. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/dashboard-instructions.js +1 -2
  118. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/dashboard-instructions.js.map +1 -1
  119. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/docs-index.d.ts.map +1 -1
  120. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/docs-index.js +2 -3
  121. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/docs-index.js.map +1 -1
  122. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/docs-json.generated.js +1 -1
  123. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/docs-json.generated.js.map +1 -1
  124. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/openapi-specs.js +1 -2
  125. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/openapi-specs.js.map +1 -1
  126. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/sdk-interface-source.js +1 -2
  127. package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/sdk-interface-source.js.map +1 -1
  128. package/dist/esm/ai/unified-prompts/skill-site-prompt.d.ts.map +1 -1
  129. package/dist/esm/ai/unified-prompts/skill-site-prompt.js +1 -2
  130. package/dist/esm/ai/unified-prompts/skill-site-prompt.js.map +1 -1
  131. package/dist/esm/apps/apps-config.d.ts.map +1 -1
  132. package/dist/esm/apps/apps-config.js +1 -1
  133. package/dist/esm/apps/apps-config.js.map +1 -1
  134. package/dist/esm/apps/apps-ui.d.ts +2 -3
  135. package/dist/esm/apps/apps-ui.d.ts.map +1 -1
  136. package/dist/esm/apps/apps-ui.js +2 -3
  137. package/dist/esm/apps/apps-ui.js.map +1 -1
  138. package/dist/esm/config/db-sync-mappings.js +1 -1
  139. package/dist/esm/config/db-sync-mappings.js.map +1 -1
  140. package/dist/esm/config/format.d.ts +1 -1
  141. package/dist/esm/config/format.d.ts.map +1 -1
  142. package/dist/esm/config/format.js +1 -190
  143. package/dist/esm/config/format.js.map +1 -1
  144. package/dist/esm/config/migrate-catalogs-to-product-lines.d.ts.map +1 -1
  145. package/dist/esm/config/migrate-catalogs-to-product-lines.js +1 -194
  146. package/dist/esm/config/migrate-catalogs-to-product-lines.js.map +1 -1
  147. package/dist/esm/config/schema-fuzzer.test.js +20 -173
  148. package/dist/esm/config/schema-fuzzer.test.js.map +1 -1
  149. package/dist/esm/config/schema.d.ts +227 -228
  150. package/dist/esm/config/schema.d.ts.map +1 -1
  151. package/dist/esm/config/schema.js +2 -347
  152. package/dist/esm/config/schema.js.map +1 -1
  153. package/dist/esm/config-authoring.d.ts +1 -1
  154. package/dist/esm/config-authoring.d.ts.map +1 -1
  155. package/dist/esm/config-authoring.js +1 -1
  156. package/dist/esm/config-authoring.js.map +1 -1
  157. package/dist/esm/config-authoring.test.js +2 -3
  158. package/dist/esm/config-authoring.test.js.map +1 -1
  159. package/dist/esm/config-eval.d.ts +1 -1
  160. package/dist/esm/config-eval.d.ts.map +1 -1
  161. package/dist/esm/config-eval.js +1 -43
  162. package/dist/esm/config-eval.js.map +1 -1
  163. package/dist/esm/config-rendering.d.ts.map +1 -1
  164. package/dist/esm/config-rendering.js +1 -46
  165. package/dist/esm/config-rendering.js.map +1 -1
  166. package/dist/esm/crud.d.ts +1 -1
  167. package/dist/esm/crud.d.ts.map +1 -1
  168. package/dist/esm/crud.js +2 -69
  169. package/dist/esm/crud.js.map +1 -1
  170. package/dist/esm/helpers/emails.js +1 -2
  171. package/dist/esm/helpers/emails.js.map +1 -1
  172. package/dist/esm/helpers/init-prompt.d.ts.map +1 -1
  173. package/dist/esm/helpers/init-prompt.js +1 -2
  174. package/dist/esm/helpers/init-prompt.js.map +1 -1
  175. package/dist/esm/helpers/password.d.ts +1 -1
  176. package/dist/esm/helpers/password.d.ts.map +1 -1
  177. package/dist/esm/helpers/password.js +1 -2
  178. package/dist/esm/helpers/password.js.map +1 -1
  179. package/dist/esm/helpers/production-mode.d.ts +1 -1
  180. package/dist/esm/helpers/production-mode.d.ts.map +1 -1
  181. package/dist/esm/helpers/production-mode.js +1 -2
  182. package/dist/esm/helpers/production-mode.js.map +1 -1
  183. package/dist/esm/helpers/support-sla.d.ts.map +1 -1
  184. package/dist/esm/helpers/support-sla.js +1 -1
  185. package/dist/esm/helpers/support-sla.js.map +1 -1
  186. package/dist/esm/helpers/support-sla.test.js +2 -3
  187. package/dist/esm/helpers/support-sla.test.js.map +1 -1
  188. package/dist/esm/helpers/vault/client-side.d.ts.map +1 -1
  189. package/dist/esm/helpers/vault/client-side.js +1 -20
  190. package/dist/esm/helpers/vault/client-side.js.map +1 -1
  191. package/dist/esm/helpers/vault/server-side.js +1 -2
  192. package/dist/esm/helpers/vault/server-side.js.map +1 -1
  193. package/dist/esm/hooks/use-async-callback.d.ts.map +1 -1
  194. package/dist/esm/hooks/use-async-callback.js +1 -2
  195. package/dist/esm/hooks/use-async-callback.js.map +1 -1
  196. package/dist/esm/hooks/use-async-external-store.d.ts +1 -1
  197. package/dist/esm/hooks/use-async-external-store.d.ts.map +1 -1
  198. package/dist/esm/hooks/use-async-external-store.js +1 -2
  199. package/dist/esm/hooks/use-async-external-store.js.map +1 -1
  200. package/dist/esm/hooks/use-hash.js +1 -2
  201. package/dist/esm/hooks/use-hash.js.map +1 -1
  202. package/dist/esm/hooks/use-hover.d.ts.map +1 -1
  203. package/dist/esm/hooks/use-hover.js +1 -2
  204. package/dist/esm/hooks/use-hover.js.map +1 -1
  205. package/dist/esm/hooks/use-strict-memo.d.ts.map +1 -1
  206. package/dist/esm/hooks/use-strict-memo.js +1 -70
  207. package/dist/esm/hooks/use-strict-memo.js.map +1 -1
  208. package/dist/esm/index.d.ts +4 -4
  209. package/dist/esm/index.js +1 -2
  210. package/dist/esm/interface/admin-interface.d.ts +19 -19
  211. package/dist/esm/interface/admin-interface.d.ts.map +1 -1
  212. package/dist/esm/interface/admin-interface.js +2 -3
  213. package/dist/esm/interface/admin-interface.js.map +1 -1
  214. package/dist/esm/interface/admin-metrics.d.ts +10 -10
  215. package/dist/esm/interface/admin-metrics.d.ts.map +1 -1
  216. package/dist/esm/interface/admin-metrics.js +1 -2
  217. package/dist/esm/interface/admin-metrics.js.map +1 -1
  218. package/dist/esm/interface/client-interface.d.ts +22 -22
  219. package/dist/esm/interface/client-interface.d.ts.map +1 -1
  220. package/dist/esm/interface/client-interface.js +32 -16
  221. package/dist/esm/interface/client-interface.js.map +1 -1
  222. package/dist/esm/interface/client-interface.test.js +84 -13
  223. package/dist/esm/interface/client-interface.test.js.map +1 -1
  224. package/dist/esm/interface/conversations.d.ts +8 -8
  225. package/dist/esm/interface/conversations.d.ts.map +1 -1
  226. package/dist/esm/interface/conversations.js +1 -2
  227. package/dist/esm/interface/conversations.js.map +1 -1
  228. package/dist/esm/interface/crud/analytics.d.ts.map +1 -1
  229. package/dist/esm/interface/crud/analytics.js +1 -1
  230. package/dist/esm/interface/crud/connected-accounts.d.ts +15 -17
  231. package/dist/esm/interface/crud/connected-accounts.d.ts.map +1 -1
  232. package/dist/esm/interface/crud/connected-accounts.js +1 -2
  233. package/dist/esm/interface/crud/connected-accounts.js.map +1 -1
  234. package/dist/esm/interface/crud/contact-channels.d.ts +24 -26
  235. package/dist/esm/interface/crud/contact-channels.d.ts.map +1 -1
  236. package/dist/esm/interface/crud/contact-channels.js +1 -2
  237. package/dist/esm/interface/crud/contact-channels.js.map +1 -1
  238. package/dist/esm/interface/crud/current-user.d.ts +22 -24
  239. package/dist/esm/interface/crud/current-user.d.ts.map +1 -1
  240. package/dist/esm/interface/crud/current-user.js +25 -29
  241. package/dist/esm/interface/crud/current-user.js.map +1 -1
  242. package/dist/esm/interface/crud/email-outbox.d.ts +30 -32
  243. package/dist/esm/interface/crud/email-outbox.d.ts.map +1 -1
  244. package/dist/esm/interface/crud/email-outbox.js +1 -2
  245. package/dist/esm/interface/crud/email-outbox.js.map +1 -1
  246. package/dist/esm/interface/crud/email-templates.d.ts +16 -18
  247. package/dist/esm/interface/crud/email-templates.d.ts.map +1 -1
  248. package/dist/esm/interface/crud/email-templates.js +1 -2
  249. package/dist/esm/interface/crud/email-templates.js.map +1 -1
  250. package/dist/esm/interface/crud/emails.d.ts +6 -8
  251. package/dist/esm/interface/crud/emails.d.ts.map +1 -1
  252. package/dist/esm/interface/crud/emails.js +1 -2
  253. package/dist/esm/interface/crud/emails.js.map +1 -1
  254. package/dist/esm/interface/crud/internal-api-keys.d.ts +16 -18
  255. package/dist/esm/interface/crud/internal-api-keys.d.ts.map +1 -1
  256. package/dist/esm/interface/crud/internal-api-keys.js +1 -2
  257. package/dist/esm/interface/crud/internal-api-keys.js.map +1 -1
  258. package/dist/esm/interface/crud/invoices.d.ts.map +1 -1
  259. package/dist/esm/interface/crud/invoices.js +1 -2
  260. package/dist/esm/interface/crud/invoices.js.map +1 -1
  261. package/dist/esm/interface/crud/items.d.ts +6 -8
  262. package/dist/esm/interface/crud/items.d.ts.map +1 -1
  263. package/dist/esm/interface/crud/items.js +12 -16
  264. package/dist/esm/interface/crud/items.js.map +1 -1
  265. package/dist/esm/interface/crud/notification-preferences.d.ts +6 -8
  266. package/dist/esm/interface/crud/notification-preferences.d.ts.map +1 -1
  267. package/dist/esm/interface/crud/notification-preferences.js +8 -12
  268. package/dist/esm/interface/crud/notification-preferences.js.map +1 -1
  269. package/dist/esm/interface/crud/oauth-providers.d.ts +24 -26
  270. package/dist/esm/interface/crud/oauth-providers.d.ts.map +1 -1
  271. package/dist/esm/interface/crud/oauth-providers.js +1 -2
  272. package/dist/esm/interface/crud/oauth-providers.js.map +1 -1
  273. package/dist/esm/interface/crud/products.d.ts +21 -22
  274. package/dist/esm/interface/crud/products.d.ts.map +1 -1
  275. package/dist/esm/interface/crud/products.js +3 -2
  276. package/dist/esm/interface/crud/products.js.map +1 -1
  277. package/dist/esm/interface/crud/project-api-keys.d.ts +5 -6
  278. package/dist/esm/interface/crud/project-api-keys.d.ts.map +1 -1
  279. package/dist/esm/interface/crud/project-api-keys.js +1 -2
  280. package/dist/esm/interface/crud/project-api-keys.js.map +1 -1
  281. package/dist/esm/interface/crud/project-permissions.d.ts +29 -31
  282. package/dist/esm/interface/crud/project-permissions.d.ts.map +1 -1
  283. package/dist/esm/interface/crud/project-permissions.js +1 -2
  284. package/dist/esm/interface/crud/project-permissions.js.map +1 -1
  285. package/dist/esm/interface/crud/projects.d.ts +63 -65
  286. package/dist/esm/interface/crud/projects.d.ts.map +1 -1
  287. package/dist/esm/interface/crud/projects.js +3 -2
  288. package/dist/esm/interface/crud/projects.js.map +1 -1
  289. package/dist/esm/interface/crud/session-replays.d.ts.map +1 -1
  290. package/dist/esm/interface/crud/session-replays.js +1 -1
  291. package/dist/esm/interface/crud/sessions.d.ts +15 -17
  292. package/dist/esm/interface/crud/sessions.d.ts.map +1 -1
  293. package/dist/esm/interface/crud/sessions.js +1 -2
  294. package/dist/esm/interface/crud/sessions.js.map +1 -1
  295. package/dist/esm/interface/crud/sign-up-rules.d.ts.map +1 -1
  296. package/dist/esm/interface/crud/sign-up-rules.js +1 -1
  297. package/dist/esm/interface/crud/svix-token.d.ts +8 -10
  298. package/dist/esm/interface/crud/svix-token.d.ts.map +1 -1
  299. package/dist/esm/interface/crud/svix-token.js +1 -2
  300. package/dist/esm/interface/crud/svix-token.js.map +1 -1
  301. package/dist/esm/interface/crud/team-invitation-details.d.ts +6 -8
  302. package/dist/esm/interface/crud/team-invitation-details.d.ts.map +1 -1
  303. package/dist/esm/interface/crud/team-invitation-details.js +1 -2
  304. package/dist/esm/interface/crud/team-invitation-details.js.map +1 -1
  305. package/dist/esm/interface/crud/team-invitation.d.ts +7 -9
  306. package/dist/esm/interface/crud/team-invitation.d.ts.map +1 -1
  307. package/dist/esm/interface/crud/team-invitation.js +1 -2
  308. package/dist/esm/interface/crud/team-invitation.js.map +1 -1
  309. package/dist/esm/interface/crud/team-member-profiles.d.ts +36 -38
  310. package/dist/esm/interface/crud/team-member-profiles.d.ts.map +1 -1
  311. package/dist/esm/interface/crud/team-member-profiles.js +1 -2
  312. package/dist/esm/interface/crud/team-member-profiles.js.map +1 -1
  313. package/dist/esm/interface/crud/team-memberships.d.ts +14 -16
  314. package/dist/esm/interface/crud/team-memberships.d.ts.map +1 -1
  315. package/dist/esm/interface/crud/team-memberships.js +1 -2
  316. package/dist/esm/interface/crud/team-memberships.js.map +1 -1
  317. package/dist/esm/interface/crud/team-permissions.d.ts +29 -31
  318. package/dist/esm/interface/crud/team-permissions.d.ts.map +1 -1
  319. package/dist/esm/interface/crud/team-permissions.js +1 -2
  320. package/dist/esm/interface/crud/team-permissions.js.map +1 -1
  321. package/dist/esm/interface/crud/teams.d.ts +36 -38
  322. package/dist/esm/interface/crud/teams.d.ts.map +1 -1
  323. package/dist/esm/interface/crud/teams.js +2 -4
  324. package/dist/esm/interface/crud/teams.js.map +1 -1
  325. package/dist/esm/interface/crud/transactions.d.ts +14 -16
  326. package/dist/esm/interface/crud/transactions.d.ts.map +1 -1
  327. package/dist/esm/interface/crud/transactions.js +7 -13
  328. package/dist/esm/interface/crud/transactions.js.map +1 -1
  329. package/dist/esm/interface/crud/users.d.ts +21 -22
  330. package/dist/esm/interface/crud/users.d.ts.map +1 -1
  331. package/dist/esm/interface/crud/users.js +9 -5
  332. package/dist/esm/interface/crud/users.js.map +1 -1
  333. package/dist/esm/interface/handler-urls.d.ts +1 -1
  334. package/dist/esm/interface/handler-urls.d.ts.map +1 -1
  335. package/dist/esm/interface/handler-urls.js +1 -2
  336. package/dist/esm/interface/page-component-versions.d.ts +1 -1
  337. package/dist/esm/interface/page-component-versions.d.ts.map +1 -1
  338. package/dist/esm/interface/page-component-versions.js +1 -2
  339. package/dist/esm/interface/page-component-versions.js.map +1 -1
  340. package/dist/esm/interface/plan-usage.d.ts +1 -1
  341. package/dist/esm/interface/plan-usage.d.ts.map +1 -1
  342. package/dist/esm/interface/plan-usage.js +1 -2
  343. package/dist/esm/interface/plan-usage.js.map +1 -1
  344. package/dist/esm/interface/server-interface.d.ts +19 -19
  345. package/dist/esm/interface/server-interface.d.ts.map +1 -1
  346. package/dist/esm/interface/server-interface.js +2 -3
  347. package/dist/esm/interface/server-interface.js.map +1 -1
  348. package/dist/esm/interface/webhooks.d.ts +4 -4
  349. package/dist/esm/interface/webhooks.d.ts.map +1 -1
  350. package/dist/esm/interface/webhooks.js +1 -2
  351. package/dist/esm/interface/webhooks.js.map +1 -1
  352. package/dist/esm/known-errors.d.ts +2 -2
  353. package/dist/esm/known-errors.d.ts.map +1 -1
  354. package/dist/esm/known-errors.js +10 -21
  355. package/dist/esm/known-errors.js.map +1 -1
  356. package/dist/esm/payments/payment-methods.d.ts.map +1 -1
  357. package/dist/esm/payments/payment-methods.js +1 -1
  358. package/dist/esm/payments/payment-methods.js.map +1 -1
  359. package/dist/esm/payments/stripe-limits.d.ts.map +1 -1
  360. package/dist/esm/payments/stripe-limits.js +1 -1
  361. package/dist/esm/payments/stripe-limits.js.map +1 -1
  362. package/dist/esm/plans.d.ts.map +1 -1
  363. package/dist/esm/plans.js +1 -1
  364. package/dist/esm/plans.js.map +1 -1
  365. package/dist/esm/schema-fields.d.ts +14 -14
  366. package/dist/esm/schema-fields.d.ts.map +1 -1
  367. package/dist/esm/schema-fields.js +3 -64
  368. package/dist/esm/schema-fields.js.map +1 -1
  369. package/dist/esm/sessions.d.ts +6 -6
  370. package/dist/esm/sessions.d.ts.map +1 -1
  371. package/dist/esm/sessions.js +1 -2
  372. package/dist/esm/sessions.js.map +1 -1
  373. package/dist/esm/sessions.test.js +2 -3
  374. package/dist/esm/sessions.test.js.map +1 -1
  375. package/dist/esm/utils/analytics-clickmap-overlay.d.ts.map +1 -1
  376. package/dist/esm/utils/analytics-clickmap-overlay.js +1 -1
  377. package/dist/esm/utils/api-keys.d.ts.map +1 -1
  378. package/dist/esm/utils/api-keys.js +1 -2
  379. package/dist/esm/utils/api-keys.js.map +1 -1
  380. package/dist/esm/utils/arrays.d.ts.map +1 -1
  381. package/dist/esm/utils/arrays.js +1 -470
  382. package/dist/esm/utils/arrays.js.map +1 -1
  383. package/dist/esm/utils/auth-methods.d.ts.map +1 -1
  384. package/dist/esm/utils/auth-methods.js +1 -1
  385. package/dist/esm/utils/auth-methods.js.map +1 -1
  386. package/dist/esm/utils/base64.d.ts.map +1 -1
  387. package/dist/esm/utils/base64.js +1 -10
  388. package/dist/esm/utils/base64.js.map +1 -1
  389. package/dist/esm/utils/booleans.d.ts.map +1 -1
  390. package/dist/esm/utils/booleans.js +1 -25
  391. package/dist/esm/utils/booleans.js.map +1 -1
  392. package/dist/esm/utils/browser-compat.d.ts.map +1 -1
  393. package/dist/esm/utils/browser-compat.js +1 -1
  394. package/dist/esm/utils/browser-compat.js.map +1 -1
  395. package/dist/esm/utils/bytes.d.ts.map +1 -1
  396. package/dist/esm/utils/bytes.js +3 -198
  397. package/dist/esm/utils/bytes.js.map +1 -1
  398. package/dist/esm/utils/caches.d.ts +1 -1
  399. package/dist/esm/utils/caches.d.ts.map +1 -1
  400. package/dist/esm/utils/caches.js +1 -27
  401. package/dist/esm/utils/caches.js.map +1 -1
  402. package/dist/esm/utils/cel-fields.d.ts.map +1 -1
  403. package/dist/esm/utils/cel-fields.js +1 -2
  404. package/dist/esm/utils/cel-fields.js.map +1 -1
  405. package/dist/esm/utils/cloud-hosts.d.ts.map +1 -1
  406. package/dist/esm/utils/cloud-hosts.js +1 -27
  407. package/dist/esm/utils/cloud-hosts.js.map +1 -1
  408. package/dist/esm/utils/compile-time.d.ts.map +1 -1
  409. package/dist/esm/utils/compile-time.js +1 -1
  410. package/dist/esm/utils/compile-time.js.map +1 -1
  411. package/dist/esm/utils/country-codes.d.ts.map +1 -1
  412. package/dist/esm/utils/country-codes.js +1 -16
  413. package/dist/esm/utils/country-codes.js.map +1 -1
  414. package/dist/esm/utils/crypto.d.ts.map +1 -1
  415. package/dist/esm/utils/crypto.js +3 -113
  416. package/dist/esm/utils/crypto.js.map +1 -1
  417. package/dist/esm/utils/currencies.d.ts +1 -1
  418. package/dist/esm/utils/currencies.d.ts.map +1 -1
  419. package/dist/esm/utils/currencies.js +2 -37
  420. package/dist/esm/utils/currencies.js.map +1 -1
  421. package/dist/esm/utils/currency-constants.d.ts.map +1 -1
  422. package/dist/esm/utils/currency-constants.js +1 -1
  423. package/dist/esm/utils/currency-constants.js.map +1 -1
  424. package/dist/esm/utils/dates.d.ts.map +1 -1
  425. package/dist/esm/utils/dates.js +1 -44
  426. package/dist/esm/utils/dates.js.map +1 -1
  427. package/dist/esm/utils/dev-env-state-path.d.ts.map +1 -1
  428. package/dist/esm/utils/dev-env-state-path.js +1 -2
  429. package/dist/esm/utils/dev-env-state-path.js.map +1 -1
  430. package/dist/esm/utils/dev-tool.d.ts.map +1 -1
  431. package/dist/esm/utils/dev-tool.js +1 -1
  432. package/dist/esm/utils/dom.d.ts.map +1 -1
  433. package/dist/esm/utils/dom.js +1 -1
  434. package/dist/esm/utils/dom.js.map +1 -1
  435. package/dist/esm/utils/elements-chain.d.ts.map +1 -1
  436. package/dist/esm/utils/elements-chain.js +5 -50
  437. package/dist/esm/utils/elements-chain.js.map +1 -1
  438. package/dist/esm/utils/env.d.ts.map +1 -1
  439. package/dist/esm/utils/env.js +1 -2
  440. package/dist/esm/utils/env.js.map +1 -1
  441. package/dist/esm/utils/env.test.js +2 -3
  442. package/dist/esm/utils/env.test.js.map +1 -1
  443. package/dist/esm/utils/errors.d.ts +1 -1
  444. package/dist/esm/utils/errors.d.ts.map +1 -1
  445. package/dist/esm/utils/errors.js +1 -2
  446. package/dist/esm/utils/errors.js.map +1 -1
  447. package/dist/esm/utils/esbuild.d.ts +1 -1
  448. package/dist/esm/utils/esbuild.d.ts.map +1 -1
  449. package/dist/esm/utils/esbuild.js +2 -3
  450. package/dist/esm/utils/esbuild.js.map +1 -1
  451. package/dist/esm/utils/featurebase.d.ts.map +1 -1
  452. package/dist/esm/utils/featurebase.js +1 -2
  453. package/dist/esm/utils/featurebase.js.map +1 -1
  454. package/dist/esm/utils/fs.d.ts.map +1 -1
  455. package/dist/esm/utils/fs.js +1 -2
  456. package/dist/esm/utils/fs.js.map +1 -1
  457. package/dist/esm/utils/functions.d.ts.map +1 -1
  458. package/dist/esm/utils/functions.js +1 -24
  459. package/dist/esm/utils/functions.js.map +1 -1
  460. package/dist/esm/utils/geo.d.ts.map +1 -1
  461. package/dist/esm/utils/geo.js +1 -2
  462. package/dist/esm/utils/geo.js.map +1 -1
  463. package/dist/esm/utils/globals.d.ts.map +1 -1
  464. package/dist/esm/utils/globals.js +1 -1
  465. package/dist/esm/utils/globals.js.map +1 -1
  466. package/dist/esm/utils/hashes.d.ts.map +1 -1
  467. package/dist/esm/utils/hashes.js +1 -2
  468. package/dist/esm/utils/hashes.js.map +1 -1
  469. package/dist/esm/utils/html.d.ts.map +1 -1
  470. package/dist/esm/utils/html.js +1 -19
  471. package/dist/esm/utils/html.js.map +1 -1
  472. package/dist/esm/utils/http.d.ts.map +1 -1
  473. package/dist/esm/utils/http.js +1 -19
  474. package/dist/esm/utils/http.js.map +1 -1
  475. package/dist/esm/utils/ips.d.ts.map +1 -1
  476. package/dist/esm/utils/ips.js +1 -25
  477. package/dist/esm/utils/ips.js.map +1 -1
  478. package/dist/esm/utils/json.d.ts +1 -1
  479. package/dist/esm/utils/json.d.ts.map +1 -1
  480. package/dist/esm/utils/json.js +1 -155
  481. package/dist/esm/utils/json.js.map +1 -1
  482. package/dist/esm/utils/jsx-editable-transpiler.d.ts.map +1 -1
  483. package/dist/esm/utils/jsx-editable-transpiler.js +1 -2
  484. package/dist/esm/utils/jsx-editable-transpiler.js.map +1 -1
  485. package/dist/esm/utils/jsx-editable-transpiler.test.js +2 -3
  486. package/dist/esm/utils/jsx-editable-transpiler.test.js.map +1 -1
  487. package/dist/esm/utils/jwt.d.ts.map +1 -1
  488. package/dist/esm/utils/jwt.js +1 -2
  489. package/dist/esm/utils/jwt.js.map +1 -1
  490. package/dist/esm/utils/locks.d.ts.map +1 -1
  491. package/dist/esm/utils/locks.js +1 -2
  492. package/dist/esm/utils/locks.js.map +1 -1
  493. package/dist/esm/utils/maps.d.ts.map +1 -1
  494. package/dist/esm/utils/maps.js +1 -111
  495. package/dist/esm/utils/maps.js.map +1 -1
  496. package/dist/esm/utils/math.d.ts.map +1 -1
  497. package/dist/esm/utils/math.js +1 -11
  498. package/dist/esm/utils/math.js.map +1 -1
  499. package/dist/esm/utils/monkey-patch.d.ts.map +1 -1
  500. package/dist/esm/utils/monkey-patch.js +2 -3
  501. package/dist/esm/utils/monkey-patch.js.map +1 -1
  502. package/dist/esm/utils/node-http.js +1 -2
  503. package/dist/esm/utils/node-http.js.map +1 -1
  504. package/dist/esm/utils/numbers.d.ts.map +1 -1
  505. package/dist/esm/utils/numbers.js +1 -45
  506. package/dist/esm/utils/numbers.js.map +1 -1
  507. package/dist/esm/utils/oauth.d.ts.map +1 -1
  508. package/dist/esm/utils/oauth.js +1 -1
  509. package/dist/esm/utils/oauth.js.map +1 -1
  510. package/dist/esm/utils/objects.d.ts.map +1 -1
  511. package/dist/esm/utils/objects.js +1 -622
  512. package/dist/esm/utils/objects.js.map +1 -1
  513. package/dist/esm/utils/paginated-lists.d.ts.map +1 -1
  514. package/dist/esm/utils/paginated-lists.js +1 -2
  515. package/dist/esm/utils/paginated-lists.js.map +1 -1
  516. package/dist/esm/utils/paginated-lists.test.js +2 -3
  517. package/dist/esm/utils/paginated-lists.test.js.map +1 -1
  518. package/dist/esm/utils/passkey.d.ts +1 -1
  519. package/dist/esm/utils/passkey.js +1 -1
  520. package/dist/esm/utils/promises.d.ts +1 -1
  521. package/dist/esm/utils/promises.d.ts.map +1 -1
  522. package/dist/esm/utils/promises.js +2 -161
  523. package/dist/esm/utils/promises.js.map +1 -1
  524. package/dist/esm/utils/proxies.d.ts.map +1 -1
  525. package/dist/esm/utils/proxies.js +1 -37
  526. package/dist/esm/utils/proxies.js.map +1 -1
  527. package/dist/esm/utils/react.d.ts.map +1 -1
  528. package/dist/esm/utils/react.js +1 -41
  529. package/dist/esm/utils/react.js.map +1 -1
  530. package/dist/esm/utils/redirect-urls.d.ts.map +1 -1
  531. package/dist/esm/utils/redirect-urls.js +2 -92
  532. package/dist/esm/utils/redirect-urls.js.map +1 -1
  533. package/dist/esm/utils/regex.js +1 -1
  534. package/dist/esm/utils/regex.js.map +1 -1
  535. package/dist/esm/utils/results.d.ts.map +1 -1
  536. package/dist/esm/utils/results.js +1 -213
  537. package/dist/esm/utils/results.js.map +1 -1
  538. package/dist/esm/utils/sentry.js +1 -1
  539. package/dist/esm/utils/sentry.js.map +1 -1
  540. package/dist/esm/utils/stores.d.ts +3 -3
  541. package/dist/esm/utils/stores.d.ts.map +1 -1
  542. package/dist/esm/utils/stores.js +1 -2
  543. package/dist/esm/utils/stores.js.map +1 -1
  544. package/dist/esm/utils/strings.d.ts.map +1 -1
  545. package/dist/esm/utils/strings.js +1 -251
  546. package/dist/esm/utils/strings.js.map +1 -1
  547. package/dist/esm/utils/strings.nicify.test.js +2 -3
  548. package/dist/esm/utils/strings.nicify.test.js.map +1 -1
  549. package/dist/esm/utils/telemetry.d.ts.map +1 -1
  550. package/dist/esm/utils/telemetry.js +1 -2
  551. package/dist/esm/utils/telemetry.js.map +1 -1
  552. package/dist/esm/utils/turnstile-browser.d.ts +1 -1
  553. package/dist/esm/utils/turnstile-browser.d.ts.map +1 -1
  554. package/dist/esm/utils/turnstile-browser.js +1 -2
  555. package/dist/esm/utils/turnstile-browser.js.map +1 -1
  556. package/dist/esm/utils/turnstile-flow.d.ts +1 -1
  557. package/dist/esm/utils/turnstile-flow.d.ts.map +1 -1
  558. package/dist/esm/utils/turnstile-flow.js +1 -2
  559. package/dist/esm/utils/turnstile-flow.js.map +1 -1
  560. package/dist/esm/utils/turnstile-flow.test.js +2 -3
  561. package/dist/esm/utils/turnstile-flow.test.js.map +1 -1
  562. package/dist/esm/utils/turnstile.d.ts.map +1 -1
  563. package/dist/esm/utils/turnstile.js +1 -1
  564. package/dist/esm/utils/turnstile.js.map +1 -1
  565. package/dist/esm/utils/typed-arrays.js +1 -2
  566. package/dist/esm/utils/typed-arrays.js.map +1 -1
  567. package/dist/esm/utils/types.d.ts +1 -1
  568. package/dist/esm/utils/types.d.ts.map +1 -1
  569. package/dist/esm/utils/types.js +1 -1
  570. package/dist/esm/utils/types.js.map +1 -1
  571. package/dist/esm/utils/unicode.d.ts.map +1 -1
  572. package/dist/esm/utils/unicode.js +1 -13
  573. package/dist/esm/utils/unicode.js.map +1 -1
  574. package/dist/esm/utils/urls.d.ts.map +1 -1
  575. package/dist/esm/utils/urls.js +1 -151
  576. package/dist/esm/utils/urls.js.map +1 -1
  577. package/dist/esm/utils/uuids.d.ts.map +1 -1
  578. package/dist/esm/utils/uuids.js +2 -26
  579. package/dist/esm/utils/uuids.js.map +1 -1
  580. package/dist/format-4JG1MGv5.d.ts +61 -0
  581. package/dist/format-4JG1MGv5.d.ts.map +1 -0
  582. package/dist/handler-urls-BHt3v8Ai.d.ts +70 -0
  583. package/dist/handler-urls-BHt3v8Ai.d.ts.map +1 -0
  584. package/dist/helpers/emails.js +2 -4
  585. package/dist/helpers/emails.js.map +1 -1
  586. package/dist/helpers/init-prompt.d.ts.map +1 -1
  587. package/dist/helpers/init-prompt.js +2 -4
  588. package/dist/helpers/init-prompt.js.map +1 -1
  589. package/dist/helpers/password.d.ts +1 -1
  590. package/dist/helpers/password.d.ts.map +1 -1
  591. package/dist/helpers/password.js +2 -4
  592. package/dist/helpers/password.js.map +1 -1
  593. package/dist/helpers/production-mode.d.ts +1 -1
  594. package/dist/helpers/production-mode.d.ts.map +1 -1
  595. package/dist/helpers/production-mode.js +2 -4
  596. package/dist/helpers/production-mode.js.map +1 -1
  597. package/dist/helpers/support-sla.d.ts.map +1 -1
  598. package/dist/helpers/support-sla.js +2 -3
  599. package/dist/helpers/support-sla.js.map +1 -1
  600. package/dist/helpers/support-sla.test.js +1 -3
  601. package/dist/helpers/support-sla.test.js.map +1 -1
  602. package/dist/helpers/vault/client-side.d.ts.map +1 -1
  603. package/dist/helpers/vault/client-side.js +2 -22
  604. package/dist/helpers/vault/client-side.js.map +1 -1
  605. package/dist/helpers/vault/server-side.js +2 -4
  606. package/dist/helpers/vault/server-side.js.map +1 -1
  607. package/dist/hooks/use-async-callback.d.ts.map +1 -1
  608. package/dist/hooks/use-async-callback.js +4 -5
  609. package/dist/hooks/use-async-callback.js.map +1 -1
  610. package/dist/hooks/use-async-external-store.d.ts +1 -1
  611. package/dist/hooks/use-async-external-store.d.ts.map +1 -1
  612. package/dist/hooks/use-async-external-store.js +2 -4
  613. package/dist/hooks/use-async-external-store.js.map +1 -1
  614. package/dist/hooks/use-hash.js +2 -4
  615. package/dist/hooks/use-hash.js.map +1 -1
  616. package/dist/hooks/use-hover.d.ts.map +1 -1
  617. package/dist/hooks/use-hover.js +2 -4
  618. package/dist/hooks/use-hover.js.map +1 -1
  619. package/dist/hooks/use-strict-memo.d.ts.map +1 -1
  620. package/dist/hooks/use-strict-memo.js +2 -72
  621. package/dist/hooks/use-strict-memo.js.map +1 -1
  622. package/dist/index.d.ts +4 -4
  623. package/dist/index.js +27 -29
  624. package/dist/interface/admin-interface.d.ts +3 -379
  625. package/dist/interface/admin-interface.js +3 -5
  626. package/dist/interface/admin-interface.js.map +1 -1
  627. package/dist/interface/admin-metrics.d.ts +2 -807
  628. package/dist/interface/admin-metrics.js +2 -4
  629. package/dist/interface/admin-metrics.js.map +1 -1
  630. package/dist/interface/client-interface.d.ts +2 -447
  631. package/dist/interface/client-interface.js +33 -18
  632. package/dist/interface/client-interface.js.map +1 -1
  633. package/dist/interface/client-interface.test.js +83 -13
  634. package/dist/interface/client-interface.test.js.map +1 -1
  635. package/dist/interface/conversations.d.ts +8 -8
  636. package/dist/interface/conversations.d.ts.map +1 -1
  637. package/dist/interface/conversations.js +2 -4
  638. package/dist/interface/conversations.js.map +1 -1
  639. package/dist/interface/crud/analytics.d.ts +2 -14
  640. package/dist/interface/crud/connected-accounts.d.ts +2 -68
  641. package/dist/interface/crud/connected-accounts.js +2 -4
  642. package/dist/interface/crud/connected-accounts.js.map +1 -1
  643. package/dist/interface/crud/contact-channels.d.ts +2 -181
  644. package/dist/interface/crud/contact-channels.js +2 -4
  645. package/dist/interface/crud/contact-channels.js.map +1 -1
  646. package/dist/interface/crud/current-user.d.ts +2 -285
  647. package/dist/interface/crud/current-user.js +2 -4
  648. package/dist/interface/crud/current-user.js.map +1 -1
  649. package/dist/interface/crud/email-outbox.d.ts +2 -1465
  650. package/dist/interface/crud/email-outbox.js +4 -5
  651. package/dist/interface/crud/email-outbox.js.map +1 -1
  652. package/dist/interface/crud/email-templates.d.ts +15 -16
  653. package/dist/interface/crud/email-templates.d.ts.map +1 -1
  654. package/dist/interface/crud/email-templates.js +2 -4
  655. package/dist/interface/crud/email-templates.js.map +1 -1
  656. package/dist/interface/crud/emails.d.ts +2 -41
  657. package/dist/interface/crud/emails.js +4 -5
  658. package/dist/interface/crud/emails.js.map +1 -1
  659. package/dist/interface/crud/internal-api-keys.d.ts +2 -140
  660. package/dist/interface/crud/internal-api-keys.js +2 -4
  661. package/dist/interface/crud/internal-api-keys.js.map +1 -1
  662. package/dist/interface/crud/invoices.d.ts +2 -43
  663. package/dist/interface/crud/invoices.js +2 -4
  664. package/dist/interface/crud/invoices.js.map +1 -1
  665. package/dist/interface/crud/items.d.ts +2 -30
  666. package/dist/interface/crud/items.js +2 -4
  667. package/dist/interface/crud/items.js.map +1 -1
  668. package/dist/interface/crud/notification-preferences.d.ts +2 -38
  669. package/dist/interface/crud/notification-preferences.js +2 -4
  670. package/dist/interface/crud/notification-preferences.js.map +1 -1
  671. package/dist/interface/crud/oauth-providers.d.ts +2 -186
  672. package/dist/interface/crud/oauth-providers.js +2 -4
  673. package/dist/interface/crud/oauth-providers.js.map +1 -1
  674. package/dist/interface/crud/products.d.ts +2 -182
  675. package/dist/interface/crud/products.js +4 -4
  676. package/dist/interface/crud/products.js.map +1 -1
  677. package/dist/interface/crud/project-api-keys.d.ts +2 -203
  678. package/dist/interface/crud/project-api-keys.js +2 -4
  679. package/dist/interface/crud/project-api-keys.js.map +1 -1
  680. package/dist/interface/crud/project-permissions.d.ts +2 -161
  681. package/dist/interface/crud/project-permissions.js +4 -5
  682. package/dist/interface/crud/project-permissions.js.map +1 -1
  683. package/dist/interface/crud/projects.d.ts +2 -901
  684. package/dist/interface/crud/projects.js +6 -5
  685. package/dist/interface/crud/projects.js.map +1 -1
  686. package/dist/interface/crud/session-replays.d.ts +2 -83
  687. package/dist/interface/crud/sessions.d.ts +2 -150
  688. package/dist/interface/crud/sessions.js +2 -4
  689. package/dist/interface/crud/sessions.js.map +1 -1
  690. package/dist/interface/crud/sign-up-rules.d.ts.map +1 -1
  691. package/dist/interface/crud/svix-token.d.ts +2 -31
  692. package/dist/interface/crud/svix-token.js +2 -4
  693. package/dist/interface/crud/svix-token.js.map +1 -1
  694. package/dist/interface/crud/team-invitation-details.d.ts +5 -6
  695. package/dist/interface/crud/team-invitation-details.d.ts.map +1 -1
  696. package/dist/interface/crud/team-invitation-details.js +4 -5
  697. package/dist/interface/crud/team-invitation-details.js.map +1 -1
  698. package/dist/interface/crud/team-invitation.d.ts +2 -54
  699. package/dist/interface/crud/team-invitation.js +4 -5
  700. package/dist/interface/crud/team-invitation.js.map +1 -1
  701. package/dist/interface/crud/team-member-profiles.d.ts +2 -286
  702. package/dist/interface/crud/team-member-profiles.js +4 -5
  703. package/dist/interface/crud/team-member-profiles.js.map +1 -1
  704. package/dist/interface/crud/team-memberships.d.ts +2 -75
  705. package/dist/interface/crud/team-memberships.js +2 -4
  706. package/dist/interface/crud/team-memberships.js.map +1 -1
  707. package/dist/interface/crud/team-permissions.d.ts +2 -169
  708. package/dist/interface/crud/team-permissions.js +4 -5
  709. package/dist/interface/crud/team-permissions.js.map +1 -1
  710. package/dist/interface/crud/teams.d.ts +2 -299
  711. package/dist/interface/crud/teams.js +5 -7
  712. package/dist/interface/crud/teams.js.map +1 -1
  713. package/dist/interface/crud/transactions.d.ts +2 -183
  714. package/dist/interface/crud/transactions.js +2 -4
  715. package/dist/interface/crud/transactions.js.map +1 -1
  716. package/dist/interface/crud/users.d.ts +2 -653
  717. package/dist/interface/crud/users.js +12 -8
  718. package/dist/interface/crud/users.js.map +1 -1
  719. package/dist/interface/handler-urls.d.ts +2 -51
  720. package/dist/interface/handler-urls.js +12 -14
  721. package/dist/interface/page-component-versions.d.ts +2 -25
  722. package/dist/interface/page-component-versions.js +2 -4
  723. package/dist/interface/page-component-versions.js.map +1 -1
  724. package/dist/interface/plan-usage.d.ts +2 -57
  725. package/dist/interface/plan-usage.js +2 -4
  726. package/dist/interface/plan-usage.js.map +1 -1
  727. package/dist/interface/server-interface.d.ts +2 -257
  728. package/dist/interface/server-interface.js +3 -5
  729. package/dist/interface/server-interface.js.map +1 -1
  730. package/dist/interface/webhooks.d.ts +2 -326
  731. package/dist/interface/webhooks.js +2 -4
  732. package/dist/interface/webhooks.js.map +1 -1
  733. package/dist/internal-api-keys-D8IYDodH.d.ts +139 -0
  734. package/dist/internal-api-keys-D8IYDodH.d.ts.map +1 -0
  735. package/dist/invoices-CHo9YKbI.d.ts +43 -0
  736. package/dist/invoices-CHo9YKbI.d.ts.map +1 -0
  737. package/dist/items-DlLSlVUD.d.ts +29 -0
  738. package/dist/items-DlLSlVUD.d.ts.map +1 -0
  739. package/dist/json-a1QIXu5z.d.ts +15 -0
  740. package/dist/json-a1QIXu5z.d.ts.map +1 -0
  741. package/dist/known-errors-Bm4a61wL.d.ts +575 -0
  742. package/dist/known-errors-Bm4a61wL.d.ts.map +1 -0
  743. package/dist/known-errors.d.ts +2 -575
  744. package/dist/known-errors.js +11 -23
  745. package/dist/known-errors.js.map +1 -1
  746. package/dist/notification-preferences-Bmzr_EOY.d.ts +37 -0
  747. package/dist/notification-preferences-Bmzr_EOY.d.ts.map +1 -0
  748. package/dist/oauth-providers-BMkKSSlA.d.ts +185 -0
  749. package/dist/oauth-providers-BMkKSSlA.d.ts.map +1 -0
  750. package/dist/objects-DkCkeBWE.d.ts +59 -0
  751. package/dist/objects-DkCkeBWE.d.ts.map +1 -0
  752. package/dist/passkey-CKg87UH-.d.ts +2 -0
  753. package/dist/payments/payment-methods.d.ts.map +1 -1
  754. package/dist/payments/payment-methods.js +2 -3
  755. package/dist/payments/payment-methods.js.map +1 -1
  756. package/dist/payments/stripe-limits.d.ts.map +1 -1
  757. package/dist/payments/stripe-limits.js +2 -3
  758. package/dist/payments/stripe-limits.js.map +1 -1
  759. package/dist/plan-usage-DfDoj5K4.d.ts +57 -0
  760. package/dist/plan-usage-DfDoj5K4.d.ts.map +1 -0
  761. package/dist/plans.d.ts.map +1 -1
  762. package/dist/plans.js +2 -3
  763. package/dist/plans.js.map +1 -1
  764. package/dist/products-Bs74ld-v.d.ts +182 -0
  765. package/dist/products-Bs74ld-v.d.ts.map +1 -0
  766. package/dist/project-api-keys--7V5X_UW.d.ts +203 -0
  767. package/dist/project-api-keys--7V5X_UW.d.ts.map +1 -0
  768. package/dist/project-permissions-kdi675F-.d.ts +160 -0
  769. package/dist/project-permissions-kdi675F-.d.ts.map +1 -0
  770. package/dist/projects-CFTNXRfG.d.ts +900 -0
  771. package/dist/projects-CFTNXRfG.d.ts.map +1 -0
  772. package/dist/results-DP3BzoL6.d.ts +70 -0
  773. package/dist/results-DP3BzoL6.d.ts.map +1 -0
  774. package/dist/{chunk-BE-pF4vm.js → rolldown-runtime-D6vf50IK.js} +12 -18
  775. package/dist/schema-CJwkGkdf.d.ts +2328 -0
  776. package/dist/schema-CJwkGkdf.d.ts.map +1 -0
  777. package/dist/schema-fields-DqGQ4kF7.d.ts +517 -0
  778. package/dist/schema-fields-DqGQ4kF7.d.ts.map +1 -0
  779. package/dist/schema-fields.d.ts +3 -518
  780. package/dist/schema-fields.js +21 -82
  781. package/dist/schema-fields.js.map +1 -1
  782. package/dist/server-interface-CgpxsLT_.d.ts +257 -0
  783. package/dist/server-interface-CgpxsLT_.d.ts.map +1 -0
  784. package/dist/session-replays-CXqhDpZq.d.ts +83 -0
  785. package/dist/session-replays-CXqhDpZq.d.ts.map +1 -0
  786. package/dist/sessions-B7Ko2Ldr.d.ts +149 -0
  787. package/dist/sessions-B7Ko2Ldr.d.ts.map +1 -0
  788. package/dist/sessions-d8qtvBUB.d.ts +175 -0
  789. package/dist/sessions-d8qtvBUB.d.ts.map +1 -0
  790. package/dist/sessions.d.ts +2 -175
  791. package/dist/sessions.js +4 -5
  792. package/dist/sessions.js.map +1 -1
  793. package/dist/sessions.test.js +1 -3
  794. package/dist/sessions.test.js.map +1 -1
  795. package/dist/strings-DWgkUybS.d.ts +76 -0
  796. package/dist/strings-DWgkUybS.d.ts.map +1 -0
  797. package/dist/svix-token-BsMrLGvy.d.ts +30 -0
  798. package/dist/svix-token-BsMrLGvy.d.ts.map +1 -0
  799. package/dist/team-invitation-Cyqt9oWw.d.ts +53 -0
  800. package/dist/team-invitation-Cyqt9oWw.d.ts.map +1 -0
  801. package/dist/team-member-profiles-BoDEqx-0.d.ts +285 -0
  802. package/dist/team-member-profiles-BoDEqx-0.d.ts.map +1 -0
  803. package/dist/team-memberships-DZHk2A5b.d.ts +74 -0
  804. package/dist/team-memberships-DZHk2A5b.d.ts.map +1 -0
  805. package/dist/team-permissions-DqOpaOWh.d.ts +168 -0
  806. package/dist/team-permissions-DqOpaOWh.d.ts.map +1 -0
  807. package/dist/teams-CQMcBnjM.d.ts +298 -0
  808. package/dist/teams-CQMcBnjM.d.ts.map +1 -0
  809. package/dist/transactions-DhnbvGH5.d.ts +182 -0
  810. package/dist/transactions-DhnbvGH5.d.ts.map +1 -0
  811. package/dist/types-DfTcxNtM.d.ts +77 -0
  812. package/dist/types-DfTcxNtM.d.ts.map +1 -0
  813. package/dist/users-DHNRwoSz.d.ts +653 -0
  814. package/dist/users-DHNRwoSz.d.ts.map +1 -0
  815. package/dist/utils/analytics-clickmap-overlay.d.ts.map +1 -1
  816. package/dist/utils/analytics-clickmap-overlay.js +2 -3
  817. package/dist/utils/analytics-clickmap-overlay.js.map +1 -1
  818. package/dist/utils/api-keys.d.ts.map +1 -1
  819. package/dist/utils/api-keys.js +4 -5
  820. package/dist/utils/api-keys.js.map +1 -1
  821. package/dist/utils/arrays.d.ts.map +1 -1
  822. package/dist/utils/arrays.js +2 -472
  823. package/dist/utils/arrays.js.map +1 -1
  824. package/dist/utils/auth-methods.d.ts.map +1 -1
  825. package/dist/utils/auth-methods.js +2 -3
  826. package/dist/utils/auth-methods.js.map +1 -1
  827. package/dist/utils/base64.d.ts.map +1 -1
  828. package/dist/utils/base64.js +2 -12
  829. package/dist/utils/base64.js.map +1 -1
  830. package/dist/utils/booleans.d.ts.map +1 -1
  831. package/dist/utils/booleans.js +2 -27
  832. package/dist/utils/booleans.js.map +1 -1
  833. package/dist/utils/browser-compat.d.ts.map +1 -1
  834. package/dist/utils/browser-compat.js +2 -3
  835. package/dist/utils/browser-compat.js.map +1 -1
  836. package/dist/utils/bytes.d.ts.map +1 -1
  837. package/dist/utils/bytes.js +4 -200
  838. package/dist/utils/bytes.js.map +1 -1
  839. package/dist/utils/caches.d.ts.map +1 -1
  840. package/dist/utils/caches.js +2 -29
  841. package/dist/utils/caches.js.map +1 -1
  842. package/dist/utils/cel-fields.d.ts.map +1 -1
  843. package/dist/utils/cel-fields.js +2 -4
  844. package/dist/utils/cel-fields.js.map +1 -1
  845. package/dist/utils/cloud-hosts.d.ts.map +1 -1
  846. package/dist/utils/cloud-hosts.js +2 -29
  847. package/dist/utils/cloud-hosts.js.map +1 -1
  848. package/dist/utils/compile-time.d.ts.map +1 -1
  849. package/dist/utils/compile-time.js +2 -3
  850. package/dist/utils/compile-time.js.map +1 -1
  851. package/dist/utils/country-codes.d.ts +2 -11
  852. package/dist/utils/country-codes.js +2 -18
  853. package/dist/utils/country-codes.js.map +1 -1
  854. package/dist/utils/crypto.d.ts.map +1 -1
  855. package/dist/utils/crypto.js +4 -115
  856. package/dist/utils/crypto.js.map +1 -1
  857. package/dist/utils/currencies.d.ts +1 -1
  858. package/dist/utils/currencies.d.ts.map +1 -1
  859. package/dist/utils/currencies.js +3 -39
  860. package/dist/utils/currencies.js.map +1 -1
  861. package/dist/utils/currency-constants.d.ts +2 -45
  862. package/dist/utils/currency-constants.js +2 -3
  863. package/dist/utils/currency-constants.js.map +1 -1
  864. package/dist/utils/dates.d.ts +2 -23
  865. package/dist/utils/dates.js +2 -46
  866. package/dist/utils/dates.js.map +1 -1
  867. package/dist/utils/dev-env-state-path.d.ts.map +1 -1
  868. package/dist/utils/dev-env-state-path.js +2 -4
  869. package/dist/utils/dev-env-state-path.js.map +1 -1
  870. package/dist/utils/dev-tool.d.ts.map +1 -1
  871. package/dist/utils/dev-tool.js +2 -3
  872. package/dist/utils/dev-tool.js.map +1 -1
  873. package/dist/utils/dom.d.ts.map +1 -1
  874. package/dist/utils/dom.js +2 -3
  875. package/dist/utils/dom.js.map +1 -1
  876. package/dist/utils/elements-chain.d.ts.map +1 -1
  877. package/dist/utils/elements-chain.js +6 -52
  878. package/dist/utils/elements-chain.js.map +1 -1
  879. package/dist/utils/env.d.ts.map +1 -1
  880. package/dist/utils/env.js +2 -4
  881. package/dist/utils/env.js.map +1 -1
  882. package/dist/utils/env.test.js +1 -3
  883. package/dist/utils/env.test.js.map +1 -1
  884. package/dist/utils/errors.d.ts +2 -238
  885. package/dist/utils/errors.js +2 -4
  886. package/dist/utils/errors.js.map +1 -1
  887. package/dist/utils/esbuild.d.ts +1 -1
  888. package/dist/utils/esbuild.d.ts.map +1 -1
  889. package/dist/utils/esbuild.js +5 -6
  890. package/dist/utils/esbuild.js.map +1 -1
  891. package/dist/utils/featurebase.d.ts.map +1 -1
  892. package/dist/utils/featurebase.js +2 -4
  893. package/dist/utils/featurebase.js.map +1 -1
  894. package/dist/utils/fs.d.ts.map +1 -1
  895. package/dist/utils/fs.js +5 -6
  896. package/dist/utils/fs.js.map +1 -1
  897. package/dist/utils/functions.d.ts.map +1 -1
  898. package/dist/utils/functions.js +2 -26
  899. package/dist/utils/functions.js.map +1 -1
  900. package/dist/utils/geo.d.ts.map +1 -1
  901. package/dist/utils/geo.js +2 -4
  902. package/dist/utils/geo.js.map +1 -1
  903. package/dist/utils/globals.d.ts.map +1 -1
  904. package/dist/utils/globals.js +2 -3
  905. package/dist/utils/globals.js.map +1 -1
  906. package/dist/utils/hashes.d.ts.map +1 -1
  907. package/dist/utils/hashes.js +4 -5
  908. package/dist/utils/hashes.js.map +1 -1
  909. package/dist/utils/html.d.ts.map +1 -1
  910. package/dist/utils/html.js +2 -21
  911. package/dist/utils/html.js.map +1 -1
  912. package/dist/utils/http.d.ts.map +1 -1
  913. package/dist/utils/http.js +2 -21
  914. package/dist/utils/http.js.map +1 -1
  915. package/dist/utils/ips.d.ts.map +1 -1
  916. package/dist/utils/ips.js +4 -28
  917. package/dist/utils/ips.js.map +1 -1
  918. package/dist/utils/json.d.ts +2 -15
  919. package/dist/utils/json.js +2 -157
  920. package/dist/utils/json.js.map +1 -1
  921. package/dist/utils/jsx-editable-transpiler.d.ts.map +1 -1
  922. package/dist/utils/jsx-editable-transpiler.js +7 -8
  923. package/dist/utils/jsx-editable-transpiler.js.map +1 -1
  924. package/dist/utils/jsx-editable-transpiler.test.js +1 -3
  925. package/dist/utils/jsx-editable-transpiler.test.js.map +1 -1
  926. package/dist/utils/jwt.d.ts.map +1 -1
  927. package/dist/utils/jwt.js +6 -7
  928. package/dist/utils/jwt.js.map +1 -1
  929. package/dist/utils/locks.d.ts.map +1 -1
  930. package/dist/utils/locks.js +2 -4
  931. package/dist/utils/locks.js.map +1 -1
  932. package/dist/utils/maps.d.ts.map +1 -1
  933. package/dist/utils/maps.js +2 -113
  934. package/dist/utils/maps.js.map +1 -1
  935. package/dist/utils/math.d.ts.map +1 -1
  936. package/dist/utils/math.js +2 -13
  937. package/dist/utils/math.js.map +1 -1
  938. package/dist/utils/monkey-patch.d.ts.map +1 -1
  939. package/dist/utils/monkey-patch.js +3 -5
  940. package/dist/utils/monkey-patch.js.map +1 -1
  941. package/dist/utils/node-http.js +2 -4
  942. package/dist/utils/node-http.js.map +1 -1
  943. package/dist/utils/numbers.d.ts.map +1 -1
  944. package/dist/utils/numbers.js +2 -47
  945. package/dist/utils/numbers.js.map +1 -1
  946. package/dist/utils/oauth.d.ts.map +1 -1
  947. package/dist/utils/oauth.js +2 -3
  948. package/dist/utils/oauth.js.map +1 -1
  949. package/dist/utils/objects.d.ts +2 -59
  950. package/dist/utils/objects.js +2 -624
  951. package/dist/utils/objects.js.map +1 -1
  952. package/dist/utils/paginated-lists.d.ts.map +1 -1
  953. package/dist/utils/paginated-lists.js +2 -4
  954. package/dist/utils/paginated-lists.js.map +1 -1
  955. package/dist/utils/paginated-lists.test.js +1 -3
  956. package/dist/utils/paginated-lists.test.js.map +1 -1
  957. package/dist/utils/passkey.d.ts +2 -2
  958. package/dist/utils/promises.d.ts +1 -1
  959. package/dist/utils/promises.d.ts.map +1 -1
  960. package/dist/utils/promises.js +3 -163
  961. package/dist/utils/promises.js.map +1 -1
  962. package/dist/utils/proxies.d.ts.map +1 -1
  963. package/dist/utils/proxies.js +2 -39
  964. package/dist/utils/proxies.js.map +1 -1
  965. package/dist/utils/react.d.ts.map +1 -1
  966. package/dist/utils/react.js +4 -44
  967. package/dist/utils/react.js.map +1 -1
  968. package/dist/utils/redirect-urls.d.ts.map +1 -1
  969. package/dist/utils/redirect-urls.js +3 -94
  970. package/dist/utils/redirect-urls.js.map +1 -1
  971. package/dist/utils/regex.js +2 -3
  972. package/dist/utils/regex.js.map +1 -1
  973. package/dist/utils/results.d.ts +2 -70
  974. package/dist/utils/results.js +2 -215
  975. package/dist/utils/results.js.map +1 -1
  976. package/dist/utils/sentry.js +2 -3
  977. package/dist/utils/sentry.js.map +1 -1
  978. package/dist/utils/stores.d.ts +1 -1
  979. package/dist/utils/stores.d.ts.map +1 -1
  980. package/dist/utils/stores.js +2 -4
  981. package/dist/utils/stores.js.map +1 -1
  982. package/dist/utils/strings.d.ts +2 -76
  983. package/dist/utils/strings.js +2 -253
  984. package/dist/utils/strings.js.map +1 -1
  985. package/dist/utils/strings.nicify.test.js +1 -3
  986. package/dist/utils/strings.nicify.test.js.map +1 -1
  987. package/dist/utils/telemetry.d.ts.map +1 -1
  988. package/dist/utils/telemetry.js +2 -4
  989. package/dist/utils/telemetry.js.map +1 -1
  990. package/dist/utils/turnstile-browser.d.ts.map +1 -1
  991. package/dist/utils/turnstile-browser.js +2 -4
  992. package/dist/utils/turnstile-browser.js.map +1 -1
  993. package/dist/utils/turnstile-flow.d.ts.map +1 -1
  994. package/dist/utils/turnstile-flow.js +2 -4
  995. package/dist/utils/turnstile-flow.js.map +1 -1
  996. package/dist/utils/turnstile-flow.test.js +1 -3
  997. package/dist/utils/turnstile-flow.test.js.map +1 -1
  998. package/dist/utils/turnstile.d.ts.map +1 -1
  999. package/dist/utils/turnstile.js +2 -3
  1000. package/dist/utils/turnstile.js.map +1 -1
  1001. package/dist/utils/typed-arrays.js +2 -4
  1002. package/dist/utils/typed-arrays.js.map +1 -1
  1003. package/dist/utils/types.d.ts +2 -77
  1004. package/dist/utils/types.js +2 -3
  1005. package/dist/utils/types.js.map +1 -1
  1006. package/dist/utils/unicode.d.ts.map +1 -1
  1007. package/dist/utils/unicode.js +2 -15
  1008. package/dist/utils/unicode.js.map +1 -1
  1009. package/dist/utils/urls.d.ts.map +1 -1
  1010. package/dist/utils/urls.js +2 -153
  1011. package/dist/utils/urls.js.map +1 -1
  1012. package/dist/utils/uuids.d.ts.map +1 -1
  1013. package/dist/utils/uuids.js +3 -28
  1014. package/dist/utils/uuids.js.map +1 -1
  1015. package/dist/webhooks-8Ts1Clcb.d.ts +326 -0
  1016. package/dist/webhooks-8Ts1Clcb.d.ts.map +1 -0
  1017. package/package.json +2 -8
  1018. package/src/interface/client-interface.test.ts +77 -12
  1019. package/src/interface/client-interface.ts +9 -9
  1020. package/dist/config/format.d.ts.map +0 -1
  1021. package/dist/config/schema.d.ts.map +0 -1
  1022. package/dist/crud.d.ts.map +0 -1
  1023. package/dist/interface/admin-interface.d.ts.map +0 -1
  1024. package/dist/interface/admin-metrics.d.ts.map +0 -1
  1025. package/dist/interface/client-interface.d.ts.map +0 -1
  1026. package/dist/interface/crud/analytics.d.ts.map +0 -1
  1027. package/dist/interface/crud/connected-accounts.d.ts.map +0 -1
  1028. package/dist/interface/crud/contact-channels.d.ts.map +0 -1
  1029. package/dist/interface/crud/current-user.d.ts.map +0 -1
  1030. package/dist/interface/crud/emails.d.ts.map +0 -1
  1031. package/dist/interface/crud/internal-api-keys.d.ts.map +0 -1
  1032. package/dist/interface/crud/invoices.d.ts.map +0 -1
  1033. package/dist/interface/crud/items.d.ts.map +0 -1
  1034. package/dist/interface/crud/notification-preferences.d.ts.map +0 -1
  1035. package/dist/interface/crud/oauth-providers.d.ts.map +0 -1
  1036. package/dist/interface/crud/products.d.ts.map +0 -1
  1037. package/dist/interface/crud/project-api-keys.d.ts.map +0 -1
  1038. package/dist/interface/crud/project-permissions.d.ts.map +0 -1
  1039. package/dist/interface/crud/projects.d.ts.map +0 -1
  1040. package/dist/interface/crud/session-replays.d.ts.map +0 -1
  1041. package/dist/interface/crud/sessions.d.ts.map +0 -1
  1042. package/dist/interface/crud/svix-token.d.ts.map +0 -1
  1043. package/dist/interface/crud/team-invitation.d.ts.map +0 -1
  1044. package/dist/interface/crud/team-member-profiles.d.ts.map +0 -1
  1045. package/dist/interface/crud/team-memberships.d.ts.map +0 -1
  1046. package/dist/interface/crud/team-permissions.d.ts.map +0 -1
  1047. package/dist/interface/crud/teams.d.ts.map +0 -1
  1048. package/dist/interface/crud/transactions.d.ts.map +0 -1
  1049. package/dist/interface/crud/users.d.ts.map +0 -1
  1050. package/dist/interface/handler-urls.d.ts.map +0 -1
  1051. package/dist/interface/page-component-versions.d.ts.map +0 -1
  1052. package/dist/interface/plan-usage.d.ts.map +0 -1
  1053. package/dist/interface/server-interface.d.ts.map +0 -1
  1054. package/dist/interface/webhooks.d.ts.map +0 -1
  1055. package/dist/known-errors.d.ts.map +0 -1
  1056. package/dist/schema-fields.d.ts.map +0 -1
  1057. package/dist/sessions.d.ts.map +0 -1
  1058. package/dist/utils/country-codes.d.ts.map +0 -1
  1059. package/dist/utils/currency-constants.d.ts.map +0 -1
  1060. package/dist/utils/dates.d.ts.map +0 -1
  1061. package/dist/utils/errors.d.ts.map +0 -1
  1062. package/dist/utils/json.d.ts.map +0 -1
  1063. package/dist/utils/objects.d.ts.map +0 -1
  1064. package/dist/utils/results.d.ts.map +0 -1
  1065. package/dist/utils/strings.d.ts.map +0 -1
  1066. package/dist/utils/types.d.ts.map +0 -1
@@ -60,33 +60,7 @@ function getStackAuthApiBaseUrl(apiUrl) {
60
60
  function getHexclaveApiBaseUrl(apiUrl) {
61
61
  return getCloudApiUrlSiblings(apiUrl)?.hexclave ?? apiUrl;
62
62
  }
63
- (void 0)?.test("getCloudApiUrlSiblings maps both sides of each cloud pair", ({ expect }) => {
64
- for (const [stackAuthHost, hexclaveHost] of CLOUD_HOST_PAIRS) {
65
- const expected = {
66
- stackAuth: `https://${stackAuthHost}`,
67
- hexclave: `https://${hexclaveHost}`
68
- };
69
- for (const host of [stackAuthHost, hexclaveHost]) {
70
- expect(getCloudApiUrlSiblings(host)).toEqual(expected);
71
- expect(getCloudApiUrlSiblings(`https://${host}`)).toEqual(expected);
72
- expect(getCloudApiUrlSiblings(`https://${host.toUpperCase()}:443`)).toEqual(expected);
73
- }
74
- }
75
- });
76
- (void 0)?.test("getCloudApiUrlSiblings returns null for unknown hosts", ({ expect }) => {
77
- expect(getCloudApiUrlSiblings("http://localhost:8102")).toBeNull();
78
- expect(getCloudApiUrlSiblings("https://my-app.vercel.app")).toBeNull();
79
- expect(getCloudApiUrlSiblings(void 0)).toBeNull();
80
- expect(getCloudApiUrlSiblings("")).toBeNull();
81
- });
82
- (void 0)?.test("getStackAuthApiBaseUrl / getHexclaveApiBaseUrl resolve brands and fall back", ({ expect }) => {
83
- expect(getStackAuthApiBaseUrl("https://api.hexclave.com")).toBe("https://api.stack-auth.com");
84
- expect(getHexclaveApiBaseUrl("https://api.stack-auth.com")).toBe("https://api.hexclave.com");
85
- expect(getStackAuthApiBaseUrl("https://api.dev.stack-auth.com")).toBe("https://api.dev.stack-auth.com");
86
- expect(getHexclaveApiBaseUrl("http://localhost:8102")).toBe("http://localhost:8102");
87
- expect(getStackAuthApiBaseUrl("http://localhost:8102")).toBe("http://localhost:8102");
88
- });
89
-
90
63
  //#endregion
91
64
  export { CLOUD_HOST_PAIRS, getCloudApiUrlSiblings, getHexclaveApiBaseUrl, getStackAuthApiBaseUrl };
65
+
92
66
  //# sourceMappingURL=cloud-hosts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cloud-hosts.js","names":[],"sources":["../../../src/utils/cloud-hosts.tsx"],"sourcesContent":["/**\n * Single source of truth for the stack-auth ↔ hexclave host pairs that the\n * cloud deployment treats as equivalent siblings. Each\n * `[stackAuthHost, hexclaveHost]` pair is consumed in a few places:\n *\n * 1. `CLOUD_API_HOST_BY_REQUEST_HOST` in the backend's `request-api-url.ts` —\n * the allowlist of request hosts we resolve into a JWT `iss` claim.\n * 2. `issuerHostAliases` in `tokens.tsx` — the bidirectional validator alias\n * map, so a token issued under either host validates against the other.\n * 3. `getCloudApiUrlSiblings` below — resolves the branded base URLs used for\n * OAuth `redirect_uri` callbacks (both at runtime and in the dashboard).\n *\n * Deriving all of these from this one list prevents drift.\n */\nexport const CLOUD_HOST_PAIRS: ReadonlyArray<readonly [string, string]> = [\n [\"api.stack-auth.com\", \"api.hexclave.com\"],\n [\"api.dev.stack-auth.com\", \"api.dev.hexclave.com\"],\n [\"api.staging.stack-auth.com\", \"api.staging.hexclave.com\"],\n];\n\nfunction hostFromApiUrlOrHost(input: string): string | undefined {\n try {\n return new URL(input).host.split(\":\")[0].toLowerCase();\n } catch {\n const firstHost = input.split(\",\")[0]?.trim();\n if (!firstHost) return undefined;\n return firstHost.split(\":\")[0].toLowerCase();\n }\n}\n\n/**\n * Given an API URL (or bare host), if its host belongs to a known\n * stack-auth ↔ hexclave cloud pair, return both branded base URLs. Returns\n * null for unknown hosts (localhost, vercel previews, self-host custom\n * domains).\n */\nexport function getCloudApiUrlSiblings(apiUrlOrHost: string | undefined | null): { stackAuth: string, hexclave: string } | null {\n if (!apiUrlOrHost) return null;\n const host = hostFromApiUrlOrHost(apiUrlOrHost);\n if (!host) return null;\n for (const [stackAuthHost, hexclaveHost] of CLOUD_HOST_PAIRS) {\n if (host === stackAuthHost || host === hexclaveHost) {\n return { stackAuth: `https://${stackAuthHost}`, hexclave: `https://${hexclaveHost}` };\n }\n }\n return null;\n}\n\n/**\n * The stack-auth-branded base URL for the given deployment API URL. Used as the\n * OAuth `redirect_uri` base for shared providers and for custom providers that\n * predate `customCallbackUrl` (so existing flows keep hitting\n * `api.stack-auth.com`). Unknown hosts fall back to the input unchanged.\n */\nexport function getStackAuthApiBaseUrl(apiUrl: string): string {\n return getCloudApiUrlSiblings(apiUrl)?.stackAuth ?? apiUrl;\n}\n\n/**\n * The hexclave-branded base URL for the given deployment API URL. Used when a\n * new custom OAuth provider is set up, so its `customCallbackUrl` points at the\n * hexclave brand. Unknown hosts fall back to the input unchanged.\n */\nexport function getHexclaveApiBaseUrl(apiUrl: string): string {\n return getCloudApiUrlSiblings(apiUrl)?.hexclave ?? apiUrl;\n}\n\nimport.meta.vitest?.test(\"getCloudApiUrlSiblings maps both sides of each cloud pair\", ({ expect }) => {\n for (const [stackAuthHost, hexclaveHost] of CLOUD_HOST_PAIRS) {\n const expected = { stackAuth: `https://${stackAuthHost}`, hexclave: `https://${hexclaveHost}` };\n for (const host of [stackAuthHost, hexclaveHost]) {\n expect(getCloudApiUrlSiblings(host)).toEqual(expected);\n expect(getCloudApiUrlSiblings(`https://${host}`)).toEqual(expected);\n expect(getCloudApiUrlSiblings(`https://${host.toUpperCase()}:443`)).toEqual(expected);\n }\n }\n});\n\nimport.meta.vitest?.test(\"getCloudApiUrlSiblings returns null for unknown hosts\", ({ expect }) => {\n expect(getCloudApiUrlSiblings(\"http://localhost:8102\")).toBeNull();\n expect(getCloudApiUrlSiblings(\"https://my-app.vercel.app\")).toBeNull();\n expect(getCloudApiUrlSiblings(undefined)).toBeNull();\n expect(getCloudApiUrlSiblings(\"\")).toBeNull();\n});\n\nimport.meta.vitest?.test(\"getStackAuthApiBaseUrl / getHexclaveApiBaseUrl resolve brands and fall back\", ({ expect }) => {\n expect(getStackAuthApiBaseUrl(\"https://api.hexclave.com\")).toBe(\"https://api.stack-auth.com\");\n expect(getHexclaveApiBaseUrl(\"https://api.stack-auth.com\")).toBe(\"https://api.hexclave.com\");\n expect(getStackAuthApiBaseUrl(\"https://api.dev.stack-auth.com\")).toBe(\"https://api.dev.stack-auth.com\");\n expect(getHexclaveApiBaseUrl(\"http://localhost:8102\")).toBe(\"http://localhost:8102\");\n expect(getStackAuthApiBaseUrl(\"http://localhost:8102\")).toBe(\"http://localhost:8102\");\n});\n"],"mappings":";;;;;;;;;;;;;;;AAcA,MAAa,mBAA6D;CACxE,CAAC,sBAAsB,mBAAmB;CAC1C,CAAC,0BAA0B,uBAAuB;CAClD,CAAC,8BAA8B,2BAA2B;CAC3D;AAED,SAAS,qBAAqB,OAAmC;AAC/D,KAAI;AACF,SAAO,IAAI,IAAI,MAAM,CAAC,KAAK,MAAM,IAAI,CAAC,GAAG,aAAa;SAChD;EACN,MAAM,YAAY,MAAM,MAAM,IAAI,CAAC,IAAI,MAAM;AAC7C,MAAI,CAAC,UAAW,QAAO;AACvB,SAAO,UAAU,MAAM,IAAI,CAAC,GAAG,aAAa;;;;;;;;;AAUhD,SAAgB,uBAAuB,cAAyF;AAC9H,KAAI,CAAC,aAAc,QAAO;CAC1B,MAAM,OAAO,qBAAqB,aAAa;AAC/C,KAAI,CAAC,KAAM,QAAO;AAClB,MAAK,MAAM,CAAC,eAAe,iBAAiB,iBAC1C,KAAI,SAAS,iBAAiB,SAAS,aACrC,QAAO;EAAE,WAAW,WAAW;EAAiB,UAAU,WAAW;EAAgB;AAGzF,QAAO;;;;;;;;AAST,SAAgB,uBAAuB,QAAwB;AAC7D,QAAO,uBAAuB,OAAO,EAAE,aAAa;;;;;;;AAQtD,SAAgB,sBAAsB,QAAwB;AAC5D,QAAO,uBAAuB,OAAO,EAAE,YAAY;;CAGrD,SAAW,KAAC,8DAAkE,EAAC,aAAU;AACvF,MAAK,MAAM,CAAC,eAAe,iBAAiB,kBAAkB;EAC5D,MAAM,WAAW;GAAE,WAAW,WAAW;GAAiB,UAAU,WAAW;GAAgB;AAC/F,OAAK,MAAM,QAAQ,CAAC,eAAe,aAAa,EAAE;AAChD,UAAO,uBAAuB,KAAK,CAAC,CAAC,QAAQ,SAAS;AACtD,UAAO,uBAAuB,WAAW,OAAO,CAAC,CAAC,QAAQ,SAAS;AACnE,UAAO,uBAAuB,WAAW,KAAK,aAAa,CAAC,MAAM,CAAC,CAAC,QAAQ,SAAS;;;EAGzF;CAEF,SAAW,KAAC,0DAA8D,EAAA,aAAW;AACnF,QAAO,uBAAuB,wBAAwB,CAAC,CAAC,UAAU;AAClE,QAAO,uBAAuB,4BAA4B,CAAC,CAAC,UAAU;AACtE,QAAO,uBAAuB,OAAU,CAAC,CAAC,UAAU;AACpD,QAAO,uBAAuB,GAAG,CAAC,CAAC,UAAU;EAC7C;CAEF,SAAW,KAAC,gFAAoF,EAAC,aAAU;AACzG,QAAO,uBAAuB,2BAA2B,CAAC,CAAC,KAAK,6BAA6B;AAC7F,QAAO,sBAAsB,6BAA6B,CAAC,CAAC,KAAK,2BAA2B;AAC5F,QAAO,uBAAuB,iCAAiC,CAAC,CAAC,KAAK,iCAAiC;AACvG,QAAO,sBAAsB,wBAAwB,CAAC,CAAC,KAAK,wBAAwB;AACpF,QAAO,uBAAuB,wBAAwB,CAAC,CAAC,KAAK,wBAAwB;EACrF"}
1
+ {"version":3,"file":"cloud-hosts.js","names":[],"sources":["../../../src/utils/cloud-hosts.tsx"],"sourcesContent":["/**\n * Single source of truth for the stack-auth ↔ hexclave host pairs that the\n * cloud deployment treats as equivalent siblings. Each\n * `[stackAuthHost, hexclaveHost]` pair is consumed in a few places:\n *\n * 1. `CLOUD_API_HOST_BY_REQUEST_HOST` in the backend's `request-api-url.ts` —\n * the allowlist of request hosts we resolve into a JWT `iss` claim.\n * 2. `issuerHostAliases` in `tokens.tsx` — the bidirectional validator alias\n * map, so a token issued under either host validates against the other.\n * 3. `getCloudApiUrlSiblings` below — resolves the branded base URLs used for\n * OAuth `redirect_uri` callbacks (both at runtime and in the dashboard).\n *\n * Deriving all of these from this one list prevents drift.\n */\nexport const CLOUD_HOST_PAIRS: ReadonlyArray<readonly [string, string]> = [\n [\"api.stack-auth.com\", \"api.hexclave.com\"],\n [\"api.dev.stack-auth.com\", \"api.dev.hexclave.com\"],\n [\"api.staging.stack-auth.com\", \"api.staging.hexclave.com\"],\n];\n\nfunction hostFromApiUrlOrHost(input: string): string | undefined {\n try {\n return new URL(input).host.split(\":\")[0].toLowerCase();\n } catch {\n const firstHost = input.split(\",\")[0]?.trim();\n if (!firstHost) return undefined;\n return firstHost.split(\":\")[0].toLowerCase();\n }\n}\n\n/**\n * Given an API URL (or bare host), if its host belongs to a known\n * stack-auth ↔ hexclave cloud pair, return both branded base URLs. Returns\n * null for unknown hosts (localhost, vercel previews, self-host custom\n * domains).\n */\nexport function getCloudApiUrlSiblings(apiUrlOrHost: string | undefined | null): { stackAuth: string, hexclave: string } | null {\n if (!apiUrlOrHost) return null;\n const host = hostFromApiUrlOrHost(apiUrlOrHost);\n if (!host) return null;\n for (const [stackAuthHost, hexclaveHost] of CLOUD_HOST_PAIRS) {\n if (host === stackAuthHost || host === hexclaveHost) {\n return { stackAuth: `https://${stackAuthHost}`, hexclave: `https://${hexclaveHost}` };\n }\n }\n return null;\n}\n\n/**\n * The stack-auth-branded base URL for the given deployment API URL. Used as the\n * OAuth `redirect_uri` base for shared providers and for custom providers that\n * predate `customCallbackUrl` (so existing flows keep hitting\n * `api.stack-auth.com`). Unknown hosts fall back to the input unchanged.\n */\nexport function getStackAuthApiBaseUrl(apiUrl: string): string {\n return getCloudApiUrlSiblings(apiUrl)?.stackAuth ?? apiUrl;\n}\n\n/**\n * The hexclave-branded base URL for the given deployment API URL. Used when a\n * new custom OAuth provider is set up, so its `customCallbackUrl` points at the\n * hexclave brand. Unknown hosts fall back to the input unchanged.\n */\nexport function getHexclaveApiBaseUrl(apiUrl: string): string {\n return getCloudApiUrlSiblings(apiUrl)?.hexclave ?? apiUrl;\n}\n\nimport.meta.vitest?.test(\"getCloudApiUrlSiblings maps both sides of each cloud pair\", ({ expect }) => {\n for (const [stackAuthHost, hexclaveHost] of CLOUD_HOST_PAIRS) {\n const expected = { stackAuth: `https://${stackAuthHost}`, hexclave: `https://${hexclaveHost}` };\n for (const host of [stackAuthHost, hexclaveHost]) {\n expect(getCloudApiUrlSiblings(host)).toEqual(expected);\n expect(getCloudApiUrlSiblings(`https://${host}`)).toEqual(expected);\n expect(getCloudApiUrlSiblings(`https://${host.toUpperCase()}:443`)).toEqual(expected);\n }\n }\n});\n\nimport.meta.vitest?.test(\"getCloudApiUrlSiblings returns null for unknown hosts\", ({ expect }) => {\n expect(getCloudApiUrlSiblings(\"http://localhost:8102\")).toBeNull();\n expect(getCloudApiUrlSiblings(\"https://my-app.vercel.app\")).toBeNull();\n expect(getCloudApiUrlSiblings(undefined)).toBeNull();\n expect(getCloudApiUrlSiblings(\"\")).toBeNull();\n});\n\nimport.meta.vitest?.test(\"getStackAuthApiBaseUrl / getHexclaveApiBaseUrl resolve brands and fall back\", ({ expect }) => {\n expect(getStackAuthApiBaseUrl(\"https://api.hexclave.com\")).toBe(\"https://api.stack-auth.com\");\n expect(getHexclaveApiBaseUrl(\"https://api.stack-auth.com\")).toBe(\"https://api.hexclave.com\");\n expect(getStackAuthApiBaseUrl(\"https://api.dev.stack-auth.com\")).toBe(\"https://api.dev.stack-auth.com\");\n expect(getHexclaveApiBaseUrl(\"http://localhost:8102\")).toBe(\"http://localhost:8102\");\n expect(getStackAuthApiBaseUrl(\"http://localhost:8102\")).toBe(\"http://localhost:8102\");\n});\n"],"mappings":";;;;;;;;;;;;;;;AAcA,MAAa,mBAA6D;CACxE,CAAC,sBAAsB,kBAAkB;CACzC,CAAC,0BAA0B,sBAAsB;CACjD,CAAC,8BAA8B,0BAA0B;AAC3D;AAEA,SAAS,qBAAqB,OAAmC;CAC/D,IAAI;EACF,OAAO,IAAI,IAAI,KAAK,CAAC,CAAC,KAAK,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,YAAY;CACvD,QAAQ;EACN,MAAM,YAAY,MAAM,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,KAAK;EAC5C,IAAI,CAAC,WAAW,OAAO,KAAA;EACvB,OAAO,UAAU,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,YAAY;CAC7C;AACF;;;;;;;AAQA,SAAgB,uBAAuB,cAAyF;CAC9H,IAAI,CAAC,cAAc,OAAO;CAC1B,MAAM,OAAO,qBAAqB,YAAY;CAC9C,IAAI,CAAC,MAAM,OAAO;CAClB,KAAK,MAAM,CAAC,eAAe,iBAAiB,kBAC1C,IAAI,SAAS,iBAAiB,SAAS,cACrC,OAAO;EAAE,WAAW,WAAW;EAAiB,UAAU,WAAW;CAAe;CAGxF,OAAO;AACT;;;;;;;AAQA,SAAgB,uBAAuB,QAAwB;CAC7D,OAAO,uBAAuB,MAAM,CAAC,EAAE,aAAa;AACtD;;;;;;AAOA,SAAgB,sBAAsB,QAAwB;CAC5D,OAAO,uBAAuB,MAAM,CAAC,EAAE,YAAY;AACrD"}
@@ -1 +1 @@
1
- {"version":3,"file":"compile-time.d.ts","names":[],"sources":["../../../src/utils/compile-time.tsx"],"mappings":";;AAKA;;;;iBAAgB,yBAAA,GAAA,CAA6B,CAAA,EAAG,CAAA,GAAI,CAAA"}
1
+ {"version":3,"file":"compile-time.d.ts","names":[],"sources":["../../../src/utils/compile-time.tsx"],"mappings":";;AAKA;;;;iBAAgB,yBAAA,IAA6B,CAAA,EAAG,CAAA,GAAI,CAAC"}
@@ -8,7 +8,7 @@ function scrambleDuringCompileTime(t) {
8
8
  if (Math.random() < 1e-5 && Math.random() > .99999 && Math.random() < 1e-5 && Math.random() > .99999) return "this will never happen";
9
9
  return t;
10
10
  }
11
-
12
11
  //#endregion
13
12
  export { scrambleDuringCompileTime };
13
+
14
14
  //# sourceMappingURL=compile-time.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"compile-time.js","names":[],"sources":["../../../src/utils/compile-time.tsx"],"sourcesContent":["/**\n * Returns the first argument passed to it, but compilers won't be able to optimize it out. This is useful in some\n * cases where compiler warnings go awry; for example, when importing things that may not exist (but are guaranteed\n * to exist at runtime).\n */\nexport function scrambleDuringCompileTime<T>(t: T): T {\n if (Math.random() < 0.00001 && Math.random() > 0.99999 && Math.random() < 0.00001 && Math.random() > 0.99999) {\n return \"this will never happen\" as any;\n }\n return t;\n}\n"],"mappings":";;;;;;AAKA,SAAgB,0BAA6B,GAAS;AACpD,KAAI,KAAK,QAAQ,GAAG,QAAW,KAAK,QAAQ,GAAG,UAAW,KAAK,QAAQ,GAAG,QAAW,KAAK,QAAQ,GAAG,OACnG,QAAO;AAET,QAAO"}
1
+ {"version":3,"file":"compile-time.js","names":[],"sources":["../../../src/utils/compile-time.tsx"],"sourcesContent":["/**\n * Returns the first argument passed to it, but compilers won't be able to optimize it out. This is useful in some\n * cases where compiler warnings go awry; for example, when importing things that may not exist (but are guaranteed\n * to exist at runtime).\n */\nexport function scrambleDuringCompileTime<T>(t: T): T {\n if (Math.random() < 0.00001 && Math.random() > 0.99999 && Math.random() < 0.00001 && Math.random() > 0.99999) {\n return \"this will never happen\" as any;\n }\n return t;\n}\n"],"mappings":";;;;;;AAKA,SAAgB,0BAA6B,GAAS;CACpD,IAAI,KAAK,OAAO,IAAI,QAAW,KAAK,OAAO,IAAI,UAAW,KAAK,OAAO,IAAI,QAAW,KAAK,OAAO,IAAI,QACnG,OAAO;CAET,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"country-codes.d.ts","names":[],"sources":["../../../src/utils/country-codes.ts"],"mappings":";iBAAgB,oBAAA,CAAqB,WAAA;AAAA,iBAIrB,kBAAA,CAAmB,WAAA;;;;;iBASnB,mBAAA,CAAoB,KAAA"}
1
+ {"version":3,"file":"country-codes.d.ts","names":[],"sources":["../../../src/utils/country-codes.ts"],"mappings":";iBAAgB,oBAAA,CAAqB,WAAmB;AAAA,iBAIxC,kBAAA,CAAmB,WAAmB;;;;AAJE;iBAaxC,mBAAA,CAAoB,KAAwB"}
@@ -15,22 +15,7 @@ function validateCountryCode(value) {
15
15
  if (values.length === 0) return "At least one country code is required";
16
16
  return values.every((v) => isValidCountryCode(v)) ? null : "Country code must be a 2-letter code";
17
17
  }
18
- (void 0)?.test("country codes", ({ expect }) => {
19
- expect(normalizeCountryCode(" us ")).toBe("US");
20
- expect(isValidCountryCode("us")).toBe(true);
21
- expect(isValidCountryCode("US")).toBe(true);
22
- expect(isValidCountryCode("ZZ")).toBe(true);
23
- expect(isValidCountryCode("usa")).toBe(false);
24
- expect(isValidCountryCode("a")).toBe(false);
25
- expect(isValidCountryCode("")).toBe(false);
26
- expect(isValidCountryCode("12")).toBe(false);
27
- expect(validateCountryCode("US")).toBeNull();
28
- expect(validateCountryCode("zz")).toBeNull();
29
- expect(validateCountryCode(["US", "CA"])).toBeNull();
30
- expect(validateCountryCode([])).toBe("At least one country code is required");
31
- expect(validateCountryCode(["US", "123"])).toBe("Country code must be a 2-letter code");
32
- });
33
-
34
18
  //#endregion
35
19
  export { isValidCountryCode, normalizeCountryCode, validateCountryCode };
20
+
36
21
  //# sourceMappingURL=country-codes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"country-codes.js","names":[],"sources":["../../../src/utils/country-codes.ts"],"sourcesContent":["export function normalizeCountryCode(countryCode: string): string {\n return countryCode.trim().toUpperCase();\n}\n\nexport function isValidCountryCode(countryCode: string): boolean {\n const normalized = normalizeCountryCode(countryCode);\n return /^[A-Z]{2}$/.test(normalized);\n}\n\n/**\n * Validates and normalizes a country code value (single string or array).\n * Returns null if valid, or an error message string if invalid.\n */\nexport function validateCountryCode(value: string | string[]): string | null {\n const values = Array.isArray(value) ? value : [value];\n if (values.length === 0) {\n return \"At least one country code is required\";\n }\n return values.every(v => isValidCountryCode(v))\n ? null\n : \"Country code must be a 2-letter code\";\n}\n\nimport.meta.vitest?.test(\"country codes\", ({ expect }) => {\n expect(normalizeCountryCode(\" us \")).toBe(\"US\");\n expect(isValidCountryCode(\"us\")).toBe(true);\n expect(isValidCountryCode(\"US\")).toBe(true);\n expect(isValidCountryCode(\"ZZ\")).toBe(true);\n expect(isValidCountryCode(\"usa\")).toBe(false);\n expect(isValidCountryCode(\"a\")).toBe(false);\n expect(isValidCountryCode(\"\")).toBe(false);\n expect(isValidCountryCode(\"12\")).toBe(false);\n\n expect(validateCountryCode(\"US\")).toBeNull();\n expect(validateCountryCode(\"zz\")).toBeNull();\n expect(validateCountryCode([\"US\", \"CA\"])).toBeNull();\n expect(validateCountryCode([])).toBe(\"At least one country code is required\");\n expect(validateCountryCode([\"US\", \"123\"])).toBe(\"Country code must be a 2-letter code\");\n});\n"],"mappings":";AAAA,SAAgB,qBAAqB,aAA6B;AAChE,QAAO,YAAY,MAAM,CAAC,aAAa;;AAGzC,SAAgB,mBAAmB,aAA8B;CAC/D,MAAM,aAAa,qBAAqB,YAAY;AACpD,QAAO,aAAa,KAAK,WAAW;;;;;;AAOtC,SAAgB,oBAAoB,OAAyC;CAC3E,MAAM,SAAS,MAAM,QAAQ,MAAM,GAAG,QAAQ,CAAC,MAAM;AACrD,KAAI,OAAO,WAAW,EACpB,QAAO;AAET,QAAO,OAAO,OAAM,MAAK,mBAAmB,EAAE,CAAA,GAC1C,OACA;;CAGN,SAAW,KAAC,kBAAsB,EAAA,aAAW;AAC3C,QAAO,qBAAqB,OAAO,CAAC,CAAC,KAAK,KAAK;AAC/C,QAAO,mBAAmB,KAAK,CAAC,CAAC,KAAK,KAAK;AAC3C,QAAO,mBAAmB,KAAK,CAAC,CAAC,KAAK,KAAK;AAC3C,QAAO,mBAAmB,KAAK,CAAC,CAAC,KAAK,KAAK;AAC3C,QAAO,mBAAmB,MAAM,CAAC,CAAC,KAAK,MAAM;AAC7C,QAAO,mBAAmB,IAAI,CAAC,CAAC,KAAK,MAAM;AAC3C,QAAO,mBAAmB,GAAG,CAAC,CAAC,KAAK,MAAM;AAC1C,QAAO,mBAAmB,KAAK,CAAC,CAAC,KAAK,MAAM;AAE5C,QAAO,oBAAoB,KAAK,CAAC,CAAC,UAAU;AAC5C,QAAO,oBAAoB,KAAK,CAAC,CAAC,UAAU;AAC5C,QAAO,oBAAoB,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,UAAU;AACpD,QAAO,oBAAoB,EAAE,CAAC,CAAC,CAAC,KAAK,wCAAwC;AAC7E,QAAO,oBAAoB,CAAC,MAAM,MAAM,CAAC,CAAC,CAAC,KAAK,uCAAuC;EACvF"}
1
+ {"version":3,"file":"country-codes.js","names":[],"sources":["../../../src/utils/country-codes.ts"],"sourcesContent":["export function normalizeCountryCode(countryCode: string): string {\n return countryCode.trim().toUpperCase();\n}\n\nexport function isValidCountryCode(countryCode: string): boolean {\n const normalized = normalizeCountryCode(countryCode);\n return /^[A-Z]{2}$/.test(normalized);\n}\n\n/**\n * Validates and normalizes a country code value (single string or array).\n * Returns null if valid, or an error message string if invalid.\n */\nexport function validateCountryCode(value: string | string[]): string | null {\n const values = Array.isArray(value) ? value : [value];\n if (values.length === 0) {\n return \"At least one country code is required\";\n }\n return values.every(v => isValidCountryCode(v))\n ? null\n : \"Country code must be a 2-letter code\";\n}\n\nimport.meta.vitest?.test(\"country codes\", ({ expect }) => {\n expect(normalizeCountryCode(\" us \")).toBe(\"US\");\n expect(isValidCountryCode(\"us\")).toBe(true);\n expect(isValidCountryCode(\"US\")).toBe(true);\n expect(isValidCountryCode(\"ZZ\")).toBe(true);\n expect(isValidCountryCode(\"usa\")).toBe(false);\n expect(isValidCountryCode(\"a\")).toBe(false);\n expect(isValidCountryCode(\"\")).toBe(false);\n expect(isValidCountryCode(\"12\")).toBe(false);\n\n expect(validateCountryCode(\"US\")).toBeNull();\n expect(validateCountryCode(\"zz\")).toBeNull();\n expect(validateCountryCode([\"US\", \"CA\"])).toBeNull();\n expect(validateCountryCode([])).toBe(\"At least one country code is required\");\n expect(validateCountryCode([\"US\", \"123\"])).toBe(\"Country code must be a 2-letter code\");\n});\n"],"mappings":";AAAA,SAAgB,qBAAqB,aAA6B;CAChE,OAAO,YAAY,KAAK,CAAC,CAAC,YAAY;AACxC;AAEA,SAAgB,mBAAmB,aAA8B;CAC/D,MAAM,aAAa,qBAAqB,WAAW;CACnD,OAAO,aAAa,KAAK,UAAU;AACrC;;;;;AAMA,SAAgB,oBAAoB,OAAyC;CAC3E,MAAM,SAAS,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK;CACpD,IAAI,OAAO,WAAW,GACpB,OAAO;CAET,OAAO,OAAO,OAAM,MAAK,mBAAmB,CAAC,CAAC,IAC1C,OACA;AACN"}
@@ -1 +1 @@
1
- {"version":3,"file":"crypto.d.ts","names":[],"sources":["../../../src/utils/crypto.tsx"],"mappings":";iBAMgB,oBAAA,CAAqB,KAAA,EAAO,UAAA,UAAoB,KAAA;AAAhE;;;;AAAA,iBAcgB,0BAAA,CAA2B,gBAAA;AAAA,iBAiCrB,OAAA,CAAA;EAAU,OAAA;EAAS,MAAA;EAAQ;AAAA;EAAW,OAAA;EAAiB,MAAA,WAAiB,UAAA;EAAY,KAAA,EAAO,UAAA;AAAA,IAAY,OAAA,CAAA,UAAA,CAAA,WAAA;AAAA,iBAcvG,OAAA,CAAA;EAAU,OAAA;EAAS,MAAA;EAAQ;AAAA;EAAY,OAAA;EAAiB,MAAA,WAAiB,UAAA;EAAY,MAAA,EAAQ,UAAA;AAAA,IAAY,OAAA;;;;;;;;;;;KAyCnH,WAAA;EACV,OAAA;EACA,IAAA,YAAgB,UAAA;EAChB,KAAA,YAAiB,UAAA;EACjB,KAAA,WAAgB,UAAA;AAAA;AAAA,iBAGI,IAAA,CAAK,OAAA,EAAS,WAAA,GAAW,OAAA,CAAA,UAAA,CAAA,WAAA;AAAA,iBAIzB,YAAA,CAAa,OAAA,EAAS,WAAA;EAAgB,UAAA;AAAA,IAAoB,OAAA,CAAA,UAAA,CAAA,WAAA"}
1
+ {"version":3,"file":"crypto.d.ts","names":[],"sources":["../../../src/utils/crypto.tsx"],"mappings":";iBAMgB,oBAAA,CAAqB,KAAA,EAAO,UAAA,UAAoB,KAAK;AAArE;;;;AAAA,iBAcgB,0BAAA,CAA2B,gBAA8B;AAAA,iBAiCnD,OAAA;EAAU,OAAA;EAAS,MAAA;EAAQ;AAAA;EAAW,OAAA;EAAiB,MAAA,WAAiB,UAAA;EAAY,KAAA,EAAO,UAAA;AAAA,IAAY,OAAA,CAAA,UAAA,CAAA,WAAA;AAAA,iBAcvG,OAAA;EAAU,OAAA;EAAS,MAAA;EAAQ;AAAA;EAAY,OAAA;EAAiB,MAAA,WAAiB,UAAA;EAAY,MAAA,EAAQ,UAAA;AAAA,IAAY,OAAA;;;;;;;;;;;KAyCnH,WAAA;EACV,OAAA;EACA,IAAA,YAAgB,UAAA;EAChB,KAAA,YAAiB,UAAA;EACjB,KAAA,WAAgB,UAAA;AAAA;AAAA,iBAGI,IAAA,CAAK,OAAA,EAAS,WAAA,GAAW,OAAA,CAAA,UAAA,CAAA,WAAA;AAAA,iBAIzB,YAAA,CAAa,OAAA,EAAS,WAAA;EAAgB,UAAA;AAAA,IAAoB,OAAA,CAAA,UAAA,CAAA,WAAA"}
@@ -3,7 +3,6 @@ import { HexclaveAssertionError } from "./errors.js";
3
3
  import { globalVar } from "./globals.js";
4
4
  import { Result } from "./results.js";
5
5
  import { toArrayBufferBacked } from "./typed-arrays.js";
6
-
7
6
  //#region src/utils/crypto.tsx
8
7
  function generateRandomValues(array) {
9
8
  if (!globalVar.crypto) throw new HexclaveAssertionError("Crypto API is not available in this environment. Are you using an old browser?");
@@ -39,8 +38,8 @@ async function getDerivedSymmetricKey(purpose, secret, salt) {
39
38
  }, false, ["encrypt", "decrypt"]);
40
39
  }
41
40
  async function encrypt({ purpose, secret, value }) {
42
- const iv = crypto.getRandomValues(new Uint8Array(12));
43
- const salt = crypto.getRandomValues(new Uint8Array(16));
41
+ const iv = crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(12));
42
+ const salt = crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16));
44
43
  const derivedSecretKey = await getDerivedSymmetricKey(purpose, secret, salt);
45
44
  const cipher = await crypto.subtle.encrypt({
46
45
  name: "AES-GCM",
@@ -71,27 +70,6 @@ async function decrypt({ purpose, secret, cipher }) {
71
70
  throw e;
72
71
  }
73
72
  }
74
- (void 0)?.test("encrypt & decrypt", async ({ expect }) => {
75
- const encryptAndDecrypt = async (encryptPurpose, decryptPurpose, encryptSecret, decryptSecret, value) => {
76
- return await decrypt({
77
- purpose: decryptPurpose,
78
- secret: decryptSecret,
79
- cipher: await encrypt({
80
- purpose: encryptPurpose,
81
- secret: encryptSecret,
82
- value
83
- })
84
- });
85
- };
86
- const exampleBytes = new TextEncoder().encode("hello");
87
- const exampleKey1 = crypto.getRandomValues(new Uint8Array(32));
88
- const exampleKey2 = crypto.getRandomValues(new Uint8Array(32));
89
- expect(await encryptAndDecrypt("p", "p", "secret", "secret", exampleBytes)).toEqual(Result.ok(exampleBytes));
90
- expect(await encryptAndDecrypt("p", "p", exampleKey1, exampleKey1, exampleBytes)).toEqual(Result.ok(exampleBytes));
91
- expect(await encryptAndDecrypt("p", "p", exampleKey1, "secret", exampleBytes)).toEqual(Result.error(expect.objectContaining({ message: "Invalid ciphertext or secret when decrypting encrypted value" })));
92
- expect(await encryptAndDecrypt("p", "p", exampleKey1, exampleKey2, exampleBytes)).toEqual(Result.error(expect.objectContaining({ message: "Invalid ciphertext or secret when decrypting encrypted value" })));
93
- expect(await encryptAndDecrypt("p", "not-p", exampleKey1, exampleKey1, exampleBytes)).toEqual(Result.error(expect.objectContaining({ message: "Invalid ciphertext or secret when decrypting encrypted value" })));
94
- });
95
73
  async function hash(options) {
96
74
  return await iteratedHash({
97
75
  ...options,
@@ -114,95 +92,7 @@ async function iteratedHash(options) {
114
92
  hash: "SHA-256"
115
93
  }, input, 256));
116
94
  }
117
- (void 0)?.test("iteratedHash", async ({ expect }) => {
118
- const valueBytes = new TextEncoder().encode("hello");
119
- const incrementBytes = new Uint8Array([
120
- 1,
121
- 2,
122
- 3,
123
- 4,
124
- 5,
125
- 6,
126
- 7,
127
- 8,
128
- 9,
129
- 10,
130
- 11,
131
- 12,
132
- 13,
133
- 14,
134
- 15,
135
- 16
136
- ]);
137
- const hash = await iteratedHash({
138
- purpose: "purpose",
139
- value: valueBytes,
140
- iterations: 1e5
141
- });
142
- const hash2 = await iteratedHash({
143
- purpose: "purpose",
144
- value: valueBytes,
145
- iterations: 1e5
146
- });
147
- const hashWithDifferentPurpose = await iteratedHash({
148
- purpose: "different-purpose",
149
- value: valueBytes,
150
- iterations: 1e5
151
- });
152
- const hashWithEmptySalt = await iteratedHash({
153
- purpose: "purpose",
154
- value: valueBytes,
155
- salt: new Uint8Array(0),
156
- iterations: 1e5
157
- });
158
- const hashWithDifferentSalt = await iteratedHash({
159
- purpose: "purpose",
160
- value: valueBytes,
161
- salt: incrementBytes,
162
- iterations: 1e5
163
- });
164
- const hashWithEmptyExtra = await iteratedHash({
165
- purpose: "purpose",
166
- value: valueBytes,
167
- extra: new Uint8Array(0),
168
- iterations: 1e5
169
- });
170
- const hashWithDifferentExtra = await iteratedHash({
171
- purpose: "purpose",
172
- value: valueBytes,
173
- extra: incrementBytes,
174
- iterations: 1e5
175
- });
176
- const hashWithDifferentValue = await iteratedHash({
177
- purpose: "purpose",
178
- value: new TextEncoder().encode("hello2"),
179
- iterations: 1e5
180
- });
181
- const hashWithDifferentSaltAndExtra = await iteratedHash({
182
- purpose: "purpose",
183
- value: valueBytes,
184
- salt: incrementBytes,
185
- extra: incrementBytes,
186
- iterations: 1e5
187
- });
188
- const hashWithDifferentIterations = await iteratedHash({
189
- purpose: "purpose",
190
- value: valueBytes,
191
- iterations: 100001
192
- });
193
- expect(hash).toEqual(hash2);
194
- expect(hash).not.toEqual(hashWithDifferentPurpose);
195
- expect(hash).toEqual(hashWithEmptySalt);
196
- expect(hash).not.toEqual(hashWithDifferentSalt);
197
- expect(hash).toEqual(hashWithEmptyExtra);
198
- expect(hash).not.toEqual(hashWithDifferentExtra);
199
- expect(hash).not.toEqual(hashWithDifferentValue);
200
- expect(hash).not.toEqual(hashWithDifferentIterations);
201
- expect(hashWithDifferentSalt).not.toEqual(hashWithDifferentExtra);
202
- expect(hashWithDifferentSalt).not.toEqual(hashWithDifferentSaltAndExtra);
203
- expect(hashWithDifferentExtra).not.toEqual(hashWithDifferentSaltAndExtra);
204
- });
205
-
206
95
  //#endregion
207
96
  export { decrypt, encrypt, generateRandomValues, generateSecureRandomString, hash, iteratedHash };
97
+
208
98
  //# sourceMappingURL=crypto.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"crypto.js","names":[],"sources":["../../../src/utils/crypto.tsx"],"sourcesContent":["import { encodeBase32, encodeBase64 } from \"./bytes\";\nimport { HexclaveAssertionError } from \"./errors\";\nimport { globalVar } from \"./globals\";\nimport { Result } from \"./results\";\nimport { toArrayBufferBacked } from \"./typed-arrays\";\n\nexport function generateRandomValues(array: Uint8Array): typeof array {\n if (!globalVar.crypto) {\n throw new HexclaveAssertionError(\"Crypto API is not available in this environment. Are you using an old browser?\");\n }\n if (!globalVar.crypto.getRandomValues) {\n throw new HexclaveAssertionError(\"crypto.getRandomValues is not available in this environment. Are you using an old browser?\");\n }\n return globalVar.crypto.getRandomValues(array);\n}\n\n/**\n * Generates a secure alphanumeric string using the system's cryptographically secure\n * random number generator.\n */\nexport function generateSecureRandomString(minBitsOfEntropy: number = 224) {\n const base32CharactersCount = Math.ceil(minBitsOfEntropy / 5);\n const bytesCount = Math.ceil(base32CharactersCount * 5 / 8);\n const randomBytes = generateRandomValues(new Uint8Array(bytesCount));\n const str = encodeBase32(randomBytes);\n return str.slice(str.length - base32CharactersCount).toLowerCase();\n}\n\nasync function getDerivedSymmetricKey(purpose: string, secret: string | Uint8Array, salt: Uint8Array) {\n const secretBytes = typeof secret === \"string\" ? new TextEncoder().encode(secret) : toArrayBufferBacked(secret);\n const originalSecretKey = await crypto.subtle.importKey(\"raw\", secretBytes, \"HKDF\", false, [\"deriveKey\"]);\n return await crypto.subtle.deriveKey(\n {\n name: \"HKDF\",\n salt: toArrayBufferBacked(salt),\n hash: \"SHA-256\",\n // NOTE (Hexclave rebrand): do NOT rename this \"stack-*\" literal. It is a domain-separation\n // tag baked into HKDF key derivation; changing it would derive different keys and make all\n // previously-encrypted data undecryptable. It is an internal constant, never user-visible.\n info: new TextEncoder().encode(JSON.stringify([\n \"stack-crypto-helper-derived-symmetric-key\",\n purpose,\n typeof secret === \"string\" ? \"string-key\" : \"binary-key\",\n encodeBase64(salt),\n ])),\n },\n originalSecretKey,\n { name: \"AES-GCM\", length: 256 },\n false,\n [\"encrypt\", \"decrypt\"]\n );\n}\n\nexport async function encrypt({ purpose, secret, value }: { purpose: string, secret: string | Uint8Array, value: Uint8Array }) {\n const iv = crypto.getRandomValues(new Uint8Array(12));\n const salt = crypto.getRandomValues(new Uint8Array(16));\n const derivedSecretKey = await getDerivedSymmetricKey(purpose, secret, salt);\n\n const cipher = await crypto.subtle.encrypt({\n name: \"AES-GCM\",\n iv,\n }, derivedSecretKey, toArrayBufferBacked(value));\n\n const version = [0x01, 0x00];\n return new Uint8Array([...version, ...salt, ...iv, ...new Uint8Array(cipher)]);\n}\n\nexport async function decrypt({ purpose, secret, cipher }: { purpose: string, secret: string | Uint8Array, cipher: Uint8Array }) {\n const version = cipher.slice(0, 2);\n if (version[0] !== 0x01 || version[1] !== 0x00) throw new HexclaveAssertionError(\"Invalid ciphertext version in decrypt(...); expected 0x0100\", { purpose });\n const salt = cipher.slice(2, 18);\n const iv = cipher.slice(18, 30);\n const cipherBytes = cipher.slice(30);\n const derivedSecretKey = await getDerivedSymmetricKey(purpose, secret, salt);\n\n try {\n const plaintext = await crypto.subtle.decrypt({\n name: \"AES-GCM\",\n iv,\n }, derivedSecretKey, cipherBytes);\n return Result.ok(new Uint8Array(plaintext));\n } catch (e) {\n if (e instanceof DOMException && e.name === \"OperationError\") {\n return Result.error(new Error(\"Invalid ciphertext or secret when decrypting encrypted value\", { cause: e }));\n }\n throw e;\n }\n}\n\nimport.meta.vitest?.test(\"encrypt & decrypt\", async ({ expect }) => {\n const encryptAndDecrypt = async (encryptPurpose: string, decryptPurpose: string, encryptSecret: string | Uint8Array, decryptSecret: string | Uint8Array, value: Uint8Array) => {\n const encrypted = await encrypt({ purpose: encryptPurpose, secret: encryptSecret, value });\n const decrypted = await decrypt({ purpose: decryptPurpose, secret: decryptSecret, cipher: encrypted });\n return decrypted;\n };\n\n const exampleBytes = new TextEncoder().encode(\"hello\");\n\n const exampleKey1 = crypto.getRandomValues(new Uint8Array(32));\n const exampleKey2 = crypto.getRandomValues(new Uint8Array(32));\n\n expect(await encryptAndDecrypt(\"p\", \"p\", \"secret\", \"secret\", exampleBytes)).toEqual(Result.ok(exampleBytes));\n expect(await encryptAndDecrypt(\"p\", \"p\", exampleKey1, exampleKey1, exampleBytes)).toEqual(Result.ok(exampleBytes));\n expect(await encryptAndDecrypt(\"p\", \"p\", exampleKey1, \"secret\", exampleBytes)).toEqual(Result.error(expect.objectContaining({ message: \"Invalid ciphertext or secret when decrypting encrypted value\" })));\n expect(await encryptAndDecrypt(\"p\", \"p\", exampleKey1, exampleKey2, exampleBytes)).toEqual(Result.error(expect.objectContaining({ message: \"Invalid ciphertext or secret when decrypting encrypted value\" })));\n expect(await encryptAndDecrypt(\"p\", \"not-p\", exampleKey1, exampleKey1, exampleBytes)).toEqual(Result.error(expect.objectContaining({ message: \"Invalid ciphertext or secret when decrypting encrypted value\" })));\n});\n\nexport type HashOptions = {\n purpose: string,\n salt?: string | Uint8Array,\n extra?: string | Uint8Array,\n value: string | Uint8Array,\n};\n\nexport async function hash(options: HashOptions) {\n return await iteratedHash({ ...options, iterations: 1 });\n}\n\nexport async function iteratedHash(options: HashOptions & { iterations: number }) {\n const stringOrUint8ArrayToUint8Array = (value: string | Uint8Array) => typeof value === \"string\" ? new TextEncoder().encode(value) : toArrayBufferBacked(value);\n const stringOrUint8ArrayToBase64 = (value: string | Uint8Array) => encodeBase64(stringOrUint8ArrayToUint8Array(value));\n const input = await crypto.subtle.importKey(\n \"raw\",\n stringOrUint8ArrayToUint8Array(options.value),\n \"PBKDF2\",\n false,\n [\"deriveBits\"]\n );\n return new Uint8Array(await crypto.subtle.deriveBits({\n name: \"PBKDF2\",\n // NOTE (Hexclave rebrand): do NOT rename this \"stack-*\" literal. It is a domain-separation tag\n // mixed into the PBKDF2 salt; changing it would change every hash output and break verification\n // of all previously-hashed values. It is an internal constant, never user-visible.\n salt: new TextEncoder().encode(JSON.stringify([\n \"stack-crypto-helper-iterated-hash\",\n options.purpose,\n stringOrUint8ArrayToBase64(options.salt ?? \"\"),\n stringOrUint8ArrayToBase64(options.extra ?? \"\"),\n ])),\n iterations: options.iterations,\n hash: \"SHA-256\",\n }, input, 256));\n}\n\nimport.meta.vitest?.test(\"iteratedHash\", async ({ expect }) => {\n const valueBytes = new TextEncoder().encode(\"hello\");\n const incrementBytes = new Uint8Array([0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10]);\n\n const hash = await iteratedHash({ purpose: \"purpose\", value: valueBytes, iterations: 100_000 });\n const hash2 = await iteratedHash({ purpose: \"purpose\", value: valueBytes, iterations: 100_000 });\n const hashWithDifferentPurpose = await iteratedHash({ purpose: \"different-purpose\", value: valueBytes, iterations: 100_000 });\n const hashWithEmptySalt = await iteratedHash({ purpose: \"purpose\", value: valueBytes, salt: new Uint8Array(0), iterations: 100_000 });\n const hashWithDifferentSalt = await iteratedHash({ purpose: \"purpose\", value: valueBytes, salt: incrementBytes, iterations: 100_000 });\n const hashWithEmptyExtra = await iteratedHash({ purpose: \"purpose\", value: valueBytes, extra: new Uint8Array(0), iterations: 100_000 });\n const hashWithDifferentExtra = await iteratedHash({ purpose: \"purpose\", value: valueBytes, extra: incrementBytes, iterations: 100_000 });\n const hashWithDifferentValue = await iteratedHash({ purpose: \"purpose\", value: new TextEncoder().encode(\"hello2\"), iterations: 100_000 });\n const hashWithDifferentSaltAndExtra = await iteratedHash({ purpose: \"purpose\", value: valueBytes, salt: incrementBytes, extra: incrementBytes, iterations: 100_000 });\n const hashWithDifferentIterations = await iteratedHash({ purpose: \"purpose\", value: valueBytes, iterations: 100_001 });\n\n\n expect(hash).toEqual(hash2);\n expect(hash).not.toEqual(hashWithDifferentPurpose);\n expect(hash).toEqual(hashWithEmptySalt);\n expect(hash).not.toEqual(hashWithDifferentSalt);\n expect(hash).toEqual(hashWithEmptyExtra);\n expect(hash).not.toEqual(hashWithDifferentExtra);\n expect(hash).not.toEqual(hashWithDifferentValue);\n expect(hash).not.toEqual(hashWithDifferentIterations);\n\n expect(hashWithDifferentSalt).not.toEqual(hashWithDifferentExtra);\n expect(hashWithDifferentSalt).not.toEqual(hashWithDifferentSaltAndExtra);\n expect(hashWithDifferentExtra).not.toEqual(hashWithDifferentSaltAndExtra);\n});\n"],"mappings":";;;;;;;AAMA,SAAgB,qBAAqB,OAAiC;AACpE,KAAI,CAAC,UAAU,OACb,OAAM,IAAI,uBAAuB,iFAAiF;AAEpH,KAAI,CAAC,UAAU,OAAO,gBACpB,OAAM,IAAI,uBAAuB,6FAA6F;AAEhI,QAAO,UAAU,OAAO,gBAAgB,MAAM;;;;;;AAOhD,SAAgB,2BAA2B,mBAA2B,KAAK;CACzE,MAAM,wBAAwB,KAAK,KAAK,mBAAmB,EAAE;CAC7D,MAAM,aAAa,KAAK,KAAK,wBAAwB,IAAI,EAAE;CAE3D,MAAM,MAAM,aADQ,qBAAqB,IAAI,WAAW,WAAW,CAAC,CAC/B;AACrC,QAAO,IAAI,MAAM,IAAI,SAAS,sBAAsB,CAAC,aAAa;;AAGpE,eAAe,uBAAuB,SAAiB,QAA6B,MAAkB;CACpG,MAAM,cAAc,OAAO,WAAW,WAAW,IAAI,aAAa,CAAC,OAAO,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tsx"],"sourcesContent":["import { encodeBase32, encodeBase64 } from \"./bytes\";\nimport { HexclaveAssertionError } from \"./errors\";\nimport { globalVar } from \"./globals\";\nimport { Result } from \"./results\";\nimport { toArrayBufferBacked } from \"./typed-arrays\";\n\nexport function generateRandomValues(array: Uint8Array): typeof array {\n if (!globalVar.crypto) {\n throw new HexclaveAssertionError(\"Crypto API is not available in this environment. Are you using an old browser?\");\n }\n if (!globalVar.crypto.getRandomValues) {\n throw new HexclaveAssertionError(\"crypto.getRandomValues is not available in this environment. Are you using an old browser?\");\n }\n return globalVar.crypto.getRandomValues(array);\n}\n\n/**\n * Generates a secure alphanumeric string using the system's cryptographically secure\n * random number generator.\n */\nexport function generateSecureRandomString(minBitsOfEntropy: number = 224) {\n const base32CharactersCount = Math.ceil(minBitsOfEntropy / 5);\n const bytesCount = Math.ceil(base32CharactersCount * 5 / 8);\n const randomBytes = generateRandomValues(new Uint8Array(bytesCount));\n const str = encodeBase32(randomBytes);\n return str.slice(str.length - base32CharactersCount).toLowerCase();\n}\n\nasync function getDerivedSymmetricKey(purpose: string, secret: string | Uint8Array, salt: Uint8Array) {\n const secretBytes = typeof secret === \"string\" ? new TextEncoder().encode(secret) : toArrayBufferBacked(secret);\n const originalSecretKey = await crypto.subtle.importKey(\"raw\", secretBytes, \"HKDF\", false, [\"deriveKey\"]);\n return await crypto.subtle.deriveKey(\n {\n name: \"HKDF\",\n salt: toArrayBufferBacked(salt),\n hash: \"SHA-256\",\n // NOTE (Hexclave rebrand): do NOT rename this \"stack-*\" literal. It is a domain-separation\n // tag baked into HKDF key derivation; changing it would derive different keys and make all\n // previously-encrypted data undecryptable. It is an internal constant, never user-visible.\n info: new TextEncoder().encode(JSON.stringify([\n \"stack-crypto-helper-derived-symmetric-key\",\n purpose,\n typeof secret === \"string\" ? \"string-key\" : \"binary-key\",\n encodeBase64(salt),\n ])),\n },\n originalSecretKey,\n { name: \"AES-GCM\", length: 256 },\n false,\n [\"encrypt\", \"decrypt\"]\n );\n}\n\nexport async function encrypt({ purpose, secret, value }: { purpose: string, secret: string | Uint8Array, value: Uint8Array }) {\n const iv = crypto.getRandomValues(new Uint8Array(12));\n const salt = crypto.getRandomValues(new Uint8Array(16));\n const derivedSecretKey = await getDerivedSymmetricKey(purpose, secret, salt);\n\n const cipher = await crypto.subtle.encrypt({\n name: \"AES-GCM\",\n iv,\n }, derivedSecretKey, toArrayBufferBacked(value));\n\n const version = [0x01, 0x00];\n return new Uint8Array([...version, ...salt, ...iv, ...new Uint8Array(cipher)]);\n}\n\nexport async function decrypt({ purpose, secret, cipher }: { purpose: string, secret: string | Uint8Array, cipher: Uint8Array }) {\n const version = cipher.slice(0, 2);\n if (version[0] !== 0x01 || version[1] !== 0x00) throw new HexclaveAssertionError(\"Invalid ciphertext version in decrypt(...); expected 0x0100\", { purpose });\n const salt = cipher.slice(2, 18);\n const iv = cipher.slice(18, 30);\n const cipherBytes = cipher.slice(30);\n const derivedSecretKey = await getDerivedSymmetricKey(purpose, secret, salt);\n\n try {\n const plaintext = await crypto.subtle.decrypt({\n name: \"AES-GCM\",\n iv,\n }, derivedSecretKey, cipherBytes);\n return Result.ok(new Uint8Array(plaintext));\n } catch (e) {\n if (e instanceof DOMException && e.name === \"OperationError\") {\n return Result.error(new Error(\"Invalid ciphertext or secret when decrypting encrypted value\", { cause: e }));\n }\n throw e;\n }\n}\n\nimport.meta.vitest?.test(\"encrypt & decrypt\", async ({ expect }) => {\n const encryptAndDecrypt = async (encryptPurpose: string, decryptPurpose: string, encryptSecret: string | Uint8Array, decryptSecret: string | Uint8Array, value: Uint8Array) => {\n const encrypted = await encrypt({ purpose: encryptPurpose, secret: encryptSecret, value });\n const decrypted = await decrypt({ purpose: decryptPurpose, secret: decryptSecret, cipher: encrypted });\n return decrypted;\n };\n\n const exampleBytes = new TextEncoder().encode(\"hello\");\n\n const exampleKey1 = crypto.getRandomValues(new Uint8Array(32));\n const exampleKey2 = crypto.getRandomValues(new Uint8Array(32));\n\n expect(await encryptAndDecrypt(\"p\", \"p\", \"secret\", \"secret\", exampleBytes)).toEqual(Result.ok(exampleBytes));\n expect(await encryptAndDecrypt(\"p\", \"p\", exampleKey1, exampleKey1, exampleBytes)).toEqual(Result.ok(exampleBytes));\n expect(await encryptAndDecrypt(\"p\", \"p\", exampleKey1, \"secret\", exampleBytes)).toEqual(Result.error(expect.objectContaining({ message: \"Invalid ciphertext or secret when decrypting encrypted value\" })));\n expect(await encryptAndDecrypt(\"p\", \"p\", exampleKey1, exampleKey2, exampleBytes)).toEqual(Result.error(expect.objectContaining({ message: \"Invalid ciphertext or secret when decrypting encrypted value\" })));\n expect(await encryptAndDecrypt(\"p\", \"not-p\", exampleKey1, exampleKey1, exampleBytes)).toEqual(Result.error(expect.objectContaining({ message: \"Invalid ciphertext or secret when decrypting encrypted value\" })));\n});\n\nexport type HashOptions = {\n purpose: string,\n salt?: string | Uint8Array,\n extra?: string | Uint8Array,\n value: string | Uint8Array,\n};\n\nexport async function hash(options: HashOptions) {\n return await iteratedHash({ ...options, iterations: 1 });\n}\n\nexport async function iteratedHash(options: HashOptions & { iterations: number }) {\n const stringOrUint8ArrayToUint8Array = (value: string | Uint8Array) => typeof value === \"string\" ? new TextEncoder().encode(value) : toArrayBufferBacked(value);\n const stringOrUint8ArrayToBase64 = (value: string | Uint8Array) => encodeBase64(stringOrUint8ArrayToUint8Array(value));\n const input = await crypto.subtle.importKey(\n \"raw\",\n stringOrUint8ArrayToUint8Array(options.value),\n \"PBKDF2\",\n false,\n [\"deriveBits\"]\n );\n return new Uint8Array(await crypto.subtle.deriveBits({\n name: \"PBKDF2\",\n // NOTE (Hexclave rebrand): do NOT rename this \"stack-*\" literal. It is a domain-separation tag\n // mixed into the PBKDF2 salt; changing it would change every hash output and break verification\n // of all previously-hashed values. It is an internal constant, never user-visible.\n salt: new TextEncoder().encode(JSON.stringify([\n \"stack-crypto-helper-iterated-hash\",\n options.purpose,\n stringOrUint8ArrayToBase64(options.salt ?? \"\"),\n stringOrUint8ArrayToBase64(options.extra ?? \"\"),\n ])),\n iterations: options.iterations,\n hash: \"SHA-256\",\n }, input, 256));\n}\n\nimport.meta.vitest?.test(\"iteratedHash\", async ({ expect }) => {\n const valueBytes = new TextEncoder().encode(\"hello\");\n const incrementBytes = new Uint8Array([0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10]);\n\n const hash = await iteratedHash({ purpose: \"purpose\", value: valueBytes, iterations: 100_000 });\n const hash2 = await iteratedHash({ purpose: \"purpose\", value: valueBytes, iterations: 100_000 });\n const hashWithDifferentPurpose = await iteratedHash({ purpose: \"different-purpose\", value: valueBytes, iterations: 100_000 });\n const hashWithEmptySalt = await iteratedHash({ purpose: \"purpose\", value: valueBytes, salt: new Uint8Array(0), iterations: 100_000 });\n const hashWithDifferentSalt = await iteratedHash({ purpose: \"purpose\", value: valueBytes, salt: incrementBytes, iterations: 100_000 });\n const hashWithEmptyExtra = await iteratedHash({ purpose: \"purpose\", value: valueBytes, extra: new Uint8Array(0), iterations: 100_000 });\n const hashWithDifferentExtra = await iteratedHash({ purpose: \"purpose\", value: valueBytes, extra: incrementBytes, iterations: 100_000 });\n const hashWithDifferentValue = await iteratedHash({ purpose: \"purpose\", value: new TextEncoder().encode(\"hello2\"), iterations: 100_000 });\n const hashWithDifferentSaltAndExtra = await iteratedHash({ purpose: \"purpose\", value: valueBytes, salt: incrementBytes, extra: incrementBytes, iterations: 100_000 });\n const hashWithDifferentIterations = await iteratedHash({ purpose: \"purpose\", value: valueBytes, iterations: 100_001 });\n\n\n expect(hash).toEqual(hash2);\n expect(hash).not.toEqual(hashWithDifferentPurpose);\n expect(hash).toEqual(hashWithEmptySalt);\n expect(hash).not.toEqual(hashWithDifferentSalt);\n expect(hash).toEqual(hashWithEmptyExtra);\n expect(hash).not.toEqual(hashWithDifferentExtra);\n expect(hash).not.toEqual(hashWithDifferentValue);\n expect(hash).not.toEqual(hashWithDifferentIterations);\n\n expect(hashWithDifferentSalt).not.toEqual(hashWithDifferentExtra);\n expect(hashWithDifferentSalt).not.toEqual(hashWithDifferentSaltAndExtra);\n expect(hashWithDifferentExtra).not.toEqual(hashWithDifferentSaltAndExtra);\n});\n"],"mappings":";;;;;;AAMA,SAAgB,qBAAqB,OAAiC;CACpE,IAAI,CAAC,UAAU,QACb,MAAM,IAAI,uBAAuB,gFAAgF;CAEnH,IAAI,CAAC,UAAU,OAAO,iBACpB,MAAM,IAAI,uBAAuB,4FAA4F;CAE/H,OAAO,UAAU,OAAO,gBAAgB,KAAK;AAC/C;;;;;AAMA,SAAgB,2BAA2B,mBAA2B,KAAK;CACzE,MAAM,wBAAwB,KAAK,KAAK,mBAAmB,CAAC;CAC5D,MAAM,aAAa,KAAK,KAAK,wBAAwB,IAAI,CAAC;CAE1D,MAAM,MAAM,aADQ,qBAAqB,IAAI,WAAW,UAAU,CAC/B,CAAC;CACpC,OAAO,IAAI,MAAM,IAAI,SAAS,qBAAqB,CAAC,CAAC,YAAY;AACnE;AAEA,eAAe,uBAAuB,SAAiB,QAA6B,MAAkB;CACpG,MAAM,cAAc,OAAO,WAAW,WAAW,IAAI,YAAY,CAAC,CAAC,OAAO,MAAM,IAAI,oBAAoB,MAAM;CAC9G,MAAM,oBAAoB,MAAM,OAAO,OAAO,UAAU,OAAO,aAAa,QAAQ,OAAO,CAAC,WAAW,CAAC;CACxG,OAAO,MAAM,OAAO,OAAO,UACzB;EACE,MAAM;EACN,MAAM,oBAAoB,IAAI;EAC9B,MAAM;EAIN,MAAM,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK,UAAU;GAC5C;GACA;GACA,OAAO,WAAW,WAAW,eAAe;GAC5C,aAAa,IAAI;EACnB,CAAC,CAAC;CACJ,GACA,mBACA;EAAE,MAAM;EAAW,QAAQ;CAAI,GAC/B,OACA,CAAC,WAAW,SAAS,CACvB;AACF;AAEA,eAAsB,QAAQ,EAAE,SAAS,QAAQ,SAA8E;CAC7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AI,YAAY,CAAC,CAAC,OAAO,KAAK,IAAI,oBAAoB,KAAK;CAC9J,MAAM,8BAA8B,UAA+B,aAAa,+BAA+B,KAAK,CAAC;CACrH,MAAM,QAAQ,MAAM,OAAO,OAAO,UAChC,OACA,+BAA+B,QAAQ,KAAK,GAC5C,UACA,OACA,CAAC,YAAY,CACf;CACA,OAAO,IAAI,WAAW,MAAM,OAAO,OAAO,WAAW;EACnD,MAAM;EAIN,MAAM,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK,UAAU;GAC5C;GACA,QAAQ;GACR,2BAA2B,QAAQ,QAAQ,EAAE;GAC7C,2BAA2B,QAAQ,SAAS,EAAE;EAChD,CAAC,CAAC;EACF,YAAY,QAAQ;EACpB,MAAM;CACR,GAAG,OAAO,GAAG,CAAC;AAChB"}
@@ -1,4 +1,4 @@
1
- import { Currency, MoneyAmount, SUPPORTED_CURRENCIES } from "./currency-constants";
1
+ import { Currency, MoneyAmount, SUPPORTED_CURRENCIES } from "./currency-constants.js";
2
2
 
3
3
  //#region src/utils/currencies.d.ts
4
4
  type SupportedCurrency = (typeof SUPPORTED_CURRENCIES)[number];
@@ -1 +1 @@
1
- {"version":3,"file":"currencies.d.ts","names":[],"sources":["../../../src/utils/currencies.tsx"],"mappings":";;;KAIY,iBAAA,WAA4B,oBAAA;AAAA,iBAExB,wBAAA,CAAyB,MAAA,EAAQ,WAAA,EAAa,QAAA,EAAU,QAAA"}
1
+ {"version":3,"file":"currencies.d.ts","names":[],"sources":["../../../src/utils/currencies.tsx"],"mappings":";;;KAIY,iBAAA,WAA4B,oBAAoB;AAAA,iBAE5C,wBAAA,CAAyB,MAAA,EAAQ,WAAA,EAAa,QAAA,EAAU,QAAQ"}
@@ -1,7 +1,6 @@
1
1
  import { moneyAmountSchema } from "../schema-fields.js";
2
2
  import { HexclaveAssertionError } from "./errors.js";
3
- import { SUPPORTED_CURRENCIES } from "./currency-constants.js";
4
-
3
+ import "./currency-constants.js";
5
4
  //#region src/utils/currencies.tsx
6
5
  function moneyAmountToStripeUnits(amount, currency) {
7
6
  const validated = moneyAmountSchema(currency).defined().validateSync(amount);
@@ -10,41 +9,7 @@ function moneyAmountToStripeUnits(amount, currency) {
10
9
  const paddedFractional = fractional.padEnd(currency.decimals, "0");
11
10
  return Number.parseInt(whole + paddedFractional, 10);
12
11
  }
13
- (void 0)?.describe("moneyAmountToStripeUnits", (test) => {
14
- const USD = SUPPORTED_CURRENCIES.find((c) => c.code === "USD");
15
- test("converts fully-padded USD amounts", ({ expect }) => {
16
- expect(moneyAmountToStripeUnits("5.00", USD)).toBe(500);
17
- expect(moneyAmountToStripeUnits("0.01", USD)).toBe(1);
18
- expect(moneyAmountToStripeUnits("12.34", USD)).toBe(1234);
19
- });
20
- test("converts whole-number USD amounts (no decimals)", ({ expect }) => {
21
- expect(moneyAmountToStripeUnits("5", USD)).toBe(500);
22
- expect(moneyAmountToStripeUnits("10", USD)).toBe(1e3);
23
- expect(moneyAmountToStripeUnits("0", USD)).toBe(0);
24
- });
25
- test("converts USD amounts with one decimal digit", ({ expect }) => {
26
- expect(moneyAmountToStripeUnits("5.5", USD)).toBe(550);
27
- expect(moneyAmountToStripeUnits("0.5", USD)).toBe(50);
28
- });
29
- test("matches stripeUnitsToMoneyAmount round-trip", ({ expect }) => {
30
- for (const cents of [
31
- 0,
32
- 1,
33
- 5,
34
- 50,
35
- 99,
36
- 100,
37
- 1234,
38
- 1e5
39
- ]) expect(moneyAmountToStripeUnits(`${Math.floor(cents / 100)}.${(cents % 100).toString().padStart(2, "0")}`, USD)).toBe(cents);
40
- });
41
- test("rejects invalid money strings via schema", ({ expect }) => {
42
- expect(() => moneyAmountToStripeUnits("abc", USD)).toThrow();
43
- expect(() => moneyAmountToStripeUnits("5.555", USD)).toThrow();
44
- expect(() => moneyAmountToStripeUnits("05", USD)).toThrow();
45
- });
46
- });
47
-
48
12
  //#endregion
49
13
  export { moneyAmountToStripeUnits };
14
+
50
15
  //# sourceMappingURL=currencies.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"currencies.js","names":[],"sources":["../../../src/utils/currencies.tsx"],"sourcesContent":["import { moneyAmountSchema } from \"../schema-fields\";\nimport { SUPPORTED_CURRENCIES, type Currency, type MoneyAmount } from \"./currency-constants\";\nimport { HexclaveAssertionError } from \"./errors\";\n\nexport type SupportedCurrency = (typeof SUPPORTED_CURRENCIES)[number];\n\nexport function moneyAmountToStripeUnits(amount: MoneyAmount, currency: Currency): number {\n const validated = moneyAmountSchema(currency).defined().validateSync(amount);\n if (currency.stripeDecimals !== currency.decimals) {\n throw new HexclaveAssertionError(\"unimplemented: TODO support different decimal configurations\");\n }\n // `moneyAmountSchema` accepts strings with 0..currency.decimals fractional\n // digits, so we must right-pad the fractional part before stripping the dot.\n // A naïve `replace('.', '')` underweights inputs like \"5\" → 5 (should be 500\n // for USD) and \"0.5\" → 5 (should be 50).\n const [whole, fractional = \"\"] = validated.split(\".\");\n const paddedFractional = fractional.padEnd(currency.decimals, \"0\");\n return Number.parseInt(whole + paddedFractional, 10);\n}\n\nimport.meta.vitest?.describe(\"moneyAmountToStripeUnits\", (test) => {\n const USD = SUPPORTED_CURRENCIES.find((c) => c.code === \"USD\")!;\n\n test(\"converts fully-padded USD amounts\", ({ expect }) => {\n expect(moneyAmountToStripeUnits(\"5.00\" as MoneyAmount, USD)).toBe(500);\n expect(moneyAmountToStripeUnits(\"0.01\" as MoneyAmount, USD)).toBe(1);\n expect(moneyAmountToStripeUnits(\"12.34\" as MoneyAmount, USD)).toBe(1234);\n });\n\n test(\"converts whole-number USD amounts (no decimals)\", ({ expect }) => {\n expect(moneyAmountToStripeUnits(\"5\" as MoneyAmount, USD)).toBe(500);\n expect(moneyAmountToStripeUnits(\"10\" as MoneyAmount, USD)).toBe(1000);\n expect(moneyAmountToStripeUnits(\"0\" as MoneyAmount, USD)).toBe(0);\n });\n\n test(\"converts USD amounts with one decimal digit\", ({ expect }) => {\n expect(moneyAmountToStripeUnits(\"5.5\" as MoneyAmount, USD)).toBe(550);\n expect(moneyAmountToStripeUnits(\"0.5\" as MoneyAmount, USD)).toBe(50);\n });\n\n test(\"matches stripeUnitsToMoneyAmount round-trip\", ({ expect }) => {\n for (const cents of [0, 1, 5, 50, 99, 100, 1234, 100000]) {\n const padded = `${Math.floor(cents / 100)}.${(cents % 100).toString().padStart(2, \"0\")}` as MoneyAmount;\n expect(moneyAmountToStripeUnits(padded, USD)).toBe(cents);\n }\n });\n\n test(\"rejects invalid money strings via schema\", ({ expect }) => {\n expect(() => moneyAmountToStripeUnits(\"abc\" as MoneyAmount, USD)).toThrow();\n expect(() => moneyAmountToStripeUnits(\"5.555\" as MoneyAmount, USD)).toThrow();\n expect(() => moneyAmountToStripeUnits(\"05\" as MoneyAmount, USD)).toThrow();\n });\n});\n"],"mappings":";;;;;AAMA,SAAgB,yBAAyB,QAAqB,UAA4B;CACxF,MAAM,YAAY,kBAAkB,SAAS,CAAC,SAAS,CAAC,aAAa,OAAO;AAC5E,KAAI,SAAS,mBAAmB,SAAS,SACvC,OAAM,IAAI,uBAAuB,+DAA+D;CAMlG,MAAM,CAAC,OAAO,aAAa,MAAM,UAAU,MAAM,IAAI;CACrD,MAAM,mBAAmB,WAAW,OAAO,SAAS,UAAU,IAAI;AAClE,QAAO,OAAO,SAAS,QAAQ,kBAAkB,GAAG;;CAGtD,SAAW,SAAS,6BAAU,SAA4B;CACxD,MAAM,MAAM,qBAAqB,MAAM,MAAM,EAAE,SAAS,MAAM;AAE9D,MAAK,sCAAsC,EAAE,aAAa;AACxD,SAAO,yBAAyB,QAAuB,IAAI,CAAC,CAAC,KAAK,IAAI;AACtE,SAAO,yBAAyB,QAAuB,IAAI,CAAC,CAAC,KAAK,EAAE;AACpE,SAAO,yBAAyB,SAAwB,IAAI,CAAC,CAAC,KAAK,KAAK;GACxE;AAEF,MAAK,oDAAoD,EAAE,aAAa;AACtE,SAAO,yBAAyB,KAAoB,IAAI,CAAC,CAAC,KAAK,IAAI;AACnE,SAAO,yBAAyB,MAAqB,IAAI,CAAC,CAAC,KAAK,IAAK;AACrE,SAAO,yBAAyB,KAAoB,IAAI,CAAC,CAAC,KAAK,EAAE;GACjE;AAEF,MAAK,gDAAgD,EAAE,aAAa;AAClE,SAAO,yBAAyB,OAAsB,IAAI,CAAC,CAAC,KAAK,IAAI;AACrE,SAAO,yBAAyB,OAAsB,IAAI,CAAC,CAAC,KAAK,GAAG;GACpE;AAEF,MAAK,gDAAgD,EAAE,aAAa;AAClE,OAAK,MAAM,SAAS;GAAC;GAAG;GAAG;GAAG;GAAI;GAAI;GAAK;GAAM;GAAO,CAEtD,QAAO,yBADQ,GAAG,KAAK,MAAM,QAAQ,IAAI,CAAC,IAAI,QAAQ,KAAK,UAAU,CAAC,SAAS,GAAG,IAAI,IAC9C,IAAI,CAAC,CAAC,KAAK,MAAM;GAE3D;AAEF,MAAK,6CAA6C,EAAE,aAAa;AAC/D,eAAa,yBAAyB,OAAsB,IAAI,CAAC,CAAC,SAAS;AAC3E,eAAa,yBAAyB,SAAwB,IAAI,CAAC,CAAC,SAAS;AAC7E,eAAa,yBAAyB,MAAqB,IAAI,CAAC,CAAC,SAAS;GAC1E;EACF"}
1
+ {"version":3,"file":"currencies.js","names":[],"sources":["../../../src/utils/currencies.tsx"],"sourcesContent":["import { moneyAmountSchema } from \"../schema-fields\";\nimport { SUPPORTED_CURRENCIES, type Currency, type MoneyAmount } from \"./currency-constants\";\nimport { HexclaveAssertionError } from \"./errors\";\n\nexport type SupportedCurrency = (typeof SUPPORTED_CURRENCIES)[number];\n\nexport function moneyAmountToStripeUnits(amount: MoneyAmount, currency: Currency): number {\n const validated = moneyAmountSchema(currency).defined().validateSync(amount);\n if (currency.stripeDecimals !== currency.decimals) {\n throw new HexclaveAssertionError(\"unimplemented: TODO support different decimal configurations\");\n }\n // `moneyAmountSchema` accepts strings with 0..currency.decimals fractional\n // digits, so we must right-pad the fractional part before stripping the dot.\n // A naïve `replace('.', '')` underweights inputs like \"5\" → 5 (should be 500\n // for USD) and \"0.5\" → 5 (should be 50).\n const [whole, fractional = \"\"] = validated.split(\".\");\n const paddedFractional = fractional.padEnd(currency.decimals, \"0\");\n return Number.parseInt(whole + paddedFractional, 10);\n}\n\nimport.meta.vitest?.describe(\"moneyAmountToStripeUnits\", (test) => {\n const USD = SUPPORTED_CURRENCIES.find((c) => c.code === \"USD\")!;\n\n test(\"converts fully-padded USD amounts\", ({ expect }) => {\n expect(moneyAmountToStripeUnits(\"5.00\" as MoneyAmount, USD)).toBe(500);\n expect(moneyAmountToStripeUnits(\"0.01\" as MoneyAmount, USD)).toBe(1);\n expect(moneyAmountToStripeUnits(\"12.34\" as MoneyAmount, USD)).toBe(1234);\n });\n\n test(\"converts whole-number USD amounts (no decimals)\", ({ expect }) => {\n expect(moneyAmountToStripeUnits(\"5\" as MoneyAmount, USD)).toBe(500);\n expect(moneyAmountToStripeUnits(\"10\" as MoneyAmount, USD)).toBe(1000);\n expect(moneyAmountToStripeUnits(\"0\" as MoneyAmount, USD)).toBe(0);\n });\n\n test(\"converts USD amounts with one decimal digit\", ({ expect }) => {\n expect(moneyAmountToStripeUnits(\"5.5\" as MoneyAmount, USD)).toBe(550);\n expect(moneyAmountToStripeUnits(\"0.5\" as MoneyAmount, USD)).toBe(50);\n });\n\n test(\"matches stripeUnitsToMoneyAmount round-trip\", ({ expect }) => {\n for (const cents of [0, 1, 5, 50, 99, 100, 1234, 100000]) {\n const padded = `${Math.floor(cents / 100)}.${(cents % 100).toString().padStart(2, \"0\")}` as MoneyAmount;\n expect(moneyAmountToStripeUnits(padded, USD)).toBe(cents);\n }\n });\n\n test(\"rejects invalid money strings via schema\", ({ expect }) => {\n expect(() => moneyAmountToStripeUnits(\"abc\" as MoneyAmount, USD)).toThrow();\n expect(() => moneyAmountToStripeUnits(\"5.555\" as MoneyAmount, USD)).toThrow();\n expect(() => moneyAmountToStripeUnits(\"05\" as MoneyAmount, USD)).toThrow();\n });\n});\n"],"mappings":";;;;AAMA,SAAgB,yBAAyB,QAAqB,UAA4B;CACxF,MAAM,YAAY,kBAAkB,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,aAAa,MAAM;CAC3E,IAAI,SAAS,mBAAmB,SAAS,UACvC,MAAM,IAAI,uBAAuB,8DAA8D;CAMjG,MAAM,CAAC,OAAO,aAAa,MAAM,UAAU,MAAM,GAAG;CACpD,MAAM,mBAAmB,WAAW,OAAO,SAAS,UAAU,GAAG;CACjE,OAAO,OAAO,SAAS,QAAQ,kBAAkB,EAAE;AACrD"}
@@ -1 +1 @@
1
- {"version":3,"file":"currency-constants.d.ts","names":[],"sources":["../../../src/utils/currency-constants.tsx"],"mappings":";;AAMA;;;;;KAAY,WAAA;AAAA,KAEA,QAAA;EACV,IAAA,EAAM,SAAA;EACN,QAAA;EACA,cAAA;AAAA;AAAA,cAGW,oBAAA;EAAA"}
1
+ {"version":3,"file":"currency-constants.d.ts","names":[],"sources":["../../../src/utils/currency-constants.tsx"],"mappings":";;AAMA;;;;AAAuB;KAAX,WAAA;AAAA,KAEA,QAAA;EACV,IAAA,EAAM,SAAS;EACf,QAAA;EACA,cAAA;AAAA;AAAA,cAGW,oBAAA;EAAA"}
@@ -36,7 +36,7 @@ const SUPPORTED_CURRENCIES = [
36
36
  stripeDecimals: 2
37
37
  }
38
38
  ];
39
-
40
39
  //#endregion
41
40
  export { SUPPORTED_CURRENCIES };
41
+
42
42
  //# sourceMappingURL=currency-constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"currency-constants.js","names":[],"sources":["../../../src/utils/currency-constants.tsx"],"sourcesContent":["/**\n * A decimal string representing a monetary amount, e.g. `\"9.99\"`, `\"0.01\"`, or `\"1000\"`.\n *\n * This is NOT an integer in cents/minor units — it is always a human-readable decimal string.\n * For example, nine dollars and ninety-nine cents is `\"9.99\"`, not `999`.\n */\nexport type MoneyAmount = `${number}` | `${number}.${number}`;\n\nexport type Currency = {\n code: Uppercase<string>,\n decimals: number,\n stripeDecimals: number,\n};\n\nexport const SUPPORTED_CURRENCIES = [\n {\n code: 'USD',\n decimals: 2,\n stripeDecimals: 2,\n },\n {\n code: 'EUR',\n decimals: 2,\n stripeDecimals: 2,\n },\n {\n code: 'GBP',\n decimals: 2,\n stripeDecimals: 2,\n },\n {\n code: 'JPY',\n decimals: 0,\n stripeDecimals: 0,\n },\n {\n code: 'INR',\n decimals: 2,\n stripeDecimals: 2,\n },\n {\n code: 'AUD',\n decimals: 2,\n stripeDecimals: 2,\n },\n {\n code: 'CAD',\n decimals: 2,\n stripeDecimals: 2,\n },\n] as const satisfies Currency[];\n"],"mappings":";AAcA,MAAa,uBAAuB;CAClC;EACE,MAAM;EACN,UAAU;EACV,gBAAgB;EACjB;CACD;EACE,MAAM;EACN,UAAU;EACV,gBAAgB;EACjB;CACD;EACE,MAAM;EACN,UAAU;EACV,gBAAgB;EACjB;CACD;EACE,MAAM;EACN,UAAU;EACV,gBAAgB;EACjB;CACD;EACE,MAAM;EACN,UAAU;EACV,gBAAgB;EACjB;CACD;EACE,MAAM;EACN,UAAU;EACV,gBAAgB;EACjB;CACD;EACE,MAAM;EACN,UAAU;EACV,gBAAgB;EACjB;CACF"}
1
+ {"version":3,"file":"currency-constants.js","names":[],"sources":["../../../src/utils/currency-constants.tsx"],"sourcesContent":["/**\n * A decimal string representing a monetary amount, e.g. `\"9.99\"`, `\"0.01\"`, or `\"1000\"`.\n *\n * This is NOT an integer in cents/minor units — it is always a human-readable decimal string.\n * For example, nine dollars and ninety-nine cents is `\"9.99\"`, not `999`.\n */\nexport type MoneyAmount = `${number}` | `${number}.${number}`;\n\nexport type Currency = {\n code: Uppercase<string>,\n decimals: number,\n stripeDecimals: number,\n};\n\nexport const SUPPORTED_CURRENCIES = [\n {\n code: 'USD',\n decimals: 2,\n stripeDecimals: 2,\n },\n {\n code: 'EUR',\n decimals: 2,\n stripeDecimals: 2,\n },\n {\n code: 'GBP',\n decimals: 2,\n stripeDecimals: 2,\n },\n {\n code: 'JPY',\n decimals: 0,\n stripeDecimals: 0,\n },\n {\n code: 'INR',\n decimals: 2,\n stripeDecimals: 2,\n },\n {\n code: 'AUD',\n decimals: 2,\n stripeDecimals: 2,\n },\n {\n code: 'CAD',\n decimals: 2,\n stripeDecimals: 2,\n },\n] as const satisfies Currency[];\n"],"mappings":";AAcA,MAAa,uBAAuB;CAClC;EACE,MAAM;EACN,UAAU;EACV,gBAAgB;CAClB;CACA;EACE,MAAM;EACN,UAAU;EACV,gBAAgB;CAClB;CACA;EACE,MAAM;EACN,UAAU;EACV,gBAAgB;CAClB;CACA;EACE,MAAM;EACN,UAAU;EACV,gBAAgB;CAClB;CACA;EACE,MAAM;EACN,UAAU;EACV,gBAAgB;CAClB;CACA;EACE,MAAM;EACN,UAAU;EACV,gBAAgB;CAClB;CACA;EACE,MAAM;EACN,UAAU;EACV,gBAAgB;CAClB;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"dates.d.ts","names":[],"sources":["../../../src/utils/dates.tsx"],"mappings":";iBAIgB,SAAA,CAAU,IAAA,EAAM,IAAA;AAAA,iBAuBhB,OAAA,CAAQ,IAAA,EAAM,IAAA;AAAA,iBAiCd,eAAA,CAAgB,IAAA,EAAM,IAAA;EACpC,MAAA;EAzD8B;;AAuBhC;EAsCE,kBAAA;AAAA;;;AALF;iBAkDgB,2BAAA,CAA4B,IAAA,EAAM,IAAA;AAAA,KAkCtC,QAAA;AAAA,KACA,WAAA;AAAA,iBA+CI,gBAAA,CAAiB,IAAA,EAAM,IAAA,EAAM,QAAA,EAAU,QAAA,GAAW,IAAA;AAAA,iBAIlD,WAAA,CAAY,IAAA,EAAM,IAAA,EAAM,QAAA,EAAU,QAAA,GAAW,IAAA;AAAA,cAIhD,eAAA,EAAe,IAAA;AAAA,iBAUZ,mBAAA,CAAoB,MAAA,EAAQ,IAAA,EAAM,EAAA,EAAI,IAAA,EAAM,MAAA,EAAQ,WAAA"}
1
+ {"version":3,"file":"dates.d.ts","names":[],"sources":["../../../src/utils/dates.tsx"],"mappings":";iBAIgB,SAAA,CAAU,IAAU,EAAJ,IAAI;AAAA,iBAuBpB,OAAA,CAAQ,IAAU,EAAJ,IAAI;AAAA,iBAiClB,eAAA,CAAgB,IAAA,EAAM,IAAI;EACxC,MAAA;EAzD8B;AAAI;AAuBpC;EAsCE,kBAAA;AAAA;;AAtCgC;AAiClC;iBAkDgB,2BAAA,CAA4B,IAAU,EAAJ,IAAI;AAAA,KAkC1C,QAAA;AAAA,KACA,WAAA;AAAA,iBA+CI,gBAAA,CAAiB,IAAA,EAAM,IAAA,EAAM,QAAA,EAAU,QAAA,GAAW,IAAA;AAAA,iBAIlD,WAAA,CAAY,IAAA,EAAM,IAAA,EAAM,QAAA,EAAU,QAAA,GAAW,IAAA;AAAA,cAIhD,eAAA,EAAe,IAA6B;AAAA,iBAUzC,mBAAA,CAAoB,MAAA,EAAQ,IAAA,EAAM,EAAA,EAAI,IAAA,EAAM,MAAA,EAAQ,WAAA"}
@@ -1,17 +1,10 @@
1
1
  import { intervalSchema } from "../schema-fields.js";
2
2
  import { HexclaveAssertionError } from "./errors.js";
3
3
  import { remainder } from "./math.js";
4
-
5
4
  //#region src/utils/dates.tsx
6
5
  function isWeekend(date) {
7
6
  return date.getDay() === 0 || date.getDay() === 6;
8
7
  }
9
- (void 0)?.test("isWeekend", ({ expect }) => {
10
- expect(isWeekend(new Date(2023, 0, 1))).toBe(true);
11
- expect(isWeekend(new Date(2023, 0, 7))).toBe(true);
12
- expect(isWeekend(new Date(2023, 0, 2))).toBe(false);
13
- expect(isWeekend(new Date(2023, 0, 6))).toBe(false);
14
- });
15
8
  const agoUnits = [
16
9
  [60, "second"],
17
10
  [60, "minute"],
@@ -22,23 +15,6 @@ const agoUnits = [
22
15
  function fromNow(date) {
23
16
  return fromNowDetailed(date).result;
24
17
  }
25
- (void 0)?.test("fromNow", ({ expect }) => {
26
- const fixedDate = /* @__PURE__ */ new Date("2023-01-15T12:00:00.000Z");
27
- (void 0)?.vi.useFakeTimers();
28
- (void 0)?.vi.setSystemTime(fixedDate);
29
- expect(fromNow(/* @__PURE__ */ new Date("2023-01-15T11:59:50.000Z"))).toBe("just now");
30
- expect(fromNow(/* @__PURE__ */ new Date("2023-01-15T11:59:00.000Z"))).toBe("1 minute ago");
31
- expect(fromNow(/* @__PURE__ */ new Date("2023-01-15T11:00:00.000Z"))).toBe("1 hour ago");
32
- expect(fromNow(/* @__PURE__ */ new Date("2023-01-14T12:00:00.000Z"))).toBe("1 day ago");
33
- expect(fromNow(/* @__PURE__ */ new Date("2023-01-08T12:00:00.000Z"))).toBe("1 week ago");
34
- expect(fromNow(/* @__PURE__ */ new Date("2023-01-15T12:00:10.000Z"))).toBe("just now");
35
- expect(fromNow(/* @__PURE__ */ new Date("2023-01-15T12:01:00.000Z"))).toBe("in 1 minute");
36
- expect(fromNow(/* @__PURE__ */ new Date("2023-01-15T13:00:00.000Z"))).toBe("in 1 hour");
37
- expect(fromNow(/* @__PURE__ */ new Date("2023-01-16T12:00:00.000Z"))).toBe("in 1 day");
38
- expect(fromNow(/* @__PURE__ */ new Date("2023-01-22T12:00:00.000Z"))).toBe("in 1 week");
39
- expect(fromNow(/* @__PURE__ */ new Date("2022-01-15T12:00:00.000Z"))).toMatch(/Jan 15, 2022/);
40
- (void 0)?.vi.useRealTimers();
41
- });
42
18
  function fromNowDetailed(date) {
43
19
  if (!(date instanceof Date)) throw new Error(`fromNow only accepts Date objects (received: ${date})`);
44
20
  const elapsed = (/* @__PURE__ */ new Date()).getTime() - date.getTime();
@@ -78,17 +54,6 @@ function getInputDatetimeLocalString(date) {
78
54
  date.setMinutes(date.getMinutes() - date.getTimezoneOffset());
79
55
  return date.toISOString().slice(0, 19);
80
56
  }
81
- (void 0)?.test("getInputDatetimeLocalString", ({ expect }) => {
82
- (void 0)?.vi.useFakeTimers();
83
- expect(getInputDatetimeLocalString(/* @__PURE__ */ new Date("2023-01-15T12:30:45.000Z"))).toMatch(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/);
84
- const dates = [
85
- /* @__PURE__ */ new Date("2023-01-01T00:00:00.000Z"),
86
- /* @__PURE__ */ new Date("2023-06-15T23:59:59.000Z"),
87
- /* @__PURE__ */ new Date("2023-12-31T12:34:56.000Z")
88
- ];
89
- for (const date of dates) expect(getInputDatetimeLocalString(date)).toMatch(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/);
90
- (void 0)?.vi.useRealTimers();
91
- });
92
57
  function applyInterval(date, times, interval) {
93
58
  if (!intervalSchema.isValidSync(interval)) throw new HexclaveAssertionError(`Invalid interval`, { interval });
94
59
  const [amount, unit] = interval;
@@ -153,15 +118,7 @@ function getIntervalsElapsed(anchor, to, repeat) {
153
118
  }
154
119
  return 0;
155
120
  }
156
- (void 0)?.test("getIntervalsElapsed", ({ expect }) => {
157
- const anchor = /* @__PURE__ */ new Date("2025-01-01T00:00:00.000Z");
158
- const to = /* @__PURE__ */ new Date("2025-01-15T00:00:00.000Z");
159
- expect(getIntervalsElapsed(anchor, to, [1, "week"])).toBe(2);
160
- expect(getIntervalsElapsed(anchor, to, [3, "day"])).toBe(4);
161
- expect(getIntervalsElapsed(/* @__PURE__ */ new Date("2023-01-31T00:00:00.000Z"), /* @__PURE__ */ new Date("2023-03-01T00:00:00.000Z"), [1, "month"])).toBe(0);
162
- expect(getIntervalsElapsed(/* @__PURE__ */ new Date("2020-01-01T00:00:00.000Z"), /* @__PURE__ */ new Date("2022-06-01T00:00:00.000Z"), [1, "year"])).toBe(2);
163
- });
164
-
165
121
  //#endregion
166
122
  export { FAR_FUTURE_DATE, addInterval, fromNow, fromNowDetailed, getInputDatetimeLocalString, getIntervalsElapsed, isWeekend, subtractInterval };
123
+
167
124
  //# sourceMappingURL=dates.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dates.js","names":[],"sources":["../../../src/utils/dates.tsx"],"sourcesContent":["import { intervalSchema } from \"../schema-fields\";\nimport { HexclaveAssertionError } from \"./errors\";\nimport { remainder } from \"./math\";\n\nexport function isWeekend(date: Date): boolean {\n return date.getDay() === 0 || date.getDay() === 6;\n}\n\nimport.meta.vitest?.test(\"isWeekend\", ({ expect }) => {\n // Sunday (day 0)\n expect(isWeekend(new Date(2023, 0, 1))).toBe(true);\n // Saturday (day 6)\n expect(isWeekend(new Date(2023, 0, 7))).toBe(true);\n // Monday (day 1)\n expect(isWeekend(new Date(2023, 0, 2))).toBe(false);\n // Friday (day 5)\n expect(isWeekend(new Date(2023, 0, 6))).toBe(false);\n});\n\nconst agoUnits = [\n [60, 'second'],\n [60, 'minute'],\n [24, 'hour'],\n [7, 'day'],\n [5, 'week'],\n] as const;\n\nexport function fromNow(date: Date): string {\n return fromNowDetailed(date).result;\n}\n\nimport.meta.vitest?.test(\"fromNow\", ({ expect }) => {\n // Set a fixed date for testing\n const fixedDate = new Date(\"2023-01-15T12:00:00.000Z\");\n\n // Use Vitest's fake timers\n import.meta.vitest?.vi.useFakeTimers();\n import.meta.vitest?.vi.setSystemTime(fixedDate);\n\n // Test past times\n expect(fromNow(new Date(\"2023-01-15T11:59:50.000Z\"))).toBe(\"just now\");\n expect(fromNow(new Date(\"2023-01-15T11:59:00.000Z\"))).toBe(\"1 minute ago\");\n expect(fromNow(new Date(\"2023-01-15T11:00:00.000Z\"))).toBe(\"1 hour ago\");\n expect(fromNow(new Date(\"2023-01-14T12:00:00.000Z\"))).toBe(\"1 day ago\");\n expect(fromNow(new Date(\"2023-01-08T12:00:00.000Z\"))).toBe(\"1 week ago\");\n\n // Test future times\n expect(fromNow(new Date(\"2023-01-15T12:00:10.000Z\"))).toBe(\"just now\");\n expect(fromNow(new Date(\"2023-01-15T12:01:00.000Z\"))).toBe(\"in 1 minute\");\n expect(fromNow(new Date(\"2023-01-15T13:00:00.000Z\"))).toBe(\"in 1 hour\");\n expect(fromNow(new Date(\"2023-01-16T12:00:00.000Z\"))).toBe(\"in 1 day\");\n expect(fromNow(new Date(\"2023-01-22T12:00:00.000Z\"))).toBe(\"in 1 week\");\n\n // Test very old dates (should use date format)\n expect(fromNow(new Date(\"2022-01-15T12:00:00.000Z\"))).toMatch(/Jan 15, 2022/);\n\n // Restore real timers\n import.meta.vitest?.vi.useRealTimers();\n});\n\nexport function fromNowDetailed(date: Date): {\n result: string,\n /**\n * May be Infinity if the result will never change.\n */\n secondsUntilChange: number,\n} {\n if (!(date instanceof Date)) {\n throw new Error(`fromNow only accepts Date objects (received: ${date})`);\n }\n\n const now = new Date();\n const elapsed = now.getTime() - date.getTime();\n\n let remainingInUnit = Math.abs(elapsed) / 1000;\n if (remainingInUnit < 15) {\n return {\n result: 'just now',\n secondsUntilChange: 15 - remainingInUnit,\n };\n }\n let unitInSeconds = 1;\n for (const [nextUnitSize, unitName] of agoUnits) {\n const rounded = Math.round(remainingInUnit);\n if (rounded < nextUnitSize) {\n if (elapsed < 0) {\n return {\n result: `in ${rounded} ${unitName}${rounded === 1 ? '' : 's'}`,\n secondsUntilChange: remainder((remainingInUnit - rounded + 0.5) * unitInSeconds, unitInSeconds),\n };\n } else {\n return {\n result: `${rounded} ${unitName}${rounded === 1 ? '' : 's'} ago`,\n secondsUntilChange: remainder((rounded - remainingInUnit - 0.5) * unitInSeconds, unitInSeconds),\n };\n }\n }\n unitInSeconds *= nextUnitSize;\n remainingInUnit /= nextUnitSize;\n }\n\n return {\n result: date.toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' }),\n secondsUntilChange: Infinity,\n };\n}\n\n/**\n * Returns a string representation of the given date in the format expected by the `datetime-local` input type.\n */\nexport function getInputDatetimeLocalString(date: Date): string {\n date = new Date(date);\n date.setMinutes(date.getMinutes() - date.getTimezoneOffset());\n return date.toISOString().slice(0, 19);\n}\n\nimport.meta.vitest?.test(\"getInputDatetimeLocalString\", ({ expect }) => {\n // Use Vitest's fake timers to ensure consistent timezone behavior\n import.meta.vitest?.vi.useFakeTimers();\n\n // Test with a specific date\n const mockDate = new Date(\"2023-01-15T12:30:45.000Z\");\n const result = getInputDatetimeLocalString(mockDate);\n\n // The result should be in the format YYYY-MM-DDTHH:MM:SS\n expect(result).toMatch(/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}$/);\n\n // Test with different dates\n const dates = [\n new Date(\"2023-01-01T00:00:00.000Z\"),\n new Date(\"2023-06-15T23:59:59.000Z\"),\n new Date(\"2023-12-31T12:34:56.000Z\"),\n ];\n\n for (const date of dates) {\n const result = getInputDatetimeLocalString(date);\n expect(result).toMatch(/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}$/);\n }\n\n // Restore real timers\n import.meta.vitest?.vi.useRealTimers();\n});\n\n\nexport type Interval = [number, 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year'];\nexport type DayInterval = [number, 'day' | 'week' | 'month' | 'year'];\n\nfunction applyInterval(date: Date, times: number, interval: Interval): Date {\n if (!intervalSchema.isValidSync(interval)) {\n throw new HexclaveAssertionError(`Invalid interval`, { interval });\n }\n const [amount, unit] = interval;\n switch (unit) {\n case 'millisecond': {\n date.setMilliseconds(date.getMilliseconds() + amount * times);\n break;\n }\n case 'second': {\n date.setSeconds(date.getSeconds() + amount * times);\n break;\n }\n case 'minute': {\n date.setMinutes(date.getMinutes() + amount * times);\n break;\n }\n case 'hour': {\n date.setHours(date.getHours() + amount * times);\n break;\n }\n case 'day': {\n date.setDate(date.getDate() + amount * times);\n break;\n }\n case 'week': {\n date.setDate(date.getDate() + amount * times * 7);\n break;\n }\n case 'month': {\n date.setMonth(date.getMonth() + amount * times);\n break;\n }\n case 'year': {\n date.setFullYear(date.getFullYear() + amount * times);\n break;\n }\n default: {\n throw new HexclaveAssertionError(`Invalid interval despite schema validation`, { interval });\n }\n }\n return date;\n}\n\nexport function subtractInterval(date: Date, interval: Interval): Date {\n return applyInterval(date, -1, interval);\n}\n\nexport function addInterval(date: Date, interval: Interval): Date {\n return applyInterval(date, 1, interval);\n}\n\nexport const FAR_FUTURE_DATE = new Date(8640000000000000); // 13 Sep 275760 00:00:00 UTC\n\nfunction getMsPerDayIntervalUnit(unit: 'day' | 'week'): number {\n if (unit === 'day') {\n return 24 * 60 * 60 * 1000;\n }\n return 7 * 24 * 60 * 60 * 1000;\n}\n\n\nexport function getIntervalsElapsed(anchor: Date, to: Date, repeat: DayInterval): number {\n const [amount, unit] = repeat;\n if (to <= anchor) return 0;\n if (unit === 'day' || unit === 'week') {\n const msPerUnit = getMsPerDayIntervalUnit(unit);\n const diffMs = to.getTime() - anchor.getTime();\n return Math.floor(diffMs / (msPerUnit * amount));\n }\n if ([\"month\", \"year\"].includes(unit)) {\n let count = 0;\n let current = new Date(anchor);\n for (; ;) {\n const next = addInterval(new Date(current), [amount, unit]);\n if (next > to) break;\n current = next;\n count += 1;\n }\n return count;\n }\n return 0;\n}\n\nimport.meta.vitest?.test(\"getIntervalsElapsed\", ({ expect }) => {\n const anchor = new Date('2025-01-01T00:00:00.000Z');\n const to = new Date('2025-01-15T00:00:00.000Z');\n expect(getIntervalsElapsed(anchor, to, [1, 'week'])).toBe(2);\n expect(getIntervalsElapsed(anchor, to, [3, 'day'])).toBe(4);\n\n const mAnchor = new Date('2023-01-31T00:00:00.000Z');\n const mTo = new Date('2023-03-01T00:00:00.000Z');\n expect(getIntervalsElapsed(mAnchor, mTo, [1, 'month'])).toBe(0);\n\n const yAnchor = new Date('2020-01-01T00:00:00.000Z');\n const yTo = new Date('2022-06-01T00:00:00.000Z');\n expect(getIntervalsElapsed(yAnchor, yTo, [1, 'year'])).toBe(2);\n});\n"],"mappings":";;;;;AAIA,SAAgB,UAAU,MAAqB;AAC7C,QAAO,KAAK,QAAQ,KAAK,KAAK,KAAK,QAAQ,KAAK;;CAGlD,SAAW,KAAC,cAAc,EAAA,aAAe;AAEvC,QAAO,UAAU,IAAI,KAAK,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK;AAElD,QAAO,UAAU,IAAI,KAAK,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK;AAElD,QAAO,UAAU,IAAI,KAAK,MAA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;;AAI5B,SAAgB,oBAAoB,QAAc,IAAU,QAA6B;CACvF,MAAM,CAAC,QAAQ,QAAQ;AACvB,KAAI,MAAM,OAAQ,QAAO;AACzB,KAAI,SAAS,SAAS,SAAS,QAAQ;EACrC,MAAM,YAAY,wBAAwB,KAAK;EAC/C,MAAM,SAAS,GAAG,SAAS,GAAG,OAAO,SAAS;AAC9C,SAAO,KAAK,MAAM,UAAU,YAAY,QAAQ;;AAElD,KAAI,CAAC,SAAS,OAAO,CAAC,SAAS,KAAK,EAAE;EACpC,IAAI,QAAQ;EACZ,IAAI,UAAU,IAAI,KAAK,OAAO;AAC9B,WAAU;GACR,MAAM,OAAO,YAAY,IAAI,KAAK,QAAQ,EAAE,CAAC,QAAQ,KAAK,CAAC;AAC3D,OAAI,OAAO,GAAI;AACf,aAAU;AACV,YAAS;;AAEX,SAAO;;AAET,QAAO;;CAGT,SAAW,KAAC,wBAAc,EAAA,aAAyB;CACjD,MAAM,yBAAS,IAAI,KAAK,2BAA2B;CACnD,MAAM,qBAAK,IAAI,KAAK,2BAA2B;AAC/C,QAAO,oBAAoB,QAAQ,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE;AAC5D,QAAO,oBAAoB,QAAQ,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,EAAE;AAI3D,QAAO,oCAFS,IAAI,KAAK,2BAA2B,kBACxC,IAAI,KAAK,2BAA2B,EACP,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,EAAE;AAI/D,QAAO,oCAFS,IAAI,KAAK,2BAA2B,kBACxC,IAAI,KAAK,2BAA2B,EACP,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE;EAC9D"}
1
+ {"version":3,"file":"dates.js","names":[],"sources":["../../../src/utils/dates.tsx"],"sourcesContent":["import { intervalSchema } from \"../schema-fields\";\nimport { HexclaveAssertionError } from \"./errors\";\nimport { remainder } from \"./math\";\n\nexport function isWeekend(date: Date): boolean {\n return date.getDay() === 0 || date.getDay() === 6;\n}\n\nimport.meta.vitest?.test(\"isWeekend\", ({ expect }) => {\n // Sunday (day 0)\n expect(isWeekend(new Date(2023, 0, 1))).toBe(true);\n // Saturday (day 6)\n expect(isWeekend(new Date(2023, 0, 7))).toBe(true);\n // Monday (day 1)\n expect(isWeekend(new Date(2023, 0, 2))).toBe(false);\n // Friday (day 5)\n expect(isWeekend(new Date(2023, 0, 6))).toBe(false);\n});\n\nconst agoUnits = [\n [60, 'second'],\n [60, 'minute'],\n [24, 'hour'],\n [7, 'day'],\n [5, 'week'],\n] as const;\n\nexport function fromNow(date: Date): string {\n return fromNowDetailed(date).result;\n}\n\nimport.meta.vitest?.test(\"fromNow\", ({ expect }) => {\n // Set a fixed date for testing\n const fixedDate = new Date(\"2023-01-15T12:00:00.000Z\");\n\n // Use Vitest's fake timers\n import.meta.vitest?.vi.useFakeTimers();\n import.meta.vitest?.vi.setSystemTime(fixedDate);\n\n // Test past times\n expect(fromNow(new Date(\"2023-01-15T11:59:50.000Z\"))).toBe(\"just now\");\n expect(fromNow(new Date(\"2023-01-15T11:59:00.000Z\"))).toBe(\"1 minute ago\");\n expect(fromNow(new Date(\"2023-01-15T11:00:00.000Z\"))).toBe(\"1 hour ago\");\n expect(fromNow(new Date(\"2023-01-14T12:00:00.000Z\"))).toBe(\"1 day ago\");\n expect(fromNow(new Date(\"2023-01-08T12:00:00.000Z\"))).toBe(\"1 week ago\");\n\n // Test future times\n expect(fromNow(new Date(\"2023-01-15T12:00:10.000Z\"))).toBe(\"just now\");\n expect(fromNow(new Date(\"2023-01-15T12:01:00.000Z\"))).toBe(\"in 1 minute\");\n expect(fromNow(new Date(\"2023-01-15T13:00:00.000Z\"))).toBe(\"in 1 hour\");\n expect(fromNow(new Date(\"2023-01-16T12:00:00.000Z\"))).toBe(\"in 1 day\");\n expect(fromNow(new Date(\"2023-01-22T12:00:00.000Z\"))).toBe(\"in 1 week\");\n\n // Test very old dates (should use date format)\n expect(fromNow(new Date(\"2022-01-15T12:00:00.000Z\"))).toMatch(/Jan 15, 2022/);\n\n // Restore real timers\n import.meta.vitest?.vi.useRealTimers();\n});\n\nexport function fromNowDetailed(date: Date): {\n result: string,\n /**\n * May be Infinity if the result will never change.\n */\n secondsUntilChange: number,\n} {\n if (!(date instanceof Date)) {\n throw new Error(`fromNow only accepts Date objects (received: ${date})`);\n }\n\n const now = new Date();\n const elapsed = now.getTime() - date.getTime();\n\n let remainingInUnit = Math.abs(elapsed) / 1000;\n if (remainingInUnit < 15) {\n return {\n result: 'just now',\n secondsUntilChange: 15 - remainingInUnit,\n };\n }\n let unitInSeconds = 1;\n for (const [nextUnitSize, unitName] of agoUnits) {\n const rounded = Math.round(remainingInUnit);\n if (rounded < nextUnitSize) {\n if (elapsed < 0) {\n return {\n result: `in ${rounded} ${unitName}${rounded === 1 ? '' : 's'}`,\n secondsUntilChange: remainder((remainingInUnit - rounded + 0.5) * unitInSeconds, unitInSeconds),\n };\n } else {\n return {\n result: `${rounded} ${unitName}${rounded === 1 ? '' : 's'} ago`,\n secondsUntilChange: remainder((rounded - remainingInUnit - 0.5) * unitInSeconds, unitInSeconds),\n };\n }\n }\n unitInSeconds *= nextUnitSize;\n remainingInUnit /= nextUnitSize;\n }\n\n return {\n result: date.toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' }),\n secondsUntilChange: Infinity,\n };\n}\n\n/**\n * Returns a string representation of the given date in the format expected by the `datetime-local` input type.\n */\nexport function getInputDatetimeLocalString(date: Date): string {\n date = new Date(date);\n date.setMinutes(date.getMinutes() - date.getTimezoneOffset());\n return date.toISOString().slice(0, 19);\n}\n\nimport.meta.vitest?.test(\"getInputDatetimeLocalString\", ({ expect }) => {\n // Use Vitest's fake timers to ensure consistent timezone behavior\n import.meta.vitest?.vi.useFakeTimers();\n\n // Test with a specific date\n const mockDate = new Date(\"2023-01-15T12:30:45.000Z\");\n const result = getInputDatetimeLocalString(mockDate);\n\n // The result should be in the format YYYY-MM-DDTHH:MM:SS\n expect(result).toMatch(/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}$/);\n\n // Test with different dates\n const dates = [\n new Date(\"2023-01-01T00:00:00.000Z\"),\n new Date(\"2023-06-15T23:59:59.000Z\"),\n new Date(\"2023-12-31T12:34:56.000Z\"),\n ];\n\n for (const date of dates) {\n const result = getInputDatetimeLocalString(date);\n expect(result).toMatch(/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}$/);\n }\n\n // Restore real timers\n import.meta.vitest?.vi.useRealTimers();\n});\n\n\nexport type Interval = [number, 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year'];\nexport type DayInterval = [number, 'day' | 'week' | 'month' | 'year'];\n\nfunction applyInterval(date: Date, times: number, interval: Interval): Date {\n if (!intervalSchema.isValidSync(interval)) {\n throw new HexclaveAssertionError(`Invalid interval`, { interval });\n }\n const [amount, unit] = interval;\n switch (unit) {\n case 'millisecond': {\n date.setMilliseconds(date.getMilliseconds() + amount * times);\n break;\n }\n case 'second': {\n date.setSeconds(date.getSeconds() + amount * times);\n break;\n }\n case 'minute': {\n date.setMinutes(date.getMinutes() + amount * times);\n break;\n }\n case 'hour': {\n date.setHours(date.getHours() + amount * times);\n break;\n }\n case 'day': {\n date.setDate(date.getDate() + amount * times);\n break;\n }\n case 'week': {\n date.setDate(date.getDate() + amount * times * 7);\n break;\n }\n case 'month': {\n date.setMonth(date.getMonth() + amount * times);\n break;\n }\n case 'year': {\n date.setFullYear(date.getFullYear() + amount * times);\n break;\n }\n default: {\n throw new HexclaveAssertionError(`Invalid interval despite schema validation`, { interval });\n }\n }\n return date;\n}\n\nexport function subtractInterval(date: Date, interval: Interval): Date {\n return applyInterval(date, -1, interval);\n}\n\nexport function addInterval(date: Date, interval: Interval): Date {\n return applyInterval(date, 1, interval);\n}\n\nexport const FAR_FUTURE_DATE = new Date(8640000000000000); // 13 Sep 275760 00:00:00 UTC\n\nfunction getMsPerDayIntervalUnit(unit: 'day' | 'week'): number {\n if (unit === 'day') {\n return 24 * 60 * 60 * 1000;\n }\n return 7 * 24 * 60 * 60 * 1000;\n}\n\n\nexport function getIntervalsElapsed(anchor: Date, to: Date, repeat: DayInterval): number {\n const [amount, unit] = repeat;\n if (to <= anchor) return 0;\n if (unit === 'day' || unit === 'week') {\n const msPerUnit = getMsPerDayIntervalUnit(unit);\n const diffMs = to.getTime() - anchor.getTime();\n return Math.floor(diffMs / (msPerUnit * amount));\n }\n if ([\"month\", \"year\"].includes(unit)) {\n let count = 0;\n let current = new Date(anchor);\n for (; ;) {\n const next = addInterval(new Date(current), [amount, unit]);\n if (next > to) break;\n current = next;\n count += 1;\n }\n return count;\n }\n return 0;\n}\n\nimport.meta.vitest?.test(\"getIntervalsElapsed\", ({ expect }) => {\n const anchor = new Date('2025-01-01T00:00:00.000Z');\n const to = new Date('2025-01-15T00:00:00.000Z');\n expect(getIntervalsElapsed(anchor, to, [1, 'week'])).toBe(2);\n expect(getIntervalsElapsed(anchor, to, [3, 'day'])).toBe(4);\n\n const mAnchor = new Date('2023-01-31T00:00:00.000Z');\n const mTo = new Date('2023-03-01T00:00:00.000Z');\n expect(getIntervalsElapsed(mAnchor, mTo, [1, 'month'])).toBe(0);\n\n const yAnchor = new Date('2020-01-01T00:00:00.000Z');\n const yTo = new Date('2022-06-01T00:00:00.000Z');\n expect(getIntervalsElapsed(yAnchor, yTo, [1, 'year'])).toBe(2);\n});\n"],"mappings":";;;;AAIA,SAAgB,UAAU,MAAqB;CAC7C,OAAO,KAAK,OAAO,MAAM,KAAK,KAAK,OAAO,MAAM;AAClD;AAaA,MAAM,WAAW;CACf,CAAC,IAAI,QAAQ;CACb,CAAC,IAAI,QAAQ;CACb,CAAC,IAAI,MAAM;CACX,CAAC,GAAG,KAAK;CACT,CAAC,GAAG,MAAM;AACZ;AAEA,SAAgB,QAAQ,MAAoB;CAC1C,OAAO,gBAAgB,IAAI,CAAC,CAAC;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C,IAAI,QAAQ;EACZ,IAAI,UAAU,IAAI,KAAK,MAAM;EAC7B,SAAU;GACR,MAAM,OAAO,YAAY,IAAI,KAAK,OAAO,GAAG,CAAC,QAAQ,IAAI,CAAC;GAC1D,IAAI,OAAO,IAAI;GACf,UAAU;GACV,SAAS;EACX;EACA,OAAO;CACT;CACA,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"dev-env-state-path.d.ts","names":[],"sources":["../../../src/utils/dev-env-state-path.ts"],"mappings":";iBAGgB,8BAAA,CAAA;AAAA,iBAQA,uBAAA,CAAA"}
1
+ {"version":3,"file":"dev-env-state-path.d.ts","names":[],"sources":["../../../src/utils/dev-env-state-path.ts"],"mappings":";iBAGgB,8BAAA;AAAA,iBAQA,uBAAA"}