@hexclave/shared 1.0.41 → 1.0.43
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.
- package/dist/admin-interface-Bv8rBJo-.d.ts +379 -0
- package/dist/admin-interface-Bv8rBJo-.d.ts.map +1 -0
- package/dist/admin-metrics-DyW8_G82.d.ts +807 -0
- package/dist/admin-metrics-DyW8_G82.d.ts.map +1 -0
- package/dist/ai/image-limits.d.ts.map +1 -1
- package/dist/ai/image-limits.js +6 -7
- package/dist/ai/image-limits.js.map +1 -1
- package/dist/ai/llms/llms.d.ts.map +1 -1
- package/dist/ai/llms/llms.js +2 -4
- package/dist/ai/llms/llms.js.map +1 -1
- package/dist/ai/unified-prompts/reminders.js +2 -4
- package/dist/ai/unified-prompts/reminders.js.map +1 -1
- package/dist/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.d.ts.map +1 -1
- package/dist/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.js +2 -5
- package/dist/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.js.map +1 -1
- package/dist/ai/unified-prompts/skill-site-prompt-parts/brain.js +3 -6
- package/dist/ai/unified-prompts/skill-site-prompt-parts/brain.js.map +1 -1
- package/dist/ai/unified-prompts/skill-site-prompt-parts/cli-help.js +3 -6
- package/dist/ai/unified-prompts/skill-site-prompt-parts/cli-help.js.map +1 -1
- package/dist/ai/unified-prompts/skill-site-prompt-parts/config-docs.js +3 -6
- package/dist/ai/unified-prompts/skill-site-prompt-parts/config-docs.js.map +1 -1
- package/dist/ai/unified-prompts/skill-site-prompt-parts/custom-components-instructions.js +3 -6
- package/dist/ai/unified-prompts/skill-site-prompt-parts/custom-components-instructions.js.map +1 -1
- package/dist/ai/unified-prompts/skill-site-prompt-parts/dashboard-instructions.js +3 -6
- package/dist/ai/unified-prompts/skill-site-prompt-parts/dashboard-instructions.js.map +1 -1
- package/dist/ai/unified-prompts/skill-site-prompt-parts/docs-index.d.ts.map +1 -1
- package/dist/ai/unified-prompts/skill-site-prompt-parts/docs-index.js +5 -6
- package/dist/ai/unified-prompts/skill-site-prompt-parts/docs-index.js.map +1 -1
- package/dist/ai/unified-prompts/skill-site-prompt-parts/docs-json.generated.js +1 -2
- package/dist/ai/unified-prompts/skill-site-prompt-parts/docs-json.generated.js.map +1 -1
- package/dist/ai/unified-prompts/skill-site-prompt-parts/openapi-specs.js +3 -6
- package/dist/ai/unified-prompts/skill-site-prompt-parts/openapi-specs.js.map +1 -1
- package/dist/ai/unified-prompts/skill-site-prompt-parts/sdk-interface-source.js +3 -6
- package/dist/ai/unified-prompts/skill-site-prompt-parts/sdk-interface-source.js.map +1 -1
- package/dist/ai/unified-prompts/skill-site-prompt.d.ts.map +1 -1
- package/dist/ai/unified-prompts/skill-site-prompt.js +2 -4
- package/dist/ai/unified-prompts/skill-site-prompt.js.map +1 -1
- package/dist/analytics-IjkAsefy.d.ts +14 -0
- package/dist/analytics-IjkAsefy.d.ts.map +1 -0
- package/dist/apps/apps-config.d.ts.map +1 -1
- package/dist/apps/apps-config.js +2 -3
- package/dist/apps/apps-config.js.map +1 -1
- package/dist/apps/apps-ui.d.ts +1 -2
- package/dist/apps/apps-ui.d.ts.map +1 -1
- package/dist/apps/apps-ui.js +4 -5
- package/dist/apps/apps-ui.js.map +1 -1
- package/dist/client-interface-CGrvUtX0.d.ts +447 -0
- package/dist/client-interface-CGrvUtX0.d.ts.map +1 -0
- package/dist/config/db-sync-mappings.js +2 -3
- package/dist/config/db-sync-mappings.js.map +1 -1
- package/dist/config/format.d.ts +2 -61
- package/dist/config/format.js +2 -192
- package/dist/config/format.js.map +1 -1
- package/dist/config/migrate-catalogs-to-product-lines.d.ts.map +1 -1
- package/dist/config/migrate-catalogs-to-product-lines.js +2 -196
- package/dist/config/migrate-catalogs-to-product-lines.js.map +1 -1
- package/dist/config/schema-fuzzer.test.js +18 -172
- package/dist/config/schema-fuzzer.test.js.map +1 -1
- package/dist/config/schema.d.ts +2 -2328
- package/dist/config/schema.js +6 -351
- package/dist/config/schema.js.map +1 -1
- package/dist/config-authoring.d.ts +1 -1
- package/dist/config-authoring.d.ts.map +1 -1
- package/dist/config-authoring.js +2 -3
- package/dist/config-authoring.js.map +1 -1
- package/dist/config-authoring.test.js +1 -3
- package/dist/config-authoring.test.js.map +1 -1
- package/dist/config-eval.d.ts.map +1 -1
- package/dist/config-eval.js +4 -46
- package/dist/config-eval.js.map +1 -1
- package/dist/config-rendering.d.ts.map +1 -1
- package/dist/config-rendering.js +2 -48
- package/dist/config-rendering.js.map +1 -1
- package/dist/connected-accounts-D5CKe50A.d.ts +67 -0
- package/dist/connected-accounts-D5CKe50A.d.ts.map +1 -0
- package/dist/contact-channels-DW8yQxlc.d.ts +180 -0
- package/dist/contact-channels-DW8yQxlc.d.ts.map +1 -0
- package/dist/country-codes-CRWDroBE.d.ts +11 -0
- package/dist/country-codes-CRWDroBE.d.ts.map +1 -0
- package/dist/crud-CqmEW9s6.d.ts +98 -0
- package/dist/crud-CqmEW9s6.d.ts.map +1 -0
- package/dist/crud.d.ts +2 -98
- package/dist/crud.js +3 -71
- package/dist/crud.js.map +1 -1
- package/dist/currency-constants-Cq_q8twn.d.ts +45 -0
- package/dist/currency-constants-Cq_q8twn.d.ts.map +1 -0
- package/dist/current-user-Dvf8Ttjo.d.ts +284 -0
- package/dist/current-user-Dvf8Ttjo.d.ts.map +1 -0
- package/dist/dates-B6ne9iOR.d.ts +23 -0
- package/dist/dates-B6ne9iOR.d.ts.map +1 -0
- package/dist/email-outbox-BVqBaXpn.d.ts +1464 -0
- package/dist/{interface/crud/email-outbox.d.ts.map → email-outbox-BVqBaXpn.d.ts.map} +1 -1
- package/dist/emails-Ba4yEaCS.d.ts +40 -0
- package/dist/emails-Ba4yEaCS.d.ts.map +1 -0
- package/dist/errors-Cl-RUyed.d.ts +238 -0
- package/dist/errors-Cl-RUyed.d.ts.map +1 -0
- package/dist/esm/ai/image-limits.d.ts.map +1 -1
- package/dist/esm/ai/image-limits.js +5 -5
- package/dist/esm/ai/image-limits.js.map +1 -1
- package/dist/esm/ai/llms/llms.d.ts +1 -1
- package/dist/esm/ai/llms/llms.d.ts.map +1 -1
- package/dist/esm/ai/llms/llms.js +1 -2
- package/dist/esm/ai/llms/llms.js.map +1 -1
- package/dist/esm/ai/unified-prompts/reminders.js +1 -2
- package/dist/esm/ai/unified-prompts/reminders.js.map +1 -1
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.d.ts.map +1 -1
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.js +25 -28
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.js.map +1 -1
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/brain.js +1 -2
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/brain.js.map +1 -1
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/cli-help.js +1 -2
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/cli-help.js.map +1 -1
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/config-docs.js +1 -2
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/config-docs.js.map +1 -1
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/custom-components-instructions.js +1 -2
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/custom-components-instructions.js.map +1 -1
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/dashboard-instructions.js +1 -2
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/dashboard-instructions.js.map +1 -1
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/docs-index.d.ts.map +1 -1
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/docs-index.js +2 -3
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/docs-index.js.map +1 -1
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/docs-json.generated.js +1 -1
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/docs-json.generated.js.map +1 -1
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/openapi-specs.js +1 -2
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/openapi-specs.js.map +1 -1
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/sdk-interface-source.js +1 -2
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/sdk-interface-source.js.map +1 -1
- package/dist/esm/ai/unified-prompts/skill-site-prompt.d.ts.map +1 -1
- package/dist/esm/ai/unified-prompts/skill-site-prompt.js +1 -2
- package/dist/esm/ai/unified-prompts/skill-site-prompt.js.map +1 -1
- package/dist/esm/apps/apps-config.d.ts.map +1 -1
- package/dist/esm/apps/apps-config.js +1 -1
- package/dist/esm/apps/apps-config.js.map +1 -1
- package/dist/esm/apps/apps-ui.d.ts +2 -3
- package/dist/esm/apps/apps-ui.d.ts.map +1 -1
- package/dist/esm/apps/apps-ui.js +2 -3
- package/dist/esm/apps/apps-ui.js.map +1 -1
- package/dist/esm/config/db-sync-mappings.js +1 -1
- package/dist/esm/config/db-sync-mappings.js.map +1 -1
- package/dist/esm/config/format.d.ts +1 -1
- package/dist/esm/config/format.d.ts.map +1 -1
- package/dist/esm/config/format.js +1 -190
- package/dist/esm/config/format.js.map +1 -1
- package/dist/esm/config/migrate-catalogs-to-product-lines.d.ts.map +1 -1
- package/dist/esm/config/migrate-catalogs-to-product-lines.js +1 -194
- package/dist/esm/config/migrate-catalogs-to-product-lines.js.map +1 -1
- package/dist/esm/config/schema-fuzzer.test.js +20 -173
- package/dist/esm/config/schema-fuzzer.test.js.map +1 -1
- package/dist/esm/config/schema.d.ts +249 -250
- package/dist/esm/config/schema.d.ts.map +1 -1
- package/dist/esm/config/schema.js +2 -347
- package/dist/esm/config/schema.js.map +1 -1
- package/dist/esm/config-authoring.d.ts +1 -1
- package/dist/esm/config-authoring.d.ts.map +1 -1
- package/dist/esm/config-authoring.js +1 -1
- package/dist/esm/config-authoring.js.map +1 -1
- package/dist/esm/config-authoring.test.js +2 -3
- package/dist/esm/config-authoring.test.js.map +1 -1
- package/dist/esm/config-eval.d.ts +1 -1
- package/dist/esm/config-eval.d.ts.map +1 -1
- package/dist/esm/config-eval.js +1 -43
- package/dist/esm/config-eval.js.map +1 -1
- package/dist/esm/config-rendering.d.ts.map +1 -1
- package/dist/esm/config-rendering.js +1 -46
- package/dist/esm/config-rendering.js.map +1 -1
- package/dist/esm/crud.d.ts +1 -1
- package/dist/esm/crud.d.ts.map +1 -1
- package/dist/esm/crud.js +2 -69
- package/dist/esm/crud.js.map +1 -1
- package/dist/esm/helpers/emails.js +1 -2
- package/dist/esm/helpers/emails.js.map +1 -1
- package/dist/esm/helpers/init-prompt.d.ts.map +1 -1
- package/dist/esm/helpers/init-prompt.js +1 -2
- package/dist/esm/helpers/init-prompt.js.map +1 -1
- package/dist/esm/helpers/password.d.ts +1 -1
- package/dist/esm/helpers/password.d.ts.map +1 -1
- package/dist/esm/helpers/password.js +1 -2
- package/dist/esm/helpers/password.js.map +1 -1
- package/dist/esm/helpers/production-mode.d.ts +1 -1
- package/dist/esm/helpers/production-mode.d.ts.map +1 -1
- package/dist/esm/helpers/production-mode.js +1 -2
- package/dist/esm/helpers/production-mode.js.map +1 -1
- package/dist/esm/helpers/support-sla.d.ts.map +1 -1
- package/dist/esm/helpers/support-sla.js +1 -1
- package/dist/esm/helpers/support-sla.js.map +1 -1
- package/dist/esm/helpers/support-sla.test.js +2 -3
- package/dist/esm/helpers/support-sla.test.js.map +1 -1
- package/dist/esm/helpers/vault/client-side.d.ts.map +1 -1
- package/dist/esm/helpers/vault/client-side.js +1 -20
- package/dist/esm/helpers/vault/client-side.js.map +1 -1
- package/dist/esm/helpers/vault/server-side.js +1 -2
- package/dist/esm/helpers/vault/server-side.js.map +1 -1
- package/dist/esm/hooks/use-async-callback.d.ts.map +1 -1
- package/dist/esm/hooks/use-async-callback.js +1 -2
- package/dist/esm/hooks/use-async-callback.js.map +1 -1
- package/dist/esm/hooks/use-async-external-store.d.ts +1 -1
- package/dist/esm/hooks/use-async-external-store.d.ts.map +1 -1
- package/dist/esm/hooks/use-async-external-store.js +1 -2
- package/dist/esm/hooks/use-async-external-store.js.map +1 -1
- package/dist/esm/hooks/use-hash.js +1 -2
- package/dist/esm/hooks/use-hash.js.map +1 -1
- package/dist/esm/hooks/use-hover.d.ts.map +1 -1
- package/dist/esm/hooks/use-hover.js +1 -2
- package/dist/esm/hooks/use-hover.js.map +1 -1
- package/dist/esm/hooks/use-strict-memo.d.ts.map +1 -1
- package/dist/esm/hooks/use-strict-memo.js +1 -70
- package/dist/esm/hooks/use-strict-memo.js.map +1 -1
- package/dist/esm/index.d.ts +4 -4
- package/dist/esm/index.js +1 -2
- package/dist/esm/interface/admin-interface.d.ts +19 -19
- package/dist/esm/interface/admin-interface.d.ts.map +1 -1
- package/dist/esm/interface/admin-interface.js +1 -2
- package/dist/esm/interface/admin-interface.js.map +1 -1
- package/dist/esm/interface/admin-metrics.d.ts +11 -11
- package/dist/esm/interface/admin-metrics.d.ts.map +1 -1
- package/dist/esm/interface/admin-metrics.js +1 -2
- package/dist/esm/interface/admin-metrics.js.map +1 -1
- package/dist/esm/interface/client-interface.d.ts +22 -22
- package/dist/esm/interface/client-interface.d.ts.map +1 -1
- package/dist/esm/interface/client-interface.js +31 -15
- package/dist/esm/interface/client-interface.js.map +1 -1
- package/dist/esm/interface/client-interface.test.js +84 -13
- package/dist/esm/interface/client-interface.test.js.map +1 -1
- package/dist/esm/interface/conversations.d.ts +33 -33
- package/dist/esm/interface/conversations.d.ts.map +1 -1
- package/dist/esm/interface/conversations.js +1 -2
- package/dist/esm/interface/conversations.js.map +1 -1
- package/dist/esm/interface/crud/analytics.d.ts.map +1 -1
- package/dist/esm/interface/crud/analytics.js +1 -1
- package/dist/esm/interface/crud/connected-accounts.d.ts +15 -17
- package/dist/esm/interface/crud/connected-accounts.d.ts.map +1 -1
- package/dist/esm/interface/crud/connected-accounts.js +1 -2
- package/dist/esm/interface/crud/connected-accounts.js.map +1 -1
- package/dist/esm/interface/crud/contact-channels.d.ts +24 -26
- package/dist/esm/interface/crud/contact-channels.d.ts.map +1 -1
- package/dist/esm/interface/crud/contact-channels.js +1 -2
- package/dist/esm/interface/crud/contact-channels.js.map +1 -1
- package/dist/esm/interface/crud/current-user.d.ts +20 -22
- package/dist/esm/interface/crud/current-user.d.ts.map +1 -1
- package/dist/esm/interface/crud/current-user.js +25 -29
- package/dist/esm/interface/crud/current-user.js.map +1 -1
- package/dist/esm/interface/crud/email-outbox.d.ts +32 -34
- package/dist/esm/interface/crud/email-outbox.d.ts.map +1 -1
- package/dist/esm/interface/crud/email-outbox.js +1 -2
- package/dist/esm/interface/crud/email-outbox.js.map +1 -1
- package/dist/esm/interface/crud/email-templates.d.ts +16 -18
- package/dist/esm/interface/crud/email-templates.d.ts.map +1 -1
- package/dist/esm/interface/crud/email-templates.js +1 -2
- package/dist/esm/interface/crud/email-templates.js.map +1 -1
- package/dist/esm/interface/crud/emails.d.ts +6 -8
- package/dist/esm/interface/crud/emails.d.ts.map +1 -1
- package/dist/esm/interface/crud/emails.js +1 -2
- package/dist/esm/interface/crud/emails.js.map +1 -1
- package/dist/esm/interface/crud/internal-api-keys.d.ts +16 -18
- package/dist/esm/interface/crud/internal-api-keys.d.ts.map +1 -1
- package/dist/esm/interface/crud/internal-api-keys.js +1 -2
- package/dist/esm/interface/crud/internal-api-keys.js.map +1 -1
- package/dist/esm/interface/crud/invoices.d.ts +2 -2
- package/dist/esm/interface/crud/invoices.d.ts.map +1 -1
- package/dist/esm/interface/crud/invoices.js +1 -2
- package/dist/esm/interface/crud/invoices.js.map +1 -1
- package/dist/esm/interface/crud/items.d.ts +6 -8
- package/dist/esm/interface/crud/items.d.ts.map +1 -1
- package/dist/esm/interface/crud/items.js +12 -16
- package/dist/esm/interface/crud/items.js.map +1 -1
- package/dist/esm/interface/crud/notification-preferences.d.ts +6 -8
- package/dist/esm/interface/crud/notification-preferences.d.ts.map +1 -1
- package/dist/esm/interface/crud/notification-preferences.js +8 -12
- package/dist/esm/interface/crud/notification-preferences.js.map +1 -1
- package/dist/esm/interface/crud/oauth-providers.d.ts +24 -26
- package/dist/esm/interface/crud/oauth-providers.d.ts.map +1 -1
- package/dist/esm/interface/crud/oauth-providers.js +1 -2
- package/dist/esm/interface/crud/oauth-providers.js.map +1 -1
- package/dist/esm/interface/crud/products.d.ts +21 -22
- package/dist/esm/interface/crud/products.d.ts.map +1 -1
- package/dist/esm/interface/crud/products.js +3 -2
- package/dist/esm/interface/crud/products.js.map +1 -1
- package/dist/esm/interface/crud/project-api-keys.d.ts +5 -6
- package/dist/esm/interface/crud/project-api-keys.d.ts.map +1 -1
- package/dist/esm/interface/crud/project-api-keys.js +1 -2
- package/dist/esm/interface/crud/project-api-keys.js.map +1 -1
- package/dist/esm/interface/crud/project-permissions.d.ts +29 -31
- package/dist/esm/interface/crud/project-permissions.d.ts.map +1 -1
- package/dist/esm/interface/crud/project-permissions.js +1 -2
- package/dist/esm/interface/crud/project-permissions.js.map +1 -1
- package/dist/esm/interface/crud/projects.d.ts +71 -73
- package/dist/esm/interface/crud/projects.d.ts.map +1 -1
- package/dist/esm/interface/crud/projects.js +3 -2
- package/dist/esm/interface/crud/projects.js.map +1 -1
- package/dist/esm/interface/crud/session-replays.d.ts.map +1 -1
- package/dist/esm/interface/crud/session-replays.js +1 -1
- package/dist/esm/interface/crud/sessions.d.ts +15 -17
- package/dist/esm/interface/crud/sessions.d.ts.map +1 -1
- package/dist/esm/interface/crud/sessions.js +1 -2
- package/dist/esm/interface/crud/sessions.js.map +1 -1
- package/dist/esm/interface/crud/sign-up-rules.d.ts.map +1 -1
- package/dist/esm/interface/crud/sign-up-rules.js +1 -1
- package/dist/esm/interface/crud/svix-token.d.ts +8 -10
- package/dist/esm/interface/crud/svix-token.d.ts.map +1 -1
- package/dist/esm/interface/crud/svix-token.js +1 -2
- package/dist/esm/interface/crud/svix-token.js.map +1 -1
- package/dist/esm/interface/crud/team-invitation-details.d.ts +6 -8
- package/dist/esm/interface/crud/team-invitation-details.d.ts.map +1 -1
- package/dist/esm/interface/crud/team-invitation-details.js +1 -2
- package/dist/esm/interface/crud/team-invitation-details.js.map +1 -1
- package/dist/esm/interface/crud/team-invitation.d.ts +7 -9
- package/dist/esm/interface/crud/team-invitation.d.ts.map +1 -1
- package/dist/esm/interface/crud/team-invitation.js +1 -2
- package/dist/esm/interface/crud/team-invitation.js.map +1 -1
- package/dist/esm/interface/crud/team-member-profiles.d.ts +26 -28
- package/dist/esm/interface/crud/team-member-profiles.d.ts.map +1 -1
- package/dist/esm/interface/crud/team-member-profiles.js +1 -2
- package/dist/esm/interface/crud/team-member-profiles.js.map +1 -1
- package/dist/esm/interface/crud/team-memberships.d.ts +14 -16
- package/dist/esm/interface/crud/team-memberships.d.ts.map +1 -1
- package/dist/esm/interface/crud/team-memberships.js +1 -2
- package/dist/esm/interface/crud/team-memberships.js.map +1 -1
- package/dist/esm/interface/crud/team-permissions.d.ts +29 -31
- package/dist/esm/interface/crud/team-permissions.d.ts.map +1 -1
- package/dist/esm/interface/crud/team-permissions.js +1 -2
- package/dist/esm/interface/crud/team-permissions.js.map +1 -1
- package/dist/esm/interface/crud/teams.d.ts +36 -38
- package/dist/esm/interface/crud/teams.d.ts.map +1 -1
- package/dist/esm/interface/crud/teams.js +2 -4
- package/dist/esm/interface/crud/teams.js.map +1 -1
- package/dist/esm/interface/crud/transactions.d.ts +14 -16
- package/dist/esm/interface/crud/transactions.d.ts.map +1 -1
- package/dist/esm/interface/crud/transactions.js +7 -13
- package/dist/esm/interface/crud/transactions.js.map +1 -1
- package/dist/esm/interface/crud/users.d.ts +11 -12
- package/dist/esm/interface/crud/users.d.ts.map +1 -1
- package/dist/esm/interface/crud/users.js +9 -5
- package/dist/esm/interface/crud/users.js.map +1 -1
- package/dist/esm/interface/handler-urls.d.ts +1 -1
- package/dist/esm/interface/handler-urls.d.ts.map +1 -1
- package/dist/esm/interface/handler-urls.js +1 -2
- package/dist/esm/interface/page-component-versions.d.ts +1 -1
- package/dist/esm/interface/page-component-versions.d.ts.map +1 -1
- package/dist/esm/interface/page-component-versions.js +1 -2
- package/dist/esm/interface/page-component-versions.js.map +1 -1
- package/dist/esm/interface/plan-usage.d.ts +1 -1
- package/dist/esm/interface/plan-usage.d.ts.map +1 -1
- package/dist/esm/interface/plan-usage.js +1 -2
- package/dist/esm/interface/plan-usage.js.map +1 -1
- package/dist/esm/interface/server-interface.d.ts +19 -19
- package/dist/esm/interface/server-interface.d.ts.map +1 -1
- package/dist/esm/interface/server-interface.js +1 -2
- package/dist/esm/interface/server-interface.js.map +1 -1
- package/dist/esm/interface/webhooks.d.ts +2 -2
- package/dist/esm/interface/webhooks.d.ts.map +1 -1
- package/dist/esm/interface/webhooks.js +1 -2
- package/dist/esm/interface/webhooks.js.map +1 -1
- package/dist/esm/known-errors.d.ts +2 -2
- package/dist/esm/known-errors.d.ts.map +1 -1
- package/dist/esm/known-errors.js +10 -21
- package/dist/esm/known-errors.js.map +1 -1
- package/dist/esm/payments/payment-methods.d.ts.map +1 -1
- package/dist/esm/payments/payment-methods.js +1 -1
- package/dist/esm/payments/payment-methods.js.map +1 -1
- package/dist/esm/payments/stripe-limits.d.ts.map +1 -1
- package/dist/esm/payments/stripe-limits.js +1 -1
- package/dist/esm/payments/stripe-limits.js.map +1 -1
- package/dist/esm/plans.d.ts.map +1 -1
- package/dist/esm/plans.js +1 -1
- package/dist/esm/plans.js.map +1 -1
- package/dist/esm/schema-fields.d.ts +14 -14
- package/dist/esm/schema-fields.d.ts.map +1 -1
- package/dist/esm/schema-fields.js +3 -64
- package/dist/esm/schema-fields.js.map +1 -1
- package/dist/esm/sessions.d.ts +6 -6
- package/dist/esm/sessions.d.ts.map +1 -1
- package/dist/esm/sessions.js +1 -2
- package/dist/esm/sessions.js.map +1 -1
- package/dist/esm/sessions.test.js +2 -3
- package/dist/esm/sessions.test.js.map +1 -1
- package/dist/esm/utils/analytics-clickmap-overlay.d.ts.map +1 -1
- package/dist/esm/utils/analytics-clickmap-overlay.js +1 -1
- package/dist/esm/utils/api-keys.d.ts.map +1 -1
- package/dist/esm/utils/api-keys.js +1 -2
- package/dist/esm/utils/api-keys.js.map +1 -1
- package/dist/esm/utils/arrays.d.ts.map +1 -1
- package/dist/esm/utils/arrays.js +1 -470
- package/dist/esm/utils/arrays.js.map +1 -1
- package/dist/esm/utils/auth-methods.d.ts.map +1 -1
- package/dist/esm/utils/auth-methods.js +1 -1
- package/dist/esm/utils/auth-methods.js.map +1 -1
- package/dist/esm/utils/base64.d.ts.map +1 -1
- package/dist/esm/utils/base64.js +1 -10
- package/dist/esm/utils/base64.js.map +1 -1
- package/dist/esm/utils/booleans.d.ts.map +1 -1
- package/dist/esm/utils/booleans.js +1 -25
- package/dist/esm/utils/booleans.js.map +1 -1
- package/dist/esm/utils/browser-compat.d.ts.map +1 -1
- package/dist/esm/utils/browser-compat.js +1 -1
- package/dist/esm/utils/browser-compat.js.map +1 -1
- package/dist/esm/utils/bytes.d.ts.map +1 -1
- package/dist/esm/utils/bytes.js +3 -198
- package/dist/esm/utils/bytes.js.map +1 -1
- package/dist/esm/utils/caches.d.ts +1 -1
- package/dist/esm/utils/caches.d.ts.map +1 -1
- package/dist/esm/utils/caches.js +1 -27
- package/dist/esm/utils/caches.js.map +1 -1
- package/dist/esm/utils/cel-fields.d.ts.map +1 -1
- package/dist/esm/utils/cel-fields.js +1 -2
- package/dist/esm/utils/cel-fields.js.map +1 -1
- package/dist/esm/utils/cloud-hosts.d.ts.map +1 -1
- package/dist/esm/utils/cloud-hosts.js +1 -27
- package/dist/esm/utils/cloud-hosts.js.map +1 -1
- package/dist/esm/utils/compile-time.d.ts.map +1 -1
- package/dist/esm/utils/compile-time.js +1 -1
- package/dist/esm/utils/compile-time.js.map +1 -1
- package/dist/esm/utils/country-codes.d.ts.map +1 -1
- package/dist/esm/utils/country-codes.js +1 -16
- package/dist/esm/utils/country-codes.js.map +1 -1
- package/dist/esm/utils/crypto.d.ts.map +1 -1
- package/dist/esm/utils/crypto.js +3 -113
- package/dist/esm/utils/crypto.js.map +1 -1
- package/dist/esm/utils/currencies.d.ts +1 -1
- package/dist/esm/utils/currencies.d.ts.map +1 -1
- package/dist/esm/utils/currencies.js +2 -37
- package/dist/esm/utils/currencies.js.map +1 -1
- package/dist/esm/utils/currency-constants.d.ts.map +1 -1
- package/dist/esm/utils/currency-constants.js +1 -1
- package/dist/esm/utils/currency-constants.js.map +1 -1
- package/dist/esm/utils/dates.d.ts.map +1 -1
- package/dist/esm/utils/dates.js +1 -44
- package/dist/esm/utils/dates.js.map +1 -1
- package/dist/esm/utils/dev-env-state-path.d.ts.map +1 -1
- package/dist/esm/utils/dev-env-state-path.js +1 -2
- package/dist/esm/utils/dev-env-state-path.js.map +1 -1
- package/dist/esm/utils/dev-tool.d.ts.map +1 -1
- package/dist/esm/utils/dev-tool.js +1 -1
- package/dist/esm/utils/dom.d.ts.map +1 -1
- package/dist/esm/utils/dom.js +1 -1
- package/dist/esm/utils/dom.js.map +1 -1
- package/dist/esm/utils/elements-chain.d.ts.map +1 -1
- package/dist/esm/utils/elements-chain.js +5 -50
- package/dist/esm/utils/elements-chain.js.map +1 -1
- package/dist/esm/utils/env.d.ts.map +1 -1
- package/dist/esm/utils/env.js +1 -2
- package/dist/esm/utils/env.js.map +1 -1
- package/dist/esm/utils/env.test.js +2 -3
- package/dist/esm/utils/env.test.js.map +1 -1
- package/dist/esm/utils/errors.d.ts +1 -1
- package/dist/esm/utils/errors.d.ts.map +1 -1
- package/dist/esm/utils/errors.js +1 -2
- package/dist/esm/utils/errors.js.map +1 -1
- package/dist/esm/utils/esbuild.d.ts +1 -1
- package/dist/esm/utils/esbuild.d.ts.map +1 -1
- package/dist/esm/utils/esbuild.js +2 -3
- package/dist/esm/utils/esbuild.js.map +1 -1
- package/dist/esm/utils/featurebase.d.ts.map +1 -1
- package/dist/esm/utils/featurebase.js +1 -2
- package/dist/esm/utils/featurebase.js.map +1 -1
- package/dist/esm/utils/fs.d.ts.map +1 -1
- package/dist/esm/utils/fs.js +1 -2
- package/dist/esm/utils/fs.js.map +1 -1
- package/dist/esm/utils/functions.d.ts.map +1 -1
- package/dist/esm/utils/functions.js +1 -24
- package/dist/esm/utils/functions.js.map +1 -1
- package/dist/esm/utils/geo.d.ts.map +1 -1
- package/dist/esm/utils/geo.js +1 -2
- package/dist/esm/utils/geo.js.map +1 -1
- package/dist/esm/utils/globals.d.ts.map +1 -1
- package/dist/esm/utils/globals.js +1 -1
- package/dist/esm/utils/globals.js.map +1 -1
- package/dist/esm/utils/hashes.d.ts.map +1 -1
- package/dist/esm/utils/hashes.js +1 -2
- package/dist/esm/utils/hashes.js.map +1 -1
- package/dist/esm/utils/html.d.ts.map +1 -1
- package/dist/esm/utils/html.js +1 -19
- package/dist/esm/utils/html.js.map +1 -1
- package/dist/esm/utils/http.d.ts.map +1 -1
- package/dist/esm/utils/http.js +1 -19
- package/dist/esm/utils/http.js.map +1 -1
- package/dist/esm/utils/ips.d.ts.map +1 -1
- package/dist/esm/utils/ips.js +1 -25
- package/dist/esm/utils/ips.js.map +1 -1
- package/dist/esm/utils/json.d.ts +1 -1
- package/dist/esm/utils/json.d.ts.map +1 -1
- package/dist/esm/utils/json.js +1 -155
- package/dist/esm/utils/json.js.map +1 -1
- package/dist/esm/utils/jsx-editable-transpiler.d.ts.map +1 -1
- package/dist/esm/utils/jsx-editable-transpiler.js +1 -2
- package/dist/esm/utils/jsx-editable-transpiler.js.map +1 -1
- package/dist/esm/utils/jsx-editable-transpiler.test.js +2 -3
- package/dist/esm/utils/jsx-editable-transpiler.test.js.map +1 -1
- package/dist/esm/utils/jwt.d.ts.map +1 -1
- package/dist/esm/utils/jwt.js +1 -2
- package/dist/esm/utils/jwt.js.map +1 -1
- package/dist/esm/utils/locks.d.ts.map +1 -1
- package/dist/esm/utils/locks.js +1 -2
- package/dist/esm/utils/locks.js.map +1 -1
- package/dist/esm/utils/maps.d.ts.map +1 -1
- package/dist/esm/utils/maps.js +1 -111
- package/dist/esm/utils/maps.js.map +1 -1
- package/dist/esm/utils/math.d.ts.map +1 -1
- package/dist/esm/utils/math.js +1 -11
- package/dist/esm/utils/math.js.map +1 -1
- package/dist/esm/utils/monkey-patch.d.ts.map +1 -1
- package/dist/esm/utils/monkey-patch.js +2 -3
- package/dist/esm/utils/monkey-patch.js.map +1 -1
- package/dist/esm/utils/node-http.js +1 -2
- package/dist/esm/utils/node-http.js.map +1 -1
- package/dist/esm/utils/numbers.d.ts.map +1 -1
- package/dist/esm/utils/numbers.js +1 -45
- package/dist/esm/utils/numbers.js.map +1 -1
- package/dist/esm/utils/oauth.d.ts.map +1 -1
- package/dist/esm/utils/oauth.js +1 -1
- package/dist/esm/utils/oauth.js.map +1 -1
- package/dist/esm/utils/objects.d.ts.map +1 -1
- package/dist/esm/utils/objects.js +1 -622
- package/dist/esm/utils/objects.js.map +1 -1
- package/dist/esm/utils/paginated-lists.d.ts.map +1 -1
- package/dist/esm/utils/paginated-lists.js +1 -2
- package/dist/esm/utils/paginated-lists.js.map +1 -1
- package/dist/esm/utils/paginated-lists.test.js +2 -3
- package/dist/esm/utils/paginated-lists.test.js.map +1 -1
- package/dist/esm/utils/passkey.d.ts +1 -1
- package/dist/esm/utils/passkey.js +1 -1
- package/dist/esm/utils/promises.d.ts +1 -1
- package/dist/esm/utils/promises.d.ts.map +1 -1
- package/dist/esm/utils/promises.js +1 -160
- package/dist/esm/utils/promises.js.map +1 -1
- package/dist/esm/utils/proxies.d.ts.map +1 -1
- package/dist/esm/utils/proxies.js +1 -37
- package/dist/esm/utils/proxies.js.map +1 -1
- package/dist/esm/utils/react.d.ts.map +1 -1
- package/dist/esm/utils/react.js +1 -41
- package/dist/esm/utils/react.js.map +1 -1
- package/dist/esm/utils/redirect-urls.d.ts.map +1 -1
- package/dist/esm/utils/redirect-urls.js +2 -92
- package/dist/esm/utils/redirect-urls.js.map +1 -1
- package/dist/esm/utils/regex.js +1 -1
- package/dist/esm/utils/regex.js.map +1 -1
- package/dist/esm/utils/results.d.ts.map +1 -1
- package/dist/esm/utils/results.js +1 -213
- package/dist/esm/utils/results.js.map +1 -1
- package/dist/esm/utils/sentry.js +1 -1
- package/dist/esm/utils/sentry.js.map +1 -1
- package/dist/esm/utils/stores.d.ts +3 -3
- package/dist/esm/utils/stores.d.ts.map +1 -1
- package/dist/esm/utils/stores.js +1 -2
- package/dist/esm/utils/stores.js.map +1 -1
- package/dist/esm/utils/strings.d.ts.map +1 -1
- package/dist/esm/utils/strings.js +1 -251
- package/dist/esm/utils/strings.js.map +1 -1
- package/dist/esm/utils/strings.nicify.test.js +2 -3
- package/dist/esm/utils/strings.nicify.test.js.map +1 -1
- package/dist/esm/utils/telemetry.d.ts.map +1 -1
- package/dist/esm/utils/telemetry.js +1 -2
- package/dist/esm/utils/telemetry.js.map +1 -1
- package/dist/esm/utils/turnstile-browser.d.ts +1 -1
- package/dist/esm/utils/turnstile-browser.d.ts.map +1 -1
- package/dist/esm/utils/turnstile-browser.js +1 -2
- package/dist/esm/utils/turnstile-browser.js.map +1 -1
- package/dist/esm/utils/turnstile-flow.d.ts +1 -1
- package/dist/esm/utils/turnstile-flow.d.ts.map +1 -1
- package/dist/esm/utils/turnstile-flow.js +1 -2
- package/dist/esm/utils/turnstile-flow.js.map +1 -1
- package/dist/esm/utils/turnstile-flow.test.js +2 -3
- package/dist/esm/utils/turnstile-flow.test.js.map +1 -1
- package/dist/esm/utils/turnstile.d.ts.map +1 -1
- package/dist/esm/utils/turnstile.js +1 -1
- package/dist/esm/utils/turnstile.js.map +1 -1
- package/dist/esm/utils/typed-arrays.js +1 -2
- package/dist/esm/utils/typed-arrays.js.map +1 -1
- package/dist/esm/utils/types.d.ts +1 -1
- package/dist/esm/utils/types.d.ts.map +1 -1
- package/dist/esm/utils/types.js +1 -1
- package/dist/esm/utils/types.js.map +1 -1
- package/dist/esm/utils/unicode.d.ts.map +1 -1
- package/dist/esm/utils/unicode.js +1 -13
- package/dist/esm/utils/unicode.js.map +1 -1
- package/dist/esm/utils/urls.d.ts.map +1 -1
- package/dist/esm/utils/urls.js +1 -151
- package/dist/esm/utils/urls.js.map +1 -1
- package/dist/esm/utils/uuids.d.ts.map +1 -1
- package/dist/esm/utils/uuids.js +2 -26
- package/dist/esm/utils/uuids.js.map +1 -1
- package/dist/format-4JG1MGv5.d.ts +61 -0
- package/dist/format-4JG1MGv5.d.ts.map +1 -0
- package/dist/handler-urls-BHt3v8Ai.d.ts +70 -0
- package/dist/handler-urls-BHt3v8Ai.d.ts.map +1 -0
- package/dist/helpers/emails.js +2 -4
- package/dist/helpers/emails.js.map +1 -1
- package/dist/helpers/init-prompt.d.ts.map +1 -1
- package/dist/helpers/init-prompt.js +2 -4
- package/dist/helpers/init-prompt.js.map +1 -1
- package/dist/helpers/password.d.ts +1 -1
- package/dist/helpers/password.d.ts.map +1 -1
- package/dist/helpers/password.js +2 -4
- package/dist/helpers/password.js.map +1 -1
- package/dist/helpers/production-mode.d.ts +1 -1
- package/dist/helpers/production-mode.d.ts.map +1 -1
- package/dist/helpers/production-mode.js +2 -4
- package/dist/helpers/production-mode.js.map +1 -1
- package/dist/helpers/support-sla.d.ts.map +1 -1
- package/dist/helpers/support-sla.js +2 -3
- package/dist/helpers/support-sla.js.map +1 -1
- package/dist/helpers/support-sla.test.js +1 -3
- package/dist/helpers/support-sla.test.js.map +1 -1
- package/dist/helpers/vault/client-side.d.ts.map +1 -1
- package/dist/helpers/vault/client-side.js +2 -22
- package/dist/helpers/vault/client-side.js.map +1 -1
- package/dist/helpers/vault/server-side.js +2 -4
- package/dist/helpers/vault/server-side.js.map +1 -1
- package/dist/hooks/use-async-callback.d.ts.map +1 -1
- package/dist/hooks/use-async-callback.js +4 -5
- package/dist/hooks/use-async-callback.js.map +1 -1
- package/dist/hooks/use-async-external-store.d.ts +1 -1
- package/dist/hooks/use-async-external-store.d.ts.map +1 -1
- package/dist/hooks/use-async-external-store.js +2 -4
- package/dist/hooks/use-async-external-store.js.map +1 -1
- package/dist/hooks/use-hash.js +2 -4
- package/dist/hooks/use-hash.js.map +1 -1
- package/dist/hooks/use-hover.d.ts.map +1 -1
- package/dist/hooks/use-hover.js +2 -4
- package/dist/hooks/use-hover.js.map +1 -1
- package/dist/hooks/use-strict-memo.d.ts.map +1 -1
- package/dist/hooks/use-strict-memo.js +2 -72
- package/dist/hooks/use-strict-memo.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +27 -29
- package/dist/interface/admin-interface.d.ts +3 -379
- package/dist/interface/admin-interface.js +2 -4
- package/dist/interface/admin-interface.js.map +1 -1
- package/dist/interface/admin-metrics.d.ts +2 -807
- package/dist/interface/admin-metrics.js +2 -4
- package/dist/interface/admin-metrics.js.map +1 -1
- package/dist/interface/client-interface.d.ts +2 -447
- package/dist/interface/client-interface.js +32 -17
- package/dist/interface/client-interface.js.map +1 -1
- package/dist/interface/client-interface.test.js +83 -13
- package/dist/interface/client-interface.test.js.map +1 -1
- package/dist/interface/conversations.d.ts +33 -33
- package/dist/interface/conversations.d.ts.map +1 -1
- package/dist/interface/conversations.js +2 -4
- package/dist/interface/conversations.js.map +1 -1
- package/dist/interface/crud/analytics.d.ts +2 -14
- package/dist/interface/crud/connected-accounts.d.ts +2 -68
- package/dist/interface/crud/connected-accounts.js +2 -4
- package/dist/interface/crud/connected-accounts.js.map +1 -1
- package/dist/interface/crud/contact-channels.d.ts +2 -181
- package/dist/interface/crud/contact-channels.js +2 -4
- package/dist/interface/crud/contact-channels.js.map +1 -1
- package/dist/interface/crud/current-user.d.ts +2 -285
- package/dist/interface/crud/current-user.js +2 -4
- package/dist/interface/crud/current-user.js.map +1 -1
- package/dist/interface/crud/email-outbox.d.ts +2 -1465
- package/dist/interface/crud/email-outbox.js +4 -5
- package/dist/interface/crud/email-outbox.js.map +1 -1
- package/dist/interface/crud/email-templates.d.ts +15 -16
- package/dist/interface/crud/email-templates.d.ts.map +1 -1
- package/dist/interface/crud/email-templates.js +2 -4
- package/dist/interface/crud/email-templates.js.map +1 -1
- package/dist/interface/crud/emails.d.ts +2 -41
- package/dist/interface/crud/emails.js +4 -5
- package/dist/interface/crud/emails.js.map +1 -1
- package/dist/interface/crud/internal-api-keys.d.ts +2 -140
- package/dist/interface/crud/internal-api-keys.js +2 -4
- package/dist/interface/crud/internal-api-keys.js.map +1 -1
- package/dist/interface/crud/invoices.d.ts +2 -43
- package/dist/interface/crud/invoices.js +2 -4
- package/dist/interface/crud/invoices.js.map +1 -1
- package/dist/interface/crud/items.d.ts +2 -30
- package/dist/interface/crud/items.js +2 -4
- package/dist/interface/crud/items.js.map +1 -1
- package/dist/interface/crud/notification-preferences.d.ts +2 -38
- package/dist/interface/crud/notification-preferences.js +2 -4
- package/dist/interface/crud/notification-preferences.js.map +1 -1
- package/dist/interface/crud/oauth-providers.d.ts +2 -186
- package/dist/interface/crud/oauth-providers.js +2 -4
- package/dist/interface/crud/oauth-providers.js.map +1 -1
- package/dist/interface/crud/products.d.ts +2 -182
- package/dist/interface/crud/products.js +4 -4
- package/dist/interface/crud/products.js.map +1 -1
- package/dist/interface/crud/project-api-keys.d.ts +2 -203
- package/dist/interface/crud/project-api-keys.js +2 -4
- package/dist/interface/crud/project-api-keys.js.map +1 -1
- package/dist/interface/crud/project-permissions.d.ts +2 -161
- package/dist/interface/crud/project-permissions.js +4 -5
- package/dist/interface/crud/project-permissions.js.map +1 -1
- package/dist/interface/crud/projects.d.ts +2 -901
- package/dist/interface/crud/projects.js +6 -5
- package/dist/interface/crud/projects.js.map +1 -1
- package/dist/interface/crud/session-replays.d.ts +2 -83
- package/dist/interface/crud/sessions.d.ts +2 -150
- package/dist/interface/crud/sessions.js +2 -4
- package/dist/interface/crud/sessions.js.map +1 -1
- package/dist/interface/crud/sign-up-rules.d.ts.map +1 -1
- package/dist/interface/crud/svix-token.d.ts +2 -31
- package/dist/interface/crud/svix-token.js +2 -4
- package/dist/interface/crud/svix-token.js.map +1 -1
- package/dist/interface/crud/team-invitation-details.d.ts +5 -6
- package/dist/interface/crud/team-invitation-details.d.ts.map +1 -1
- package/dist/interface/crud/team-invitation-details.js +4 -5
- package/dist/interface/crud/team-invitation-details.js.map +1 -1
- package/dist/interface/crud/team-invitation.d.ts +2 -54
- package/dist/interface/crud/team-invitation.js +4 -5
- package/dist/interface/crud/team-invitation.js.map +1 -1
- package/dist/interface/crud/team-member-profiles.d.ts +2 -286
- package/dist/interface/crud/team-member-profiles.js +4 -5
- package/dist/interface/crud/team-member-profiles.js.map +1 -1
- package/dist/interface/crud/team-memberships.d.ts +2 -75
- package/dist/interface/crud/team-memberships.js +2 -4
- package/dist/interface/crud/team-memberships.js.map +1 -1
- package/dist/interface/crud/team-permissions.d.ts +2 -169
- package/dist/interface/crud/team-permissions.js +4 -5
- package/dist/interface/crud/team-permissions.js.map +1 -1
- package/dist/interface/crud/teams.d.ts +2 -299
- package/dist/interface/crud/teams.js +5 -7
- package/dist/interface/crud/teams.js.map +1 -1
- package/dist/interface/crud/transactions.d.ts +2 -183
- package/dist/interface/crud/transactions.js +2 -4
- package/dist/interface/crud/transactions.js.map +1 -1
- package/dist/interface/crud/users.d.ts +2 -653
- package/dist/interface/crud/users.js +12 -8
- package/dist/interface/crud/users.js.map +1 -1
- package/dist/interface/handler-urls.d.ts +2 -51
- package/dist/interface/handler-urls.js +12 -14
- package/dist/interface/page-component-versions.d.ts +2 -25
- package/dist/interface/page-component-versions.js +2 -4
- package/dist/interface/page-component-versions.js.map +1 -1
- package/dist/interface/plan-usage.d.ts +2 -57
- package/dist/interface/plan-usage.js +2 -4
- package/dist/interface/plan-usage.js.map +1 -1
- package/dist/interface/server-interface.d.ts +2 -257
- package/dist/interface/server-interface.js +2 -4
- package/dist/interface/server-interface.js.map +1 -1
- package/dist/interface/webhooks.d.ts +2 -326
- package/dist/interface/webhooks.js +2 -4
- package/dist/interface/webhooks.js.map +1 -1
- package/dist/internal-api-keys-D8IYDodH.d.ts +139 -0
- package/dist/internal-api-keys-D8IYDodH.d.ts.map +1 -0
- package/dist/invoices-U65KzAZX.d.ts +43 -0
- package/dist/invoices-U65KzAZX.d.ts.map +1 -0
- package/dist/items-DlLSlVUD.d.ts +29 -0
- package/dist/items-DlLSlVUD.d.ts.map +1 -0
- package/dist/json-a1QIXu5z.d.ts +15 -0
- package/dist/json-a1QIXu5z.d.ts.map +1 -0
- package/dist/known-errors-Bm4a61wL.d.ts +575 -0
- package/dist/known-errors-Bm4a61wL.d.ts.map +1 -0
- package/dist/known-errors.d.ts +2 -575
- package/dist/known-errors.js +11 -23
- package/dist/known-errors.js.map +1 -1
- package/dist/notification-preferences-Bmzr_EOY.d.ts +37 -0
- package/dist/notification-preferences-Bmzr_EOY.d.ts.map +1 -0
- package/dist/oauth-providers-BMkKSSlA.d.ts +185 -0
- package/dist/oauth-providers-BMkKSSlA.d.ts.map +1 -0
- package/dist/objects-DkCkeBWE.d.ts +59 -0
- package/dist/objects-DkCkeBWE.d.ts.map +1 -0
- package/dist/passkey-CKg87UH-.d.ts +2 -0
- package/dist/payments/payment-methods.d.ts.map +1 -1
- package/dist/payments/payment-methods.js +2 -3
- package/dist/payments/payment-methods.js.map +1 -1
- package/dist/payments/stripe-limits.d.ts.map +1 -1
- package/dist/payments/stripe-limits.js +2 -3
- package/dist/payments/stripe-limits.js.map +1 -1
- package/dist/plan-usage-DfDoj5K4.d.ts +57 -0
- package/dist/plan-usage-DfDoj5K4.d.ts.map +1 -0
- package/dist/plans.d.ts.map +1 -1
- package/dist/plans.js +2 -3
- package/dist/plans.js.map +1 -1
- package/dist/products-Bs74ld-v.d.ts +182 -0
- package/dist/products-Bs74ld-v.d.ts.map +1 -0
- package/dist/project-api-keys--7V5X_UW.d.ts +203 -0
- package/dist/project-api-keys--7V5X_UW.d.ts.map +1 -0
- package/dist/project-permissions-kdi675F-.d.ts +160 -0
- package/dist/project-permissions-kdi675F-.d.ts.map +1 -0
- package/dist/projects-CgFGB3nO.d.ts +900 -0
- package/dist/projects-CgFGB3nO.d.ts.map +1 -0
- package/dist/results-DP3BzoL6.d.ts +70 -0
- package/dist/results-DP3BzoL6.d.ts.map +1 -0
- package/dist/{chunk-BE-pF4vm.js → rolldown-runtime-D6vf50IK.js} +12 -18
- package/dist/schema-01nWxmb4.d.ts +2328 -0
- package/dist/schema-01nWxmb4.d.ts.map +1 -0
- package/dist/schema-fields-DqGQ4kF7.d.ts +517 -0
- package/dist/schema-fields-DqGQ4kF7.d.ts.map +1 -0
- package/dist/schema-fields.d.ts +3 -518
- package/dist/schema-fields.js +21 -82
- package/dist/schema-fields.js.map +1 -1
- package/dist/server-interface-BUPG1kor.d.ts +257 -0
- package/dist/server-interface-BUPG1kor.d.ts.map +1 -0
- package/dist/session-replays-CXqhDpZq.d.ts +83 -0
- package/dist/session-replays-CXqhDpZq.d.ts.map +1 -0
- package/dist/sessions-B7Ko2Ldr.d.ts +149 -0
- package/dist/sessions-B7Ko2Ldr.d.ts.map +1 -0
- package/dist/sessions-d8qtvBUB.d.ts +175 -0
- package/dist/sessions-d8qtvBUB.d.ts.map +1 -0
- package/dist/sessions.d.ts +2 -175
- package/dist/sessions.js +4 -5
- package/dist/sessions.js.map +1 -1
- package/dist/sessions.test.js +1 -3
- package/dist/sessions.test.js.map +1 -1
- package/dist/strings-DWgkUybS.d.ts +76 -0
- package/dist/strings-DWgkUybS.d.ts.map +1 -0
- package/dist/svix-token-BsMrLGvy.d.ts +30 -0
- package/dist/svix-token-BsMrLGvy.d.ts.map +1 -0
- package/dist/team-invitation-Cyqt9oWw.d.ts +53 -0
- package/dist/team-invitation-Cyqt9oWw.d.ts.map +1 -0
- package/dist/team-member-profiles-uTluO8XI.d.ts +285 -0
- package/dist/team-member-profiles-uTluO8XI.d.ts.map +1 -0
- package/dist/team-memberships-DZHk2A5b.d.ts +74 -0
- package/dist/team-memberships-DZHk2A5b.d.ts.map +1 -0
- package/dist/team-permissions-DqOpaOWh.d.ts +168 -0
- package/dist/team-permissions-DqOpaOWh.d.ts.map +1 -0
- package/dist/teams-CQMcBnjM.d.ts +298 -0
- package/dist/teams-CQMcBnjM.d.ts.map +1 -0
- package/dist/transactions-DhnbvGH5.d.ts +182 -0
- package/dist/transactions-DhnbvGH5.d.ts.map +1 -0
- package/dist/types-DfTcxNtM.d.ts +77 -0
- package/dist/types-DfTcxNtM.d.ts.map +1 -0
- package/dist/users-CmBBuF00.d.ts +653 -0
- package/dist/users-CmBBuF00.d.ts.map +1 -0
- package/dist/utils/analytics-clickmap-overlay.d.ts.map +1 -1
- package/dist/utils/analytics-clickmap-overlay.js +2 -3
- package/dist/utils/analytics-clickmap-overlay.js.map +1 -1
- package/dist/utils/api-keys.d.ts.map +1 -1
- package/dist/utils/api-keys.js +4 -5
- package/dist/utils/api-keys.js.map +1 -1
- package/dist/utils/arrays.d.ts.map +1 -1
- package/dist/utils/arrays.js +2 -472
- package/dist/utils/arrays.js.map +1 -1
- package/dist/utils/auth-methods.d.ts.map +1 -1
- package/dist/utils/auth-methods.js +2 -3
- package/dist/utils/auth-methods.js.map +1 -1
- package/dist/utils/base64.d.ts.map +1 -1
- package/dist/utils/base64.js +2 -12
- package/dist/utils/base64.js.map +1 -1
- package/dist/utils/booleans.d.ts.map +1 -1
- package/dist/utils/booleans.js +2 -27
- package/dist/utils/booleans.js.map +1 -1
- package/dist/utils/browser-compat.d.ts.map +1 -1
- package/dist/utils/browser-compat.js +2 -3
- package/dist/utils/browser-compat.js.map +1 -1
- package/dist/utils/bytes.d.ts.map +1 -1
- package/dist/utils/bytes.js +4 -200
- package/dist/utils/bytes.js.map +1 -1
- package/dist/utils/caches.d.ts.map +1 -1
- package/dist/utils/caches.js +2 -29
- package/dist/utils/caches.js.map +1 -1
- package/dist/utils/cel-fields.d.ts.map +1 -1
- package/dist/utils/cel-fields.js +2 -4
- package/dist/utils/cel-fields.js.map +1 -1
- package/dist/utils/cloud-hosts.d.ts.map +1 -1
- package/dist/utils/cloud-hosts.js +2 -29
- package/dist/utils/cloud-hosts.js.map +1 -1
- package/dist/utils/compile-time.d.ts.map +1 -1
- package/dist/utils/compile-time.js +2 -3
- package/dist/utils/compile-time.js.map +1 -1
- package/dist/utils/country-codes.d.ts +2 -11
- package/dist/utils/country-codes.js +2 -18
- package/dist/utils/country-codes.js.map +1 -1
- package/dist/utils/crypto.d.ts.map +1 -1
- package/dist/utils/crypto.js +4 -115
- package/dist/utils/crypto.js.map +1 -1
- package/dist/utils/currencies.d.ts +1 -1
- package/dist/utils/currencies.d.ts.map +1 -1
- package/dist/utils/currencies.js +3 -39
- package/dist/utils/currencies.js.map +1 -1
- package/dist/utils/currency-constants.d.ts +2 -45
- package/dist/utils/currency-constants.js +2 -3
- package/dist/utils/currency-constants.js.map +1 -1
- package/dist/utils/dates.d.ts +2 -23
- package/dist/utils/dates.js +2 -46
- package/dist/utils/dates.js.map +1 -1
- package/dist/utils/dev-env-state-path.d.ts.map +1 -1
- package/dist/utils/dev-env-state-path.js +2 -4
- package/dist/utils/dev-env-state-path.js.map +1 -1
- package/dist/utils/dev-tool.d.ts.map +1 -1
- package/dist/utils/dev-tool.js +2 -3
- package/dist/utils/dev-tool.js.map +1 -1
- package/dist/utils/dom.d.ts.map +1 -1
- package/dist/utils/dom.js +2 -3
- package/dist/utils/dom.js.map +1 -1
- package/dist/utils/elements-chain.d.ts.map +1 -1
- package/dist/utils/elements-chain.js +6 -52
- package/dist/utils/elements-chain.js.map +1 -1
- package/dist/utils/env.d.ts.map +1 -1
- package/dist/utils/env.js +2 -4
- package/dist/utils/env.js.map +1 -1
- package/dist/utils/env.test.js +1 -3
- package/dist/utils/env.test.js.map +1 -1
- package/dist/utils/errors.d.ts +2 -238
- package/dist/utils/errors.js +2 -4
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/esbuild.d.ts +1 -1
- package/dist/utils/esbuild.d.ts.map +1 -1
- package/dist/utils/esbuild.js +5 -6
- package/dist/utils/esbuild.js.map +1 -1
- package/dist/utils/featurebase.d.ts.map +1 -1
- package/dist/utils/featurebase.js +2 -4
- package/dist/utils/featurebase.js.map +1 -1
- package/dist/utils/fs.d.ts.map +1 -1
- package/dist/utils/fs.js +5 -6
- package/dist/utils/fs.js.map +1 -1
- package/dist/utils/functions.d.ts.map +1 -1
- package/dist/utils/functions.js +2 -26
- package/dist/utils/functions.js.map +1 -1
- package/dist/utils/geo.d.ts.map +1 -1
- package/dist/utils/geo.js +2 -4
- package/dist/utils/geo.js.map +1 -1
- package/dist/utils/globals.d.ts.map +1 -1
- package/dist/utils/globals.js +2 -3
- package/dist/utils/globals.js.map +1 -1
- package/dist/utils/hashes.d.ts.map +1 -1
- package/dist/utils/hashes.js +4 -5
- package/dist/utils/hashes.js.map +1 -1
- package/dist/utils/html.d.ts.map +1 -1
- package/dist/utils/html.js +2 -21
- package/dist/utils/html.js.map +1 -1
- package/dist/utils/http.d.ts.map +1 -1
- package/dist/utils/http.js +2 -21
- package/dist/utils/http.js.map +1 -1
- package/dist/utils/ips.d.ts.map +1 -1
- package/dist/utils/ips.js +4 -28
- package/dist/utils/ips.js.map +1 -1
- package/dist/utils/json.d.ts +2 -15
- package/dist/utils/json.js +2 -157
- package/dist/utils/json.js.map +1 -1
- package/dist/utils/jsx-editable-transpiler.d.ts.map +1 -1
- package/dist/utils/jsx-editable-transpiler.js +7 -8
- package/dist/utils/jsx-editable-transpiler.js.map +1 -1
- package/dist/utils/jsx-editable-transpiler.test.js +1 -3
- package/dist/utils/jsx-editable-transpiler.test.js.map +1 -1
- package/dist/utils/jwt.d.ts.map +1 -1
- package/dist/utils/jwt.js +6 -7
- package/dist/utils/jwt.js.map +1 -1
- package/dist/utils/locks.d.ts.map +1 -1
- package/dist/utils/locks.js +2 -4
- package/dist/utils/locks.js.map +1 -1
- package/dist/utils/maps.d.ts.map +1 -1
- package/dist/utils/maps.js +2 -113
- package/dist/utils/maps.js.map +1 -1
- package/dist/utils/math.d.ts.map +1 -1
- package/dist/utils/math.js +2 -13
- package/dist/utils/math.js.map +1 -1
- package/dist/utils/monkey-patch.d.ts.map +1 -1
- package/dist/utils/monkey-patch.js +3 -5
- package/dist/utils/monkey-patch.js.map +1 -1
- package/dist/utils/node-http.js +2 -4
- package/dist/utils/node-http.js.map +1 -1
- package/dist/utils/numbers.d.ts.map +1 -1
- package/dist/utils/numbers.js +2 -47
- package/dist/utils/numbers.js.map +1 -1
- package/dist/utils/oauth.d.ts.map +1 -1
- package/dist/utils/oauth.js +2 -3
- package/dist/utils/oauth.js.map +1 -1
- package/dist/utils/objects.d.ts +2 -59
- package/dist/utils/objects.js +2 -624
- package/dist/utils/objects.js.map +1 -1
- package/dist/utils/paginated-lists.d.ts.map +1 -1
- package/dist/utils/paginated-lists.js +2 -4
- package/dist/utils/paginated-lists.js.map +1 -1
- package/dist/utils/paginated-lists.test.js +1 -3
- package/dist/utils/paginated-lists.test.js.map +1 -1
- package/dist/utils/passkey.d.ts +2 -2
- package/dist/utils/promises.d.ts +1 -1
- package/dist/utils/promises.d.ts.map +1 -1
- package/dist/utils/promises.js +2 -162
- package/dist/utils/promises.js.map +1 -1
- package/dist/utils/proxies.d.ts.map +1 -1
- package/dist/utils/proxies.js +2 -39
- package/dist/utils/proxies.js.map +1 -1
- package/dist/utils/react.d.ts.map +1 -1
- package/dist/utils/react.js +4 -44
- package/dist/utils/react.js.map +1 -1
- package/dist/utils/redirect-urls.d.ts.map +1 -1
- package/dist/utils/redirect-urls.js +3 -94
- package/dist/utils/redirect-urls.js.map +1 -1
- package/dist/utils/regex.js +2 -3
- package/dist/utils/regex.js.map +1 -1
- package/dist/utils/results.d.ts +2 -70
- package/dist/utils/results.js +2 -215
- package/dist/utils/results.js.map +1 -1
- package/dist/utils/sentry.js +2 -3
- package/dist/utils/sentry.js.map +1 -1
- package/dist/utils/stores.d.ts +1 -1
- package/dist/utils/stores.d.ts.map +1 -1
- package/dist/utils/stores.js +2 -4
- package/dist/utils/stores.js.map +1 -1
- package/dist/utils/strings.d.ts +2 -76
- package/dist/utils/strings.js +2 -253
- package/dist/utils/strings.js.map +1 -1
- package/dist/utils/strings.nicify.test.js +1 -3
- package/dist/utils/strings.nicify.test.js.map +1 -1
- package/dist/utils/telemetry.d.ts.map +1 -1
- package/dist/utils/telemetry.js +2 -4
- package/dist/utils/telemetry.js.map +1 -1
- package/dist/utils/turnstile-browser.d.ts.map +1 -1
- package/dist/utils/turnstile-browser.js +2 -4
- package/dist/utils/turnstile-browser.js.map +1 -1
- package/dist/utils/turnstile-flow.d.ts.map +1 -1
- package/dist/utils/turnstile-flow.js +2 -4
- package/dist/utils/turnstile-flow.js.map +1 -1
- package/dist/utils/turnstile-flow.test.js +1 -3
- package/dist/utils/turnstile-flow.test.js.map +1 -1
- package/dist/utils/turnstile.d.ts.map +1 -1
- package/dist/utils/turnstile.js +2 -3
- package/dist/utils/turnstile.js.map +1 -1
- package/dist/utils/typed-arrays.js +2 -4
- package/dist/utils/typed-arrays.js.map +1 -1
- package/dist/utils/types.d.ts +2 -77
- package/dist/utils/types.js +2 -3
- package/dist/utils/types.js.map +1 -1
- package/dist/utils/unicode.d.ts.map +1 -1
- package/dist/utils/unicode.js +2 -15
- package/dist/utils/unicode.js.map +1 -1
- package/dist/utils/urls.d.ts.map +1 -1
- package/dist/utils/urls.js +2 -153
- package/dist/utils/urls.js.map +1 -1
- package/dist/utils/uuids.d.ts.map +1 -1
- package/dist/utils/uuids.js +3 -28
- package/dist/utils/uuids.js.map +1 -1
- package/dist/webhooks-ByXrdSOx.d.ts +326 -0
- package/dist/webhooks-ByXrdSOx.d.ts.map +1 -0
- package/package.json +2 -8
- package/src/interface/client-interface.test.ts +77 -12
- package/src/interface/client-interface.ts +9 -9
- package/dist/config/format.d.ts.map +0 -1
- package/dist/config/schema.d.ts.map +0 -1
- package/dist/crud.d.ts.map +0 -1
- package/dist/interface/admin-interface.d.ts.map +0 -1
- package/dist/interface/admin-metrics.d.ts.map +0 -1
- package/dist/interface/client-interface.d.ts.map +0 -1
- package/dist/interface/crud/analytics.d.ts.map +0 -1
- package/dist/interface/crud/connected-accounts.d.ts.map +0 -1
- package/dist/interface/crud/contact-channels.d.ts.map +0 -1
- package/dist/interface/crud/current-user.d.ts.map +0 -1
- package/dist/interface/crud/emails.d.ts.map +0 -1
- package/dist/interface/crud/internal-api-keys.d.ts.map +0 -1
- package/dist/interface/crud/invoices.d.ts.map +0 -1
- package/dist/interface/crud/items.d.ts.map +0 -1
- package/dist/interface/crud/notification-preferences.d.ts.map +0 -1
- package/dist/interface/crud/oauth-providers.d.ts.map +0 -1
- package/dist/interface/crud/products.d.ts.map +0 -1
- package/dist/interface/crud/project-api-keys.d.ts.map +0 -1
- package/dist/interface/crud/project-permissions.d.ts.map +0 -1
- package/dist/interface/crud/projects.d.ts.map +0 -1
- package/dist/interface/crud/session-replays.d.ts.map +0 -1
- package/dist/interface/crud/sessions.d.ts.map +0 -1
- package/dist/interface/crud/svix-token.d.ts.map +0 -1
- package/dist/interface/crud/team-invitation.d.ts.map +0 -1
- package/dist/interface/crud/team-member-profiles.d.ts.map +0 -1
- package/dist/interface/crud/team-memberships.d.ts.map +0 -1
- package/dist/interface/crud/team-permissions.d.ts.map +0 -1
- package/dist/interface/crud/teams.d.ts.map +0 -1
- package/dist/interface/crud/transactions.d.ts.map +0 -1
- package/dist/interface/crud/users.d.ts.map +0 -1
- package/dist/interface/handler-urls.d.ts.map +0 -1
- package/dist/interface/page-component-versions.d.ts.map +0 -1
- package/dist/interface/plan-usage.d.ts.map +0 -1
- package/dist/interface/server-interface.d.ts.map +0 -1
- package/dist/interface/webhooks.d.ts.map +0 -1
- package/dist/known-errors.d.ts.map +0 -1
- package/dist/schema-fields.d.ts.map +0 -1
- package/dist/sessions.d.ts.map +0 -1
- package/dist/utils/country-codes.d.ts.map +0 -1
- package/dist/utils/currency-constants.d.ts.map +0 -1
- package/dist/utils/dates.d.ts.map +0 -1
- package/dist/utils/errors.d.ts.map +0 -1
- package/dist/utils/json.d.ts.map +0 -1
- package/dist/utils/objects.d.ts.map +0 -1
- package/dist/utils/results.d.ts.map +0 -1
- package/dist/utils/strings.d.ts.map +0 -1
- package/dist/utils/types.d.ts.map +0 -1
package/dist/utils/caches.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"caches.js","names":[],"sources":["../../src/utils/caches.tsx"],"sourcesContent":["import { isBrowserLike } from \"./env\";\nimport { DependenciesMap } from \"./maps\";\nimport { filterUndefined } from \"./objects\";\nimport { RateLimitOptions, ReactPromise, pending, rateLimited, resolved, runAsynchronously, wait } from \"./promises\";\nimport { AsyncStore } from \"./stores\";\n\n/**\n * Can be used to cache the result of a function call, for example for the `use` hook in React.\n */\nexport function cacheFunction<F extends Function>(f: F): F {\n const dependenciesMap = new DependenciesMap<any, any>();\n\n return ((...args: any) => {\n if (dependenciesMap.has(args)) {\n return dependenciesMap.get(args);\n }\n\n const value = f(...args);\n dependenciesMap.set(args, value);\n return value;\n }) as any as F;\n}\nimport.meta.vitest?.test(\"cacheFunction\", ({ expect }) => {\n // Test with a simple function\n let callCount = 0;\n const add = (a: number, b: number) => {\n callCount++;\n return a + b;\n };\n\n const cachedAdd = cacheFunction(add);\n\n // First call should execute the function\n expect(cachedAdd(1, 2)).toBe(3);\n expect(callCount).toBe(1);\n\n // Second call with same args should use cached result\n expect(cachedAdd(1, 2)).toBe(3);\n expect(callCount).toBe(1);\n\n // Call with different args should execute the function again\n expect(cachedAdd(2, 3)).toBe(5);\n expect(callCount).toBe(2);\n\n // Test with a function that returns objects\n let objectCallCount = 0;\n const createObject = (id: number) => {\n objectCallCount++;\n return { id };\n };\n\n const cachedCreateObject = cacheFunction(createObject);\n\n // First call should execute the function\n const obj1 = cachedCreateObject(1);\n expect(obj1).toEqual({ id: 1 });\n expect(objectCallCount).toBe(1);\n\n // Second call with same args should use cached result\n const obj2 = cachedCreateObject(1);\n expect(obj2).toBe(obj1); // Same reference\n expect(objectCallCount).toBe(1);\n});\n\n\ntype CacheStrategy = \"write-only\" | \"read-write\" | \"never\";\n\nexport class AsyncCache<D extends any[], T> {\n private readonly _map = new DependenciesMap<D, AsyncValueCache<T>>();\n\n constructor(\n private readonly _fetcher: (dependencies: D) => Promise<T>,\n private readonly _options: {\n onSubscribe?: (key: D, refresh: () => void) => (() => void),\n rateLimiter?: Omit<RateLimitOptions, \"batchCalls\">,\n } = {},\n ) {\n // nothing here yet\n }\n\n private _createKeyed<FunctionName extends keyof AsyncValueCache<T>>(\n functionName: FunctionName,\n ): (key: D, ...args: Parameters<AsyncValueCache<T>[FunctionName]>) => ReturnType<AsyncValueCache<T>[FunctionName]> {\n return (key: D, ...args) => {\n const valueCache = this.getValueCache(key);\n return (valueCache[functionName] as any).apply(valueCache, args);\n };\n }\n\n getValueCache(dependencies: D): AsyncValueCache<T> {\n let cache = this._map.get(dependencies);\n if (!cache) {\n cache = new AsyncValueCache(\n async () => await this._fetcher(dependencies),\n {\n ...this._options,\n onSubscribe: this._options.onSubscribe ? (cb) => this._options.onSubscribe!(dependencies, cb) : undefined,\n },\n );\n this._map.set(dependencies, cache);\n }\n return cache;\n }\n\n async refreshWhere(predicate: (dependencies: D) => boolean) {\n const promises: Promise<void>[] = [];\n for (const [dependencies, cache] of this._map) {\n if (predicate(dependencies)) {\n promises.push(cache.refresh());\n }\n }\n await Promise.all(promises);\n }\n\n async invalidateWhere(predicate: (dependencies: D) => boolean) {\n const promises: Promise<void>[] = [];\n for (const [dependencies, cache] of this._map) {\n if (predicate(dependencies)) {\n promises.push(cache.invalidate().catch(() => undefined));\n }\n }\n await Promise.all(promises);\n }\n\n readonly isCacheAvailable = this._createKeyed(\"isCacheAvailable\");\n readonly getIfCached = this._createKeyed(\"getIfCached\");\n readonly getOrWait = this._createKeyed(\"getOrWait\");\n readonly forceSetCachedValue = this._createKeyed(\"forceSetCachedValue\");\n readonly forceSetCachedValueAsync = this._createKeyed(\"forceSetCachedValueAsync\");\n readonly refresh = this._createKeyed(\"refresh\");\n readonly invalidate = this._createKeyed(\"invalidate\");\n readonly onStateChange = this._createKeyed(\"onStateChange\");\n readonly isDirty = this._createKeyed(\"isDirty\");\n}\n\nclass AsyncValueCache<T> {\n private _store: AsyncStore<T>;\n private _pendingPromise: ReactPromise<T> | undefined;\n private _fetcher: () => Promise<T>;\n private readonly _rateLimitOptions: Omit<RateLimitOptions, \"batchCalls\">;\n private _subscriptionsCount = 0;\n private _unsubscribers: (() => void)[] = [];\n private _mostRecentRefreshPromiseIndex = 0;\n\n constructor(\n fetcher: () => Promise<T>,\n private readonly _options: {\n onSubscribe?: (refresh: () => void) => (() => void),\n rateLimiter?: Omit<RateLimitOptions, \"batchCalls\">,\n } = {},\n ) {\n this._store = new AsyncStore();\n this._rateLimitOptions = {\n concurrency: 1,\n throttleMs: 300,\n ...filterUndefined(_options.rateLimiter ?? {}),\n };\n\n\n this._fetcher = rateLimited(fetcher, {\n ...this._rateLimitOptions,\n batchCalls: true,\n });\n }\n\n isCacheAvailable(): boolean {\n return this._store.isAvailable();\n }\n\n getIfCached() {\n return this._store.get();\n }\n\n getOrWait(cacheStrategy: CacheStrategy): ReactPromise<T> {\n const cached = this.getIfCached();\n if (cacheStrategy === \"read-write\" && cached.status === \"ok\") {\n return resolved(cached.data);\n }\n\n return this._refetch(cacheStrategy);\n }\n\n private _set(value: T): void {\n this._store.set(value);\n }\n\n private _setAsync(value: Promise<T>): ReactPromise<void> {\n if (this._subscriptionsCount === 0 && !isBrowserLike()) {\n // if we're in a server-like environment, we'd rather cache less aggressively to avoid memory leaks.\n // hence, if no one is listening to this cache, let's invalidate it\n this._invalidateCacheSoon();\n }\n const promise = pending(value);\n this._pendingPromise = promise;\n return pending(this._store.setAsync(promise).then(() => undefined));\n }\n\n private _refetch(cacheStrategy: CacheStrategy): ReactPromise<T> {\n if (cacheStrategy === \"read-write\" && this._pendingPromise) {\n return this._pendingPromise;\n }\n const promise = pending(this._fetcher());\n if (cacheStrategy === \"never\") {\n return promise;\n }\n return pending(this._setAsync(promise).then(() => promise));\n }\n\n forceSetCachedValue(value: T): void {\n this._set(value);\n }\n\n forceSetCachedValueAsync(value: Promise<T>): ReactPromise<void> {\n return this._setAsync(value);\n }\n\n /**\n * If anyone is listening to the cache, refreshes the value, and sets it without invalidating the cache.\n */\n async refresh(): Promise<void> {\n // note that we do the extra check here to save a request if no one is listening to the cache anyway\n if (this._subscriptionsCount > 0) {\n await this.getOrWait(\"write-only\");\n }\n }\n\n /**\n * Invalidates the cache, marking it dirty (ie. it will be refreshed on the next read). If anyone is listening to the cache, it will refresh immediately.\n */\n async invalidate(): Promise<void> {\n this._store.setUnavailable();\n this._pendingPromise = undefined;\n await this.refresh();\n }\n\n isDirty(): boolean {\n return this._pendingPromise === undefined;\n }\n\n _invalidateCacheSoon(): void {\n // wait a few seconds; we want to keep the cache up during this time\n // else we do unnecessary requests if we unsubscribe and then subscribe again immediately\n const currentRefreshPromiseIndex = ++this._mostRecentRefreshPromiseIndex;\n runAsynchronously(async () => {\n await wait(5000);\n if (this._subscriptionsCount === 0 && currentRefreshPromiseIndex === this._mostRecentRefreshPromiseIndex) {\n await this.invalidate();\n }\n });\n }\n\n onStateChange(callback: (value: T, oldValue: T | undefined) => void): { unsubscribe: () => void } {\n const storeObj = this._store.onChange(callback);\n\n runAsynchronously(this.getOrWait(\"read-write\"));\n\n if (this._subscriptionsCount++ === 0 && this._options.onSubscribe) {\n const unsubscribe = this._options.onSubscribe(() => {\n runAsynchronously(this.refresh());\n });\n this._unsubscribers.push(unsubscribe);\n }\n\n let hasUnsubscribed = false;\n return {\n unsubscribe: () => {\n if (hasUnsubscribed) return;\n hasUnsubscribed = true;\n storeObj.unsubscribe();\n if (--this._subscriptionsCount === 0) {\n this._invalidateCacheSoon();\n\n for (const unsubscribe of this._unsubscribers) {\n unsubscribe();\n }\n }\n },\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;AASA,SAAgB,cAAkC,GAAS;CACzD,MAAM,kBAAkB,IAAI,2BAA2B;AAEvD,UAAS,GAAG,SAAc;AACxB,MAAI,gBAAgB,IAAI,KAAK,CAC3B,QAAO,gBAAgB,IAAI,KAAK;EAGlC,MAAM,QAAQ,EAAE,GAAG,KAAK;AACxB,kBAAgB,IAAI,MAAM,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KACjC;AACF,QAAK,eAAe,KAAK,YAAY;;EAGvC,IAAI,kBAAkB;AACtB,SAAO,EACL,mBAAmB;AACjB,OAAI,gBAAiB;AACrB,qBAAkB;AAClB,YAAS,aAAa;AACtB,OAAI,EAAE,KAAK,wBAAwB,GAAG;AACpC,SAAK,sBAAsB;AAE3B,SAAK,MAAM,eAAe,KAAK,eAC7B,cAAa;;KAIpB"}
|
|
1
|
+
{"version":3,"file":"caches.js","names":["DependenciesMap","AsyncStore"],"sources":["../../src/utils/caches.tsx"],"sourcesContent":["import { isBrowserLike } from \"./env\";\nimport { DependenciesMap } from \"./maps\";\nimport { filterUndefined } from \"./objects\";\nimport { RateLimitOptions, ReactPromise, pending, rateLimited, resolved, runAsynchronously, wait } from \"./promises\";\nimport { AsyncStore } from \"./stores\";\n\n/**\n * Can be used to cache the result of a function call, for example for the `use` hook in React.\n */\nexport function cacheFunction<F extends Function>(f: F): F {\n const dependenciesMap = new DependenciesMap<any, any>();\n\n return ((...args: any) => {\n if (dependenciesMap.has(args)) {\n return dependenciesMap.get(args);\n }\n\n const value = f(...args);\n dependenciesMap.set(args, value);\n return value;\n }) as any as F;\n}\nimport.meta.vitest?.test(\"cacheFunction\", ({ expect }) => {\n // Test with a simple function\n let callCount = 0;\n const add = (a: number, b: number) => {\n callCount++;\n return a + b;\n };\n\n const cachedAdd = cacheFunction(add);\n\n // First call should execute the function\n expect(cachedAdd(1, 2)).toBe(3);\n expect(callCount).toBe(1);\n\n // Second call with same args should use cached result\n expect(cachedAdd(1, 2)).toBe(3);\n expect(callCount).toBe(1);\n\n // Call with different args should execute the function again\n expect(cachedAdd(2, 3)).toBe(5);\n expect(callCount).toBe(2);\n\n // Test with a function that returns objects\n let objectCallCount = 0;\n const createObject = (id: number) => {\n objectCallCount++;\n return { id };\n };\n\n const cachedCreateObject = cacheFunction(createObject);\n\n // First call should execute the function\n const obj1 = cachedCreateObject(1);\n expect(obj1).toEqual({ id: 1 });\n expect(objectCallCount).toBe(1);\n\n // Second call with same args should use cached result\n const obj2 = cachedCreateObject(1);\n expect(obj2).toBe(obj1); // Same reference\n expect(objectCallCount).toBe(1);\n});\n\n\ntype CacheStrategy = \"write-only\" | \"read-write\" | \"never\";\n\nexport class AsyncCache<D extends any[], T> {\n private readonly _map = new DependenciesMap<D, AsyncValueCache<T>>();\n\n constructor(\n private readonly _fetcher: (dependencies: D) => Promise<T>,\n private readonly _options: {\n onSubscribe?: (key: D, refresh: () => void) => (() => void),\n rateLimiter?: Omit<RateLimitOptions, \"batchCalls\">,\n } = {},\n ) {\n // nothing here yet\n }\n\n private _createKeyed<FunctionName extends keyof AsyncValueCache<T>>(\n functionName: FunctionName,\n ): (key: D, ...args: Parameters<AsyncValueCache<T>[FunctionName]>) => ReturnType<AsyncValueCache<T>[FunctionName]> {\n return (key: D, ...args) => {\n const valueCache = this.getValueCache(key);\n return (valueCache[functionName] as any).apply(valueCache, args);\n };\n }\n\n getValueCache(dependencies: D): AsyncValueCache<T> {\n let cache = this._map.get(dependencies);\n if (!cache) {\n cache = new AsyncValueCache(\n async () => await this._fetcher(dependencies),\n {\n ...this._options,\n onSubscribe: this._options.onSubscribe ? (cb) => this._options.onSubscribe!(dependencies, cb) : undefined,\n },\n );\n this._map.set(dependencies, cache);\n }\n return cache;\n }\n\n async refreshWhere(predicate: (dependencies: D) => boolean) {\n const promises: Promise<void>[] = [];\n for (const [dependencies, cache] of this._map) {\n if (predicate(dependencies)) {\n promises.push(cache.refresh());\n }\n }\n await Promise.all(promises);\n }\n\n async invalidateWhere(predicate: (dependencies: D) => boolean) {\n const promises: Promise<void>[] = [];\n for (const [dependencies, cache] of this._map) {\n if (predicate(dependencies)) {\n promises.push(cache.invalidate().catch(() => undefined));\n }\n }\n await Promise.all(promises);\n }\n\n readonly isCacheAvailable = this._createKeyed(\"isCacheAvailable\");\n readonly getIfCached = this._createKeyed(\"getIfCached\");\n readonly getOrWait = this._createKeyed(\"getOrWait\");\n readonly forceSetCachedValue = this._createKeyed(\"forceSetCachedValue\");\n readonly forceSetCachedValueAsync = this._createKeyed(\"forceSetCachedValueAsync\");\n readonly refresh = this._createKeyed(\"refresh\");\n readonly invalidate = this._createKeyed(\"invalidate\");\n readonly onStateChange = this._createKeyed(\"onStateChange\");\n readonly isDirty = this._createKeyed(\"isDirty\");\n}\n\nclass AsyncValueCache<T> {\n private _store: AsyncStore<T>;\n private _pendingPromise: ReactPromise<T> | undefined;\n private _fetcher: () => Promise<T>;\n private readonly _rateLimitOptions: Omit<RateLimitOptions, \"batchCalls\">;\n private _subscriptionsCount = 0;\n private _unsubscribers: (() => void)[] = [];\n private _mostRecentRefreshPromiseIndex = 0;\n\n constructor(\n fetcher: () => Promise<T>,\n private readonly _options: {\n onSubscribe?: (refresh: () => void) => (() => void),\n rateLimiter?: Omit<RateLimitOptions, \"batchCalls\">,\n } = {},\n ) {\n this._store = new AsyncStore();\n this._rateLimitOptions = {\n concurrency: 1,\n throttleMs: 300,\n ...filterUndefined(_options.rateLimiter ?? {}),\n };\n\n\n this._fetcher = rateLimited(fetcher, {\n ...this._rateLimitOptions,\n batchCalls: true,\n });\n }\n\n isCacheAvailable(): boolean {\n return this._store.isAvailable();\n }\n\n getIfCached() {\n return this._store.get();\n }\n\n getOrWait(cacheStrategy: CacheStrategy): ReactPromise<T> {\n const cached = this.getIfCached();\n if (cacheStrategy === \"read-write\" && cached.status === \"ok\") {\n return resolved(cached.data);\n }\n\n return this._refetch(cacheStrategy);\n }\n\n private _set(value: T): void {\n this._store.set(value);\n }\n\n private _setAsync(value: Promise<T>): ReactPromise<void> {\n if (this._subscriptionsCount === 0 && !isBrowserLike()) {\n // if we're in a server-like environment, we'd rather cache less aggressively to avoid memory leaks.\n // hence, if no one is listening to this cache, let's invalidate it\n this._invalidateCacheSoon();\n }\n const promise = pending(value);\n this._pendingPromise = promise;\n return pending(this._store.setAsync(promise).then(() => undefined));\n }\n\n private _refetch(cacheStrategy: CacheStrategy): ReactPromise<T> {\n if (cacheStrategy === \"read-write\" && this._pendingPromise) {\n return this._pendingPromise;\n }\n const promise = pending(this._fetcher());\n if (cacheStrategy === \"never\") {\n return promise;\n }\n return pending(this._setAsync(promise).then(() => promise));\n }\n\n forceSetCachedValue(value: T): void {\n this._set(value);\n }\n\n forceSetCachedValueAsync(value: Promise<T>): ReactPromise<void> {\n return this._setAsync(value);\n }\n\n /**\n * If anyone is listening to the cache, refreshes the value, and sets it without invalidating the cache.\n */\n async refresh(): Promise<void> {\n // note that we do the extra check here to save a request if no one is listening to the cache anyway\n if (this._subscriptionsCount > 0) {\n await this.getOrWait(\"write-only\");\n }\n }\n\n /**\n * Invalidates the cache, marking it dirty (ie. it will be refreshed on the next read). If anyone is listening to the cache, it will refresh immediately.\n */\n async invalidate(): Promise<void> {\n this._store.setUnavailable();\n this._pendingPromise = undefined;\n await this.refresh();\n }\n\n isDirty(): boolean {\n return this._pendingPromise === undefined;\n }\n\n _invalidateCacheSoon(): void {\n // wait a few seconds; we want to keep the cache up during this time\n // else we do unnecessary requests if we unsubscribe and then subscribe again immediately\n const currentRefreshPromiseIndex = ++this._mostRecentRefreshPromiseIndex;\n runAsynchronously(async () => {\n await wait(5000);\n if (this._subscriptionsCount === 0 && currentRefreshPromiseIndex === this._mostRecentRefreshPromiseIndex) {\n await this.invalidate();\n }\n });\n }\n\n onStateChange(callback: (value: T, oldValue: T | undefined) => void): { unsubscribe: () => void } {\n const storeObj = this._store.onChange(callback);\n\n runAsynchronously(this.getOrWait(\"read-write\"));\n\n if (this._subscriptionsCount++ === 0 && this._options.onSubscribe) {\n const unsubscribe = this._options.onSubscribe(() => {\n runAsynchronously(this.refresh());\n });\n this._unsubscribers.push(unsubscribe);\n }\n\n let hasUnsubscribed = false;\n return {\n unsubscribe: () => {\n if (hasUnsubscribed) return;\n hasUnsubscribed = true;\n storeObj.unsubscribe();\n if (--this._subscriptionsCount === 0) {\n this._invalidateCacheSoon();\n\n for (const unsubscribe of this._unsubscribers) {\n unsubscribe();\n }\n }\n },\n };\n }\n}\n"],"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mB;GACjB,IAAI,iBAAiB;GACrB,kBAAkB;GAClB,SAAS,YAAY;GACrB,IAAI,EAAE,KAAK,wBAAwB,GAAG;IACpC,KAAK,qBAAqB;IAE1B,KAAK,MAAM,eAAe,KAAK,gBAC7B,YAAY;GAEhB;EACF,EACF;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cel-fields.d.ts","names":[],"sources":["../../src/utils/cel-fields.ts"],"mappings":";KAKY,cAAA;AAAA,KASA,iBAAA;AAAA,iBAeI,cAAA,CAAe,
|
|
1
|
+
{"version":3,"file":"cel-fields.d.ts","names":[],"sources":["../../src/utils/cel-fields.ts"],"mappings":";KAKY,cAAA;AAAA,KASA,iBAAA;AAAA,iBAeI,cAAA,CAAe,KAAqB,EAAd,cAAc;;;AAxB1B;AAS1B;iBAuBgB,yBAAA,CAA0B,KAAA,UAAe,KAAsB;AAAA,iBAc/D,eAAA,CAAgB,KAAa;AAAA,iBAI7B,iBAAA,CAAkB,KAAa;AAAA,KAUnC,kBAAA;EACV,KAAA;EACA,SAAA,EAAW,iBAAiB;EAC5B,gBAAA;AAAA;AAAA,cAGW,aAAA,EAAe,MAAA,CAAO,cAAA,EAAgB,kBAAA;AAAA,cAUtC,eAAA,EAAgD,cAAc;AAAA,cAE9D,kBAAA,EAAoB,iBAAiB;AAAA,iBAMlC,oBAAA,CAAqB,KAAA,EAAO,cAAA,GAAiB,iBAAiB"}
|
package/dist/utils/cel-fields.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value:
|
|
2
|
-
const require_chunk = require('../chunk-BE-pF4vm.js');
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
2
|
let __auth_methods_js = require("./auth-methods.js");
|
|
4
3
|
let __oauth_js = require("./oauth.js");
|
|
5
|
-
|
|
6
4
|
//#region src/utils/cel-fields.ts
|
|
7
5
|
function isNumericField(field) {
|
|
8
6
|
return field === "riskScores.bot" || field === "riskScores.free_trial_abuse";
|
|
@@ -95,7 +93,6 @@ const conditionOperators = [
|
|
|
95
93
|
function getOperatorsForField(field) {
|
|
96
94
|
return fieldMetadata[field].operators;
|
|
97
95
|
}
|
|
98
|
-
|
|
99
96
|
//#endregion
|
|
100
97
|
exports.conditionFields = conditionFields;
|
|
101
98
|
exports.conditionOperators = conditionOperators;
|
|
@@ -105,4 +102,5 @@ exports.getOperatorsForField = getOperatorsForField;
|
|
|
105
102
|
exports.isNumericField = isNumericField;
|
|
106
103
|
exports.unescapeCelString = unescapeCelString;
|
|
107
104
|
exports.validateNumericFieldValue = validateNumericFieldValue;
|
|
105
|
+
|
|
108
106
|
//# sourceMappingURL=cel-fields.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cel-fields.js","names":["signUpAuthMethodValues","standardProviders"],"sources":["../../src/utils/cel-fields.ts"],"sourcesContent":["import { signUpAuthMethodValues } from \"./auth-methods\";\nimport { standardProviders } from \"./oauth\";\n\n// ── Types ──────────────────────────────────────────────────────────────\n\nexport type ConditionField =\n | 'email'\n | 'countryCode'\n | 'emailDomain'\n | 'authMethod'\n | 'oauthProvider'\n | 'riskScores.bot'\n | 'riskScores.free_trial_abuse';\n\nexport type ConditionOperator =\n | 'equals'\n | 'not_equals'\n | 'greater_than'\n | 'greater_or_equal'\n | 'less_than'\n | 'less_or_equal'\n | 'matches'\n | 'ends_with'\n | 'starts_with'\n | 'contains'\n | 'in_list';\n\n// ── Helpers ────────────────────────────────────────────────────────────\n\nexport function isNumericField(field: ConditionField): boolean {\n return field === 'riskScores.bot' || field === 'riskScores.free_trial_abuse';\n}\n\n/**\n * Validates a numeric field value is a finite integer within [0, 100].\n * Returns null if valid, or an error message string if invalid.\n */\nexport function validateNumericFieldValue(field: string, value: string | number): string | null {\n const num = typeof value === 'number' ? value : Number(value);\n if (!Number.isFinite(num)) {\n return `Expected a finite number for field \"${field}\", got \"${String(value)}\"`;\n }\n if (!Number.isInteger(num)) {\n return `Expected an integer for field \"${field}\", got \"${String(value)}\"`;\n }\n if (num < 0 || num > 100) {\n return `Value for field \"${field}\" must be between 0 and 100, got ${num}`;\n }\n return null;\n}\n\nexport function escapeCelString(value: string): string {\n return value.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"');\n}\n\nexport function unescapeCelString(value: string): string {\n return value.replace(/\\\\\\\\/g, '\\\\').replace(/\\\\\"/g, '\"');\n}\n\n// ── Field metadata ─────────────────────────────────────────────────────\n\nconst numericOperators: ConditionOperator[] = ['equals', 'not_equals', 'greater_than', 'greater_or_equal', 'less_than', 'less_or_equal'];\nconst enumOperators: ConditionOperator[] = ['equals', 'not_equals', 'in_list'];\nconst stringOperators: ConditionOperator[] = ['equals', 'not_equals', 'contains', 'starts_with', 'ends_with', 'matches', 'in_list'];\n\nexport type FieldMetadataEntry = {\n label: string,\n operators: ConditionOperator[],\n predefinedValues?: string[],\n};\n\nexport const fieldMetadata: Record<ConditionField, FieldMetadataEntry> = {\n email: { label: 'Email', operators: stringOperators },\n countryCode: { label: 'Country Code', operators: enumOperators },\n emailDomain: { label: 'Email Domain', operators: stringOperators },\n authMethod: { label: 'Auth Method', operators: enumOperators, predefinedValues: [...signUpAuthMethodValues] },\n oauthProvider: { label: 'OAuth Provider', operators: enumOperators, predefinedValues: [...standardProviders] },\n 'riskScores.bot': { label: 'Risk Score: Bot', operators: numericOperators },\n 'riskScores.free_trial_abuse': { label: 'Risk Score: Free Trial Abuse', operators: numericOperators },\n};\n\nexport const conditionFields = Object.keys(fieldMetadata) as ConditionField[];\n\nexport const conditionOperators: ConditionOperator[] = [\n 'equals', 'not_equals', 'greater_than', 'greater_or_equal',\n 'less_than', 'less_or_equal', 'matches', 'ends_with',\n 'starts_with', 'contains', 'in_list',\n];\n\nexport function getOperatorsForField(field: ConditionField): ConditionOperator[] {\n return fieldMetadata[field].operators;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"cel-fields.js","names":["signUpAuthMethodValues","standardProviders"],"sources":["../../src/utils/cel-fields.ts"],"sourcesContent":["import { signUpAuthMethodValues } from \"./auth-methods\";\nimport { standardProviders } from \"./oauth\";\n\n// ── Types ──────────────────────────────────────────────────────────────\n\nexport type ConditionField =\n | 'email'\n | 'countryCode'\n | 'emailDomain'\n | 'authMethod'\n | 'oauthProvider'\n | 'riskScores.bot'\n | 'riskScores.free_trial_abuse';\n\nexport type ConditionOperator =\n | 'equals'\n | 'not_equals'\n | 'greater_than'\n | 'greater_or_equal'\n | 'less_than'\n | 'less_or_equal'\n | 'matches'\n | 'ends_with'\n | 'starts_with'\n | 'contains'\n | 'in_list';\n\n// ── Helpers ────────────────────────────────────────────────────────────\n\nexport function isNumericField(field: ConditionField): boolean {\n return field === 'riskScores.bot' || field === 'riskScores.free_trial_abuse';\n}\n\n/**\n * Validates a numeric field value is a finite integer within [0, 100].\n * Returns null if valid, or an error message string if invalid.\n */\nexport function validateNumericFieldValue(field: string, value: string | number): string | null {\n const num = typeof value === 'number' ? value : Number(value);\n if (!Number.isFinite(num)) {\n return `Expected a finite number for field \"${field}\", got \"${String(value)}\"`;\n }\n if (!Number.isInteger(num)) {\n return `Expected an integer for field \"${field}\", got \"${String(value)}\"`;\n }\n if (num < 0 || num > 100) {\n return `Value for field \"${field}\" must be between 0 and 100, got ${num}`;\n }\n return null;\n}\n\nexport function escapeCelString(value: string): string {\n return value.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"');\n}\n\nexport function unescapeCelString(value: string): string {\n return value.replace(/\\\\\\\\/g, '\\\\').replace(/\\\\\"/g, '\"');\n}\n\n// ── Field metadata ─────────────────────────────────────────────────────\n\nconst numericOperators: ConditionOperator[] = ['equals', 'not_equals', 'greater_than', 'greater_or_equal', 'less_than', 'less_or_equal'];\nconst enumOperators: ConditionOperator[] = ['equals', 'not_equals', 'in_list'];\nconst stringOperators: ConditionOperator[] = ['equals', 'not_equals', 'contains', 'starts_with', 'ends_with', 'matches', 'in_list'];\n\nexport type FieldMetadataEntry = {\n label: string,\n operators: ConditionOperator[],\n predefinedValues?: string[],\n};\n\nexport const fieldMetadata: Record<ConditionField, FieldMetadataEntry> = {\n email: { label: 'Email', operators: stringOperators },\n countryCode: { label: 'Country Code', operators: enumOperators },\n emailDomain: { label: 'Email Domain', operators: stringOperators },\n authMethod: { label: 'Auth Method', operators: enumOperators, predefinedValues: [...signUpAuthMethodValues] },\n oauthProvider: { label: 'OAuth Provider', operators: enumOperators, predefinedValues: [...standardProviders] },\n 'riskScores.bot': { label: 'Risk Score: Bot', operators: numericOperators },\n 'riskScores.free_trial_abuse': { label: 'Risk Score: Free Trial Abuse', operators: numericOperators },\n};\n\nexport const conditionFields = Object.keys(fieldMetadata) as ConditionField[];\n\nexport const conditionOperators: ConditionOperator[] = [\n 'equals', 'not_equals', 'greater_than', 'greater_or_equal',\n 'less_than', 'less_or_equal', 'matches', 'ends_with',\n 'starts_with', 'contains', 'in_list',\n];\n\nexport function getOperatorsForField(field: ConditionField): ConditionOperator[] {\n return fieldMetadata[field].operators;\n}\n"],"mappings":";;;;AA6BA,SAAgB,eAAe,OAAgC;CAC7D,OAAO,UAAU,oBAAoB,UAAU;AACjD;;;;;AAMA,SAAgB,0BAA0B,OAAe,OAAuC;CAC9F,MAAM,MAAM,OAAO,UAAU,WAAW,QAAQ,OAAO,KAAK;CAC5D,IAAI,CAAC,OAAO,SAAS,GAAG,GACtB,OAAO,uCAAuC,MAAM,UAAU,OAAO,KAAK,EAAE;CAE9E,IAAI,CAAC,OAAO,UAAU,GAAG,GACvB,OAAO,kCAAkC,MAAM,UAAU,OAAO,KAAK,EAAE;CAEzE,IAAI,MAAM,KAAK,MAAM,KACnB,OAAO,oBAAoB,MAAM,mCAAmC;CAEtE,OAAO;AACT;AAEA,SAAgB,gBAAgB,OAAuB;CACrD,OAAO,MAAM,QAAQ,OAAO,MAAM,CAAC,CAAC,QAAQ,MAAM,MAAK;AACzD;AAEA,SAAgB,kBAAkB,OAAuB;CACvD,OAAO,MAAM,QAAQ,SAAS,IAAI,CAAC,CAAC,QAAQ,QAAQ,IAAG;AACzD;AAIA,MAAM,mBAAwC;CAAC;CAAU;CAAc;CAAgB;CAAoB;CAAa;AAAe;AACvI,MAAM,gBAAqC;CAAC;CAAU;CAAc;AAAS;AAC7E,MAAM,kBAAuC;CAAC;CAAU;CAAc;CAAY;CAAe;CAAa;CAAW;AAAS;AAQlI,MAAa,gBAA4D;CACvE,OAAO;EAAE,OAAO;EAAS,WAAW;CAAgB;CACpD,aAAa;EAAE,OAAO;EAAgB,WAAW;CAAc;CAC/D,aAAa;EAAE,OAAO;EAAgB,WAAW;CAAgB;CACjE,YAAY;EAAE,OAAO;EAAe,WAAW;EAAe,kBAAkB,CAAC,GAAGA,kBAAAA,sBAAsB;CAAE;CAC5G,eAAe;EAAE,OAAO;EAAkB,WAAW;EAAe,kBAAkB,CAAC,GAAGC,WAAAA,iBAAiB;CAAE;CAC7G,kBAAkB;EAAE,OAAO;EAAmB,WAAW;CAAiB;CAC1E,+BAA+B;EAAE,OAAO;EAAgC,WAAW;CAAiB;AACtG;AAEA,MAAa,kBAAkB,OAAO,KAAK,aAAa;AAExD,MAAa,qBAA0C;CACrD;CAAU;CAAc;CAAgB;CACxC;CAAa;CAAiB;CAAW;CACzC;CAAe;CAAY;AAC7B;AAEA,SAAgB,qBAAqB,OAA4C;CAC/E,OAAO,cAAc,MAAM,CAAC;AAC9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloud-hosts.d.ts","names":[],"sources":["../../src/utils/cloud-hosts.tsx"],"mappings":";;AAcA
|
|
1
|
+
{"version":3,"file":"cloud-hosts.d.ts","names":[],"sources":["../../src/utils/cloud-hosts.tsx"],"mappings":";;AAcA;;;;AAA4C;AAsB5C;;;;;;;;cAtBa,gBAAA,EAAkB,aAAa;AAwC5C;;;;AAAqD;AASrD;AATA,iBAlBgB,sBAAA,CAAuB,YAAA;EAA4C,SAAA;EAAmB,QAAA;AAAA;;;;;;;iBAkBtF,sBAAA,CAAuB,MAAc;;;;;;iBASrC,qBAAA,CAAsB,MAAc"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value:
|
|
2
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
2
|
//#region src/utils/cloud-hosts.tsx
|
|
4
3
|
/**
|
|
5
4
|
* Single source of truth for the stack-auth ↔ hexclave host pairs that the
|
|
@@ -62,36 +61,10 @@ function getStackAuthApiBaseUrl(apiUrl) {
|
|
|
62
61
|
function getHexclaveApiBaseUrl(apiUrl) {
|
|
63
62
|
return getCloudApiUrlSiblings(apiUrl)?.hexclave ?? apiUrl;
|
|
64
63
|
}
|
|
65
|
-
(void 0)?.test("getCloudApiUrlSiblings maps both sides of each cloud pair", ({ expect }) => {
|
|
66
|
-
for (const [stackAuthHost, hexclaveHost] of CLOUD_HOST_PAIRS) {
|
|
67
|
-
const expected = {
|
|
68
|
-
stackAuth: `https://${stackAuthHost}`,
|
|
69
|
-
hexclave: `https://${hexclaveHost}`
|
|
70
|
-
};
|
|
71
|
-
for (const host of [stackAuthHost, hexclaveHost]) {
|
|
72
|
-
expect(getCloudApiUrlSiblings(host)).toEqual(expected);
|
|
73
|
-
expect(getCloudApiUrlSiblings(`https://${host}`)).toEqual(expected);
|
|
74
|
-
expect(getCloudApiUrlSiblings(`https://${host.toUpperCase()}:443`)).toEqual(expected);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
(void 0)?.test("getCloudApiUrlSiblings returns null for unknown hosts", ({ expect }) => {
|
|
79
|
-
expect(getCloudApiUrlSiblings("http://localhost:8102")).toBeNull();
|
|
80
|
-
expect(getCloudApiUrlSiblings("https://my-app.vercel.app")).toBeNull();
|
|
81
|
-
expect(getCloudApiUrlSiblings(void 0)).toBeNull();
|
|
82
|
-
expect(getCloudApiUrlSiblings("")).toBeNull();
|
|
83
|
-
});
|
|
84
|
-
(void 0)?.test("getStackAuthApiBaseUrl / getHexclaveApiBaseUrl resolve brands and fall back", ({ expect }) => {
|
|
85
|
-
expect(getStackAuthApiBaseUrl("https://api.hexclave.com")).toBe("https://api.stack-auth.com");
|
|
86
|
-
expect(getHexclaveApiBaseUrl("https://api.stack-auth.com")).toBe("https://api.hexclave.com");
|
|
87
|
-
expect(getStackAuthApiBaseUrl("https://api.dev.stack-auth.com")).toBe("https://api.dev.stack-auth.com");
|
|
88
|
-
expect(getHexclaveApiBaseUrl("http://localhost:8102")).toBe("http://localhost:8102");
|
|
89
|
-
expect(getStackAuthApiBaseUrl("http://localhost:8102")).toBe("http://localhost:8102");
|
|
90
|
-
});
|
|
91
|
-
|
|
92
64
|
//#endregion
|
|
93
65
|
exports.CLOUD_HOST_PAIRS = CLOUD_HOST_PAIRS;
|
|
94
66
|
exports.getCloudApiUrlSiblings = getCloudApiUrlSiblings;
|
|
95
67
|
exports.getHexclaveApiBaseUrl = getHexclaveApiBaseUrl;
|
|
96
68
|
exports.getStackAuthApiBaseUrl = getStackAuthApiBaseUrl;
|
|
69
|
+
|
|
97
70
|
//# 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":"
|
|
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,
|
|
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"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value:
|
|
2
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
2
|
//#region src/utils/compile-time.tsx
|
|
4
3
|
/**
|
|
5
4
|
* Returns the first argument passed to it, but compilers won't be able to optimize it out. This is useful in some
|
|
@@ -10,7 +9,7 @@ function scrambleDuringCompileTime(t) {
|
|
|
10
9
|
if (Math.random() < 1e-5 && Math.random() > .99999 && Math.random() < 1e-5 && Math.random() > .99999) return "this will never happen";
|
|
11
10
|
return t;
|
|
12
11
|
}
|
|
13
|
-
|
|
14
12
|
//#endregion
|
|
15
13
|
exports.scrambleDuringCompileTime = scrambleDuringCompileTime;
|
|
14
|
+
|
|
16
15
|
//# 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":"
|
|
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,11 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
declare function isValidCountryCode(countryCode: string): boolean;
|
|
4
|
-
/**
|
|
5
|
-
* Validates and normalizes a country code value (single string or array).
|
|
6
|
-
* Returns null if valid, or an error message string if invalid.
|
|
7
|
-
*/
|
|
8
|
-
declare function validateCountryCode(value: string | string[]): string | null;
|
|
9
|
-
//#endregion
|
|
10
|
-
export { isValidCountryCode, normalizeCountryCode, validateCountryCode };
|
|
11
|
-
//# sourceMappingURL=country-codes.d.ts.map
|
|
1
|
+
import { n as normalizeCountryCode, r as validateCountryCode, t as isValidCountryCode } from "../country-codes-CRWDroBE.js";
|
|
2
|
+
export { isValidCountryCode, normalizeCountryCode, validateCountryCode };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value:
|
|
2
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
2
|
//#region src/utils/country-codes.ts
|
|
4
3
|
function normalizeCountryCode(countryCode) {
|
|
5
4
|
return countryCode.trim().toUpperCase();
|
|
@@ -17,24 +16,9 @@ function validateCountryCode(value) {
|
|
|
17
16
|
if (values.length === 0) return "At least one country code is required";
|
|
18
17
|
return values.every((v) => isValidCountryCode(v)) ? null : "Country code must be a 2-letter code";
|
|
19
18
|
}
|
|
20
|
-
(void 0)?.test("country codes", ({ expect }) => {
|
|
21
|
-
expect(normalizeCountryCode(" us ")).toBe("US");
|
|
22
|
-
expect(isValidCountryCode("us")).toBe(true);
|
|
23
|
-
expect(isValidCountryCode("US")).toBe(true);
|
|
24
|
-
expect(isValidCountryCode("ZZ")).toBe(true);
|
|
25
|
-
expect(isValidCountryCode("usa")).toBe(false);
|
|
26
|
-
expect(isValidCountryCode("a")).toBe(false);
|
|
27
|
-
expect(isValidCountryCode("")).toBe(false);
|
|
28
|
-
expect(isValidCountryCode("12")).toBe(false);
|
|
29
|
-
expect(validateCountryCode("US")).toBeNull();
|
|
30
|
-
expect(validateCountryCode("zz")).toBeNull();
|
|
31
|
-
expect(validateCountryCode(["US", "CA"])).toBeNull();
|
|
32
|
-
expect(validateCountryCode([])).toBe("At least one country code is required");
|
|
33
|
-
expect(validateCountryCode(["US", "123"])).toBe("Country code must be a 2-letter code");
|
|
34
|
-
});
|
|
35
|
-
|
|
36
19
|
//#endregion
|
|
37
20
|
exports.isValidCountryCode = isValidCountryCode;
|
|
38
21
|
exports.normalizeCountryCode = normalizeCountryCode;
|
|
39
22
|
exports.validateCountryCode = validateCountryCode;
|
|
23
|
+
|
|
40
24
|
//# 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":"
|
|
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,
|
|
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"}
|
package/dist/utils/crypto.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value:
|
|
2
|
-
const require_chunk = require('../chunk-BE-pF4vm.js');
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
2
|
let __bytes_js = require("./bytes.js");
|
|
4
3
|
let __errors_js = require("./errors.js");
|
|
5
4
|
let __globals_js = require("./globals.js");
|
|
6
5
|
let __results_js = require("./results.js");
|
|
7
6
|
let __typed_arrays_js = require("./typed-arrays.js");
|
|
8
|
-
|
|
9
7
|
//#region src/utils/crypto.tsx
|
|
10
8
|
function generateRandomValues(array) {
|
|
11
9
|
if (!__globals_js.globalVar.crypto) throw new __errors_js.HexclaveAssertionError("Crypto API is not available in this environment. Are you using an old browser?");
|
|
@@ -41,8 +39,8 @@ async function getDerivedSymmetricKey(purpose, secret, salt) {
|
|
|
41
39
|
}, false, ["encrypt", "decrypt"]);
|
|
42
40
|
}
|
|
43
41
|
async function encrypt({ purpose, secret, value }) {
|
|
44
|
-
const iv = crypto.getRandomValues(new Uint8Array(12));
|
|
45
|
-
const salt = crypto.getRandomValues(new Uint8Array(16));
|
|
42
|
+
const iv = crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(12));
|
|
43
|
+
const salt = crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16));
|
|
46
44
|
const derivedSecretKey = await getDerivedSymmetricKey(purpose, secret, salt);
|
|
47
45
|
const cipher = await crypto.subtle.encrypt({
|
|
48
46
|
name: "AES-GCM",
|
|
@@ -73,27 +71,6 @@ async function decrypt({ purpose, secret, cipher }) {
|
|
|
73
71
|
throw e;
|
|
74
72
|
}
|
|
75
73
|
}
|
|
76
|
-
(void 0)?.test("encrypt & decrypt", async ({ expect }) => {
|
|
77
|
-
const encryptAndDecrypt = async (encryptPurpose, decryptPurpose, encryptSecret, decryptSecret, value) => {
|
|
78
|
-
return await decrypt({
|
|
79
|
-
purpose: decryptPurpose,
|
|
80
|
-
secret: decryptSecret,
|
|
81
|
-
cipher: await encrypt({
|
|
82
|
-
purpose: encryptPurpose,
|
|
83
|
-
secret: encryptSecret,
|
|
84
|
-
value
|
|
85
|
-
})
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
const exampleBytes = new TextEncoder().encode("hello");
|
|
89
|
-
const exampleKey1 = crypto.getRandomValues(new Uint8Array(32));
|
|
90
|
-
const exampleKey2 = crypto.getRandomValues(new Uint8Array(32));
|
|
91
|
-
expect(await encryptAndDecrypt("p", "p", "secret", "secret", exampleBytes)).toEqual(__results_js.Result.ok(exampleBytes));
|
|
92
|
-
expect(await encryptAndDecrypt("p", "p", exampleKey1, exampleKey1, exampleBytes)).toEqual(__results_js.Result.ok(exampleBytes));
|
|
93
|
-
expect(await encryptAndDecrypt("p", "p", exampleKey1, "secret", exampleBytes)).toEqual(__results_js.Result.error(expect.objectContaining({ message: "Invalid ciphertext or secret when decrypting encrypted value" })));
|
|
94
|
-
expect(await encryptAndDecrypt("p", "p", exampleKey1, exampleKey2, exampleBytes)).toEqual(__results_js.Result.error(expect.objectContaining({ message: "Invalid ciphertext or secret when decrypting encrypted value" })));
|
|
95
|
-
expect(await encryptAndDecrypt("p", "not-p", exampleKey1, exampleKey1, exampleBytes)).toEqual(__results_js.Result.error(expect.objectContaining({ message: "Invalid ciphertext or secret when decrypting encrypted value" })));
|
|
96
|
-
});
|
|
97
74
|
async function hash(options) {
|
|
98
75
|
return await iteratedHash({
|
|
99
76
|
...options,
|
|
@@ -116,95 +93,6 @@ async function iteratedHash(options) {
|
|
|
116
93
|
hash: "SHA-256"
|
|
117
94
|
}, input, 256));
|
|
118
95
|
}
|
|
119
|
-
(void 0)?.test("iteratedHash", async ({ expect }) => {
|
|
120
|
-
const valueBytes = new TextEncoder().encode("hello");
|
|
121
|
-
const incrementBytes = new Uint8Array([
|
|
122
|
-
1,
|
|
123
|
-
2,
|
|
124
|
-
3,
|
|
125
|
-
4,
|
|
126
|
-
5,
|
|
127
|
-
6,
|
|
128
|
-
7,
|
|
129
|
-
8,
|
|
130
|
-
9,
|
|
131
|
-
10,
|
|
132
|
-
11,
|
|
133
|
-
12,
|
|
134
|
-
13,
|
|
135
|
-
14,
|
|
136
|
-
15,
|
|
137
|
-
16
|
|
138
|
-
]);
|
|
139
|
-
const hash = await iteratedHash({
|
|
140
|
-
purpose: "purpose",
|
|
141
|
-
value: valueBytes,
|
|
142
|
-
iterations: 1e5
|
|
143
|
-
});
|
|
144
|
-
const hash2 = await iteratedHash({
|
|
145
|
-
purpose: "purpose",
|
|
146
|
-
value: valueBytes,
|
|
147
|
-
iterations: 1e5
|
|
148
|
-
});
|
|
149
|
-
const hashWithDifferentPurpose = await iteratedHash({
|
|
150
|
-
purpose: "different-purpose",
|
|
151
|
-
value: valueBytes,
|
|
152
|
-
iterations: 1e5
|
|
153
|
-
});
|
|
154
|
-
const hashWithEmptySalt = await iteratedHash({
|
|
155
|
-
purpose: "purpose",
|
|
156
|
-
value: valueBytes,
|
|
157
|
-
salt: new Uint8Array(0),
|
|
158
|
-
iterations: 1e5
|
|
159
|
-
});
|
|
160
|
-
const hashWithDifferentSalt = await iteratedHash({
|
|
161
|
-
purpose: "purpose",
|
|
162
|
-
value: valueBytes,
|
|
163
|
-
salt: incrementBytes,
|
|
164
|
-
iterations: 1e5
|
|
165
|
-
});
|
|
166
|
-
const hashWithEmptyExtra = await iteratedHash({
|
|
167
|
-
purpose: "purpose",
|
|
168
|
-
value: valueBytes,
|
|
169
|
-
extra: new Uint8Array(0),
|
|
170
|
-
iterations: 1e5
|
|
171
|
-
});
|
|
172
|
-
const hashWithDifferentExtra = await iteratedHash({
|
|
173
|
-
purpose: "purpose",
|
|
174
|
-
value: valueBytes,
|
|
175
|
-
extra: incrementBytes,
|
|
176
|
-
iterations: 1e5
|
|
177
|
-
});
|
|
178
|
-
const hashWithDifferentValue = await iteratedHash({
|
|
179
|
-
purpose: "purpose",
|
|
180
|
-
value: new TextEncoder().encode("hello2"),
|
|
181
|
-
iterations: 1e5
|
|
182
|
-
});
|
|
183
|
-
const hashWithDifferentSaltAndExtra = await iteratedHash({
|
|
184
|
-
purpose: "purpose",
|
|
185
|
-
value: valueBytes,
|
|
186
|
-
salt: incrementBytes,
|
|
187
|
-
extra: incrementBytes,
|
|
188
|
-
iterations: 1e5
|
|
189
|
-
});
|
|
190
|
-
const hashWithDifferentIterations = await iteratedHash({
|
|
191
|
-
purpose: "purpose",
|
|
192
|
-
value: valueBytes,
|
|
193
|
-
iterations: 100001
|
|
194
|
-
});
|
|
195
|
-
expect(hash).toEqual(hash2);
|
|
196
|
-
expect(hash).not.toEqual(hashWithDifferentPurpose);
|
|
197
|
-
expect(hash).toEqual(hashWithEmptySalt);
|
|
198
|
-
expect(hash).not.toEqual(hashWithDifferentSalt);
|
|
199
|
-
expect(hash).toEqual(hashWithEmptyExtra);
|
|
200
|
-
expect(hash).not.toEqual(hashWithDifferentExtra);
|
|
201
|
-
expect(hash).not.toEqual(hashWithDifferentValue);
|
|
202
|
-
expect(hash).not.toEqual(hashWithDifferentIterations);
|
|
203
|
-
expect(hashWithDifferentSalt).not.toEqual(hashWithDifferentExtra);
|
|
204
|
-
expect(hashWithDifferentSalt).not.toEqual(hashWithDifferentSaltAndExtra);
|
|
205
|
-
expect(hashWithDifferentExtra).not.toEqual(hashWithDifferentSaltAndExtra);
|
|
206
|
-
});
|
|
207
|
-
|
|
208
96
|
//#endregion
|
|
209
97
|
exports.decrypt = decrypt;
|
|
210
98
|
exports.encrypt = encrypt;
|
|
@@ -212,4 +100,5 @@ exports.generateRandomValues = generateRandomValues;
|
|
|
212
100
|
exports.generateSecureRandomString = generateSecureRandomString;
|
|
213
101
|
exports.hash = hash;
|
|
214
102
|
exports.iteratedHash = iteratedHash;
|
|
103
|
+
|
|
215
104
|
//# sourceMappingURL=crypto.js.map
|
package/dist/utils/crypto.js.map
CHANGED
|
@@ -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(h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;EAAY,YAAY;EAAS,CAAC;AAGtH,QAAO,KAAK,CAAC,QAAQ,MAAM;AAC3B,QAAO,KAAK,CAAC,IAAI,QAAQ,yBAAyB;AAClD,QAAO,KAAK,CAAC,QAAQ,kBAAkB;AACvC,QAAO,KAAK,CAAC,IAAI,QAAQ,sBAAsB;AAC/C,QAAO,KAAK,CAAC,QAAQ,mBAAmB;AACxC,QAAO,KAAK,CAAC,IAAI,QAAQ,uBAAuB;AAChD,QAAO,KAAK,CAAC,IAAI,QAAQ,uBAAuB;AAChD,QAAO,KAAK,CAAC,IAAI,QAAQ,4BAA4B;AAErD,QAAO,sBAAsB,CAAC,IAAI,QAAQ,uBAAuB;AACjE,QAAO,sBAAsB,CAAC,IAAI,QAAQ,8BAA8B;AACxE,QAAO,uBAAuB,CAAC,IAAI,QAAQ,8BAA8B;EACzE"}
|
|
1
|
+
{"version":3,"file":"crypto.js","names":["globalVar","HexclaveAssertionError","Result"],"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;CACpE,IAAI,CAACA,aAAAA,UAAU,QACb,MAAM,IAAIC,YAAAA,uBAAuB,gFAAgF;CAEnH,IAAI,CAACD,aAAAA,UAAU,OAAO,iBACpB,MAAM,IAAIC,YAAAA,uBAAuB,4FAA4F;CAE/H,OAAOD,aAAAA,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,OAAA,GAAA,WAAA,aAAA,CADc,qBAAqB,IAAI,WAAW,UAAU,C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,MAAM;CACR,GAAG,OAAO,GAAG,CAAC;AAChB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as MoneyAmount, r as SUPPORTED_CURRENCIES, t as Currency } from "../currency-constants-Cq_q8twn.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,
|
|
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"}
|
package/dist/utils/currencies.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value:
|
|
2
|
-
const require_chunk = require('../chunk-BE-pF4vm.js');
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
2
|
let ___schema_fields_js = require("../schema-fields.js");
|
|
4
3
|
let __errors_js = require("./errors.js");
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
require("./currency-constants.js");
|
|
7
5
|
//#region src/utils/currencies.tsx
|
|
8
6
|
function moneyAmountToStripeUnits(amount, currency) {
|
|
9
7
|
const validated = (0, ___schema_fields_js.moneyAmountSchema)(currency).defined().validateSync(amount);
|
|
@@ -12,41 +10,7 @@ function moneyAmountToStripeUnits(amount, currency) {
|
|
|
12
10
|
const paddedFractional = fractional.padEnd(currency.decimals, "0");
|
|
13
11
|
return Number.parseInt(whole + paddedFractional, 10);
|
|
14
12
|
}
|
|
15
|
-
(void 0)?.describe("moneyAmountToStripeUnits", (test) => {
|
|
16
|
-
const USD = __currency_constants_js.SUPPORTED_CURRENCIES.find((c) => c.code === "USD");
|
|
17
|
-
test("converts fully-padded USD amounts", ({ expect }) => {
|
|
18
|
-
expect(moneyAmountToStripeUnits("5.00", USD)).toBe(500);
|
|
19
|
-
expect(moneyAmountToStripeUnits("0.01", USD)).toBe(1);
|
|
20
|
-
expect(moneyAmountToStripeUnits("12.34", USD)).toBe(1234);
|
|
21
|
-
});
|
|
22
|
-
test("converts whole-number USD amounts (no decimals)", ({ expect }) => {
|
|
23
|
-
expect(moneyAmountToStripeUnits("5", USD)).toBe(500);
|
|
24
|
-
expect(moneyAmountToStripeUnits("10", USD)).toBe(1e3);
|
|
25
|
-
expect(moneyAmountToStripeUnits("0", USD)).toBe(0);
|
|
26
|
-
});
|
|
27
|
-
test("converts USD amounts with one decimal digit", ({ expect }) => {
|
|
28
|
-
expect(moneyAmountToStripeUnits("5.5", USD)).toBe(550);
|
|
29
|
-
expect(moneyAmountToStripeUnits("0.5", USD)).toBe(50);
|
|
30
|
-
});
|
|
31
|
-
test("matches stripeUnitsToMoneyAmount round-trip", ({ expect }) => {
|
|
32
|
-
for (const cents of [
|
|
33
|
-
0,
|
|
34
|
-
1,
|
|
35
|
-
5,
|
|
36
|
-
50,
|
|
37
|
-
99,
|
|
38
|
-
100,
|
|
39
|
-
1234,
|
|
40
|
-
1e5
|
|
41
|
-
]) expect(moneyAmountToStripeUnits(`${Math.floor(cents / 100)}.${(cents % 100).toString().padStart(2, "0")}`, USD)).toBe(cents);
|
|
42
|
-
});
|
|
43
|
-
test("rejects invalid money strings via schema", ({ expect }) => {
|
|
44
|
-
expect(() => moneyAmountToStripeUnits("abc", USD)).toThrow();
|
|
45
|
-
expect(() => moneyAmountToStripeUnits("5.555", USD)).toThrow();
|
|
46
|
-
expect(() => moneyAmountToStripeUnits("05", USD)).toThrow();
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
|
|
50
13
|
//#endregion
|
|
51
14
|
exports.moneyAmountToStripeUnits = moneyAmountToStripeUnits;
|
|
15
|
+
|
|
52
16
|
//# sourceMappingURL=currencies.js.map
|