@hexclave/shared 1.0.40 → 1.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin-interface-Y9EZqwD6.d.ts +379 -0
- package/dist/admin-interface-Y9EZqwD6.d.ts.map +1 -0
- package/dist/admin-metrics-bsOkw4YQ.d.ts +807 -0
- package/dist/admin-metrics-bsOkw4YQ.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 +3 -6
- 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 +3 -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-iIw4nU5k.d.ts +447 -0
- package/dist/client-interface-iIw4nU5k.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-BBoN3hsn.d.ts +284 -0
- package/dist/current-user-BBoN3hsn.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-B1wmVPRG.d.ts +1464 -0
- package/dist/{interface/crud/email-outbox.d.ts.map → email-outbox-B1wmVPRG.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 +26 -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 +81 -82
- 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 +2 -3
- package/dist/esm/interface/admin-interface.js.map +1 -1
- package/dist/esm/interface/admin-metrics.d.ts +2 -2
- 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 +32 -16
- 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 +11 -11
- 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 +11 -13
- 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 +10 -12
- 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.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 +16 -17
- 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 +3 -4
- 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 +28 -30
- 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 +14 -16
- 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 +12 -14
- 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 +5 -6
- 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 +2 -3
- package/dist/esm/interface/server-interface.js.map +1 -1
- 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 +3 -3
- 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 +1 -1
- 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 +2 -161
- 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 +3 -5
- 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 +33 -18
- 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 +11 -11
- 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 +3 -5
- 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-CHo9YKbI.d.ts +43 -0
- package/dist/invoices-CHo9YKbI.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-CFTNXRfG.d.ts +900 -0
- package/dist/projects-CFTNXRfG.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-CJwkGkdf.d.ts +2328 -0
- package/dist/schema-CJwkGkdf.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-CgpxsLT_.d.ts +257 -0
- package/dist/server-interface-CgpxsLT_.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-BoDEqx-0.d.ts +285 -0
- package/dist/team-member-profiles-BoDEqx-0.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-DHNRwoSz.d.ts +653 -0
- package/dist/users-DHNRwoSz.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 +3 -163
- 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-8Ts1Clcb.d.ts +326 -0
- package/dist/webhooks-8Ts1Clcb.d.ts.map +1 -0
- package/package.json +2 -8
- package/src/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.ts +1 -0
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","names":[],"sources":["../../../src/utils/errors.tsx"],"sourcesContent":["import { globalVar } from \"./globals\";\nimport { Json } from \"./json\";\nimport { pick } from \"./objects\";\nimport { nicify } from \"./strings\";\n\n\nexport function throwErr(errorMessage: string, extraData?: any): never;\nexport function throwErr(error: Error): never;\nexport function throwErr(...args: StatusErrorConstructorParameters): never;\nexport function throwErr(...args: any[]): never {\n if (typeof args[0] === \"string\") {\n throw new HexclaveAssertionError(args[0], args[1]);\n } else if (args[0] instanceof Error) {\n throw args[0];\n } else {\n // @ts-expect-error\n throw new StatusError(...args);\n }\n}\n\nfunction removeStacktraceNameLine(stack: string): string {\n // some browsers (eg. Chrome) prepend the stack with an extra line with the error name\n const addsNameLine = new Error().stack?.startsWith(\"Error\\n\");\n return stack.split(\"\\n\").slice(addsNameLine ? 1 : 0).join(\"\\n\");\n}\n\n\n/**\n * Concatenates the (original) stacktraces of the given errors onto the first.\n *\n * Note: Very often, the concatStacktracesIfRejected function in promises.tsx is an easier way to use this function.\n *\n * Useful when you invoke an async function to receive a promise without awaiting it immediately. Browsers are smart\n * enough to keep track of the call stack in async function calls when you invoke `.then` within the same async tick,\n * but if you don't, the stacktrace will be lost.\n *\n * Here's an example of the unwanted behavior:\n *\n * ```tsx\n * async function log() {\n * await wait(0); // put the task on the event loop\n * console.log(new Error().stack);\n * }\n *\n * async function main() {\n * await log(); // good; prints both \"log\" and \"main\" on the stacktrace\n * log(); // bad; prints only \"log\" on the stacktrace\n * }\n * ```\n */\nexport function concatStacktraces(first: Error, ...errors: Error[]): void {\n // some browsers (eg. Firefox) add an extra empty line at the end\n const addsEmptyLineAtEnd = first.stack?.endsWith(\"\\n\");\n\n\n // Add a reference to this function itself so that we know that stacktraces were concatenated\n // If you are coming here from a stacktrace, please know that the two parts before and after this line are different\n // stacktraces that were concatenated with concatStacktraces\n const separator = removeStacktraceNameLine(new Error().stack ?? \"\").split(\"\\n\")[0];\n\n\n for (const error of errors) {\n const toAppend = removeStacktraceNameLine(error.stack ?? \"\");\n first.stack += (addsEmptyLineAtEnd ? \"\" : \"\\n\") + separator + \"\\n\" + toAppend;\n }\n}\n\n\nexport class HexclaveAssertionError extends Error {\n constructor(message: string, public readonly extraData?: Record<string, any> & ErrorOptions) {\n const disclaimer = `\\n\\nThis is likely an error in Hexclave. Please make sure you are running the newest version and report it.`;\n super(`${message}${message.endsWith(disclaimer) ? \"\" : disclaimer}`, pick(extraData ?? {}, [\"cause\"]));\n\n Object.defineProperty(this, \"customCaptureExtraArgs\", {\n get() {\n return [this.extraData];\n },\n enumerable: false,\n });\n\n // Use literal dot-form (guarded with `typeof process`) so Next.js / webpack\n // DefinePlugin can inline the value at build time. See getProcessEnv in ./env.\n const hexclaveDebuggerValue = typeof process !== \"undefined\" ? process.env.NEXT_PUBLIC_HEXCLAVE_DEBUGGER_ON_ASSERTION_ERROR : undefined;\n const stackDebuggerValue = typeof process !== \"undefined\" ? process.env.NEXT_PUBLIC_STACK_DEBUGGER_ON_ASSERTION_ERROR : undefined;\n if (hexclaveDebuggerValue && stackDebuggerValue && hexclaveDebuggerValue !== stackDebuggerValue) {\n throw new Error(\"Environment variables NEXT_PUBLIC_HEXCLAVE_DEBUGGER_ON_ASSERTION_ERROR and NEXT_PUBLIC_STACK_DEBUGGER_ON_ASSERTION_ERROR are both set to different values. Remove one of them or set them to the same value.\");\n }\n if ((hexclaveDebuggerValue || stackDebuggerValue) === \"true\") {\n debugger;\n }\n }\n}\nHexclaveAssertionError.prototype.name = \"HexclaveAssertionError\";\n\n\nexport function errorToNiceString(error: unknown): string {\n if (!(error instanceof Error)) return `${typeof error}<${nicify(error)}>`;\n return nicify(error, { maxDepth: 8 });\n}\n\n\nexport type CaptureLevel = \"error\" | \"warning\";\n\ntype ErrorSink = (location: string, error: unknown, level: CaptureLevel, ...extraArgs: unknown[]) => void;\n\nconst errorSinks = new Set<ErrorSink>();\nexport function registerErrorSink(sink: ErrorSink): void {\n if (errorSinks.has(sink)) {\n return;\n }\n errorSinks.add(sink);\n}\nregisterErrorSink((location, error, level, ...extraArgs) => {\n const logger = level === \"warning\" ? console.warn : console.error;\n const colorCode = level === \"warning\" ? \"\\x1b[43m\" : \"\\x1b[41m\";\n const label = level === \"warning\" ? \"warning\" : \"error\";\n logger(\n `${colorCode}Captured ${label} in ${location}:`,\n // HACK: Log a nicified version of the error to get around buggy Next.js pretty-printing\n // https://www.reddit.com/r/nextjs/comments/1gkxdqe/comment/m19kxgn/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button\n errorToNiceString(error),\n ...extraArgs,\n \"\\x1b[0m\",\n );\n});\nregisterErrorSink((location, error, level, ...extraArgs) => {\n globalVar.hexclaveCapturedErrors = globalVar.hexclaveCapturedErrors ?? [];\n globalVar.hexclaveCapturedErrors.push({ location, error, level, extraArgs });\n});\n\nfunction dispatchToSinks(location: string, error: unknown, level: CaptureLevel): void {\n for (const sink of errorSinks) {\n sink(\n location,\n error,\n level,\n ...error && (typeof error === 'object' || typeof error === 'function') && \"customCaptureExtraArgs\" in error && Array.isArray(error.customCaptureExtraArgs) ? (error.customCaptureExtraArgs as any[]) : [],\n );\n }\n}\n\n/**\n * Captures an error and sends it to the error sinks (most notably, Sentry). Errors caught with captureError are\n * supposed to be seen by an engineer, so they should be actionable and important.\n *\n * The location string is a machine-readable ID, and should hence not contain spaces or anything like that. Good\n * examples are: \"api-route-handler\", \"renderPart()\", etc.\n *\n * Errors that bubble up to the top of runAsynchronously or a route handler are already captured with captureError.\n */\nexport function captureError(location: string, error: unknown): void {\n dispatchToSinks(location, error, \"error\");\n}\n\n/**\n * Like captureError, but logs at warning level. Use for issues that an engineer should know about but that aren't\n * severe enough to be treated as an error (e.g. recoverable failures in background tasks).\n */\nexport function captureWarning(location: string, error: unknown): void {\n dispatchToSinks(location, error, \"warning\");\n}\n\n\ntype Status = {\n statusCode: number,\n message: string,\n};\n\ntype StatusErrorConstructorParameters =\n| [\n status: Status,\n message?: string\n]\n| [\n statusCode: number | Status,\n message: string,\n];\n\nexport class StatusError extends Error {\n private readonly __stackStatusErrorBrand = \"stack-status-error-brand-sentinel\" as const;\n public name = \"StatusError\";\n public readonly statusCode: number;\n\n public static BadRequest = { statusCode: 400, message: \"Bad Request\" };\n public static Unauthorized = { statusCode: 401, message: \"Unauthorized\" };\n public static PaymentRequired = { statusCode: 402, message: \"Payment Required\" };\n public static Forbidden = { statusCode: 403, message: \"Forbidden\" };\n public static NotFound = { statusCode: 404, message: \"Not Found\" };\n public static MethodNotAllowed = { statusCode: 405, message: \"Method Not Allowed\" };\n public static NotAcceptable = { statusCode: 406, message: \"Not Acceptable\" };\n public static ProxyAuthenticationRequired = { statusCode: 407, message: \"Proxy Authentication Required\" };\n public static RequestTimeout = { statusCode: 408, message: \"Request Timeout\" };\n public static Conflict = { statusCode: 409, message: \"Conflict\" };\n public static Gone = { statusCode: 410, message: \"Gone\" };\n public static LengthRequired = { statusCode: 411, message: \"Length Required\" };\n public static PreconditionFailed = { statusCode: 412, message: \"Precondition Failed\" };\n public static PayloadTooLarge = { statusCode: 413, message: \"Payload Too Large\" };\n public static URITooLong = { statusCode: 414, message: \"URI Too Long\" };\n public static UnsupportedMediaType = { statusCode: 415, message: \"Unsupported Media Type\" };\n public static RangeNotSatisfiable = { statusCode: 416, message: \"Range Not Satisfiable\" };\n public static ExpectationFailed = { statusCode: 417, message: \"Expectation Failed\" };\n public static ImATeapot = { statusCode: 418, message: \"I'm a teapot\" };\n public static MisdirectedRequest = { statusCode: 421, message: \"Misdirected Request\" };\n public static UnprocessableEntity = { statusCode: 422, message: \"Unprocessable Entity\" };\n public static Locked = { statusCode: 423, message: \"Locked\" };\n public static FailedDependency = { statusCode: 424, message: \"Failed Dependency\" };\n public static TooEarly = { statusCode: 425, message: \"Too Early\" };\n public static UpgradeRequired = { statusCode: 426, message: \"Upgrade Required\" };\n public static PreconditionRequired = { statusCode: 428, message: \"Precondition Required\" };\n public static TooManyRequests = { statusCode: 429, message: \"Too Many Requests\" };\n public static RequestHeaderFieldsTooLarge = { statusCode: 431, message: \"Request Header Fields Too Large\" };\n public static UnavailableForLegalReasons = { statusCode: 451, message: \"Unavailable For Legal Reasons\" };\n\n public static InternalServerError = { statusCode: 500, message: \"Internal Server Error\" };\n public static NotImplemented = { statusCode: 501, message: \"Not Implemented\" };\n public static BadGateway = { statusCode: 502, message: \"Bad Gateway\" };\n public static ServiceUnavailable = { statusCode: 503, message: \"Service Unavailable\" };\n public static GatewayTimeout = { statusCode: 504, message: \"Gateway Timeout\" };\n public static HTTPVersionNotSupported = { statusCode: 505, message: \"HTTP Version Not Supported\" };\n public static VariantAlsoNegotiates = { statusCode: 506, message: \"Variant Also Negotiates\" };\n public static InsufficientStorage = { statusCode: 507, message: \"Insufficient Storage\" };\n public static LoopDetected = { statusCode: 508, message: \"Loop Detected\" };\n public static NotExtended = { statusCode: 510, message: \"Not Extended\" };\n public static NetworkAuthenticationRequired = { statusCode: 511, message: \"Network Authentication Required\" };\n\n\n constructor(...args: StatusErrorConstructorParameters);\n constructor(\n status: number | Status,\n message?: string,\n ) {\n if (typeof status === \"object\") {\n message ??= status.message;\n status = status.statusCode;\n }\n super(message);\n this.statusCode = status;\n if (!message) {\n throw new HexclaveAssertionError(\"StatusError always requires a message unless a Status object is passed\", { cause: this });\n }\n }\n\n public static isStatusError(error: unknown): error is StatusError {\n // like instanceof, but also works for errors thrown in other realms or by different versions of the same package\n return typeof error === \"object\" && error !== null && \"__stackStatusErrorBrand\" in error && error.__stackStatusErrorBrand === \"stack-status-error-brand-sentinel\";\n }\n\n public isClientError() {\n return this.statusCode >= 400 && this.statusCode < 500;\n }\n\n public isServerError() {\n return !this.isClientError();\n }\n\n public getStatusCode(): number {\n return this.statusCode;\n }\n\n public getBody(): Uint8Array {\n return new TextEncoder().encode(this.message);\n }\n\n public getHeaders(): Record<string, string[]> {\n return {\n \"Content-Type\": [\"text/plain; charset=utf-8\"],\n };\n }\n\n public toDescriptiveJson(): Json {\n return {\n status_code: this.getStatusCode(),\n message: this.message,\n headers: this.getHeaders(),\n };\n }\n\n /**\n * @deprecated this is not a good way to make status errors human-readable, use toDescriptiveJson instead\n */\n public toHttpJson(): Json {\n return {\n status_code: this.statusCode,\n body: this.message,\n headers: this.getHeaders(),\n };\n }\n}\nStatusError.prototype.name = \"StatusError\";\n"],"mappings":";;;;;AASA,SAAgB,SAAS,GAAG,MAAoB;AAC9C,KAAI,OAAO,KAAK,OAAO,SACrB,OAAM,IAAI,uBAAuB,KAAK,IAAI,KAAK,GAAG;UACzC,KAAK,cAAc,MAC5B,OAAM,KAAK;KAGX,OAAM,IAAI,YAAY,GAAG,KAAK;;AAIlC,SAAS,yBAAyB,OAAuB;CAEvD,MAAM,gCAAe,IAAI,OAAO,EAAC,OAAO,WAAW,UAAU;AAC7D,QAAO,MAAM,MAAM,KAAK,CAAC,MAAM,eAAe,IAAI,EAAE,CAAC,KAAK,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;AA2BjE,SAAgB,kBAAkB,OAAc,GAAG,QAAuB;CAExE,MAAM,qBAAqB,MAAM,OAAO,SAAS,KAAK;CAMtD,MAAM,YAAY,0CAAyB,IAAI,OAAO,EAAC,SAAS,GAAG,CAAC,MAAM,KAAK,CAAC;AAGhF,MAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,WAAW,yBAAyB,MAAM,SAAS,GAAG;AAC5D,QAAM,UAAU,qBAAqB,KAAK,QAAQ,YAAY,OAAO;;;AAKzE,IAAa,yBAAb,cAA4C,MAAM;CAChD,YAAY,SAAiB,AAAgB,WAAgD;EAC3F,MAAM,aAAa;AACnB,QAAM,GAAG,UAAU,QAAQ,SAAS,WAAW,GAAG,KAAK,cAAc,KAAK,aAAa,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC;EAF3D;AAI3C,SAAO,eAAe,MAAM,0BAA0B;GACpD,MAAM;AACJ,WAAO,CAAC,KAAK,UAAU;;GAEzB,YAAY;GACb,CAAC;EAIF,MAAM,wB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AAAO,aAAmB;AACxB,SAAO;GACL,aAAa,KAAK;GAClB,MAAM,KAAK;GACX,SAAS,KAAK,YAAY;GAC3B;;;AAGL,YAAY,UAAU,OAAO"}
|
|
1
|
+
{"version":3,"file":"errors.js","names":[],"sources":["../../../src/utils/errors.tsx"],"sourcesContent":["import { globalVar } from \"./globals\";\nimport { Json } from \"./json\";\nimport { pick } from \"./objects\";\nimport { nicify } from \"./strings\";\n\n\nexport function throwErr(errorMessage: string, extraData?: any): never;\nexport function throwErr(error: Error): never;\nexport function throwErr(...args: StatusErrorConstructorParameters): never;\nexport function throwErr(...args: any[]): never {\n if (typeof args[0] === \"string\") {\n throw new HexclaveAssertionError(args[0], args[1]);\n } else if (args[0] instanceof Error) {\n throw args[0];\n } else {\n // @ts-expect-error\n throw new StatusError(...args);\n }\n}\n\nfunction removeStacktraceNameLine(stack: string): string {\n // some browsers (eg. Chrome) prepend the stack with an extra line with the error name\n const addsNameLine = new Error().stack?.startsWith(\"Error\\n\");\n return stack.split(\"\\n\").slice(addsNameLine ? 1 : 0).join(\"\\n\");\n}\n\n\n/**\n * Concatenates the (original) stacktraces of the given errors onto the first.\n *\n * Note: Very often, the concatStacktracesIfRejected function in promises.tsx is an easier way to use this function.\n *\n * Useful when you invoke an async function to receive a promise without awaiting it immediately. Browsers are smart\n * enough to keep track of the call stack in async function calls when you invoke `.then` within the same async tick,\n * but if you don't, the stacktrace will be lost.\n *\n * Here's an example of the unwanted behavior:\n *\n * ```tsx\n * async function log() {\n * await wait(0); // put the task on the event loop\n * console.log(new Error().stack);\n * }\n *\n * async function main() {\n * await log(); // good; prints both \"log\" and \"main\" on the stacktrace\n * log(); // bad; prints only \"log\" on the stacktrace\n * }\n * ```\n */\nexport function concatStacktraces(first: Error, ...errors: Error[]): void {\n // some browsers (eg. Firefox) add an extra empty line at the end\n const addsEmptyLineAtEnd = first.stack?.endsWith(\"\\n\");\n\n\n // Add a reference to this function itself so that we know that stacktraces were concatenated\n // If you are coming here from a stacktrace, please know that the two parts before and after this line are different\n // stacktraces that were concatenated with concatStacktraces\n const separator = removeStacktraceNameLine(new Error().stack ?? \"\").split(\"\\n\")[0];\n\n\n for (const error of errors) {\n const toAppend = removeStacktraceNameLine(error.stack ?? \"\");\n first.stack += (addsEmptyLineAtEnd ? \"\" : \"\\n\") + separator + \"\\n\" + toAppend;\n }\n}\n\n\nexport class HexclaveAssertionError extends Error {\n constructor(message: string, public readonly extraData?: Record<string, any> & ErrorOptions) {\n const disclaimer = `\\n\\nThis is likely an error in Hexclave. Please make sure you are running the newest version and report it.`;\n super(`${message}${message.endsWith(disclaimer) ? \"\" : disclaimer}`, pick(extraData ?? {}, [\"cause\"]));\n\n Object.defineProperty(this, \"customCaptureExtraArgs\", {\n get() {\n return [this.extraData];\n },\n enumerable: false,\n });\n\n // Use literal dot-form (guarded with `typeof process`) so Next.js / webpack\n // DefinePlugin can inline the value at build time. See getProcessEnv in ./env.\n const hexclaveDebuggerValue = typeof process !== \"undefined\" ? process.env.NEXT_PUBLIC_HEXCLAVE_DEBUGGER_ON_ASSERTION_ERROR : undefined;\n const stackDebuggerValue = typeof process !== \"undefined\" ? process.env.NEXT_PUBLIC_STACK_DEBUGGER_ON_ASSERTION_ERROR : undefined;\n if (hexclaveDebuggerValue && stackDebuggerValue && hexclaveDebuggerValue !== stackDebuggerValue) {\n throw new Error(\"Environment variables NEXT_PUBLIC_HEXCLAVE_DEBUGGER_ON_ASSERTION_ERROR and NEXT_PUBLIC_STACK_DEBUGGER_ON_ASSERTION_ERROR are both set to different values. Remove one of them or set them to the same value.\");\n }\n if ((hexclaveDebuggerValue || stackDebuggerValue) === \"true\") {\n debugger;\n }\n }\n}\nHexclaveAssertionError.prototype.name = \"HexclaveAssertionError\";\n\n\nexport function errorToNiceString(error: unknown): string {\n if (!(error instanceof Error)) return `${typeof error}<${nicify(error)}>`;\n return nicify(error, { maxDepth: 8 });\n}\n\n\nexport type CaptureLevel = \"error\" | \"warning\";\n\ntype ErrorSink = (location: string, error: unknown, level: CaptureLevel, ...extraArgs: unknown[]) => void;\n\nconst errorSinks = new Set<ErrorSink>();\nexport function registerErrorSink(sink: ErrorSink): void {\n if (errorSinks.has(sink)) {\n return;\n }\n errorSinks.add(sink);\n}\nregisterErrorSink((location, error, level, ...extraArgs) => {\n const logger = level === \"warning\" ? console.warn : console.error;\n const colorCode = level === \"warning\" ? \"\\x1b[43m\" : \"\\x1b[41m\";\n const label = level === \"warning\" ? \"warning\" : \"error\";\n logger(\n `${colorCode}Captured ${label} in ${location}:`,\n // HACK: Log a nicified version of the error to get around buggy Next.js pretty-printing\n // https://www.reddit.com/r/nextjs/comments/1gkxdqe/comment/m19kxgn/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button\n errorToNiceString(error),\n ...extraArgs,\n \"\\x1b[0m\",\n );\n});\nregisterErrorSink((location, error, level, ...extraArgs) => {\n globalVar.hexclaveCapturedErrors = globalVar.hexclaveCapturedErrors ?? [];\n globalVar.hexclaveCapturedErrors.push({ location, error, level, extraArgs });\n});\n\nfunction dispatchToSinks(location: string, error: unknown, level: CaptureLevel): void {\n for (const sink of errorSinks) {\n sink(\n location,\n error,\n level,\n ...error && (typeof error === 'object' || typeof error === 'function') && \"customCaptureExtraArgs\" in error && Array.isArray(error.customCaptureExtraArgs) ? (error.customCaptureExtraArgs as any[]) : [],\n );\n }\n}\n\n/**\n * Captures an error and sends it to the error sinks (most notably, Sentry). Errors caught with captureError are\n * supposed to be seen by an engineer, so they should be actionable and important.\n *\n * The location string is a machine-readable ID, and should hence not contain spaces or anything like that. Good\n * examples are: \"api-route-handler\", \"renderPart()\", etc.\n *\n * Errors that bubble up to the top of runAsynchronously or a route handler are already captured with captureError.\n */\nexport function captureError(location: string, error: unknown): void {\n dispatchToSinks(location, error, \"error\");\n}\n\n/**\n * Like captureError, but logs at warning level. Use for issues that an engineer should know about but that aren't\n * severe enough to be treated as an error (e.g. recoverable failures in background tasks).\n */\nexport function captureWarning(location: string, error: unknown): void {\n dispatchToSinks(location, error, \"warning\");\n}\n\n\ntype Status = {\n statusCode: number,\n message: string,\n};\n\ntype StatusErrorConstructorParameters =\n| [\n status: Status,\n message?: string\n]\n| [\n statusCode: number | Status,\n message: string,\n];\n\nexport class StatusError extends Error {\n private readonly __stackStatusErrorBrand = \"stack-status-error-brand-sentinel\" as const;\n public name = \"StatusError\";\n public readonly statusCode: number;\n\n public static BadRequest = { statusCode: 400, message: \"Bad Request\" };\n public static Unauthorized = { statusCode: 401, message: \"Unauthorized\" };\n public static PaymentRequired = { statusCode: 402, message: \"Payment Required\" };\n public static Forbidden = { statusCode: 403, message: \"Forbidden\" };\n public static NotFound = { statusCode: 404, message: \"Not Found\" };\n public static MethodNotAllowed = { statusCode: 405, message: \"Method Not Allowed\" };\n public static NotAcceptable = { statusCode: 406, message: \"Not Acceptable\" };\n public static ProxyAuthenticationRequired = { statusCode: 407, message: \"Proxy Authentication Required\" };\n public static RequestTimeout = { statusCode: 408, message: \"Request Timeout\" };\n public static Conflict = { statusCode: 409, message: \"Conflict\" };\n public static Gone = { statusCode: 410, message: \"Gone\" };\n public static LengthRequired = { statusCode: 411, message: \"Length Required\" };\n public static PreconditionFailed = { statusCode: 412, message: \"Precondition Failed\" };\n public static PayloadTooLarge = { statusCode: 413, message: \"Payload Too Large\" };\n public static URITooLong = { statusCode: 414, message: \"URI Too Long\" };\n public static UnsupportedMediaType = { statusCode: 415, message: \"Unsupported Media Type\" };\n public static RangeNotSatisfiable = { statusCode: 416, message: \"Range Not Satisfiable\" };\n public static ExpectationFailed = { statusCode: 417, message: \"Expectation Failed\" };\n public static ImATeapot = { statusCode: 418, message: \"I'm a teapot\" };\n public static MisdirectedRequest = { statusCode: 421, message: \"Misdirected Request\" };\n public static UnprocessableEntity = { statusCode: 422, message: \"Unprocessable Entity\" };\n public static Locked = { statusCode: 423, message: \"Locked\" };\n public static FailedDependency = { statusCode: 424, message: \"Failed Dependency\" };\n public static TooEarly = { statusCode: 425, message: \"Too Early\" };\n public static UpgradeRequired = { statusCode: 426, message: \"Upgrade Required\" };\n public static PreconditionRequired = { statusCode: 428, message: \"Precondition Required\" };\n public static TooManyRequests = { statusCode: 429, message: \"Too Many Requests\" };\n public static RequestHeaderFieldsTooLarge = { statusCode: 431, message: \"Request Header Fields Too Large\" };\n public static UnavailableForLegalReasons = { statusCode: 451, message: \"Unavailable For Legal Reasons\" };\n\n public static InternalServerError = { statusCode: 500, message: \"Internal Server Error\" };\n public static NotImplemented = { statusCode: 501, message: \"Not Implemented\" };\n public static BadGateway = { statusCode: 502, message: \"Bad Gateway\" };\n public static ServiceUnavailable = { statusCode: 503, message: \"Service Unavailable\" };\n public static GatewayTimeout = { statusCode: 504, message: \"Gateway Timeout\" };\n public static HTTPVersionNotSupported = { statusCode: 505, message: \"HTTP Version Not Supported\" };\n public static VariantAlsoNegotiates = { statusCode: 506, message: \"Variant Also Negotiates\" };\n public static InsufficientStorage = { statusCode: 507, message: \"Insufficient Storage\" };\n public static LoopDetected = { statusCode: 508, message: \"Loop Detected\" };\n public static NotExtended = { statusCode: 510, message: \"Not Extended\" };\n public static NetworkAuthenticationRequired = { statusCode: 511, message: \"Network Authentication Required\" };\n\n\n constructor(...args: StatusErrorConstructorParameters);\n constructor(\n status: number | Status,\n message?: string,\n ) {\n if (typeof status === \"object\") {\n message ??= status.message;\n status = status.statusCode;\n }\n super(message);\n this.statusCode = status;\n if (!message) {\n throw new HexclaveAssertionError(\"StatusError always requires a message unless a Status object is passed\", { cause: this });\n }\n }\n\n public static isStatusError(error: unknown): error is StatusError {\n // like instanceof, but also works for errors thrown in other realms or by different versions of the same package\n return typeof error === \"object\" && error !== null && \"__stackStatusErrorBrand\" in error && error.__stackStatusErrorBrand === \"stack-status-error-brand-sentinel\";\n }\n\n public isClientError() {\n return this.statusCode >= 400 && this.statusCode < 500;\n }\n\n public isServerError() {\n return !this.isClientError();\n }\n\n public getStatusCode(): number {\n return this.statusCode;\n }\n\n public getBody(): Uint8Array {\n return new TextEncoder().encode(this.message);\n }\n\n public getHeaders(): Record<string, string[]> {\n return {\n \"Content-Type\": [\"text/plain; charset=utf-8\"],\n };\n }\n\n public toDescriptiveJson(): Json {\n return {\n status_code: this.getStatusCode(),\n message: this.message,\n headers: this.getHeaders(),\n };\n }\n\n /**\n * @deprecated this is not a good way to make status errors human-readable, use toDescriptiveJson instead\n */\n public toHttpJson(): Json {\n return {\n status_code: this.statusCode,\n body: this.message,\n headers: this.getHeaders(),\n };\n }\n}\nStatusError.prototype.name = \"StatusError\";\n"],"mappings":";;;;AASA,SAAgB,SAAS,GAAG,MAAoB;CAC9C,IAAI,OAAO,KAAK,OAAO,UACrB,MAAM,IAAI,uBAAuB,KAAK,IAAI,KAAK,EAAE;MAC5C,IAAI,KAAK,cAAc,OAC5B,MAAM,KAAK;MAGX,MAAM,IAAI,YAAY,GAAG,IAAI;AAEjC;AAEA,SAAS,yBAAyB,OAAuB;CAEvD,MAAM,gCAAe,IAAI,MAAM,EAAA,CAAE,OAAO,WAAW,SAAS;CAC5D,OAAO,MAAM,MAAM,IAAI,CAAC,CAAC,MAAM,eAAe,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI;AAChE;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,kBAAkB,OAAc,GAAG,QAAuB;CAExE,MAAM,qBAAqB,MAAM,OAAO,SAAS,IAAI;CAMrD,MAAM,YAAY,0CAAyB,IAAI,MAAM,EAAA,CAAE,SAAS,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC;CAGhF,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,WAAW,yBAAyB,MAAM,SAAS,EAAE;EAC3D,MAAM,UAAU,qBAAqB,KAAK,QAAQ,YAAY,OAAO;CACvE;AACF;AAGA,IAAa,yBAAb,cAA4C,MAAM;CAChD,YAAY,SAAiB,WAAgE;EAC3F,MAAM,aAAa;EACnB,MAAM,GAAG,UAAU,QAAQ,SAAS,UAAU,IAAI,KAAK,cAAc,KAAK,aAAa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AAY,CAAC,CAAC,OAAO,KAAK,OAAO;CAC9C;CAEA,aAA8C;EAC5C,OAAO,EACL,gBAAgB,CAAC,2BAA2B,EAC9C;CACF;CAEA,oBAAiC;EAC/B,OAAO;GACL,aAAa,KAAK,cAAc;GAChC,SAAS,KAAK;GACd,SAAS,KAAK,WAAW;EAC3B;CACF;;;;CAKA,aAA0B;EACxB,OAAO;GACL,aAAa,KAAK;GAClB,MAAM,KAAK;GACX,SAAS,KAAK,WAAW;EAC3B;CACF;AACF;AACA,YAAY,UAAU,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"esbuild.d.ts","names":[],"sources":["../../../src/utils/esbuild.tsx"],"mappings":";;;iBA0BgB,iBAAA,
|
|
1
|
+
{"version":3,"file":"esbuild.d.ts","names":[],"sources":["../../../src/utils/esbuild.tsx"],"mappings":";;;iBA0BgB,iBAAA,IAAqB,OAAO;AAAA,iBAgDtB,gBAAA,CAAiB,WAAA,EAAa,MAAA;EAA2B,WAAA;AAAA,GAAuB,OAAA;EACpG,MAAA;EACA,gBAAA,GAAmB,MAAA;EACnB,aAAA;EACA,SAAA;EACA,gBAAA;AAAA,IACO,OAAA,CAAQ,MAAA"}
|
|
@@ -6,7 +6,6 @@ import { createGlobalAsync } from "./globals.js";
|
|
|
6
6
|
import { Result } from "./results.js";
|
|
7
7
|
import * as esbuild from "esbuild-wasm/lib/browser.js";
|
|
8
8
|
import { traceSpan, withTraceSpan } from "./telemetry.js";
|
|
9
|
-
|
|
10
9
|
//#region src/utils/esbuild.tsx
|
|
11
10
|
globalThis.self ??= globalThis;
|
|
12
11
|
let esbuildInitializePromise = null;
|
|
@@ -55,7 +54,7 @@ async function bundleJavaScript(sourceFiles, options = {}) {
|
|
|
55
54
|
const externalPackagesMap = new Map(Object.entries(options.externalPackages ?? {}));
|
|
56
55
|
const keepAsImports = options.keepAsImports ?? [];
|
|
57
56
|
const httpImportCache = /* @__PURE__ */ new Map();
|
|
58
|
-
const extToLoader = new Map([
|
|
57
|
+
const extToLoader = /* @__PURE__ */ new Map([
|
|
59
58
|
["tsx", "tsx"],
|
|
60
59
|
["ts", "ts"],
|
|
61
60
|
["js", "js"],
|
|
@@ -175,7 +174,7 @@ async function bundleJavaScript(sourceFiles, options = {}) {
|
|
|
175
174
|
if (result.outputFiles.length > 0) return Result.ok(result.outputFiles[0].text);
|
|
176
175
|
return throwErr("No output generated??");
|
|
177
176
|
}
|
|
178
|
-
|
|
179
177
|
//#endregion
|
|
180
178
|
export { bundleJavaScript, initializeEsbuild };
|
|
179
|
+
|
|
181
180
|
//# sourceMappingURL=esbuild.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"esbuild.js","names":[],"sources":["../../../src/utils/esbuild.tsx"],"sourcesContent":["import * as esbuild from 'esbuild-wasm/lib/browser.js';\nimport { join } from 'path';\nimport { getProcessEnv, isBrowserLike } from './env';\nimport { captureError, HexclaveAssertionError, throwErr } from \"./errors\";\nimport { createGlobalAsync } from './globals';\nimport { ignoreUnhandledRejection, runAsynchronously } from './promises';\nimport { Result } from \"./results\";\nimport { traceSpan, withTraceSpan } from './telemetry';\n\n\n// esbuild requires self property to be set, and it is not set by default in nodejs\n(globalThis.self as any) ??= globalThis as any;\n\nlet esbuildInitializePromise: Promise<void> | null = null;\n\nif (typeof process !== \"undefined\" && typeof process.exit === \"function\" && getProcessEnv(\"NODE_ENV\") === 'development') {\n // On development Node.js servers, initialize ESBuild as soon as the module is imported so we have to wait less on the first request\n runAsynchronously(async () => {\n try {\n await initializeEsbuild();\n } catch (e) {\n captureError(\"initialize-esbuild-in-dev\", e);\n }\n });\n}\n\nexport function initializeEsbuild(): Promise<void> {\n const esbuildWasmUrl = `https://unpkg.com/esbuild-wasm@${esbuild.version}/esbuild.wasm`;\n if (esbuildInitializePromise == null) {\n esbuildInitializePromise = withTraceSpan('initializeEsbuild', async () => {\n try {\n let initOptions;\n if (isBrowserLike()) {\n initOptions = {\n wasmURL: esbuildWasmUrl,\n };\n } else {\n const esbuildWasmModule = await createGlobalAsync('esbuildWasmModule', async () => {\n const esbuildWasmResponse = await fetch(esbuildWasmUrl);\n if (!esbuildWasmResponse.ok) {\n throw new HexclaveAssertionError(`Failed to fetch esbuild.wasm: ${esbuildWasmResponse.status} ${esbuildWasmResponse.statusText}: ${await esbuildWasmResponse.text()}`);\n }\n const esbuildWasm = await esbuildWasmResponse.arrayBuffer();\n const esbuildWasmArray = new Uint8Array(esbuildWasm);\n if (esbuildWasmArray[0] !== 0x00 || esbuildWasmArray[1] !== 0x61 || esbuildWasmArray[2] !== 0x73 || esbuildWasmArray[3] !== 0x6d) {\n throw new HexclaveAssertionError(`Invalid esbuild.wasm file: ${new TextDecoder().decode(esbuildWasmArray)}`);\n }\n return new WebAssembly.Module(esbuildWasm);\n });\n initOptions = {\n wasmModule: esbuildWasmModule,\n worker: false,\n };\n }\n try {\n await esbuild.initialize(initOptions);\n } catch (e) {\n if (e instanceof Error && e.message === 'Cannot call \"initialize\" more than once') {\n // this happens especially in local development, just ignore\n } else {\n throw e;\n }\n }\n } catch (e) {\n esbuildInitializePromise = null;\n throw new HexclaveAssertionError(\"Failed to initialize ESBuild\", { cause: e });\n }\n })();\n ignoreUnhandledRejection(esbuildInitializePromise);\n }\n\n return esbuildInitializePromise;\n}\n\nexport async function bundleJavaScript(sourceFiles: Record<string, string> & { '/entry.js': string }, options: {\n format?: 'iife' | 'esm' | 'cjs',\n externalPackages?: Record<string, string>,\n keepAsImports?: string[],\n sourcemap?: false | 'inline',\n allowHttpImports?: boolean,\n} = {}): Promise<Result<string, string>> {\n await initializeEsbuild();\n\n const sourceFilesMap = new Map(Object.entries(sourceFiles));\n const externalPackagesMap = new Map(Object.entries(options.externalPackages ?? {}));\n const keepAsImports = options.keepAsImports ?? [];\n\n const httpImportCache = new Map<string, { contents: string, loader: esbuild.Loader, resolveDir: string }>();\n\n const extToLoader: Map<string, esbuild.Loader> = new Map([\n ['tsx', 'tsx'],\n ['ts', 'ts'],\n ['js', 'js'],\n ['jsx', 'jsx'],\n ['json', 'json'],\n ['css', 'css'],\n ]);\n let result;\n try {\n result = await traceSpan('bundleJavaScript', async () => await esbuild.build({\n entryPoints: ['/entry.js'],\n bundle: true,\n write: false,\n format: options.format ?? 'iife',\n platform: 'browser',\n target: 'es2015',\n jsx: 'automatic',\n sourcemap: options.sourcemap ?? 'inline',\n external: keepAsImports,\n plugins: [\n ...options.allowHttpImports ? [{\n name: \"esm-sh-only\",\n setup(build: esbuild.PluginBuild) {\n // Handle absolute URLs and relative imports from esm.sh modules.\n build.onResolve({ filter: /.*/ }, (args) => {\n // Only touch absolute http(s) specifiers or children of our own namespace\n const isHttp = args.path.startsWith(\"http://\") || args.path.startsWith(\"https://\");\n const fromEsmNs = args.namespace === \"esm-sh\";\n\n if (!isHttp && !fromEsmNs) return null; // Let other plugins handle bare/relative/local\n\n // Resolve relative URLs inside esm.sh-fetched modules\n const url = new URL(args.path, fromEsmNs ? args.importer : undefined);\n\n if (url.protocol !== \"https:\" || url.host !== \"esm.sh\") {\n throw new Error(`Blocked non-esm.sh URL import: ${url.href}`);\n }\n\n return { path: url.href, namespace: \"esm-sh\" };\n });\n\n build.onLoad({ filter: /.*/, namespace: \"esm-sh\" }, async (args) => {\n if (httpImportCache.has(args.path)) return httpImportCache.get(args.path)!;\n\n const res = await fetch(args.path, { redirect: \"follow\" });\n if (!res.ok) throw new Error(`Fetch ${res.status} ${res.statusText} for ${args.path}`);\n const finalUrl = new URL(res.url);\n // Defensive: follow shouldn’t leave esm.sh, but re-check.\n if (finalUrl.host !== \"esm.sh\") {\n throw new Error(`Redirect escaped esm.sh: ${finalUrl.href}`);\n }\n\n const ct = (res.headers.get(\"content-type\") || \"\").toLowerCase();\n let loader: esbuild.Loader =\n ct.includes(\"css\") ? \"css\" :\n ct.includes(\"json\") ? \"json\" :\n ct.includes(\"typescript\") ? \"ts\" :\n ct.includes(\"jsx\") ? \"jsx\" :\n ct.includes(\"tsx\") ? \"tsx\" :\n \"js\";\n\n // Fallback by extension (esm.sh sometimes omits CT)\n const p = finalUrl.pathname;\n if (p.endsWith(\".css\")) loader = \"css\";\n else if (p.endsWith(\".json\")) loader = \"json\";\n else if (p.endsWith(\".ts\")) loader = \"ts\";\n else if (p.endsWith(\".tsx\")) loader = \"tsx\";\n else if (p.endsWith(\".jsx\")) loader = \"jsx\";\n\n const contents = await res.text();\n const result = {\n contents,\n loader,\n // Ensures relative imports inside that module resolve against the file’s URL\n resolveDir: new URL(\".\", finalUrl.href).toString(),\n watchFiles: [finalUrl.href],\n };\n httpImportCache.set(args.path, result);\n return result;\n });\n },\n } as esbuild.Plugin] : [],\n {\n name: 'replace-packages-with-globals',\n setup(build) {\n build.onResolve({ filter: /.*/ }, args => {\n // Skip packages that should remain external (not be shimmed)\n if (keepAsImports.includes(args.path)) {\n return undefined;\n }\n if (externalPackagesMap.has(args.path)) {\n return { path: args.path, namespace: 'package-shim' };\n }\n return undefined;\n });\n\n build.onLoad({ filter: /.*/, namespace: 'package-shim' }, (args) => {\n const contents = externalPackagesMap.get(args.path);\n if (contents == null) throw new HexclaveAssertionError(`esbuild requested file ${args.path} that is not in the virtual file system`);\n\n return { contents, loader: 'ts' };\n });\n },\n },\n {\n name: 'virtual-fs',\n setup(build) {\n build.onResolve({ filter: /.*/ }, args => {\n const absolutePath = join(\"/\", args.path);\n if (sourceFilesMap.has(absolutePath)) {\n return { path: absolutePath, namespace: 'virtual' };\n }\n return undefined;\n });\n\n /* 2️⃣ Load the module from the map */\n build.onLoad({ filter: /.*/, namespace: 'virtual' }, args => {\n const contents = sourceFilesMap.get(args.path);\n if (contents == null) throw new HexclaveAssertionError(`esbuild requested file ${args.path} that is not in the virtual file system`);\n\n const ext = args.path.split('.').pop() ?? '';\n const loader = extToLoader.get(ext) ?? throwErr(`esbuild requested file ${args.path} with unknown extension ${ext}`);\n\n return { contents, loader };\n });\n },\n },\n ],\n }));\n } catch (e) {\n if (e instanceof Error && e.message.startsWith(\"Build failed with \")) {\n return Result.error(e.message);\n }\n throw e;\n }\n\n if (result.errors.length > 0) {\n return Result.error(result.errors.map(e => e.text).join('\\n'));\n }\n\n if (result.outputFiles.length > 0) {\n return Result.ok(result.outputFiles[0].text);\n }\n return throwErr(\"No output generated??\");\n}\n"],"mappings":";;;;;;;;;;AAWA,AAAC,WAAW,SAAiB;AAE7B,IAAI,2BAAiD;AAErD,IAAI,OAAO,YAAY,eAAe,OAAO,QAAQ,SAAS,cAAc,cAAc,WAAW,KAAK,cAExG,mBAAkB,YAAY;AAC5B,KAAI;AACF,QAAM,mBAAmB;UAClB,GAAG;AACV,eAAa,6BAA6B,EAAE;;EAE9C;AAGJ,SAAgB,oBAAmC;CACjD,MAAM,iBAAiB,kCAAkC,QAAQ,QAAQ;AACzE,KAAI,4BAA4B,MAAM;AACpC,6BAA2B,cAAc,qBAAqB,YAAY;AACxE,OAAI;IACF,IAAI;AACJ,QAAI,eAAe,CACjB,eAAc,EACZ,SAAS,gBACV;QAcD,eAAc;KACZ,YAbwB,MAAM,kBAAkB,qBAAqB,YAAY;MACjF,MAAM,sBAAsB,MAAM,MAAM,eAAe;AACvD,UAAI,CAAC,oBAAoB,GACvB,OAAM,IAAI,uBAAuB,iCAAiC,oBAAoB,OAAO,GAAG,oBAAoB,WAAW,IAAI,MAAM,oBAAoB,MAAM,GAAG;MAExK,MAAM,cAAc,MAAM,oBAAoB,aAAa;MAC3D,MAAM,mBAAmB,IAAI,WAAW,YAAY;AACpD,UAAI,iBAAiB,OAAO,KAAQ,iBAAiB,OAAO,MAAQ,iBAAiB,OAAO,OAAQ,iBAAiB,OAAO,IAC1H,OAAM,IAAI,uBAAuB,8BAA8B,IAAI,aAAa,CAAC,OAAO,iBAAiB,GAAG;AAE9G,aAAO,IAAI,YAAY,OAAO,YAAY;OAC1C;KAGA,QAAQ;KACT;AAEH,QAAI;AACF,WAAM,QAAQ,WAAW,YAAY;aAC9B,GAAG;AACV,SAAI,aAAa,SAAS,EAAE,YAAY,6CAA2C,OAG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K,CAAC;AAGhE,KAAI,OAAO,YAAY,SAAS,EAC9B,QAAO,OAAO,GAAG,OAAO,YAAY,GAAG,KAAK;AAE9C,QAAO,SAAS,wBAAwB"}
|
|
1
|
+
{"version":3,"file":"esbuild.js","names":[],"sources":["../../../src/utils/esbuild.tsx"],"sourcesContent":["import * as esbuild from 'esbuild-wasm/lib/browser.js';\nimport { join } from 'path';\nimport { getProcessEnv, isBrowserLike } from './env';\nimport { captureError, HexclaveAssertionError, throwErr } from \"./errors\";\nimport { createGlobalAsync } from './globals';\nimport { ignoreUnhandledRejection, runAsynchronously } from './promises';\nimport { Result } from \"./results\";\nimport { traceSpan, withTraceSpan } from './telemetry';\n\n\n// esbuild requires self property to be set, and it is not set by default in nodejs\n(globalThis.self as any) ??= globalThis as any;\n\nlet esbuildInitializePromise: Promise<void> | null = null;\n\nif (typeof process !== \"undefined\" && typeof process.exit === \"function\" && getProcessEnv(\"NODE_ENV\") === 'development') {\n // On development Node.js servers, initialize ESBuild as soon as the module is imported so we have to wait less on the first request\n runAsynchronously(async () => {\n try {\n await initializeEsbuild();\n } catch (e) {\n captureError(\"initialize-esbuild-in-dev\", e);\n }\n });\n}\n\nexport function initializeEsbuild(): Promise<void> {\n const esbuildWasmUrl = `https://unpkg.com/esbuild-wasm@${esbuild.version}/esbuild.wasm`;\n if (esbuildInitializePromise == null) {\n esbuildInitializePromise = withTraceSpan('initializeEsbuild', async () => {\n try {\n let initOptions;\n if (isBrowserLike()) {\n initOptions = {\n wasmURL: esbuildWasmUrl,\n };\n } else {\n const esbuildWasmModule = await createGlobalAsync('esbuildWasmModule', async () => {\n const esbuildWasmResponse = await fetch(esbuildWasmUrl);\n if (!esbuildWasmResponse.ok) {\n throw new HexclaveAssertionError(`Failed to fetch esbuild.wasm: ${esbuildWasmResponse.status} ${esbuildWasmResponse.statusText}: ${await esbuildWasmResponse.text()}`);\n }\n const esbuildWasm = await esbuildWasmResponse.arrayBuffer();\n const esbuildWasmArray = new Uint8Array(esbuildWasm);\n if (esbuildWasmArray[0] !== 0x00 || esbuildWasmArray[1] !== 0x61 || esbuildWasmArray[2] !== 0x73 || esbuildWasmArray[3] !== 0x6d) {\n throw new HexclaveAssertionError(`Invalid esbuild.wasm file: ${new TextDecoder().decode(esbuildWasmArray)}`);\n }\n return new WebAssembly.Module(esbuildWasm);\n });\n initOptions = {\n wasmModule: esbuildWasmModule,\n worker: false,\n };\n }\n try {\n await esbuild.initialize(initOptions);\n } catch (e) {\n if (e instanceof Error && e.message === 'Cannot call \"initialize\" more than once') {\n // this happens especially in local development, just ignore\n } else {\n throw e;\n }\n }\n } catch (e) {\n esbuildInitializePromise = null;\n throw new HexclaveAssertionError(\"Failed to initialize ESBuild\", { cause: e });\n }\n })();\n ignoreUnhandledRejection(esbuildInitializePromise);\n }\n\n return esbuildInitializePromise;\n}\n\nexport async function bundleJavaScript(sourceFiles: Record<string, string> & { '/entry.js': string }, options: {\n format?: 'iife' | 'esm' | 'cjs',\n externalPackages?: Record<string, string>,\n keepAsImports?: string[],\n sourcemap?: false | 'inline',\n allowHttpImports?: boolean,\n} = {}): Promise<Result<string, string>> {\n await initializeEsbuild();\n\n const sourceFilesMap = new Map(Object.entries(sourceFiles));\n const externalPackagesMap = new Map(Object.entries(options.externalPackages ?? {}));\n const keepAsImports = options.keepAsImports ?? [];\n\n const httpImportCache = new Map<string, { contents: string, loader: esbuild.Loader, resolveDir: string }>();\n\n const extToLoader: Map<string, esbuild.Loader> = new Map([\n ['tsx', 'tsx'],\n ['ts', 'ts'],\n ['js', 'js'],\n ['jsx', 'jsx'],\n ['json', 'json'],\n ['css', 'css'],\n ]);\n let result;\n try {\n result = await traceSpan('bundleJavaScript', async () => await esbuild.build({\n entryPoints: ['/entry.js'],\n bundle: true,\n write: false,\n format: options.format ?? 'iife',\n platform: 'browser',\n target: 'es2015',\n jsx: 'automatic',\n sourcemap: options.sourcemap ?? 'inline',\n external: keepAsImports,\n plugins: [\n ...options.allowHttpImports ? [{\n name: \"esm-sh-only\",\n setup(build: esbuild.PluginBuild) {\n // Handle absolute URLs and relative imports from esm.sh modules.\n build.onResolve({ filter: /.*/ }, (args) => {\n // Only touch absolute http(s) specifiers or children of our own namespace\n const isHttp = args.path.startsWith(\"http://\") || args.path.startsWith(\"https://\");\n const fromEsmNs = args.namespace === \"esm-sh\";\n\n if (!isHttp && !fromEsmNs) return null; // Let other plugins handle bare/relative/local\n\n // Resolve relative URLs inside esm.sh-fetched modules\n const url = new URL(args.path, fromEsmNs ? args.importer : undefined);\n\n if (url.protocol !== \"https:\" || url.host !== \"esm.sh\") {\n throw new Error(`Blocked non-esm.sh URL import: ${url.href}`);\n }\n\n return { path: url.href, namespace: \"esm-sh\" };\n });\n\n build.onLoad({ filter: /.*/, namespace: \"esm-sh\" }, async (args) => {\n if (httpImportCache.has(args.path)) return httpImportCache.get(args.path)!;\n\n const res = await fetch(args.path, { redirect: \"follow\" });\n if (!res.ok) throw new Error(`Fetch ${res.status} ${res.statusText} for ${args.path}`);\n const finalUrl = new URL(res.url);\n // Defensive: follow shouldn’t leave esm.sh, but re-check.\n if (finalUrl.host !== \"esm.sh\") {\n throw new Error(`Redirect escaped esm.sh: ${finalUrl.href}`);\n }\n\n const ct = (res.headers.get(\"content-type\") || \"\").toLowerCase();\n let loader: esbuild.Loader =\n ct.includes(\"css\") ? \"css\" :\n ct.includes(\"json\") ? \"json\" :\n ct.includes(\"typescript\") ? \"ts\" :\n ct.includes(\"jsx\") ? \"jsx\" :\n ct.includes(\"tsx\") ? \"tsx\" :\n \"js\";\n\n // Fallback by extension (esm.sh sometimes omits CT)\n const p = finalUrl.pathname;\n if (p.endsWith(\".css\")) loader = \"css\";\n else if (p.endsWith(\".json\")) loader = \"json\";\n else if (p.endsWith(\".ts\")) loader = \"ts\";\n else if (p.endsWith(\".tsx\")) loader = \"tsx\";\n else if (p.endsWith(\".jsx\")) loader = \"jsx\";\n\n const contents = await res.text();\n const result = {\n contents,\n loader,\n // Ensures relative imports inside that module resolve against the file’s URL\n resolveDir: new URL(\".\", finalUrl.href).toString(),\n watchFiles: [finalUrl.href],\n };\n httpImportCache.set(args.path, result);\n return result;\n });\n },\n } as esbuild.Plugin] : [],\n {\n name: 'replace-packages-with-globals',\n setup(build) {\n build.onResolve({ filter: /.*/ }, args => {\n // Skip packages that should remain external (not be shimmed)\n if (keepAsImports.includes(args.path)) {\n return undefined;\n }\n if (externalPackagesMap.has(args.path)) {\n return { path: args.path, namespace: 'package-shim' };\n }\n return undefined;\n });\n\n build.onLoad({ filter: /.*/, namespace: 'package-shim' }, (args) => {\n const contents = externalPackagesMap.get(args.path);\n if (contents == null) throw new HexclaveAssertionError(`esbuild requested file ${args.path} that is not in the virtual file system`);\n\n return { contents, loader: 'ts' };\n });\n },\n },\n {\n name: 'virtual-fs',\n setup(build) {\n build.onResolve({ filter: /.*/ }, args => {\n const absolutePath = join(\"/\", args.path);\n if (sourceFilesMap.has(absolutePath)) {\n return { path: absolutePath, namespace: 'virtual' };\n }\n return undefined;\n });\n\n /* 2️⃣ Load the module from the map */\n build.onLoad({ filter: /.*/, namespace: 'virtual' }, args => {\n const contents = sourceFilesMap.get(args.path);\n if (contents == null) throw new HexclaveAssertionError(`esbuild requested file ${args.path} that is not in the virtual file system`);\n\n const ext = args.path.split('.').pop() ?? '';\n const loader = extToLoader.get(ext) ?? throwErr(`esbuild requested file ${args.path} with unknown extension ${ext}`);\n\n return { contents, loader };\n });\n },\n },\n ],\n }));\n } catch (e) {\n if (e instanceof Error && e.message.startsWith(\"Build failed with \")) {\n return Result.error(e.message);\n }\n throw e;\n }\n\n if (result.errors.length > 0) {\n return Result.error(result.errors.map(e => e.text).join('\\n'));\n }\n\n if (result.outputFiles.length > 0) {\n return Result.ok(result.outputFiles[0].text);\n }\n return throwErr(\"No output generated??\");\n}\n"],"mappings":";;;;;;;;;AAWA,WAAY,SAAiB;AAE7B,IAAI,2BAAiD;AAErD,IAAI,OAAO,YAAY,eAAe,OAAO,QAAQ,SAAS,cAAc,cAAc,UAAU,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-1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"featurebase.d.ts","names":[],"sources":["../../../src/utils/featurebase.tsx"],"mappings":";KAGY,eAAA;EACV,MAAA;EACA,KAAA;EACA,IAAA;EACA,cAAA;AAAA;AAAA,KAGU,gBAAA;EACV,EAAA;EACA,YAAA;EACA,WAAA;EACA,eAAA;AAAA;;;;;;;;;iBAgKoB,0BAAA,CACpB,gBAAA,EAAkB,gBAAA,EAClB,OAAA;EAAY,MAAA;AAAA,IACX,
|
|
1
|
+
{"version":3,"file":"featurebase.d.ts","names":[],"sources":["../../../src/utils/featurebase.tsx"],"mappings":";KAGY,eAAA;EACV,MAAA;EACA,KAAA;EACA,IAAA;EACA,cAAA;AAAA;AAAA,KAGU,gBAAA;EACV,EAAA;EACA,YAAA;EACA,WAAA;EACA,eAAA;AAAA;;;;;;;;;iBAgKoB,0BAAA,CACpB,gBAAA,EAAkB,gBAAA,EAClB,OAAA;EAAY,MAAA;AAAA,IACX,OAAO;EAAG,MAAA;EAAgB,KAAA;AAAA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { HexclaveAssertionError } from "./errors.js";
|
|
2
2
|
import { getEnvVariable } from "./env.js";
|
|
3
|
-
|
|
4
3
|
//#region src/utils/featurebase.tsx
|
|
5
4
|
/**
|
|
6
5
|
* Find a Featurebase user by their Hexclave user ID
|
|
@@ -160,7 +159,7 @@ async function getOrCreateFeaturebaseUser(hexclaveAuthUser, options) {
|
|
|
160
159
|
email: created.email
|
|
161
160
|
};
|
|
162
161
|
}
|
|
163
|
-
|
|
164
162
|
//#endregion
|
|
165
163
|
export { getOrCreateFeaturebaseUser };
|
|
164
|
+
|
|
166
165
|
//# sourceMappingURL=featurebase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"featurebase.js","names":[],"sources":["../../../src/utils/featurebase.tsx"],"sourcesContent":["import { getEnvVariable } from \"./env\";\nimport { HexclaveAssertionError } from \"./errors\";\n\nexport type FeaturebaseUser = {\n userId: string,\n email: string,\n name?: string,\n profilePicture?: string,\n};\n\nexport type HexclaveAuthUser = {\n id: string,\n primaryEmail: string | null,\n displayName?: string | null,\n profileImageUrl?: string | null,\n};\n\n/**\n * Find a Featurebase user by their Hexclave user ID\n */\nasync function findFeaturebaseUserById(hexclaveAuthUserId: string, apiKey: string): Promise<FeaturebaseUser | null> {\n try {\n const response = await fetch(`https://do.featurebase.app/v2/organization/identifyUser?id=${hexclaveAuthUserId}`, {\n method: 'GET',\n headers: {\n 'X-API-Key': apiKey,\n },\n });\n\n if (response.status === 404) {\n return null;\n }\n\n if (!response.ok) {\n throw new HexclaveAssertionError(`Failed to find Featurebase user by ID: ${response.statusText}`);\n }\n\n const data = await response.json();\n const user = data.user;\n\n if (!user) {\n throw new HexclaveAssertionError(`Featurebase API returned success but no user data for ID: ${hexclaveAuthUserId}`, { data });\n }\n\n return {\n userId: user.externalUserId || user.userId || hexclaveAuthUserId,\n email: user.email,\n name: user.name,\n profilePicture: user.profilePicture,\n };\n } catch (error) {\n if (error instanceof HexclaveAssertionError) {\n throw error;\n }\n throw new HexclaveAssertionError(\"Failed to find Featurebase user by ID\", { cause: error });\n }\n}\n\n/**\n * Find a Featurebase user by their email address\n */\nasync function findFeaturebaseUserByEmail(email: string, apiKey: string): Promise<FeaturebaseUser | null> {\n try {\n const response = await fetch(`https://do.featurebase.app/v2/organization/identifyUser?email=${encodeURIComponent(email)}`, {\n method: 'GET',\n headers: {\n 'X-API-Key': apiKey,\n },\n });\n\n if (response.status === 404) {\n return null;\n }\n\n if (!response.ok) {\n throw new HexclaveAssertionError(`Failed to find Featurebase user by email: ${response.statusText}`);\n }\n\n const data = await response.json();\n const user = data.user;\n\n if (!user) {\n throw new HexclaveAssertionError(`Featurebase API returned success but no user data for email: ${email}`, { data });\n }\n\n return {\n userId: user.externalUserId || user.userId,\n email: user.email,\n name: user.name,\n profilePicture: user.profilePicture,\n };\n } catch (error) {\n console.error('Error finding Featurebase user by email:', error);\n return null;\n }\n}\n\n/**\n * Create a new Featurebase user using the identifyUser endpoint\n */\nasync function createFeaturebaseUser(user: FeaturebaseUser, apiKey: string): Promise<FeaturebaseUser> {\n try {\n const response = await fetch('https://do.featurebase.app/v2/organization/identifyUser', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'X-API-Key': apiKey,\n },\n body: JSON.stringify({\n userId: user.userId,\n email: user.email,\n name: user.name,\n profilePicture: user.profilePicture,\n }),\n });\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({}));\n throw new HexclaveAssertionError(`Failed to create Featurebase user: ${errorData.error || response.statusText}`, { errorData });\n }\n\n // The identifyUser endpoint just returns { \"success\": true }, so we return the input data\n return user;\n } catch (error) {\n if (error instanceof HexclaveAssertionError) {\n throw error;\n }\n throw new HexclaveAssertionError(\"Failed to create Featurebase user\", { cause: error });\n\n }\n}\n\n/**\n * Update an existing Featurebase user (excluding email)\n */\nasync function updateFeaturebaseUser(userId: string, updates: Partial<Omit<FeaturebaseUser, 'userId' | 'email'>>, apiKey: string): Promise<FeaturebaseUser> {\n try {\n const response = await fetch(`https://do.featurebase.app/v2/users/${userId}`, {\n method: 'PATCH',\n headers: {\n 'Content-Type': 'application/json',\n 'X-API-Key': apiKey,\n },\n body: JSON.stringify(updates),\n });\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({}));\n throw new HexclaveAssertionError(`Failed to update Featurebase user: ${errorData.error || response.statusText}`, { errorData });\n }\n\n const data = await response.json();\n return {\n userId: data.userId || userId,\n email: data.email,\n name: data.name,\n profilePicture: data.profilePicture,\n };\n } catch (error) {\n if (error instanceof HexclaveAssertionError) {\n throw error;\n }\n throw new HexclaveAssertionError(\"Failed to update Featurebase user\", { cause: error });\n }\n}\n\n/**\n * Get or create a Featurebase user based on Hexclave user data.\n * This function ensures that:\n * 1. We never change a user's email address on Featurebase\n * 2. We use Hexclave user ID as the primary identifier\n * 3. We handle email conflicts by using fallback emails\n * 4. We update profile information when needed\n */\nexport async function getOrCreateFeaturebaseUser(\n hexclaveAuthUser: HexclaveAuthUser,\n options?: { apiKey?: string }\n): Promise<{ userId: string, email: string }> {\n const apiKey = options?.apiKey || getEnvVariable(\"STACK_FEATUREBASE_API_KEY\");\n const fallbackEmail = `${hexclaveAuthUser.id}@featurebase-user.stack-auth-app.com`;\n\n // First, try to find existing user by Hexclave user ID\n const existingById = await findFeaturebaseUserById(hexclaveAuthUser.id, apiKey);\n if (existingById) {\n // Ensure the user has an email on Featurebase.\n let ensuredEmail = existingById.email;\n if (!ensuredEmail) {\n try {\n await createFeaturebaseUser({\n userId: existingById.userId,\n email: fallbackEmail,\n name: hexclaveAuthUser.displayName || undefined,\n profilePicture: hexclaveAuthUser.profileImageUrl || undefined,\n }, apiKey);\n ensuredEmail = fallbackEmail;\n } catch (e) {\n // If setting fallback email failed, keep ensuredEmail as-is (undefined) and let callers handle\n throw new HexclaveAssertionError(`Failed to set fallback email for existing Featurebase user ${existingById.userId}`, { cause: e });\n }\n }\n\n // Update profile information if needed (but not email)\n try {\n const updates: Partial<Omit<FeaturebaseUser, 'userId' | 'email'>> = {};\n\n if (hexclaveAuthUser.displayName && hexclaveAuthUser.displayName !== existingById.name) {\n updates.name = hexclaveAuthUser.displayName;\n }\n\n if (hexclaveAuthUser.profileImageUrl && hexclaveAuthUser.profileImageUrl !== existingById.profilePicture) {\n updates.profilePicture = hexclaveAuthUser.profileImageUrl;\n }\n\n if (Object.keys(updates).length > 0) {\n await updateFeaturebaseUser(existingById.userId, updates, apiKey);\n }\n } catch (error) {\n console.error('Failed to update existing Featurebase user profile:', error);\n // Continue with existing user data even if update fails\n }\n\n return {\n userId: existingById.userId,\n email: ensuredEmail,\n };\n }\n\n // No existing user found by ID, need to create one\n const candidateEmail = hexclaveAuthUser.primaryEmail ?? fallbackEmail;\n\n // Check if someone already has this email on Featurebase\n const existingByEmail = await findFeaturebaseUserByEmail(candidateEmail, apiKey);\n const safeEmail = existingByEmail ? fallbackEmail : candidateEmail;\n\n // Create new user\n const created = await createFeaturebaseUser({\n userId: hexclaveAuthUser.id,\n email: safeEmail,\n name: hexclaveAuthUser.displayName || hexclaveAuthUser.primaryEmail?.split('@')[0] || 'User',\n profilePicture: hexclaveAuthUser.profileImageUrl || undefined,\n }, apiKey);\n\n return {\n userId: created.userId,\n email: created.email,\n };\n}\n"],"mappings":";;;;;;;AAoBA,eAAe,wBAAwB,oBAA4B,QAAiD;AAClH,KAAI;EACF,MAAM,WAAW,MAAM,MAAM,8DAA8D,sBAAsB;GAC/G,QAAQ;GACR,SAAS,EACP,aAAa,QACd;GACF,CAAC;AAEF,MAAI,SAAS,WAAW,IACtB,QAAO;AAGT,MAAI,CAAC,SAAS,GACZ,OAAM,IAAI,uBAAuB,0CAA0C,SAAS,aAAa;EAGnG,MAAM,OAAO,MAAM,SAAS,MAAM;EAClC,MAAM,OAAO,KAAK;AAElB,MAAI,CAAC,KACH,OAAM,IAAI,uBAAuB,6DAA6D,sBAAsB,EAAE,MAAM,CAAC;AAG/H,SAAO;GACL,QAAQ,KAAK,kBAAkB,KAAK,UAAU;GAC9C,OAAO,KAAK;GACZ,MAAM,KAAK;GACX,gBAAgB,KAAK;GACtB;UACM,OAAO;AACd,MAAI,iBAAiB,uBACnB,OAAM;AAER,QAAM,IAAI,uBAAuB,yCAAyC,EAAE,OAAO,OAAO,CAAC;;;;;;AAO/F,eAAe,2BAA2B,OAAe,QAAiD;AACxG,KAAI;EACF,MAAM,WAAW,MAAM,MAAM,iEAAiE,mBAAmB,MAAM,IAAI;GACzH,QAAQ;GACR,SAAS,EACP,aAAa,QACd;GACF,CAAC;AAEF,MAAI,SAAS,WAAW,IACtB,QAAO;AAGT,MAAI,CAAC,SAAS,GACZ,OAAM,IAAI,uBAAuB,6CAA6C,SAAS,aAAa;EAGtG,MAAM,OAAO,MAAM,SAAS,MAAM;EAClC,MAAM,OAAO,KAAK;AAElB,MAAI,CAAC,KACH,OAAM,IAAI,uBAAuB,gEAAgE,SAAS,EAAE,MAAM,CAAC;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OAAO;AAEV,QAAO;EACL,QAAQ,QAAQ;EAChB,OAAO,QAAQ;EAChB"}
|
|
1
|
+
{"version":3,"file":"featurebase.js","names":[],"sources":["../../../src/utils/featurebase.tsx"],"sourcesContent":["import { getEnvVariable } from \"./env\";\nimport { HexclaveAssertionError } from \"./errors\";\n\nexport type FeaturebaseUser = {\n userId: string,\n email: string,\n name?: string,\n profilePicture?: string,\n};\n\nexport type HexclaveAuthUser = {\n id: string,\n primaryEmail: string | null,\n displayName?: string | null,\n profileImageUrl?: string | null,\n};\n\n/**\n * Find a Featurebase user by their Hexclave user ID\n */\nasync function findFeaturebaseUserById(hexclaveAuthUserId: string, apiKey: string): Promise<FeaturebaseUser | null> {\n try {\n const response = await fetch(`https://do.featurebase.app/v2/organization/identifyUser?id=${hexclaveAuthUserId}`, {\n method: 'GET',\n headers: {\n 'X-API-Key': apiKey,\n },\n });\n\n if (response.status === 404) {\n return null;\n }\n\n if (!response.ok) {\n throw new HexclaveAssertionError(`Failed to find Featurebase user by ID: ${response.statusText}`);\n }\n\n const data = await response.json();\n const user = data.user;\n\n if (!user) {\n throw new HexclaveAssertionError(`Featurebase API returned success but no user data for ID: ${hexclaveAuthUserId}`, { data });\n }\n\n return {\n userId: user.externalUserId || user.userId || hexclaveAuthUserId,\n email: user.email,\n name: user.name,\n profilePicture: user.profilePicture,\n };\n } catch (error) {\n if (error instanceof HexclaveAssertionError) {\n throw error;\n }\n throw new HexclaveAssertionError(\"Failed to find Featurebase user by ID\", { cause: error });\n }\n}\n\n/**\n * Find a Featurebase user by their email address\n */\nasync function findFeaturebaseUserByEmail(email: string, apiKey: string): Promise<FeaturebaseUser | null> {\n try {\n const response = await fetch(`https://do.featurebase.app/v2/organization/identifyUser?email=${encodeURIComponent(email)}`, {\n method: 'GET',\n headers: {\n 'X-API-Key': apiKey,\n },\n });\n\n if (response.status === 404) {\n return null;\n }\n\n if (!response.ok) {\n throw new HexclaveAssertionError(`Failed to find Featurebase user by email: ${response.statusText}`);\n }\n\n const data = await response.json();\n const user = data.user;\n\n if (!user) {\n throw new HexclaveAssertionError(`Featurebase API returned success but no user data for email: ${email}`, { data });\n }\n\n return {\n userId: user.externalUserId || user.userId,\n email: user.email,\n name: user.name,\n profilePicture: user.profilePicture,\n };\n } catch (error) {\n console.error('Error finding Featurebase user by email:', error);\n return null;\n }\n}\n\n/**\n * Create a new Featurebase user using the identifyUser endpoint\n */\nasync function createFeaturebaseUser(user: FeaturebaseUser, apiKey: string): Promise<FeaturebaseUser> {\n try {\n const response = await fetch('https://do.featurebase.app/v2/organization/identifyUser', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'X-API-Key': apiKey,\n },\n body: JSON.stringify({\n userId: user.userId,\n email: user.email,\n name: user.name,\n profilePicture: user.profilePicture,\n }),\n });\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({}));\n throw new HexclaveAssertionError(`Failed to create Featurebase user: ${errorData.error || response.statusText}`, { errorData });\n }\n\n // The identifyUser endpoint just returns { \"success\": true }, so we return the input data\n return user;\n } catch (error) {\n if (error instanceof HexclaveAssertionError) {\n throw error;\n }\n throw new HexclaveAssertionError(\"Failed to create Featurebase user\", { cause: error });\n\n }\n}\n\n/**\n * Update an existing Featurebase user (excluding email)\n */\nasync function updateFeaturebaseUser(userId: string, updates: Partial<Omit<FeaturebaseUser, 'userId' | 'email'>>, apiKey: string): Promise<FeaturebaseUser> {\n try {\n const response = await fetch(`https://do.featurebase.app/v2/users/${userId}`, {\n method: 'PATCH',\n headers: {\n 'Content-Type': 'application/json',\n 'X-API-Key': apiKey,\n },\n body: JSON.stringify(updates),\n });\n\n if (!response.ok) {\n const errorData = await response.json().catch(() => ({}));\n throw new HexclaveAssertionError(`Failed to update Featurebase user: ${errorData.error || response.statusText}`, { errorData });\n }\n\n const data = await response.json();\n return {\n userId: data.userId || userId,\n email: data.email,\n name: data.name,\n profilePicture: data.profilePicture,\n };\n } catch (error) {\n if (error instanceof HexclaveAssertionError) {\n throw error;\n }\n throw new HexclaveAssertionError(\"Failed to update Featurebase user\", { cause: error });\n }\n}\n\n/**\n * Get or create a Featurebase user based on Hexclave user data.\n * This function ensures that:\n * 1. We never change a user's email address on Featurebase\n * 2. We use Hexclave user ID as the primary identifier\n * 3. We handle email conflicts by using fallback emails\n * 4. We update profile information when needed\n */\nexport async function getOrCreateFeaturebaseUser(\n hexclaveAuthUser: HexclaveAuthUser,\n options?: { apiKey?: string }\n): Promise<{ userId: string, email: string }> {\n const apiKey = options?.apiKey || getEnvVariable(\"STACK_FEATUREBASE_API_KEY\");\n const fallbackEmail = `${hexclaveAuthUser.id}@featurebase-user.stack-auth-app.com`;\n\n // First, try to find existing user by Hexclave user ID\n const existingById = await findFeaturebaseUserById(hexclaveAuthUser.id, apiKey);\n if (existingById) {\n // Ensure the user has an email on Featurebase.\n let ensuredEmail = existingById.email;\n if (!ensuredEmail) {\n try {\n await createFeaturebaseUser({\n userId: existingById.userId,\n email: fallbackEmail,\n name: hexclaveAuthUser.displayName || undefined,\n profilePicture: hexclaveAuthUser.profileImageUrl || undefined,\n }, apiKey);\n ensuredEmail = fallbackEmail;\n } catch (e) {\n // If setting fallback email failed, keep ensuredEmail as-is (undefined) and let callers handle\n throw new HexclaveAssertionError(`Failed to set fallback email for existing Featurebase user ${existingById.userId}`, { cause: e });\n }\n }\n\n // Update profile information if needed (but not email)\n try {\n const updates: Partial<Omit<FeaturebaseUser, 'userId' | 'email'>> = {};\n\n if (hexclaveAuthUser.displayName && hexclaveAuthUser.displayName !== existingById.name) {\n updates.name = hexclaveAuthUser.displayName;\n }\n\n if (hexclaveAuthUser.profileImageUrl && hexclaveAuthUser.profileImageUrl !== existingById.profilePicture) {\n updates.profilePicture = hexclaveAuthUser.profileImageUrl;\n }\n\n if (Object.keys(updates).length > 0) {\n await updateFeaturebaseUser(existingById.userId, updates, apiKey);\n }\n } catch (error) {\n console.error('Failed to update existing Featurebase user profile:', error);\n // Continue with existing user data even if update fails\n }\n\n return {\n userId: existingById.userId,\n email: ensuredEmail,\n };\n }\n\n // No existing user found by ID, need to create one\n const candidateEmail = hexclaveAuthUser.primaryEmail ?? fallbackEmail;\n\n // Check if someone already has this email on Featurebase\n const existingByEmail = await findFeaturebaseUserByEmail(candidateEmail, apiKey);\n const safeEmail = existingByEmail ? fallbackEmail : candidateEmail;\n\n // Create new user\n const created = await createFeaturebaseUser({\n userId: hexclaveAuthUser.id,\n email: safeEmail,\n name: hexclaveAuthUser.displayName || hexclaveAuthUser.primaryEmail?.split('@')[0] || 'User',\n profilePicture: hexclaveAuthUser.profileImageUrl || undefined,\n }, apiKey);\n\n return {\n userId: created.userId,\n email: created.email,\n };\n}\n"],"mappings":";;;;;;AAoBA,eAAe,wBAAwB,oBAA4B,QAAiD;CAClH,IAAI;EACF,MAAM,WAAW,MAAM,MAAM,8DAA8D,sBAAsB;GAC/G,QAAQ;GACR,SAAS,EACP,aAAa,OACf;EACF,CAAC;EAED,IAAI,SAAS,WAAW,KACtB,OAAO;EAGT,IAAI,CAAC,SAAS,IACZ,MAAM,IAAI,uBAAuB,0CAA0C,SAAS,YAAY;EAGlG,MAAM,OAAO,MAAM,SAAS,KAAK;EACjC,MAAM,OAAO,KAAK;EAElB,IAAI,CAAC,MACH,MAAM,IAAI,uBAAuB,6DAA6D,sBAAsB,EAAE,KAAK,CAAC;EAG9H,OAAO;GACL,QAAQ,KAAK,kBAAkB,KAAK,UAAU;GAC9C,OAAO,KAAK;GACZ,MAAM,KAAK;GACX,gBAAgB,KAAK;EACvB;CACF,SAAS,OAAO;EACd,IAAI,iBAAiB,wBACnB,MAAM;EAER,MAAM,IAAI,uBAAuB,yCAAyC,EAAE,OAAO,MAAM,CAAC;CAC5F;AACF;;;;AAKA,eAAe,2BAA2B,OAAe,QAAiD;CACxG,IAAI;EACF,MAAM,WAAW,MAAM,MAAM,iEAAiE,mBAAmB,KAAK,KAAK;GACzH,QAAQ;GACR,SAAS,EACP,aAAa,OACf;EACF,CAAC;EAED,IAAI,SAAS,WAAW,KAC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L,QAAQ,aAAa;GACrB,OAAO;EACT;CACF;CAGA,MAAM,iBAAiB,iBAAiB,gBAAgB;CAIxD,MAAM,YAAY,MADY,2BAA2B,gBAAgB,MAAM,IAC3C,gBAAgB;CAGpD,MAAM,UAAU,MAAM,sBAAsB;EAC1C,QAAQ,iBAAiB;EACzB,OAAO;EACP,MAAM,iBAAiB,eAAe,iBAAiB,cAAc,MAAM,GAAG,CAAC,CAAC,MAAM;EACtF,gBAAgB,iBAAiB,mBAAmB,KAAA;CACtD,GAAG,MAAM;CAET,OAAO;EACL,QAAQ,QAAQ;EAChB,OAAO,QAAQ;CACjB;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs.d.ts","names":[],"sources":["../../../src/utils/fs.tsx"],"mappings":";iBAGsB,IAAA,CAAK,IAAA,WAAY,OAAA;AAAA,iBAIjB,eAAA,CAAgB,CAAA,UAAW,OAAA;EAAW,kBAAA;AAAA,IAAsC,
|
|
1
|
+
{"version":3,"file":"fs.d.ts","names":[],"sources":["../../../src/utils/fs.tsx"],"mappings":";iBAGsB,IAAA,CAAK,IAAA,WAAY,OAAA;AAAA,iBAIjB,eAAA,CAAgB,CAAA,UAAW,OAAA;EAAW,kBAAA;AAAA,IAAsC,OAAO;AAAA,iBAiBzF,sBAAA,CAAuB,IAAA,UAAc,OAAe"}
|
package/dist/esm/utils/fs.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as hexclaveFs from "fs";
|
|
2
2
|
import * as path$1 from "path";
|
|
3
|
-
|
|
4
3
|
//#region src/utils/fs.tsx
|
|
5
4
|
async function list(path) {
|
|
6
5
|
return await hexclaveFs.promises.readdir(path);
|
|
@@ -19,7 +18,7 @@ function writeFileSyncIfChanged(path, content) {
|
|
|
19
18
|
}
|
|
20
19
|
hexclaveFs.writeFileSync(path, content);
|
|
21
20
|
}
|
|
22
|
-
|
|
23
21
|
//#endregion
|
|
24
22
|
export { list, listRecursively, writeFileSyncIfChanged };
|
|
23
|
+
|
|
25
24
|
//# sourceMappingURL=fs.js.map
|
package/dist/esm/utils/fs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs.js","names":["path"],"sources":["../../../src/utils/fs.tsx"],"sourcesContent":["import * as hexclaveFs from \"fs\";\nimport * as path from \"path\";\n\nexport async function list(path: string) {\n return await hexclaveFs.promises.readdir(path);\n}\n\nexport async function listRecursively(p: string, options: { excludeDirectories?: boolean } = {}): Promise<string[]> {\n const files = await list(p);\n return [\n ...(await Promise.all(files.map(async (fileName) => {\n const filePath = path.join(p, fileName);\n if ((await hexclaveFs.promises.stat(filePath)).isDirectory()) {\n return [\n ...(await listRecursively(filePath, options)),\n ...(options.excludeDirectories ? [] : [filePath]),\n ];\n } else {\n return [filePath];\n }\n }))).flat(),\n ];\n}\n\nexport function writeFileSyncIfChanged(path: string, content: string): void {\n if (hexclaveFs.existsSync(path)) {\n const existingContent = hexclaveFs.readFileSync(path, \"utf-8\");\n if (existingContent === content) {\n return;\n }\n }\n hexclaveFs.writeFileSync(path, content);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"fs.js","names":["path"],"sources":["../../../src/utils/fs.tsx"],"sourcesContent":["import * as hexclaveFs from \"fs\";\nimport * as path from \"path\";\n\nexport async function list(path: string) {\n return await hexclaveFs.promises.readdir(path);\n}\n\nexport async function listRecursively(p: string, options: { excludeDirectories?: boolean } = {}): Promise<string[]> {\n const files = await list(p);\n return [\n ...(await Promise.all(files.map(async (fileName) => {\n const filePath = path.join(p, fileName);\n if ((await hexclaveFs.promises.stat(filePath)).isDirectory()) {\n return [\n ...(await listRecursively(filePath, options)),\n ...(options.excludeDirectories ? [] : [filePath]),\n ];\n } else {\n return [filePath];\n }\n }))).flat(),\n ];\n}\n\nexport function writeFileSyncIfChanged(path: string, content: string): void {\n if (hexclaveFs.existsSync(path)) {\n const existingContent = hexclaveFs.readFileSync(path, \"utf-8\");\n if (existingContent === content) {\n return;\n }\n }\n hexclaveFs.writeFileSync(path, content);\n}\n"],"mappings":";;;AAGA,eAAsB,KAAK,MAAc;CACvC,OAAO,MAAM,WAAW,SAAS,QAAQ,IAAI;AAC/C;AAEA,eAAsB,gBAAgB,GAAW,UAA4C,CAAC,GAAsB;CAClH,MAAM,QAAQ,MAAM,KAAK,CAAC;CAC1B,OAAO,CACL,IAAI,MAAM,QAAQ,IAAI,MAAM,IAAI,OAAO,aAAa;EAClD,MAAM,WAAWA,OAAK,KAAK,GAAG,QAAQ;EACtC,KAAK,MAAM,WAAW,SAAS,KAAK,QAAQ,EAAA,CAAG,YAAY,GACzD,OAAO,CACL,GAAI,MAAM,gBAAgB,UAAU,OAAO,GAC3C,GAAI,QAAQ,qBAAqB,CAAC,IAAI,CAAC,QAAQ,CACjD;OAEA,OAAO,CAAC,QAAQ;CAEpB,CAAC,CAAC,EAAA,CAAG,KAAK,CACZ;AACF;AAEA,SAAgB,uBAAuB,MAAc,SAAuB;CAC1E,IAAI,WAAW,WAAW,IAAI;MACJ,WAAW,aAAa,MAAM,OACpC,MAAM,SACtB;CAAA;CAGJ,WAAW,cAAc,MAAM,OAAO;AACxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.d.ts","names":[],"sources":["../../../src/utils/functions.tsx"],"mappings":";iBAAgB,QAAA,
|
|
1
|
+
{"version":3,"file":"functions.d.ts","names":[],"sources":["../../../src/utils/functions.tsx"],"mappings":";iBAAgB,QAAA,IAAY,CAAA,EAAG,CAAA,GAAI,CAAC;AAAA,iBAYpB,YAAA,qBAAiC,IAAA,EAAM,CAAA,GAAI,CAAC"}
|
|
@@ -2,33 +2,10 @@
|
|
|
2
2
|
function identity(t) {
|
|
3
3
|
return t;
|
|
4
4
|
}
|
|
5
|
-
(void 0)?.test("identity", ({ expect }) => {
|
|
6
|
-
expect(identity(1)).toBe(1);
|
|
7
|
-
expect(identity("test")).toBe("test");
|
|
8
|
-
expect(identity(null)).toBe(null);
|
|
9
|
-
expect(identity(void 0)).toBe(void 0);
|
|
10
|
-
const obj = { a: 1 };
|
|
11
|
-
expect(identity(obj)).toBe(obj);
|
|
12
|
-
});
|
|
13
5
|
function identityArgs(...args) {
|
|
14
6
|
return args;
|
|
15
7
|
}
|
|
16
|
-
(void 0)?.test("identityArgs", ({ expect }) => {
|
|
17
|
-
expect(identityArgs()).toEqual([]);
|
|
18
|
-
expect(identityArgs(1)).toEqual([1]);
|
|
19
|
-
expect(identityArgs(1, 2, 3)).toEqual([
|
|
20
|
-
1,
|
|
21
|
-
2,
|
|
22
|
-
3
|
|
23
|
-
]);
|
|
24
|
-
expect(identityArgs("a", "b", "c")).toEqual([
|
|
25
|
-
"a",
|
|
26
|
-
"b",
|
|
27
|
-
"c"
|
|
28
|
-
]);
|
|
29
|
-
expect(identityArgs(null, void 0)).toEqual([null, void 0]);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
8
|
//#endregion
|
|
33
9
|
export { identity, identityArgs };
|
|
10
|
+
|
|
34
11
|
//# sourceMappingURL=functions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions.js","names":[],"sources":["../../../src/utils/functions.tsx"],"sourcesContent":["export function identity<T>(t: T): T {\n return t;\n}\nimport.meta.vitest?.test(\"identity\", ({ expect }) => {\n expect(identity(1)).toBe(1);\n expect(identity(\"test\")).toBe(\"test\");\n expect(identity(null)).toBe(null);\n expect(identity(undefined)).toBe(undefined);\n const obj = { a: 1 };\n expect(identity(obj)).toBe(obj);\n});\n\nexport function identityArgs<T extends any[]>(...args: T): T {\n return args;\n}\nimport.meta.vitest?.test(\"identityArgs\", ({ expect }) => {\n expect(identityArgs()).toEqual([]);\n expect(identityArgs(1)).toEqual([1]);\n expect(identityArgs(1, 2, 3)).toEqual([1, 2, 3]);\n expect(identityArgs(\"a\", \"b\", \"c\")).toEqual([\"a\", \"b\", \"c\"]);\n expect(identityArgs(null, undefined)).toEqual([null, undefined]);\n});\n"],"mappings":";AAAA,SAAgB,SAAY,GAAS;
|
|
1
|
+
{"version":3,"file":"functions.js","names":[],"sources":["../../../src/utils/functions.tsx"],"sourcesContent":["export function identity<T>(t: T): T {\n return t;\n}\nimport.meta.vitest?.test(\"identity\", ({ expect }) => {\n expect(identity(1)).toBe(1);\n expect(identity(\"test\")).toBe(\"test\");\n expect(identity(null)).toBe(null);\n expect(identity(undefined)).toBe(undefined);\n const obj = { a: 1 };\n expect(identity(obj)).toBe(obj);\n});\n\nexport function identityArgs<T extends any[]>(...args: T): T {\n return args;\n}\nimport.meta.vitest?.test(\"identityArgs\", ({ expect }) => {\n expect(identityArgs()).toEqual([]);\n expect(identityArgs(1)).toEqual([1]);\n expect(identityArgs(1, 2, 3)).toEqual([1, 2, 3]);\n expect(identityArgs(\"a\", \"b\", \"c\")).toEqual([\"a\", \"b\", \"c\"]);\n expect(identityArgs(null, undefined)).toEqual([null, undefined]);\n});\n"],"mappings":";AAAA,SAAgB,SAAY,GAAS;CACnC,OAAO;AACT;AAUA,SAAgB,aAA8B,GAAG,MAAY;CAC3D,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geo.d.ts","names":[],"sources":["../../../src/utils/geo.tsx"],"mappings":";;;cAIa,aAAA,EAAa,KAAA,CAAA,YAAA;;;;;;;;GAQxB,KAAA,CAAA,SAAA;;;;;;;;;KAEU,OAAA,GAAU,KAAA,CAAI,
|
|
1
|
+
{"version":3,"file":"geo.d.ts","names":[],"sources":["../../../src/utils/geo.tsx"],"mappings":";;;cAIa,aAAA,EAAa,KAAA,CAAA,YAAA;;;;;;;;GAQxB,KAAA,CAAA,SAAA;;;;;;;;;KAEU,OAAA,GAAU,KAAA,CAAI,SAAS,QAAQ,aAAA"}
|
package/dist/esm/utils/geo.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { yupNumber, yupObject, yupString } from "../schema-fields.js";
|
|
2
|
-
|
|
3
2
|
//#region src/utils/geo.tsx
|
|
4
3
|
const geoInfoSchema = yupObject({
|
|
5
4
|
ip: yupString().defined(),
|
|
@@ -10,7 +9,7 @@ const geoInfoSchema = yupObject({
|
|
|
10
9
|
longitude: yupNumber().nullable(),
|
|
11
10
|
tzIdentifier: yupString().nullable()
|
|
12
11
|
});
|
|
13
|
-
|
|
14
12
|
//#endregion
|
|
15
13
|
export { geoInfoSchema };
|
|
14
|
+
|
|
16
15
|
//# sourceMappingURL=geo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geo.js","names":[],"sources":["../../../src/utils/geo.tsx"],"sourcesContent":["\nimport * as yup from \"yup\";\nimport { yupNumber, yupObject, yupString } from \"../schema-fields\";\n\nexport const geoInfoSchema = yupObject({\n ip: yupString().defined(),\n countryCode: yupString().nullable(),\n regionCode: yupString().nullable(),\n cityName: yupString().nullable(),\n latitude: yupNumber().nullable(),\n longitude: yupNumber().nullable(),\n tzIdentifier: yupString().nullable(),\n});\n\nexport type GeoInfo = yup.InferType<typeof geoInfoSchema>;\n\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"geo.js","names":[],"sources":["../../../src/utils/geo.tsx"],"sourcesContent":["\nimport * as yup from \"yup\";\nimport { yupNumber, yupObject, yupString } from \"../schema-fields\";\n\nexport const geoInfoSchema = yupObject({\n ip: yupString().defined(),\n countryCode: yupString().nullable(),\n regionCode: yupString().nullable(),\n cityName: yupString().nullable(),\n latitude: yupNumber().nullable(),\n longitude: yupNumber().nullable(),\n tzIdentifier: yupString().nullable(),\n});\n\nexport type GeoInfo = yup.InferType<typeof geoInfoSchema>;\n\n"],"mappings":";;AAIA,MAAa,gBAAgB,UAAU;CACrC,IAAI,UAAU,CAAC,CAAC,QAAQ;CACxB,aAAa,UAAU,CAAC,CAAC,SAAS;CAClC,YAAY,UAAU,CAAC,CAAC,SAAS;CACjC,UAAU,UAAU,CAAC,CAAC,SAAS;CAC/B,UAAU,UAAU,CAAC,CAAC,SAAS;CAC/B,WAAW,UAAU,CAAC,CAAC,SAAS;CAChC,cAAc,UAAU,CAAC,CAAC,SAAS;AACrC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globals.d.ts","names":[],"sources":["../../../src/utils/globals.tsx"],"mappings":";cAAM,SAAA;AAAA,iBAkBU,YAAA,
|
|
1
|
+
{"version":3,"file":"globals.d.ts","names":[],"sources":["../../../src/utils/globals.tsx"],"mappings":";cAAM,SAAA;AAAA,iBAkBU,YAAA,IAAgB,GAAA,UAAa,IAAA,QAAY,CAAA,GAIP,CAAC;;;AAjBvC;AAaZ;iBAWgB,iBAAA,IAAqB,GAAA,UAAa,IAAA,QAAY,OAAA,CAAQ,CAAA,IAAK,OAAA,CAAQ,CAAA;AAAA,iBAYnE,SAAA,CAAU,GAAW;AAAA,iBAIrB,SAAA,CAAU,GAAA,UAAa,KAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globals.js","names":[],"sources":["../../../src/utils/globals.tsx"],"sourcesContent":["const globalVar: any =\n typeof globalThis !== 'undefined' ? globalThis :\n typeof global !== 'undefined' ? global :\n typeof window !== 'undefined' ? window :\n typeof self !== 'undefined' ? self :\n {};\nexport {\n globalVar\n};\n\nif (typeof globalThis === 'undefined') {\n (globalVar as any).globalThis = globalVar;\n}\n\n// Hexclave rebrand: file-private symbol key, renamed outright (no cross-version compat needed).\nconst hexclaveGlobalsSymbol = Symbol.for('__hexclave-globals');\nglobalVar[hexclaveGlobalsSymbol] ??= {};\n\nexport function createGlobal<T>(key: string, init: () => T) {\n if (!globalVar[hexclaveGlobalsSymbol][key]) {\n globalVar[hexclaveGlobalsSymbol][key] = init();\n }\n return globalVar[hexclaveGlobalsSymbol][key] as T;\n}\n\n/**\n * Like createGlobal, but if the asynchronous initialization fails, the global will be reset and recomputed on the next\n * invocation.\n */\nexport function createGlobalAsync<T>(key: string, init: () => Promise<T>): Promise<T> {\n let promise: Promise<T> | null = null;\n if (!globalVar[hexclaveGlobalsSymbol][key]) {\n promise = init().catch((e) => {\n delete globalVar[hexclaveGlobalsSymbol][key];\n throw e;\n });\n globalVar[hexclaveGlobalsSymbol][key] = promise;\n }\n return promise ?? globalVar[hexclaveGlobalsSymbol][key] as Promise<T>;\n}\n\nexport function getGlobal(key: string): any {\n return globalVar[hexclaveGlobalsSymbol][key];\n}\n\nexport function setGlobal(key: string, value: any) {\n globalVar[hexclaveGlobalsSymbol][key] = value;\n}\n"],"mappings":";AAAA,MAAM,YACJ,OAAO,eAAe,cAAc,aAClC,OAAO,WAAW,cAAc,SAC9B,OAAO,WAAW,cAAc,SAC9B,OAAO,SAAS,cAAc,OAC5B,
|
|
1
|
+
{"version":3,"file":"globals.js","names":[],"sources":["../../../src/utils/globals.tsx"],"sourcesContent":["const globalVar: any =\n typeof globalThis !== 'undefined' ? globalThis :\n typeof global !== 'undefined' ? global :\n typeof window !== 'undefined' ? window :\n typeof self !== 'undefined' ? self :\n {};\nexport {\n globalVar\n};\n\nif (typeof globalThis === 'undefined') {\n (globalVar as any).globalThis = globalVar;\n}\n\n// Hexclave rebrand: file-private symbol key, renamed outright (no cross-version compat needed).\nconst hexclaveGlobalsSymbol = Symbol.for('__hexclave-globals');\nglobalVar[hexclaveGlobalsSymbol] ??= {};\n\nexport function createGlobal<T>(key: string, init: () => T) {\n if (!globalVar[hexclaveGlobalsSymbol][key]) {\n globalVar[hexclaveGlobalsSymbol][key] = init();\n }\n return globalVar[hexclaveGlobalsSymbol][key] as T;\n}\n\n/**\n * Like createGlobal, but if the asynchronous initialization fails, the global will be reset and recomputed on the next\n * invocation.\n */\nexport function createGlobalAsync<T>(key: string, init: () => Promise<T>): Promise<T> {\n let promise: Promise<T> | null = null;\n if (!globalVar[hexclaveGlobalsSymbol][key]) {\n promise = init().catch((e) => {\n delete globalVar[hexclaveGlobalsSymbol][key];\n throw e;\n });\n globalVar[hexclaveGlobalsSymbol][key] = promise;\n }\n return promise ?? globalVar[hexclaveGlobalsSymbol][key] as Promise<T>;\n}\n\nexport function getGlobal(key: string): any {\n return globalVar[hexclaveGlobalsSymbol][key];\n}\n\nexport function setGlobal(key: string, value: any) {\n globalVar[hexclaveGlobalsSymbol][key] = value;\n}\n"],"mappings":";AAAA,MAAM,YACJ,OAAO,eAAe,cAAc,aAClC,OAAO,WAAW,cAAc,SAC9B,OAAO,WAAW,cAAc,SAC9B,OAAO,SAAS,cAAc,OAC5B,CAAC;AAKX,IAAI,OAAO,eAAe,aACxB,UAAmB,aAAa;AAIlC,MAAM,wBAAwB,OAAO,IAAI,oBAAoB;AAC7D,UAAU,2BAA2B,CAAC;AAEtC,SAAgB,aAAgB,KAAa,MAAe;CAC1D,IAAI,CAAC,UAAU,sBAAsB,CAAC,MACpC,UAAU,sBAAsB,CAAC,OAAO,KAAK;CAE/C,OAAO,UAAU,sBAAsB,CAAC;AAC1C;;;;;AAMA,SAAgB,kBAAqB,KAAa,MAAoC;CACpF,IAAI,UAA6B;CACjC,IAAI,CAAC,UAAU,sBAAsB,CAAC,MAAM;EAC1C,UAAU,KAAK,CAAC,CAAC,OAAO,MAAM;GAC5B,OAAO,UAAU,sBAAsB,CAAC;GACxC,MAAM;EACR,CAAC;EACD,UAAU,sBAAsB,CAAC,OAAO;CAC1C;CACA,OAAO,WAAW,UAAU,sBAAsB,CAAC;AACrD;AAEA,SAAgB,UAAU,KAAkB;CAC1C,OAAO,UAAU,sBAAsB,CAAC;AAC1C;AAEA,SAAgB,UAAU,KAAa,OAAY;CACjD,UAAU,sBAAsB,CAAC,OAAO;AAC1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hashes.d.ts","names":[],"sources":["../../../src/utils/hashes.tsx"],"mappings":";iBAIsB,MAAA,CAAO,KAAA,EAAO,UAAA,YAAsB,OAAA,CAAQ,UAAA;AAAA,iBAK5C,YAAA,CAAa,QAAA,WAAgB,OAAA;AAAA,iBAS7B,eAAA,CAAgB,QAAA,UAAkB,IAAA,WAAe,
|
|
1
|
+
{"version":3,"file":"hashes.d.ts","names":[],"sources":["../../../src/utils/hashes.tsx"],"mappings":";iBAIsB,MAAA,CAAO,KAAA,EAAO,UAAA,YAAsB,OAAA,CAAQ,UAAA;AAAA,iBAK5C,YAAA,CAAa,QAAA,WAAgB,OAAA;AAAA,iBAS7B,eAAA,CAAgB,QAAA,UAAkB,IAAA,WAAe,OAAO;AAAA,iBAWxD,mBAAA,CAAoB,IAAA,WAAY,OAAA;AAAA,iBAIhC,wBAAA,CAAyB,IAAA,WAAe,OAAO"}
|
package/dist/esm/utils/hashes.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { HexclaveAssertionError } from "./errors.js";
|
|
2
2
|
import { toArrayBufferBacked } from "./typed-arrays.js";
|
|
3
3
|
import bcrypt from "bcryptjs";
|
|
4
|
-
|
|
5
4
|
//#region src/utils/hashes.tsx
|
|
6
5
|
async function sha512(input) {
|
|
7
6
|
const bytes = typeof input === "string" ? new TextEncoder().encode(input) : toArrayBufferBacked(input);
|
|
@@ -34,7 +33,7 @@ async function getPasswordHashAlgorithm(hash) {
|
|
|
34
33
|
}
|
|
35
34
|
else return;
|
|
36
35
|
}
|
|
37
|
-
|
|
38
36
|
//#endregion
|
|
39
37
|
export { comparePassword, getPasswordHashAlgorithm, hashPassword, isPasswordHashValid, sha512 };
|
|
38
|
+
|
|
40
39
|
//# sourceMappingURL=hashes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hashes.js","names":[],"sources":["../../../src/utils/hashes.tsx"],"sourcesContent":["import bcrypt from 'bcryptjs';\nimport { HexclaveAssertionError } from './errors';\nimport { toArrayBufferBacked } from './typed-arrays';\n\nexport async function sha512(input: Uint8Array | string): Promise<Uint8Array> {\n const bytes = typeof input === \"string\" ? new TextEncoder().encode(input) : toArrayBufferBacked(input);\n return new Uint8Array(await crypto.subtle.digest(\"SHA-512\", bytes));\n}\n\nexport async function hashPassword(password: string) {\n const passwordBytes = new TextEncoder().encode(password);\n if (passwordBytes.length >= 72) {\n throw new HexclaveAssertionError(`Password is too long for bcrypt`, { len: passwordBytes.length });\n }\n const salt = await bcrypt.genSalt(10);\n return await bcrypt.hash(password, salt);\n}\n\nexport async function comparePassword(password: string, hash: string): Promise<boolean> {\n switch (await getPasswordHashAlgorithm(hash)) {\n case \"bcrypt\": {\n return await bcrypt.compare(password, hash);\n }\n default: {\n return false;\n }\n }\n}\n\nexport async function isPasswordHashValid(hash: string) {\n return !!(await getPasswordHashAlgorithm(hash));\n}\n\nexport async function getPasswordHashAlgorithm(hash: string): Promise<\"bcrypt\" | undefined> {\n if (typeof hash !== \"string\") {\n throw new HexclaveAssertionError(`Passed non-string value to getPasswordHashAlgorithm`, { hash });\n }\n if (hash.match(/^\\$2[ayb]\\$.{56}$/)) {\n try {\n if (bcrypt.getRounds(hash) > 16) {\n return undefined;\n }\n await bcrypt.compare(\"any string\", hash);\n return \"bcrypt\";\n } catch (e) {\n console.warn(`Error while checking bcrypt password hash. Assuming the hash is invalid`, e);\n return undefined;\n }\n } else {\n return undefined;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"hashes.js","names":[],"sources":["../../../src/utils/hashes.tsx"],"sourcesContent":["import bcrypt from 'bcryptjs';\nimport { HexclaveAssertionError } from './errors';\nimport { toArrayBufferBacked } from './typed-arrays';\n\nexport async function sha512(input: Uint8Array | string): Promise<Uint8Array> {\n const bytes = typeof input === \"string\" ? new TextEncoder().encode(input) : toArrayBufferBacked(input);\n return new Uint8Array(await crypto.subtle.digest(\"SHA-512\", bytes));\n}\n\nexport async function hashPassword(password: string) {\n const passwordBytes = new TextEncoder().encode(password);\n if (passwordBytes.length >= 72) {\n throw new HexclaveAssertionError(`Password is too long for bcrypt`, { len: passwordBytes.length });\n }\n const salt = await bcrypt.genSalt(10);\n return await bcrypt.hash(password, salt);\n}\n\nexport async function comparePassword(password: string, hash: string): Promise<boolean> {\n switch (await getPasswordHashAlgorithm(hash)) {\n case \"bcrypt\": {\n return await bcrypt.compare(password, hash);\n }\n default: {\n return false;\n }\n }\n}\n\nexport async function isPasswordHashValid(hash: string) {\n return !!(await getPasswordHashAlgorithm(hash));\n}\n\nexport async function getPasswordHashAlgorithm(hash: string): Promise<\"bcrypt\" | undefined> {\n if (typeof hash !== \"string\") {\n throw new HexclaveAssertionError(`Passed non-string value to getPasswordHashAlgorithm`, { hash });\n }\n if (hash.match(/^\\$2[ayb]\\$.{56}$/)) {\n try {\n if (bcrypt.getRounds(hash) > 16) {\n return undefined;\n }\n await bcrypt.compare(\"any string\", hash);\n return \"bcrypt\";\n } catch (e) {\n console.warn(`Error while checking bcrypt password hash. Assuming the hash is invalid`, e);\n return undefined;\n }\n } else {\n return undefined;\n }\n}\n"],"mappings":";;;;AAIA,eAAsB,OAAO,OAAiD;CAC5E,MAAM,QAAQ,OAAO,UAAU,WAAW,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK,IAAI,oBAAoB,KAAK;CACrG,OAAO,IAAI,WAAW,MAAM,OAAO,OAAO,OAAO,WAAW,KAAK,CAAC;AACpE;AAEA,eAAsB,aAAa,UAAkB;CACnD,MAAM,gBAAgB,IAAI,YAAY,CAAC,CAAC,OAAO,QAAQ;CACvD,IAAI,cAAc,UAAU,IAC1B,MAAM,IAAI,uBAAuB,mCAAmC,EAAE,KAAK,cAAc,OAAO,CAAC;CAEnG,MAAM,OAAO,MAAM,OAAO,QAAQ,EAAE;CACpC,OAAO,MAAM,OAAO,KAAK,UAAU,IAAI;AACzC;AAEA,eAAsB,gBAAgB,UAAkB,MAAgC;CACtF,QAAQ,MAAM,yBAAyB,IAAI,GAA3C;EACE,KAAK,UACH,OAAO,MAAM,OAAO,QAAQ,UAAU,IAAI;EAE5C,SACE,OAAO;CAEX;AACF;AAEA,eAAsB,oBAAoB,MAAc;CACtD,OAAO,CAAC,CAAE,MAAM,yBAAyB,IAAI;AAC/C;AAEA,eAAsB,yBAAyB,MAA6C;CAC1F,IAAI,OAAO,SAAS,UAClB,MAAM,IAAI,uBAAuB,uDAAuD,EAAE,KAAK,CAAC;CAElG,IAAI,KAAK,MAAM,mBAAmB,GAChC,IAAI;EACF,IAAI,OAAO,UAAU,IAAI,IAAI,IAC3B;EAEF,MAAM,OAAO,QAAQ,cAAc,IAAI;EACvC,OAAO;CACT,SAAS,GAAG;EACV,QAAQ,KAAK,2EAA2E,CAAC;EACzF;CACF;MAEA;AAEJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.d.ts","names":[],"sources":["../../../src/utils/html.tsx"],"mappings":";iBAEgB,UAAA,CAAW,
|
|
1
|
+
{"version":3,"file":"html.d.ts","names":[],"sources":["../../../src/utils/html.tsx"],"mappings":";iBAEgB,UAAA,CAAW,MAAc;AAAA,iBA2BzB,IAAA,CAAK,OAAA,EAAS,oBAAoB,KAAK,MAAA;AAAA,iBAwBvC,UAAA,CAAW,aAAqB"}
|
package/dist/esm/utils/html.js
CHANGED
|
@@ -1,33 +1,15 @@
|
|
|
1
1
|
import { templateIdentity } from "./strings.js";
|
|
2
|
-
|
|
3
2
|
//#region src/utils/html.tsx
|
|
4
3
|
function escapeHtml(unsafe) {
|
|
5
4
|
return `${unsafe}`.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
6
5
|
}
|
|
7
|
-
(void 0)?.test("escapeHtml", ({ expect }) => {
|
|
8
|
-
expect(escapeHtml("")).toBe("");
|
|
9
|
-
expect(escapeHtml("hello world")).toBe("hello world");
|
|
10
|
-
expect(escapeHtml("<div>")).toBe("<div>");
|
|
11
|
-
expect(escapeHtml("a & b")).toBe("a & b");
|
|
12
|
-
expect(escapeHtml("a \"quoted\" string")).toBe("a "quoted" string");
|
|
13
|
-
expect(escapeHtml("it's a test")).toBe("it's a test");
|
|
14
|
-
expect(escapeHtml("<a href=\"test\">It's a link</a>")).toBe("<a href="test">It's a link</a>");
|
|
15
|
-
});
|
|
16
6
|
function html(strings, ...values) {
|
|
17
7
|
return templateIdentity(strings, ...values.map((v) => escapeHtml(`${v}`)));
|
|
18
8
|
}
|
|
19
|
-
(void 0)?.test("html", ({ expect }) => {
|
|
20
|
-
expect(html`simple string`).toBe("simple string");
|
|
21
|
-
expect(html`Hello, ${"world"}!`).toBe("Hello, world!");
|
|
22
|
-
expect(html`Count: ${42}`).toBe("Count: 42");
|
|
23
|
-
expect(html`<div>${"<script>"}</div>`).toBe("<div><script></div>");
|
|
24
|
-
expect(html`${1} + ${2} = ${"<3"}`).toBe("1 + 2 = <3");
|
|
25
|
-
expect(html`Object: ${{ toString: () => "<object>" }}`).toBe("Object: <object>");
|
|
26
|
-
});
|
|
27
9
|
function htmlToText(untrustedHtml) {
|
|
28
10
|
return new DOMParser().parseFromString(untrustedHtml, "text/html").body.textContent;
|
|
29
11
|
}
|
|
30
|
-
|
|
31
12
|
//#endregion
|
|
32
13
|
export { escapeHtml, html, htmlToText };
|
|
14
|
+
|
|
33
15
|
//# sourceMappingURL=html.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.js","names":[],"sources":["../../../src/utils/html.tsx"],"sourcesContent":["import { templateIdentity } from \"./strings\";\n\nexport function escapeHtml(unsafe: string): string {\n return `${unsafe}`\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n}\nimport.meta.vitest?.test(\"escapeHtml\", ({ expect }) => {\n // Test with empty string\n expect(escapeHtml(\"\")).toBe(\"\");\n\n // Test with string without special characters\n expect(escapeHtml(\"hello world\")).toBe(\"hello world\");\n\n // Test with special characters\n expect(escapeHtml(\"<div>\")).toBe(\"<div>\");\n expect(escapeHtml(\"a & b\")).toBe(\"a & b\");\n expect(escapeHtml('a \"quoted\" string')).toBe(\"a "quoted" string\");\n expect(escapeHtml(\"it's a test\")).toBe(\"it's a test\");\n\n // Test with multiple special characters\n expect(escapeHtml(\"<a href=\\\"test\\\">It's a link</a>\")).toBe(\n \"<a href="test">It's a link</a>\"\n );\n});\n\nexport function html(strings: TemplateStringsArray, ...values: any[]): string {\n return templateIdentity(strings, ...values.map(v => escapeHtml(`${v}`)));\n}\nimport.meta.vitest?.test(\"html\", ({ expect }) => {\n // Test with no interpolation\n expect(html`simple string`).toBe(\"simple string\");\n\n // Test with string interpolation\n expect(html`Hello, ${\"world\"}!`).toBe(\"Hello, world!\");\n\n // Test with number interpolation\n expect(html`Count: ${42}`).toBe(\"Count: 42\");\n\n // Test with HTML special characters in interpolated values\n expect(html`<div>${\"<script>\"}</div>`).toBe(\"<div><script></div>\");\n\n // Test with multiple interpolations\n expect(html`${1} + ${2} = ${\"<3\"}`).toBe(\"1 + 2 = <3\");\n\n // Test with object interpolation\n const obj = { toString: () => \"<object>\" };\n expect(html`Object: ${obj}`).toBe(\"Object: <object>\");\n});\n\nexport function htmlToText(untrustedHtml: string): string {\n\n const doc = new DOMParser().parseFromString(untrustedHtml, 'text/html');\n\n return doc.body.textContent;\n\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"html.js","names":[],"sources":["../../../src/utils/html.tsx"],"sourcesContent":["import { templateIdentity } from \"./strings\";\n\nexport function escapeHtml(unsafe: string): string {\n return `${unsafe}`\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n}\nimport.meta.vitest?.test(\"escapeHtml\", ({ expect }) => {\n // Test with empty string\n expect(escapeHtml(\"\")).toBe(\"\");\n\n // Test with string without special characters\n expect(escapeHtml(\"hello world\")).toBe(\"hello world\");\n\n // Test with special characters\n expect(escapeHtml(\"<div>\")).toBe(\"<div>\");\n expect(escapeHtml(\"a & b\")).toBe(\"a & b\");\n expect(escapeHtml('a \"quoted\" string')).toBe(\"a "quoted" string\");\n expect(escapeHtml(\"it's a test\")).toBe(\"it's a test\");\n\n // Test with multiple special characters\n expect(escapeHtml(\"<a href=\\\"test\\\">It's a link</a>\")).toBe(\n \"<a href="test">It's a link</a>\"\n );\n});\n\nexport function html(strings: TemplateStringsArray, ...values: any[]): string {\n return templateIdentity(strings, ...values.map(v => escapeHtml(`${v}`)));\n}\nimport.meta.vitest?.test(\"html\", ({ expect }) => {\n // Test with no interpolation\n expect(html`simple string`).toBe(\"simple string\");\n\n // Test with string interpolation\n expect(html`Hello, ${\"world\"}!`).toBe(\"Hello, world!\");\n\n // Test with number interpolation\n expect(html`Count: ${42}`).toBe(\"Count: 42\");\n\n // Test with HTML special characters in interpolated values\n expect(html`<div>${\"<script>\"}</div>`).toBe(\"<div><script></div>\");\n\n // Test with multiple interpolations\n expect(html`${1} + ${2} = ${\"<3\"}`).toBe(\"1 + 2 = <3\");\n\n // Test with object interpolation\n const obj = { toString: () => \"<object>\" };\n expect(html`Object: ${obj}`).toBe(\"Object: <object>\");\n});\n\nexport function htmlToText(untrustedHtml: string): string {\n\n const doc = new DOMParser().parseFromString(untrustedHtml, 'text/html');\n\n return doc.body.textContent;\n\n}\n"],"mappings":";;AAEA,SAAgB,WAAW,QAAwB;CACjD,OAAO,GAAG,SACP,QAAQ,MAAM,OAAO,CAAC,CACtB,QAAQ,MAAM,MAAM,CAAC,CACrB,QAAQ,MAAM,MAAM,CAAC,CACrB,QAAQ,MAAM,QAAQ,CAAC,CACvB,QAAQ,MAAM,QAAQ;AAC3B;AAoBA,SAAgB,KAAK,SAA+B,GAAG,QAAuB;CAC5E,OAAO,iBAAiB,SAAS,GAAG,OAAO,KAAI,MAAK,WAAW,GAAG,GAAG,CAAC,CAAC;AACzE;AAsBA,SAAgB,WAAW,eAA+B;CAIxD,OAFY,IAAI,UAAU,CAAC,CAAC,gBAAgB,eAAe,WAElD,CAAC,CAAC,KAAK;AAElB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","names":[],"sources":["../../../src/utils/http.tsx"],"mappings":";cAEa,YAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAsCD,UAAA,gBAA0B,
|
|
1
|
+
{"version":3,"file":"http.d.ts","names":[],"sources":["../../../src/utils/http.tsx"],"mappings":";cAEa,YAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAsCD,UAAA,gBAA0B,YAAY;AAAA,iBAElC,8BAAA,CAA+B,KAAa;AAAA,iBA6B5C,8BAAA,CAA+B,EAAA,UAAY,QAAgB"}
|
package/dist/esm/utils/http.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { decodeBase64, encodeBase64, isBase64 } from "./bytes.js";
|
|
2
|
-
|
|
3
2
|
//#region src/utils/http.tsx
|
|
4
3
|
const HTTP_METHODS = {
|
|
5
4
|
"GET": {
|
|
@@ -48,28 +47,11 @@ function decodeBasicAuthorizationHeader(value) {
|
|
|
48
47
|
const split = new TextDecoder().decode(decodeBase64(encoded)).split(":");
|
|
49
48
|
return [split[0], split.slice(1).join(":")];
|
|
50
49
|
}
|
|
51
|
-
(void 0)?.test("decodeBasicAuthorizationHeader", ({ expect }) => {
|
|
52
|
-
const username = "user";
|
|
53
|
-
const password = "pass";
|
|
54
|
-
expect(decodeBasicAuthorizationHeader(encodeBasicAuthorizationHeader(username, password))).toEqual([username, password]);
|
|
55
|
-
const complexPassword = "pass:with:colons";
|
|
56
|
-
expect(decodeBasicAuthorizationHeader(encodeBasicAuthorizationHeader(username, complexPassword))).toEqual([username, complexPassword]);
|
|
57
|
-
expect(decodeBasicAuthorizationHeader("NotBasic dXNlcjpwYXNz")).toBe(null);
|
|
58
|
-
expect(decodeBasicAuthorizationHeader("Basic")).toBe(null);
|
|
59
|
-
expect(decodeBasicAuthorizationHeader("Basic not-base64")).toBe(null);
|
|
60
|
-
expect(decodeBasicAuthorizationHeader("Basic dXNlcjpwYXNz extra")).toBe(null);
|
|
61
|
-
});
|
|
62
50
|
function encodeBasicAuthorizationHeader(id, password) {
|
|
63
51
|
if (id.includes(":")) throw new Error("Basic authorization header id cannot contain ':'");
|
|
64
52
|
return `Basic ${encodeBase64(new TextEncoder().encode(`${id}:${password}`))}`;
|
|
65
53
|
}
|
|
66
|
-
(void 0)?.test("encodeBasicAuthorizationHeader", ({ expect }) => {
|
|
67
|
-
expect(encodeBasicAuthorizationHeader("user", "pass")).toMatch(/^Basic [A-Za-z0-9+/=]+$/);
|
|
68
|
-
expect(encodeBasicAuthorizationHeader("user", "")).toMatch(/^Basic [A-Za-z0-9+/=]+$/);
|
|
69
|
-
expect(encodeBasicAuthorizationHeader("user", "p@ss!w0rd")).toMatch(/^Basic [A-Za-z0-9+/=]+$/);
|
|
70
|
-
expect(() => encodeBasicAuthorizationHeader("user:name", "pass")).toThrow();
|
|
71
|
-
});
|
|
72
|
-
|
|
73
54
|
//#endregion
|
|
74
55
|
export { HTTP_METHODS, decodeBasicAuthorizationHeader, encodeBasicAuthorizationHeader };
|
|
56
|
+
|
|
75
57
|
//# sourceMappingURL=http.js.map
|