@hexclave/tanstack-start 1.0.0 → 1.0.2
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/README.md +7 -23
- package/dist/components/api-key-dialogs.js +18 -18
- package/dist/components/api-key-dialogs.js.map +1 -1
- package/dist/components/api-key-table.js +19 -19
- package/dist/components/api-key-table.js.map +1 -1
- package/dist/components/credential-sign-in.js +12 -12
- package/dist/components/credential-sign-in.js.map +1 -1
- package/dist/components/credential-sign-up.js +19 -19
- package/dist/components/credential-sign-up.js.map +1 -1
- package/dist/components/elements/separator-with-text.js +3 -3
- package/dist/components/elements/separator-with-text.js.map +1 -1
- package/dist/components/elements/sidebar-layout.js +15 -15
- package/dist/components/elements/sidebar-layout.js.map +1 -1
- package/dist/components/elements/user-avatar.js +3 -3
- package/dist/components/elements/user-avatar.js.map +1 -1
- package/dist/components/link.js +2 -2
- package/dist/components/link.js.map +1 -1
- package/dist/components/magic-link-sign-in.js +17 -17
- package/dist/components/magic-link-sign-in.js.map +1 -1
- package/dist/components/message-cards/known-error-message-card.js +2 -2
- package/dist/components/message-cards/known-error-message-card.js.map +1 -1
- package/dist/components/message-cards/message-card.js +4 -4
- package/dist/components/message-cards/message-card.js.map +1 -1
- package/dist/components/message-cards/predefined-message-card.js +2 -2
- package/dist/components/message-cards/predefined-message-card.js.map +1 -1
- package/dist/components/oauth-button.d.ts.map +1 -1
- package/dist/components/oauth-button.js +15 -15
- package/dist/components/oauth-button.js.map +1 -1
- package/dist/components/passkey-button.js +2 -2
- package/dist/components/passkey-button.js.map +1 -1
- package/dist/components/profile-image-editor.js +9 -9
- package/dist/components/profile-image-editor.js.map +1 -1
- package/dist/components/selected-team-switcher.js +4 -4
- package/dist/components/selected-team-switcher.js.map +1 -1
- package/dist/components/team-icon.js +4 -4
- package/dist/components/team-icon.js.map +1 -1
- package/dist/components/team-switcher.js +21 -21
- package/dist/components/team-switcher.js.map +1 -1
- package/dist/components/user-button.js +13 -13
- package/dist/components/user-button.js.map +1 -1
- package/dist/components-page/account-settings/active-sessions/active-sessions-page.js +32 -32
- package/dist/components-page/account-settings/active-sessions/active-sessions-page.js.map +1 -1
- package/dist/components-page/account-settings/api-keys/api-keys-page.js +2 -2
- package/dist/components-page/account-settings/api-keys/api-keys-page.js.map +1 -1
- package/dist/components-page/account-settings/editable-text.js +5 -5
- package/dist/components-page/account-settings/editable-text.js.map +1 -1
- package/dist/components-page/account-settings/email-and-auth/emails-section.js +22 -22
- package/dist/components-page/account-settings/email-and-auth/emails-section.js.map +1 -1
- package/dist/components-page/account-settings/email-and-auth/mfa-section.js +17 -17
- package/dist/components-page/account-settings/email-and-auth/mfa-section.js.map +1 -1
- package/dist/components-page/account-settings/email-and-auth/otp-section.js +9 -9
- package/dist/components-page/account-settings/email-and-auth/otp-section.js.map +1 -1
- package/dist/components-page/account-settings/email-and-auth/passkey-section.js +9 -9
- package/dist/components-page/account-settings/email-and-auth/passkey-section.js.map +1 -1
- package/dist/components-page/account-settings/email-and-auth/password-section.js +23 -23
- package/dist/components-page/account-settings/email-and-auth/password-section.js.map +1 -1
- package/dist/components-page/account-settings/notifications/notifications-page.js +6 -6
- package/dist/components-page/account-settings/notifications/notifications-page.js.map +1 -1
- package/dist/components-page/account-settings/payments/payments-panel.js +52 -52
- package/dist/components-page/account-settings/payments/payments-panel.js.map +1 -1
- package/dist/components-page/account-settings/profile-page/profile-page.js +1 -1
- package/dist/components-page/account-settings/section.js +4 -4
- package/dist/components-page/account-settings/section.js.map +1 -1
- package/dist/components-page/account-settings/settings/delete-account-section.js +7 -7
- package/dist/components-page/account-settings/settings/delete-account-section.js.map +1 -1
- package/dist/components-page/account-settings/settings/sign-out-section.js +2 -2
- package/dist/components-page/account-settings/settings/sign-out-section.js.map +1 -1
- package/dist/components-page/account-settings/teams/leave-team-section.js +5 -5
- package/dist/components-page/account-settings/teams/leave-team-section.js.map +1 -1
- package/dist/components-page/account-settings/teams/team-api-keys-section.js +4 -4
- package/dist/components-page/account-settings/teams/team-api-keys-section.js.map +1 -1
- package/dist/components-page/account-settings/teams/team-creation-page.js +7 -7
- package/dist/components-page/account-settings/teams/team-creation-page.js.map +1 -1
- package/dist/components-page/account-settings/teams/team-member-invitation-section.js +20 -20
- package/dist/components-page/account-settings/teams/team-member-invitation-section.js.map +1 -1
- package/dist/components-page/account-settings/teams/team-member-list-section.js +5 -5
- package/dist/components-page/account-settings/teams/team-member-list-section.js.map +1 -1
- package/dist/components-page/account-settings.js +22 -22
- package/dist/components-page/account-settings.js.map +1 -1
- package/dist/components-page/auth-page.js +23 -23
- package/dist/components-page/auth-page.js.map +1 -1
- package/dist/components-page/cli-auth-confirm.js +9 -9
- package/dist/components-page/cli-auth-confirm.js.map +1 -1
- package/dist/components-page/cli-auth-confirm.test.js +4 -4
- package/dist/components-page/cli-auth-confirm.test.js.map +1 -1
- package/dist/components-page/email-verification.js +6 -6
- package/dist/components-page/email-verification.js.map +1 -1
- package/dist/components-page/error-page.js +11 -11
- package/dist/components-page/error-page.js.map +1 -1
- package/dist/components-page/forgot-password.js +11 -11
- package/dist/components-page/forgot-password.js.map +1 -1
- package/dist/components-page/magic-link-callback.js +8 -8
- package/dist/components-page/magic-link-callback.js.map +1 -1
- package/dist/components-page/mfa.js +13 -13
- package/dist/components-page/mfa.js.map +1 -1
- package/dist/components-page/oauth-callback.js +9 -9
- package/dist/components-page/oauth-callback.js.map +1 -1
- package/dist/components-page/onboarding.js +11 -11
- package/dist/components-page/onboarding.js.map +1 -1
- package/dist/components-page/password-reset.js +27 -27
- package/dist/components-page/password-reset.js.map +1 -1
- package/dist/components-page/section.js +1 -1
- package/dist/components-page/sign-out.js +4 -4
- package/dist/components-page/sign-out.js.map +1 -1
- package/dist/components-page/stack-handler-client.js +14 -10
- package/dist/components-page/stack-handler-client.js.map +1 -1
- package/dist/components-page/stack-handler.d.ts +14 -9
- package/dist/components-page/stack-handler.d.ts.map +1 -1
- package/dist/components-page/stack-handler.js +8 -2
- package/dist/components-page/stack-handler.js.map +1 -1
- package/dist/components-page/team-creation.js +9 -9
- package/dist/components-page/team-creation.js.map +1 -1
- package/dist/components-page/team-invitation.js +20 -20
- package/dist/components-page/team-invitation.js.map +1 -1
- package/dist/dev-tool/dev-tool-core.d.ts.map +1 -1
- package/dist/dev-tool/dev-tool-core.js +25 -25
- package/dist/dev-tool/dev-tool-core.js.map +1 -1
- package/dist/dev-tool/dev-tool-trigger-position.test.js +1 -1
- package/dist/dev-tool/index.js +6 -6
- package/dist/dev-tool/index.js.map +1 -1
- package/dist/esm/components/api-key-dialogs.js.map +1 -1
- package/dist/esm/components/api-key-table.js.map +1 -1
- package/dist/esm/components/credential-sign-in.js.map +1 -1
- package/dist/esm/components/credential-sign-up.js.map +1 -1
- package/dist/esm/components/elements/separator-with-text.js.map +1 -1
- package/dist/esm/components/elements/sidebar-layout.js.map +1 -1
- package/dist/esm/components/elements/user-avatar.js.map +1 -1
- package/dist/esm/components/link.js.map +1 -1
- package/dist/esm/components/magic-link-sign-in.js.map +1 -1
- package/dist/esm/components/message-cards/known-error-message-card.js.map +1 -1
- package/dist/esm/components/message-cards/message-card.js.map +1 -1
- package/dist/esm/components/message-cards/predefined-message-card.js.map +1 -1
- package/dist/esm/components/oauth-button.d.ts.map +1 -1
- package/dist/esm/components/oauth-button.js.map +1 -1
- package/dist/esm/components/passkey-button.js.map +1 -1
- package/dist/esm/components/profile-image-editor.js.map +1 -1
- package/dist/esm/components/selected-team-switcher.js.map +1 -1
- package/dist/esm/components/team-icon.js.map +1 -1
- package/dist/esm/components/team-switcher.js.map +1 -1
- package/dist/esm/components/user-button.js.map +1 -1
- package/dist/esm/components-page/account-settings/active-sessions/active-sessions-page.js.map +1 -1
- package/dist/esm/components-page/account-settings/api-keys/api-keys-page.js.map +1 -1
- package/dist/esm/components-page/account-settings/editable-text.js.map +1 -1
- package/dist/esm/components-page/account-settings/email-and-auth/emails-section.js.map +1 -1
- package/dist/esm/components-page/account-settings/email-and-auth/mfa-section.js.map +1 -1
- package/dist/esm/components-page/account-settings/email-and-auth/otp-section.js.map +1 -1
- package/dist/esm/components-page/account-settings/email-and-auth/passkey-section.js.map +1 -1
- package/dist/esm/components-page/account-settings/email-and-auth/password-section.js.map +1 -1
- package/dist/esm/components-page/account-settings/notifications/notifications-page.js.map +1 -1
- package/dist/esm/components-page/account-settings/payments/payments-panel.js.map +1 -1
- package/dist/esm/components-page/account-settings/profile-page/profile-page.js +1 -1
- package/dist/esm/components-page/account-settings/section.js.map +1 -1
- package/dist/esm/components-page/account-settings/settings/delete-account-section.js.map +1 -1
- package/dist/esm/components-page/account-settings/settings/sign-out-section.js.map +1 -1
- package/dist/esm/components-page/account-settings/teams/leave-team-section.js.map +1 -1
- package/dist/esm/components-page/account-settings/teams/team-api-keys-section.js.map +1 -1
- package/dist/esm/components-page/account-settings/teams/team-creation-page.js.map +1 -1
- package/dist/esm/components-page/account-settings/teams/team-member-invitation-section.js.map +1 -1
- package/dist/esm/components-page/account-settings/teams/team-member-list-section.js.map +1 -1
- package/dist/esm/components-page/account-settings.js.map +1 -1
- package/dist/esm/components-page/auth-page.js.map +1 -1
- package/dist/esm/components-page/cli-auth-confirm.js.map +1 -1
- package/dist/esm/components-page/cli-auth-confirm.test.js +2 -2
- package/dist/esm/components-page/cli-auth-confirm.test.js.map +1 -1
- package/dist/esm/components-page/email-verification.js.map +1 -1
- package/dist/esm/components-page/error-page.js.map +1 -1
- package/dist/esm/components-page/forgot-password.js.map +1 -1
- package/dist/esm/components-page/magic-link-callback.js.map +1 -1
- package/dist/esm/components-page/mfa.js.map +1 -1
- package/dist/esm/components-page/oauth-callback.js.map +1 -1
- package/dist/esm/components-page/onboarding.js.map +1 -1
- package/dist/esm/components-page/password-reset.js.map +1 -1
- package/dist/esm/components-page/sign-out.js.map +1 -1
- package/dist/esm/components-page/stack-handler-client.js +8 -4
- package/dist/esm/components-page/stack-handler-client.js.map +1 -1
- package/dist/esm/components-page/stack-handler.d.ts +13 -9
- package/dist/esm/components-page/stack-handler.d.ts.map +1 -1
- package/dist/esm/components-page/stack-handler.js +5 -2
- package/dist/esm/components-page/stack-handler.js.map +1 -1
- package/dist/esm/components-page/team-creation.js.map +1 -1
- package/dist/esm/components-page/team-invitation.js.map +1 -1
- package/dist/esm/dev-tool/dev-tool-core.d.ts.map +1 -1
- package/dist/esm/dev-tool/dev-tool-core.js +4 -4
- package/dist/esm/dev-tool/dev-tool-core.js.map +1 -1
- package/dist/esm/dev-tool/dev-tool-trigger-position.test.js +1 -1
- package/dist/esm/dev-tool/index.js.map +1 -1
- package/dist/esm/generated/global-css.d.ts +1 -1
- package/dist/esm/generated/global-css.js +1 -1
- package/dist/esm/generated/global-css.js.map +1 -1
- package/dist/esm/generated/quetzal-translations.js.map +1 -1
- package/dist/esm/index.d.ts +5 -5
- package/dist/esm/index.js +5 -6
- package/dist/esm/integrations/convex.js.map +1 -1
- package/dist/esm/lib/auth.js.map +1 -1
- package/dist/esm/lib/auth.test.js.map +1 -1
- package/dist/esm/lib/cookie.js.map +1 -1
- package/dist/esm/lib/hooks.d.ts +11 -1
- package/dist/esm/lib/hooks.d.ts.map +1 -1
- package/dist/esm/lib/hooks.js +19 -9
- package/dist/esm/lib/hooks.js.map +1 -1
- package/dist/esm/lib/stack-app/api-keys/index.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.d.ts +11 -11
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.d.ts.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js +3 -1
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.cross-domain.test.js +67 -1
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.cross-domain.test.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.d.ts +4 -3
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.d.ts.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js +19 -3
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/common.d.ts.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/common.js +2 -2
- package/dist/esm/lib/stack-app/apps/implementations/common.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/event-tracker.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/event-tracker.test.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/index.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/redirect-page-urls.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/session-replay.d.ts.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/session-replay.js +3 -2
- package/dist/esm/lib/stack-app/apps/implementations/session-replay.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/admin-app.d.ts +4 -0
- package/dist/esm/lib/stack-app/apps/interfaces/admin-app.d.ts.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/admin-app.js +1 -0
- package/dist/esm/lib/stack-app/apps/interfaces/admin-app.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/client-app.d.ts +5 -0
- package/dist/esm/lib/stack-app/apps/interfaces/client-app.d.ts.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/client-app.js +1 -0
- package/dist/esm/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/server-app.d.ts +4 -0
- package/dist/esm/lib/stack-app/apps/interfaces/server-app.d.ts.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/server-app.js +1 -0
- package/dist/esm/lib/stack-app/apps/interfaces/server-app.js.map +1 -1
- package/dist/esm/lib/stack-app/common.js.map +1 -1
- package/dist/esm/lib/stack-app/contact-channels/index.js.map +1 -1
- package/dist/esm/lib/stack-app/email-templates/index.js.map +1 -1
- package/dist/esm/lib/stack-app/internal-api-keys/index.js.map +1 -1
- package/dist/esm/lib/stack-app/permissions/index.js.map +1 -1
- package/dist/esm/lib/stack-app/projects/index.js.map +1 -1
- package/dist/esm/lib/stack-app/teams/index.js.map +1 -1
- package/dist/esm/lib/stack-app/url-targets.js.map +1 -1
- package/dist/esm/lib/stack-app/url-targets.test.js +1 -1
- package/dist/esm/lib/stack-app/url-targets.test.js.map +1 -1
- package/dist/esm/lib/stack-app/users/index.js.map +1 -1
- package/dist/esm/providers/stack-context.d.ts +3 -2
- package/dist/esm/providers/stack-context.d.ts.map +1 -1
- package/dist/esm/providers/stack-context.js +3 -1
- package/dist/esm/providers/stack-context.js.map +1 -1
- package/dist/esm/providers/stack-provider-client.js.map +1 -1
- package/dist/esm/providers/stack-provider.d.ts +5 -1
- package/dist/esm/providers/stack-provider.d.ts.map +1 -1
- package/dist/esm/providers/stack-provider.js +5 -1
- package/dist/esm/providers/stack-provider.js.map +1 -1
- package/dist/esm/providers/theme-provider.d.ts +6 -2
- package/dist/esm/providers/theme-provider.d.ts.map +1 -1
- package/dist/esm/providers/theme-provider.js +6 -2
- package/dist/esm/providers/theme-provider.js.map +1 -1
- package/dist/esm/providers/translation-provider-client.d.ts +4 -3
- package/dist/esm/providers/translation-provider-client.d.ts.map +1 -1
- package/dist/esm/providers/translation-provider-client.js +4 -2
- package/dist/esm/providers/translation-provider-client.js.map +1 -1
- package/dist/esm/providers/translation-provider.js.map +1 -1
- package/dist/esm/utils/url.js.map +1 -1
- package/dist/generated/global-css.d.ts +1 -1
- package/dist/generated/global-css.js +1 -1
- package/dist/generated/global-css.js.map +1 -1
- package/dist/generated/quetzal-translations.js +16 -16
- package/dist/generated/quetzal-translations.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +9 -12
- package/dist/integrations/convex/component/convex.config.d.ts +1 -1
- package/dist/integrations/convex.js +5 -5
- package/dist/integrations/convex.js.map +1 -1
- package/dist/lib/auth.js +12 -12
- package/dist/lib/auth.js.map +1 -1
- package/dist/lib/auth.test.js +2 -2
- package/dist/lib/auth.test.js.map +1 -1
- package/dist/lib/cookie.js +13 -13
- package/dist/lib/cookie.js.map +1 -1
- package/dist/lib/hooks.d.ts +11 -1
- package/dist/lib/hooks.d.ts.map +1 -1
- package/dist/lib/hooks.js +19 -8
- package/dist/lib/hooks.js.map +1 -1
- package/dist/lib/stack-app/api-keys/index.js +2 -2
- package/dist/lib/stack-app/api-keys/index.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.d.ts +11 -11
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.d.ts.map +1 -1
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js +39 -37
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/client-app-impl.cross-domain.test.js +66 -0
- package/dist/lib/stack-app/apps/implementations/client-app-impl.cross-domain.test.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/client-app-impl.d.ts +4 -3
- package/dist/lib/stack-app/apps/implementations/client-app-impl.d.ts.map +1 -1
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js +232 -216
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/common.d.ts.map +1 -1
- package/dist/lib/stack-app/apps/implementations/common.js +31 -31
- package/dist/lib/stack-app/apps/implementations/common.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/event-tracker.js +7 -7
- package/dist/lib/stack-app/apps/implementations/event-tracker.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/event-tracker.test.js +3 -3
- package/dist/lib/stack-app/apps/implementations/event-tracker.test.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/index.js +4 -4
- package/dist/lib/stack-app/apps/implementations/index.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/redirect-page-urls.js +8 -8
- package/dist/lib/stack-app/apps/implementations/redirect-page-urls.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js +70 -70
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/session-replay.d.ts.map +1 -1
- package/dist/lib/stack-app/apps/implementations/session-replay.js +13 -12
- package/dist/lib/stack-app/apps/implementations/session-replay.js.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/admin-app.d.ts +4 -0
- package/dist/lib/stack-app/apps/interfaces/admin-app.d.ts.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/admin-app.js +1 -0
- package/dist/lib/stack-app/apps/interfaces/admin-app.js.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/client-app.d.ts +5 -0
- package/dist/lib/stack-app/apps/interfaces/client-app.d.ts.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/client-app.js +1 -0
- package/dist/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/server-app.d.ts +5 -1
- package/dist/lib/stack-app/apps/interfaces/server-app.d.ts.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/server-app.js +1 -0
- package/dist/lib/stack-app/apps/interfaces/server-app.js.map +1 -1
- package/dist/lib/stack-app/common.d.ts +1 -1
- package/dist/lib/stack-app/common.js.map +1 -1
- package/dist/lib/stack-app/contact-channels/index.js.map +1 -1
- package/dist/lib/stack-app/email-templates/index.js.map +1 -1
- package/dist/lib/stack-app/internal-api-keys/index.js.map +1 -1
- package/dist/lib/stack-app/permissions/index.js.map +1 -1
- package/dist/lib/stack-app/projects/index.js.map +1 -1
- package/dist/lib/stack-app/teams/index.js.map +1 -1
- package/dist/lib/stack-app/url-targets.js +6 -6
- package/dist/lib/stack-app/url-targets.js.map +1 -1
- package/dist/lib/stack-app/url-targets.test.js +1 -1
- package/dist/lib/stack-app/url-targets.test.js.map +1 -1
- package/dist/lib/stack-app/users/index.js +3 -3
- package/dist/lib/stack-app/users/index.js.map +1 -1
- package/dist/providers/stack-context.d.ts +3 -2
- package/dist/providers/stack-context.d.ts.map +1 -1
- package/dist/providers/stack-context.js +3 -1
- package/dist/providers/stack-context.js.map +1 -1
- package/dist/providers/stack-provider-client.js +2 -2
- package/dist/providers/stack-provider-client.js.map +1 -1
- package/dist/providers/stack-provider.d.ts +6 -1
- package/dist/providers/stack-provider.d.ts.map +1 -1
- package/dist/providers/stack-provider.js +8 -1
- package/dist/providers/stack-provider.js.map +1 -1
- package/dist/providers/theme-provider.d.ts +6 -2
- package/dist/providers/theme-provider.d.ts.map +1 -1
- package/dist/providers/theme-provider.js +10 -5
- package/dist/providers/theme-provider.js.map +1 -1
- package/dist/providers/translation-provider-client.d.ts +4 -3
- package/dist/providers/translation-provider-client.d.ts.map +1 -1
- package/dist/providers/translation-provider-client.js +4 -1
- package/dist/providers/translation-provider-client.js.map +1 -1
- package/dist/providers/translation-provider.js +2 -2
- package/dist/providers/translation-provider.js.map +1 -1
- package/dist/{storage-CPqRDIqg.d.ts → storage-CKzvsBxG.d.ts} +1 -1
- package/dist/{storage-CPqRDIqg.d.ts.map → storage-CKzvsBxG.d.ts.map} +1 -1
- package/dist/utils/url.js +2 -2
- package/dist/utils/url.js.map +1 -1
- package/package.json +6 -6
- package/dist/esm/internal/deprecation-warning.d.ts +0 -1
- package/dist/esm/internal/deprecation-warning.js +0 -24
- package/dist/esm/internal/deprecation-warning.js.map +0 -1
- package/dist/internal/deprecation-warning.d.ts +0 -1
- package/dist/internal/deprecation-warning.js +0 -24
- package/dist/internal/deprecation-warning.js.map +0 -1
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_chunk = require('../../../../chunk-BE-pF4vm.js');
|
|
3
|
-
let
|
|
4
|
-
let
|
|
3
|
+
let _hexclave_shared_dist_utils_errors = require("@hexclave/shared/dist/utils/errors");
|
|
4
|
+
let _hexclave_shared_dist_utils_promises = require("@hexclave/shared/dist/utils/promises");
|
|
5
5
|
let react = require("react");
|
|
6
6
|
react = require_chunk.__toESM(react);
|
|
7
|
-
let
|
|
8
|
-
let
|
|
9
|
-
let
|
|
10
|
-
let
|
|
11
|
-
let
|
|
12
|
-
let
|
|
13
|
-
let
|
|
14
|
-
let
|
|
15
|
-
|
|
7
|
+
let _hexclave_shared = require("@hexclave/shared");
|
|
8
|
+
let _hexclave_shared_dist_utils_react = require("@hexclave/shared/dist/utils/react");
|
|
9
|
+
let _hexclave_shared_dist_utils_objects = require("@hexclave/shared/dist/utils/objects");
|
|
10
|
+
let _hexclave_shared_dist_utils_urls = require("@hexclave/shared/dist/utils/urls");
|
|
11
|
+
let _hexclave_shared_dist_utils_results = require("@hexclave/shared/dist/utils/results");
|
|
12
|
+
let _hexclave_shared_dist_utils_strings = require("@hexclave/shared/dist/utils/strings");
|
|
13
|
+
let _hexclave_shared_dist_utils_env = require("@hexclave/shared/dist/utils/env");
|
|
14
|
+
let _hexclave_tanstack_start_tanstack_start_server_context = require("@hexclave/tanstack-start/tanstack-start-server-context");
|
|
15
|
+
_hexclave_tanstack_start_tanstack_start_server_context = require_chunk.__toESM(_hexclave_tanstack_start_tanstack_start_server_context);
|
|
16
16
|
let __common_js = require("./common.js");
|
|
17
|
-
let
|
|
18
|
-
let
|
|
17
|
+
let _hexclave_shared_dist_utils_redirect_urls = require("@hexclave/shared/dist/utils/redirect-urls");
|
|
18
|
+
let _hexclave_shared_dist_utils_bytes = require("@hexclave/shared/dist/utils/bytes");
|
|
19
19
|
let ______common_js = require("../../common.js");
|
|
20
20
|
let ______projects_index_js = require("../../projects/index.js");
|
|
21
21
|
let _simplewebauthn_browser = require("@simplewebauthn/browser");
|
|
22
|
-
let
|
|
23
|
-
let
|
|
24
|
-
let
|
|
25
|
-
let
|
|
26
|
-
let
|
|
27
|
-
let
|
|
22
|
+
let _hexclave_shared_dist_sessions = require("@hexclave/shared/dist/sessions");
|
|
23
|
+
let _hexclave_shared_dist_utils_json = require("@hexclave/shared/dist/utils/json");
|
|
24
|
+
let _hexclave_shared_dist_utils_maps = require("@hexclave/shared/dist/utils/maps");
|
|
25
|
+
let _hexclave_shared_dist_utils_stores = require("@hexclave/shared/dist/utils/stores");
|
|
26
|
+
let _hexclave_shared_dist_utils_turnstile_flow = require("@hexclave/shared/dist/utils/turnstile-flow");
|
|
27
|
+
let _hexclave_shared_dist_utils_uuids = require("@hexclave/shared/dist/utils/uuids");
|
|
28
28
|
let _tanstack_react_router = require("@tanstack/react-router");
|
|
29
29
|
_tanstack_react_router = require_chunk.__toESM(_tanstack_react_router);
|
|
30
30
|
let cookie = require("cookie");
|
|
@@ -69,7 +69,7 @@ const STACK_AUTHORIZATION_VALUE_PREFIX = "stackauth_";
|
|
|
69
69
|
const HEXCLAVE_AUTHORIZATION_VALUE_PREFIX = "hexclave_";
|
|
70
70
|
function getAuthorizationHeaderValueFromAuthJson(authJson) {
|
|
71
71
|
if (authJson.accessToken == null && authJson.refreshToken == null) return null;
|
|
72
|
-
return `Bearer ${STACK_AUTHORIZATION_VALUE_PREFIX}${(0,
|
|
72
|
+
return `Bearer ${STACK_AUTHORIZATION_VALUE_PREFIX}${(0, _hexclave_shared_dist_utils_bytes.encodeBase64)(new TextEncoder().encode(JSON.stringify(authJson)))}`;
|
|
73
73
|
}
|
|
74
74
|
function getAuthJsonFromAuthorizationHeaderValue(authorizationHeaderValue) {
|
|
75
75
|
const match = authorizationHeaderValue.match(/^Bearer\s+(.+)$/i);
|
|
@@ -81,7 +81,7 @@ function getAuthJsonFromAuthorizationHeaderValue(authorizationHeaderValue) {
|
|
|
81
81
|
if (encodedAuthJson.length === 0) throw new Error("Invalid Authorization header format. Expected `Bearer stackauth_<base64(getAuthJson())>`.");
|
|
82
82
|
let parsed;
|
|
83
83
|
try {
|
|
84
|
-
const decodedAuthJson = new TextDecoder().decode((0,
|
|
84
|
+
const decodedAuthJson = new TextDecoder().decode((0, _hexclave_shared_dist_utils_bytes.decodeBase64)(encodedAuthJson));
|
|
85
85
|
parsed = JSON.parse(decodedAuthJson);
|
|
86
86
|
} catch (e) {
|
|
87
87
|
throw new Error("Invalid stackauth authorization header.", { cause: e });
|
|
@@ -103,8 +103,8 @@ function getHeaderValueFromRequestLikeHeaders(headers, name) {
|
|
|
103
103
|
return null;
|
|
104
104
|
}
|
|
105
105
|
function getTanStackStartRequestHeader(name) {
|
|
106
|
-
const { getRequestHeader } =
|
|
107
|
-
if (getRequestHeader == null) throw new
|
|
106
|
+
const { getRequestHeader } = _hexclave_tanstack_start_tanstack_start_server_context;
|
|
107
|
+
if (getRequestHeader == null) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("TanStack Start request headers are only available during server rendering");
|
|
108
108
|
return getRequestHeader(name) ?? null;
|
|
109
109
|
}
|
|
110
110
|
async function getServerRequestHost() {
|
|
@@ -126,7 +126,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
126
126
|
if (!user || !user.oauth_providers.find((p) => p.id === options.providerId)) hasConnection = false;
|
|
127
127
|
if (!await options.getOrWaitOAuthToken()) hasConnection = false;
|
|
128
128
|
if (!hasConnection && options.redirect) {
|
|
129
|
-
if (!options.session) throw new Error(
|
|
129
|
+
if (!options.session) throw new Error(_hexclave_shared_dist_utils_strings.deindent`
|
|
130
130
|
Cannot add new scopes to a user that is not a CurrentUser. Please ensure that you are calling this function on a CurrentUser object, or remove the 'or: redirect' option.
|
|
131
131
|
|
|
132
132
|
Often, you can solve this by calling this function in the browser instead, or by removing the 'or: redirect' option and dealing with the case where the user doesn't have enough permissions.
|
|
@@ -135,10 +135,10 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
135
135
|
provider: options.providerId,
|
|
136
136
|
redirectUrl: this._getOAuthCallbackRedirectUri(),
|
|
137
137
|
errorRedirectUrl: this.urls.error,
|
|
138
|
-
providerScope: (0,
|
|
138
|
+
providerScope: (0, _hexclave_shared_dist_utils_strings.mergeScopeStrings)(options.scope || "", (this._oauthScopesOnSignIn[options.providerId] ?? []).join(" "))
|
|
139
139
|
}, options.session);
|
|
140
140
|
await this._redirectTo({ url: location });
|
|
141
|
-
return await (0,
|
|
141
|
+
return await (0, _hexclave_shared_dist_utils_promises.neverResolve)();
|
|
142
142
|
} else if (!hasConnection) return null;
|
|
143
143
|
const providerAccountId = user.oauth_providers.find((p) => p.id === options.providerId)?.account_id ?? "";
|
|
144
144
|
return {
|
|
@@ -147,12 +147,12 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
147
147
|
providerAccountId,
|
|
148
148
|
async getAccessToken() {
|
|
149
149
|
const result = await options.getOrWaitOAuthToken();
|
|
150
|
-
if (!result) throw new
|
|
150
|
+
if (!result) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError(`Failed to retrieve an access token for this connected account (provider: ${options.providerId}). This usually means the OAuth refresh token has been revoked or expired. The user needs to re-authorize by calling \`linkConnectedAccount\` or using \`getOrLinkConnectedAccount\`.`);
|
|
151
151
|
return result;
|
|
152
152
|
},
|
|
153
153
|
useAccessToken() {
|
|
154
154
|
const result = options.useOAuthToken();
|
|
155
|
-
if (!result) throw new
|
|
155
|
+
if (!result) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError(`Failed to retrieve an access token for this connected account (provider: ${options.providerId}). This usually means the OAuth refresh token has been revoked or expired. The user needs to re-authorize by calling \`linkConnectedAccount\` or using \`getOrLinkConnectedAccount\`.`);
|
|
156
156
|
return result;
|
|
157
157
|
}
|
|
158
158
|
};
|
|
@@ -167,7 +167,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
167
167
|
providerAccountId,
|
|
168
168
|
async getAccessToken(options) {
|
|
169
169
|
const scopeString = options?.scopes?.join(" ") ?? "";
|
|
170
|
-
const result =
|
|
170
|
+
const result = _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserOAuthConnectionAccessTokensByAccountCache.getOrWait([
|
|
171
171
|
session,
|
|
172
172
|
providerId,
|
|
173
173
|
providerAccountId,
|
|
@@ -175,9 +175,9 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
175
175
|
], "write-only"));
|
|
176
176
|
if (!result) {
|
|
177
177
|
const scopeDetail = scopeString ? `The requested scopes [${scopeString}] are not available on the existing token.` : "The OAuth refresh token has likely been revoked or expired.";
|
|
178
|
-
return
|
|
178
|
+
return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.OAuthAccessTokenNotAvailable(providerId, `${scopeDetail} The user needs to re-authorize by calling \`linkConnectedAccount\` or using \`getOrLinkConnectedAccount\`.`));
|
|
179
179
|
}
|
|
180
|
-
return
|
|
180
|
+
return _hexclave_shared_dist_utils_results.Result.ok(result);
|
|
181
181
|
},
|
|
182
182
|
useAccessToken(options) {
|
|
183
183
|
const scopeString = options?.scopes?.join(" ") ?? "";
|
|
@@ -189,9 +189,9 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
189
189
|
], "connection.useAccessToken()");
|
|
190
190
|
if (!result) {
|
|
191
191
|
const scopeDetail = scopeString ? `The requested scopes [${scopeString}] are not available on the existing token.` : "The OAuth refresh token has likely been revoked or expired.";
|
|
192
|
-
return
|
|
192
|
+
return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.OAuthAccessTokenNotAvailable(providerId, `${scopeDetail} The user needs to re-authorize by calling \`linkConnectedAccount\` or using \`getOrLinkConnectedAccount\`.`));
|
|
193
193
|
}
|
|
194
|
-
return
|
|
194
|
+
return _hexclave_shared_dist_utils_results.Result.ok(result);
|
|
195
195
|
}
|
|
196
196
|
};
|
|
197
197
|
}
|
|
@@ -200,14 +200,14 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
200
200
|
this._sessionRecorder = null;
|
|
201
201
|
this._eventTracker = null;
|
|
202
202
|
this.__DEMO_ENABLE_SLIGHT_FETCH_DELAY = false;
|
|
203
|
-
this._ownedAdminApps = new
|
|
203
|
+
this._ownedAdminApps = new _hexclave_shared_dist_utils_maps.DependenciesMap();
|
|
204
204
|
this._currentUserCache = (0, __common_js.createCacheBySession)(async (session) => {
|
|
205
|
-
if (this.__DEMO_ENABLE_SLIGHT_FETCH_DELAY) await (0,
|
|
205
|
+
if (this.__DEMO_ENABLE_SLIGHT_FETCH_DELAY) await (0, _hexclave_shared_dist_utils_promises.wait)(2e3);
|
|
206
206
|
if (session.isKnownToBeInvalid()) return null;
|
|
207
207
|
return await this._interface.getClientUserByToken(session);
|
|
208
208
|
});
|
|
209
209
|
this._currentProjectCache = (0, __common_js.createCache)(async () => {
|
|
210
|
-
return
|
|
210
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await this._interface.getClientProject());
|
|
211
211
|
});
|
|
212
212
|
this._ownedProjectsCache = (0, __common_js.createCacheBySession)(async (session) => {
|
|
213
213
|
return await this._interface.listProjects(session);
|
|
@@ -228,14 +228,14 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
228
228
|
try {
|
|
229
229
|
return { accessToken: (await this._interface.createProviderAccessToken(providerId, scope || "", session)).access_token };
|
|
230
230
|
} catch (err) {
|
|
231
|
-
if (!(
|
|
231
|
+
if (!(_hexclave_shared.KnownErrors.OAuthAccessTokenNotAvailable.isInstance(err) || _hexclave_shared.KnownErrors.OAuthConnectionDoesNotHaveRequiredScope.isInstance(err) || _hexclave_shared.KnownErrors.OAuthConnectionNotConnectedToUser.isInstance(err))) throw err;
|
|
232
232
|
}
|
|
233
233
|
return null;
|
|
234
234
|
});
|
|
235
235
|
this._currentUserOAuthConnectionCache = (0, __common_js.createCacheBySession)(async (session, [providerId, scope, redirect]) => {
|
|
236
236
|
return await this._getUserOAuthConnectionCacheFn({
|
|
237
|
-
getUser: async () =>
|
|
238
|
-
getOrWaitOAuthToken: async () =>
|
|
237
|
+
getUser: async () => _hexclave_shared_dist_utils_results.Result.orThrow(await this._currentUserCache.getOrWait([session], "write-only")),
|
|
238
|
+
getOrWaitOAuthToken: async () => _hexclave_shared_dist_utils_results.Result.orThrow(await this._currentUserOAuthConnectionAccessTokensCache.getOrWait([
|
|
239
239
|
session,
|
|
240
240
|
providerId,
|
|
241
241
|
scope || ""
|
|
@@ -258,22 +258,22 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
258
258
|
try {
|
|
259
259
|
return { accessToken: (await this._interface.createProviderAccessTokenByAccount(providerId, providerAccountId, scope, session)).access_token };
|
|
260
260
|
} catch (err) {
|
|
261
|
-
if (
|
|
261
|
+
if (_hexclave_shared.KnownErrors.OAuthAccessTokenNotAvailable.isInstance(err) || _hexclave_shared.KnownErrors.OAuthConnectionDoesNotHaveRequiredScope.isInstance(err) || _hexclave_shared.KnownErrors.OAuthConnectionNotConnectedToUser.isInstance(err)) return null;
|
|
262
262
|
throw err;
|
|
263
263
|
}
|
|
264
264
|
});
|
|
265
265
|
this._currentUserValidConnectedAccountForProviderCache = (0, __common_js.createCacheBySession)(async (session, [provider, scopeString]) => {
|
|
266
|
-
const matchingAccounts =
|
|
266
|
+
const matchingAccounts = _hexclave_shared_dist_utils_results.Result.orThrow(await this._currentUserConnectedAccountsCache.getOrWait([session], "write-only")).filter((a) => a.provider === provider);
|
|
267
267
|
const scopes = scopeString ? scopeString.split(" ") : void 0;
|
|
268
268
|
for (const account of matchingAccounts) if ((await account.getAccessToken({ scopes })).status === "ok") return account;
|
|
269
269
|
const location = await (0, _________auth_js.getNewOAuthProviderOrScopeUrl)(this._interface, {
|
|
270
270
|
provider,
|
|
271
271
|
redirectUrl: this._getOAuthCallbackRedirectUri(),
|
|
272
272
|
errorRedirectUrl: this.urls.error,
|
|
273
|
-
providerScope: (0,
|
|
273
|
+
providerScope: (0, _hexclave_shared_dist_utils_strings.mergeScopeStrings)(scopeString, (this._oauthScopesOnSignIn[provider] ?? []).join(" "))
|
|
274
274
|
}, session);
|
|
275
275
|
await this._redirectTo({ url: location });
|
|
276
|
-
return await (0,
|
|
276
|
+
return await (0, _hexclave_shared_dist_utils_promises.neverResolve)();
|
|
277
277
|
});
|
|
278
278
|
this._teamMemberProfilesCache = (0, __common_js.createCacheBySession)(async (session, [teamId]) => {
|
|
279
279
|
return await this._interface.listTeamMemberProfiles({ teamId }, session);
|
|
@@ -381,7 +381,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
381
381
|
this._sessionsByTokenStoreAndSessionKey = /* @__PURE__ */ new WeakMap();
|
|
382
382
|
this._botChallengeSiteKeysWarned = false;
|
|
383
383
|
const resolvedOptions = (0, __common_js.resolveConstructorOptions)(options);
|
|
384
|
-
if (!_StackClientAppImplIncomplete.LazyStackAdminAppImpl.value) throw new
|
|
384
|
+
if (!_StackClientAppImplIncomplete.LazyStackAdminAppImpl.value) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("Admin app implementation not initialized. Did you import the _StackClientApp from stack-app/apps/implementations/index.ts? You can't import it directly from ./apps/implementations/client-app-impl.ts as that causes a circular dependency (see the comment at _LazyStackAdminAppImpl for more details).");
|
|
385
385
|
this._options = resolvedOptions;
|
|
386
386
|
this._extraOptions = extraOptions;
|
|
387
387
|
const projectId = resolvedOptions.projectId ?? (0, __common_js.getDefaultProjectId)();
|
|
@@ -390,7 +390,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
390
390
|
if (extraOptions && extraOptions.interface) this._interface = extraOptions.interface;
|
|
391
391
|
else {
|
|
392
392
|
const apiUrls = (0, __common_js.resolveApiUrls)(resolvedOptions.baseUrl);
|
|
393
|
-
this._interface = new
|
|
393
|
+
this._interface = new _hexclave_shared.HexclaveClientInterface({
|
|
394
394
|
getBaseUrl: () => apiUrls()[0],
|
|
395
395
|
getAnalyticsBaseUrl: () => (0, __common_js.getAnalyticsBaseUrl)(apiUrls()[0]),
|
|
396
396
|
getApiUrls: apiUrls,
|
|
@@ -402,12 +402,12 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
402
402
|
});
|
|
403
403
|
}
|
|
404
404
|
this._tokenStoreInit = resolvedOptions.tokenStore;
|
|
405
|
-
this._redirectMethod = resolvedOptions.redirectMethod || ((0,
|
|
405
|
+
this._redirectMethod = resolvedOptions.redirectMethod || ((0, _hexclave_shared_dist_utils_env.isBrowserLike)() ? "window" : "none");
|
|
406
406
|
this._redirectMethod = resolvedOptions.redirectMethod || "tanstack-start";
|
|
407
407
|
this._urlOptions = resolvedOptions.urls ?? {};
|
|
408
408
|
this._oauthScopesOnSignIn = resolvedOptions.oauthScopesOnSignIn ?? {};
|
|
409
|
-
if ((0,
|
|
410
|
-
(0,
|
|
409
|
+
if ((0, _hexclave_shared_dist_utils_env.isBrowserLike)() && (resolvedOptions.tokenStore === "cookie" || resolvedOptions.tokenStore === "nextjs-cookie")) {
|
|
410
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(this._trustedParentDomainCache.getOrWait([window.location.hostname], "write-only"));
|
|
411
411
|
this._ensureCrossSubdomainCookieExists();
|
|
412
412
|
}
|
|
413
413
|
if (extraOptions && extraOptions.uniqueIdentifier) {
|
|
@@ -424,7 +424,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
424
424
|
return (await this.getUser({ or: "anonymous" }))._internalSession;
|
|
425
425
|
};
|
|
426
426
|
const analyticsEnabled = this._analyticsOptions?.enabled !== false;
|
|
427
|
-
if (analyticsEnabled && (0,
|
|
427
|
+
if (analyticsEnabled && (0, _hexclave_shared_dist_utils_env.isBrowserLike)() && this._hasPersistentTokenStore() && this._analyticsOptions?.replays?.enabled === true) {
|
|
428
428
|
this._sessionRecorder = new __session_replay_js.SessionRecorder({
|
|
429
429
|
projectId: this.projectId,
|
|
430
430
|
sendBatch: async (body, opts) => {
|
|
@@ -433,7 +433,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
433
433
|
}, this._analyticsOptions.replays);
|
|
434
434
|
this._sessionRecorder.start();
|
|
435
435
|
}
|
|
436
|
-
if (analyticsEnabled && (0,
|
|
436
|
+
if (analyticsEnabled && (0, _hexclave_shared_dist_utils_env.isBrowserLike)() && this._hasPersistentTokenStore()) {
|
|
437
437
|
this._eventTracker = new __event_tracker_js.EventTracker({
|
|
438
438
|
projectId: this.projectId,
|
|
439
439
|
sendBatch: async (body, opts) => {
|
|
@@ -442,17 +442,17 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
442
442
|
});
|
|
443
443
|
this._eventTracker.start();
|
|
444
444
|
}
|
|
445
|
-
if ((0,
|
|
446
|
-
if ((0,
|
|
445
|
+
if ((0, _hexclave_shared_dist_utils_env.isBrowserLike)() && this._isOAuthCallbackUrlHosted() && this._currentUrlLooksLikeStackOAuthCallback()) this._trackPendingAuthResolution(async () => {
|
|
446
|
+
if ((0, _hexclave_shared_dist_utils_env.isBrowserLike)()) await this.callOAuthCallback({ dontWarnAboutMissingQueryParams: true });
|
|
447
447
|
});
|
|
448
|
-
if ((0,
|
|
448
|
+
if ((0, _hexclave_shared_dist_utils_env.isBrowserLike)()) this._trackPendingAuthResolution(async () => {
|
|
449
449
|
await this._maybeHandleNestedCrossDomainAuth();
|
|
450
450
|
});
|
|
451
|
-
if ((0,
|
|
451
|
+
if ((0, _hexclave_shared_dist_utils_env.isBrowserLike)() && resolvedOptions.devTool !== false) (0, ____________dev_tool_index_js.mountDevTool)(this);
|
|
452
452
|
}
|
|
453
453
|
_initUniqueIdentifier() {
|
|
454
|
-
if (!this._uniqueIdentifier) throw new
|
|
455
|
-
if (allClientApps.has(this._uniqueIdentifier)) throw new
|
|
454
|
+
if (!this._uniqueIdentifier) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("Unique identifier not initialized");
|
|
455
|
+
if (allClientApps.has(this._uniqueIdentifier)) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("A Stack client app with the same unique identifier already exists");
|
|
456
456
|
allClientApps.set(this._uniqueIdentifier, [this._extraOptions?.checkString ?? void 0, this]);
|
|
457
457
|
}
|
|
458
458
|
_trackPendingAuthResolution(callback) {
|
|
@@ -461,11 +461,11 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
461
461
|
try {
|
|
462
462
|
await callback();
|
|
463
463
|
} catch (error) {
|
|
464
|
-
(0,
|
|
464
|
+
(0, _hexclave_shared_dist_utils_errors.captureError)("pending-auth-resolution-failed", error);
|
|
465
465
|
}
|
|
466
466
|
})();
|
|
467
467
|
this._pendingAuthResolutionPromises.push(promise);
|
|
468
|
-
(0,
|
|
468
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
469
469
|
try {
|
|
470
470
|
await promise;
|
|
471
471
|
} finally {
|
|
@@ -479,7 +479,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
479
479
|
}
|
|
480
480
|
_usePendingAuthResolutions(overrideTokenStoreInit) {
|
|
481
481
|
if (overrideTokenStoreInit !== void 0 || !this._hasPersistentTokenStore() || this._pendingAuthResolutionPromises.length === 0) return;
|
|
482
|
-
(0,
|
|
482
|
+
(0, _hexclave_shared_dist_utils_react.use)(Promise.all(this._pendingAuthResolutionPromises));
|
|
483
483
|
}
|
|
484
484
|
_isOAuthCallbackUrlHosted() {
|
|
485
485
|
const oauthCallbackTarget = this._urlOptions.oauthCallback ?? this._urlOptions.default;
|
|
@@ -499,7 +499,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
499
499
|
}
|
|
500
500
|
_getOAuthCallbackRedirectUri() {
|
|
501
501
|
if (!this._isOAuthCallbackUrlHosted()) return this.urls.oauthCallback;
|
|
502
|
-
if (typeof window === "undefined") throw new
|
|
502
|
+
if (typeof window === "undefined") throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("Hosted OAuth callback URLs require a browser environment to use the current URL as the redirect URI");
|
|
503
503
|
const currentUrl = new URL(window.location.href);
|
|
504
504
|
for (const param of oauthCallbackResponseQueryParams) currentUrl.searchParams.delete(param);
|
|
505
505
|
return currentUrl.toString();
|
|
@@ -531,13 +531,13 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
531
531
|
const state = currentUrl.searchParams.get(nestedCrossDomainAuthQueryParams.state);
|
|
532
532
|
const codeChallenge = currentUrl.searchParams.get(nestedCrossDomainAuthQueryParams.codeChallenge);
|
|
533
533
|
if (redirectUri != null || state != null || codeChallenge != null) {
|
|
534
|
-
if (redirectUri == null || state == null || codeChallenge == null) throw new
|
|
534
|
+
if (redirectUri == null || state == null || codeChallenge == null) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("Nested cross-domain auth callback URL is missing OAuth request parameters", {
|
|
535
535
|
redirectUri,
|
|
536
536
|
state,
|
|
537
537
|
codeChallenge
|
|
538
538
|
});
|
|
539
|
-
if ((currentUrl.searchParams.get(nestedCrossDomainAuthQueryParams.codeChallengeMethod) ?? "S256") !== "S256") throw new
|
|
540
|
-
if ((0,
|
|
539
|
+
if ((currentUrl.searchParams.get(nestedCrossDomainAuthQueryParams.codeChallengeMethod) ?? "S256") !== "S256") throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("Nested cross-domain auth only supports S256 PKCE");
|
|
540
|
+
if ((0, _hexclave_shared_dist_utils_urls.isRelative)(redirectUri)) throw new Error("Nested cross-domain auth redirect URI must be absolute.");
|
|
541
541
|
const redirectUriUrl = new URL(redirectUri);
|
|
542
542
|
if (!await this._isTrusted(redirectUriUrl.toString())) throw new Error(`Nested cross-domain auth redirect URI ${redirectUri} is not trusted.`);
|
|
543
543
|
const afterCallbackRedirectUrlString = currentUrl.searchParams.get(nestedCrossDomainAuthQueryParams.afterCallbackRedirectUrl);
|
|
@@ -558,16 +558,29 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
558
558
|
}
|
|
559
559
|
if (await this._getCurrentRefreshTokenIdIfSignedIn({ awaitPendingAuthResolutions: false }) === refreshTokenId) return false;
|
|
560
560
|
const callbackUrlString = currentUrl.searchParams.get(nestedCrossDomainAuthQueryParams.callbackUrl);
|
|
561
|
-
if (callbackUrlString == null) throw new
|
|
562
|
-
if ((0,
|
|
561
|
+
if (callbackUrlString == null) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("Nested cross-domain auth URL is missing callback URL");
|
|
562
|
+
if ((0, _hexclave_shared_dist_utils_urls.isRelative)(callbackUrlString)) throw new Error("Nested cross-domain auth callback URL must be absolute.");
|
|
563
563
|
const callbackUrl = new URL(callbackUrlString);
|
|
564
564
|
if (!await this._isTrusted(callbackUrl.toString())) throw new Error(`Nested cross-domain auth callback URL ${callbackUrlString} is not trusted.`);
|
|
565
565
|
const afterCallbackRedirectUrl = new URL(currentUrl);
|
|
566
566
|
afterCallbackRedirectUrl.searchParams.delete(nestedCrossDomainAuthQueryParams.refreshTokenId);
|
|
567
567
|
afterCallbackRedirectUrl.searchParams.delete(nestedCrossDomainAuthQueryParams.callbackUrl);
|
|
568
|
-
const { state: newState, codeChallenge: newCodeChallenge } = await this.
|
|
568
|
+
const { state: newState, codeChallenge: newCodeChallenge } = await this._getNestedCrossDomainAuthParamsForRedirect();
|
|
569
|
+
const nestedRedirectUri = new URL(this._getOAuthCallbackRedirectUri(), currentUrl);
|
|
570
|
+
nestedRedirectUri.searchParams.delete(nestedCrossDomainAuthQueryParams.refreshTokenId);
|
|
571
|
+
nestedRedirectUri.searchParams.delete(nestedCrossDomainAuthQueryParams.callbackUrl);
|
|
572
|
+
for (const param of [
|
|
573
|
+
"after_auth_return_to",
|
|
574
|
+
__redirect_page_urls_js.crossDomainAuthQueryParams.marker,
|
|
575
|
+
__redirect_page_urls_js.crossDomainAuthQueryParams.state,
|
|
576
|
+
__redirect_page_urls_js.crossDomainAuthQueryParams.codeChallenge,
|
|
577
|
+
__redirect_page_urls_js.crossDomainAuthQueryParams.afterCallbackRedirectUrl
|
|
578
|
+
]) {
|
|
579
|
+
const value = currentUrl.searchParams.get(param);
|
|
580
|
+
if (value != null && !nestedRedirectUri.searchParams.has(param)) nestedRedirectUri.searchParams.set(param, value);
|
|
581
|
+
}
|
|
569
582
|
callbackUrl.searchParams.set(nestedCrossDomainAuthQueryParams.refreshTokenId, refreshTokenId);
|
|
570
|
-
callbackUrl.searchParams.set(nestedCrossDomainAuthQueryParams.redirectUri,
|
|
583
|
+
callbackUrl.searchParams.set(nestedCrossDomainAuthQueryParams.redirectUri, nestedRedirectUri.toString());
|
|
571
584
|
callbackUrl.searchParams.set(nestedCrossDomainAuthQueryParams.state, newState);
|
|
572
585
|
callbackUrl.searchParams.set(nestedCrossDomainAuthQueryParams.codeChallenge, newCodeChallenge);
|
|
573
586
|
callbackUrl.searchParams.set(nestedCrossDomainAuthQueryParams.codeChallengeMethod, "S256");
|
|
@@ -578,6 +591,9 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
578
591
|
});
|
|
579
592
|
return true;
|
|
580
593
|
}
|
|
594
|
+
async _getNestedCrossDomainAuthParamsForRedirect() {
|
|
595
|
+
return await (0, _________cookie_js.saveVerifierAndState)();
|
|
596
|
+
}
|
|
581
597
|
/**
|
|
582
598
|
* Cloudflare workers does not allow use of randomness on the global scope (on which the Stack app is probably
|
|
583
599
|
* initialized). For that reason, we generate the unique identifier lazily when it is first needed instead of in the
|
|
@@ -585,7 +601,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
585
601
|
*/
|
|
586
602
|
_getUniqueIdentifier() {
|
|
587
603
|
if (!this._uniqueIdentifier) {
|
|
588
|
-
this._uniqueIdentifier = (0,
|
|
604
|
+
this._uniqueIdentifier = (0, _hexclave_shared_dist_utils_uuids.generateUuid)();
|
|
589
605
|
this._initUniqueIdentifier();
|
|
590
606
|
}
|
|
591
607
|
return this._uniqueIdentifier;
|
|
@@ -597,8 +613,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
597
613
|
});
|
|
598
614
|
}
|
|
599
615
|
_useCheckFeatureSupport(name, options) {
|
|
600
|
-
(0,
|
|
601
|
-
throw new
|
|
616
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(this._checkFeatureSupport(name, options));
|
|
617
|
+
throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError(`${name} is not currently supported. Please reach out to Stack support for more information.`);
|
|
602
618
|
}
|
|
603
619
|
get _legacyRefreshTokenCookieName() {
|
|
604
620
|
return `stack-refresh-${this.projectId}`;
|
|
@@ -610,7 +626,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
610
626
|
return `${secure ? "__Host-" : ""}${this._refreshTokenCookieName}--default`;
|
|
611
627
|
}
|
|
612
628
|
_getCustomRefreshCookieName(domain) {
|
|
613
|
-
const encoded = (0,
|
|
629
|
+
const encoded = (0, _hexclave_shared_dist_utils_bytes.encodeBase32)(new TextEncoder().encode(domain.toLowerCase()));
|
|
614
630
|
return `${this._refreshTokenCookieName}--custom-${encoded}`;
|
|
615
631
|
}
|
|
616
632
|
_getDomainFromCustomRefreshCookieName(name) {
|
|
@@ -618,7 +634,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
618
634
|
const prefix = `${base}--custom-`;
|
|
619
635
|
if (!name.startsWith(prefix)) continue;
|
|
620
636
|
try {
|
|
621
|
-
return new TextDecoder().decode((0,
|
|
637
|
+
return new TextDecoder().decode((0, _hexclave_shared_dist_utils_bytes.decodeBase32)(name.slice(prefix.length)));
|
|
622
638
|
} catch {
|
|
623
639
|
return null;
|
|
624
640
|
}
|
|
@@ -636,7 +652,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
636
652
|
}
|
|
637
653
|
_parseStructuredRefreshCookie(value) {
|
|
638
654
|
if (!value) return null;
|
|
639
|
-
const parsed = (0,
|
|
655
|
+
const parsed = (0, _hexclave_shared_dist_utils_json.parseJson)(value);
|
|
640
656
|
if (parsed.status !== "ok" || typeof parsed.data !== "object" || parsed.data === null) {
|
|
641
657
|
console.warn("Failed to parse structured refresh cookie");
|
|
642
658
|
return null;
|
|
@@ -695,7 +711,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
695
711
|
const accessTokenCookie = cookies[this._accessTokenCookieName] ?? cookies[this._legacyAccessTokenCookieName] ?? null;
|
|
696
712
|
let accessToken = null;
|
|
697
713
|
if (accessTokenCookie && accessTokenCookie.startsWith("[\"")) {
|
|
698
|
-
const parsed = (0,
|
|
714
|
+
const parsed = (0, _hexclave_shared_dist_utils_json.parseJson)(accessTokenCookie);
|
|
699
715
|
if (parsed.status === "ok" && typeof parsed.data === "object" && parsed.data !== null && Array.isArray(parsed.data) && parsed.data.length === 2 && typeof parsed.data[0] === "string" && typeof parsed.data[1] === "string") {
|
|
700
716
|
if (parsed.data[0] === refreshToken) accessToken = parsed.data[1];
|
|
701
717
|
} else console.warn("Access token cookie has invalid format");
|
|
@@ -712,7 +728,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
712
728
|
return `stack-access`;
|
|
713
729
|
}
|
|
714
730
|
_getAllBrowserCookies() {
|
|
715
|
-
if (!(0,
|
|
731
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)()) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("Cannot get browser cookies on the server!");
|
|
716
732
|
return cookie.parseCookie(document.cookie || "");
|
|
717
733
|
}
|
|
718
734
|
_getRefreshTokenCookieNamePatterns() {
|
|
@@ -745,7 +761,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
745
761
|
};
|
|
746
762
|
}
|
|
747
763
|
_ensureCrossSubdomainCookieExists() {
|
|
748
|
-
(0,
|
|
764
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
749
765
|
const hostname = window.location.hostname;
|
|
750
766
|
const domain = await this._trustedParentDomainCache.getOrWait([hostname], "read-write");
|
|
751
767
|
if (domain.status === "error" || !domain.data) return;
|
|
@@ -760,11 +776,11 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
760
776
|
});
|
|
761
777
|
}
|
|
762
778
|
_queueCustomRefreshCookieUpdate(refreshToken, updatedAt, context) {
|
|
763
|
-
(0,
|
|
779
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
764
780
|
this._mostRecentQueuedCookieRefreshIndex++;
|
|
765
781
|
const updateIndex = this._mostRecentQueuedCookieRefreshIndex;
|
|
766
782
|
let hostname;
|
|
767
|
-
if ((0,
|
|
783
|
+
if ((0, _hexclave_shared_dist_utils_env.isBrowserLike)()) hostname = window.location.hostname;
|
|
768
784
|
else hostname = await getServerRequestHost();
|
|
769
785
|
if (!hostname) {
|
|
770
786
|
console.warn("No hostname found when queueing custom refresh cookie update");
|
|
@@ -794,7 +810,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
794
810
|
});
|
|
795
811
|
}
|
|
796
812
|
async _getTrustedRedirectConfig() {
|
|
797
|
-
const project =
|
|
813
|
+
const project = _hexclave_shared_dist_utils_results.Result.orThrow(await this._currentProjectCache.getOrWait([], "write-only"));
|
|
798
814
|
return {
|
|
799
815
|
allowLocalhost: project.config.allow_localhost,
|
|
800
816
|
trustedDomains: [...project.config.domains.map((d) => d.domain), new URL((0, ______url_targets_js.getHostedHandlerUrl)({
|
|
@@ -804,10 +820,10 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
804
820
|
};
|
|
805
821
|
}
|
|
806
822
|
async _getTrustedParentDomain(currentDomain) {
|
|
807
|
-
return (0,
|
|
823
|
+
return (0, _hexclave_shared_dist_utils_redirect_urls.getTrustedParentDomain)(currentDomain, (await this._getTrustedRedirectConfig()).trustedDomains);
|
|
808
824
|
}
|
|
809
825
|
_getBrowserCookieTokenStore() {
|
|
810
|
-
if (!(0,
|
|
826
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)()) throw new Error("Cannot use cookie token store on the server!");
|
|
811
827
|
if (this._storedBrowserCookieTokenStore === null) {
|
|
812
828
|
const getCurrentValue = (old) => {
|
|
813
829
|
const tokens = this._getTokensFromCookies(this._getAllBrowserCookies());
|
|
@@ -816,13 +832,13 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
816
832
|
accessToken: tokens.accessToken ?? (old?.refreshToken === tokens.refreshToken ? old.accessToken : null)
|
|
817
833
|
};
|
|
818
834
|
};
|
|
819
|
-
this._storedBrowserCookieTokenStore = new
|
|
835
|
+
this._storedBrowserCookieTokenStore = new _hexclave_shared_dist_utils_stores.Store(getCurrentValue(null));
|
|
820
836
|
let hasSucceededInWriting = true;
|
|
821
837
|
setInterval(() => {
|
|
822
838
|
if (hasSucceededInWriting) {
|
|
823
839
|
const oldValue = this._storedBrowserCookieTokenStore.get();
|
|
824
840
|
const currentValue = getCurrentValue(oldValue);
|
|
825
|
-
if (!(0,
|
|
841
|
+
if (!(0, _hexclave_shared_dist_utils_objects.deepPlainEquals)(currentValue, oldValue)) this._storedBrowserCookieTokenStore.set(currentValue);
|
|
826
842
|
}
|
|
827
843
|
}, 100);
|
|
828
844
|
this._storedBrowserCookieTokenStore.onChange((value) => {
|
|
@@ -843,7 +859,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
843
859
|
this._queueCustomRefreshCookieUpdate(refreshToken, updatedAt, "browser");
|
|
844
860
|
hasSucceededInWriting = true;
|
|
845
861
|
} catch (e) {
|
|
846
|
-
if (!(0,
|
|
862
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)()) hasSucceededInWriting = false;
|
|
847
863
|
else throw e;
|
|
848
864
|
}
|
|
849
865
|
});
|
|
@@ -854,13 +870,13 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
854
870
|
const tokenStoreInit = overrideTokenStoreInit === void 0 ? this._tokenStoreInit : overrideTokenStoreInit;
|
|
855
871
|
switch (tokenStoreInit) {
|
|
856
872
|
case "cookie":
|
|
857
|
-
if (!(0,
|
|
873
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)()) return this._getOrCreateTokenStore(cookieHelper, "nextjs-cookie");
|
|
858
874
|
return this._getBrowserCookieTokenStore();
|
|
859
|
-
case "nextjs-cookie": if ((0,
|
|
875
|
+
case "nextjs-cookie": if ((0, _hexclave_shared_dist_utils_env.isBrowserLike)()) return this._getBrowserCookieTokenStore();
|
|
860
876
|
else {
|
|
861
|
-
const store = new
|
|
877
|
+
const store = new _hexclave_shared_dist_utils_stores.Store(this._getTokensFromCookies(cookieHelper.getAll()));
|
|
862
878
|
store.onChange((value) => {
|
|
863
|
-
(0,
|
|
879
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
864
880
|
const refreshToken = value.refreshToken;
|
|
865
881
|
const secure = await (0, _________cookie_js.isSecure)();
|
|
866
882
|
const defaultName = this._getRefreshTokenDefaultCookieNameForSecure(secure);
|
|
@@ -893,7 +909,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
893
909
|
if (authorizationHeader) {
|
|
894
910
|
const authJson = getAuthJsonFromAuthorizationHeaderValue(authorizationHeader);
|
|
895
911
|
if (authJson != null) {
|
|
896
|
-
const tokenStore = new
|
|
912
|
+
const tokenStore = new _hexclave_shared_dist_utils_stores.Store({
|
|
897
913
|
accessToken: authJson.accessToken,
|
|
898
914
|
refreshToken: authJson.refreshToken
|
|
899
915
|
});
|
|
@@ -918,10 +934,10 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
918
934
|
}
|
|
919
935
|
const cookieHeader = getHeaderValueFromRequestLikeHeaders(tokenStoreInit.headers, "cookie");
|
|
920
936
|
const parsed = cookie.parseCookie(cookieHeader || "");
|
|
921
|
-
const res = new
|
|
937
|
+
const res = new _hexclave_shared_dist_utils_stores.Store(this._getTokensFromCookies(parsed));
|
|
922
938
|
this._requestTokenStores.set(tokenStoreInit, res);
|
|
923
939
|
return res;
|
|
924
|
-
} else if ("accessToken" in tokenStoreInit || "refreshToken" in tokenStoreInit) return new
|
|
940
|
+
} else if ("accessToken" in tokenStoreInit || "refreshToken" in tokenStoreInit) return new _hexclave_shared_dist_utils_stores.Store({
|
|
925
941
|
refreshToken: tokenStoreInit.refreshToken,
|
|
926
942
|
accessToken: tokenStoreInit.accessToken
|
|
927
943
|
});
|
|
@@ -929,14 +945,14 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
929
945
|
}
|
|
930
946
|
}
|
|
931
947
|
_useTokenStore(overrideTokenStoreInit) {
|
|
932
|
-
if (!(0,
|
|
933
|
-
(0,
|
|
948
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)()) return this._getOrCreateTokenStore((0, _hexclave_shared_dist_utils_react.use)((0, _________cookie_js.createCookieHelper)()), overrideTokenStoreInit);
|
|
949
|
+
(0, _hexclave_shared_dist_utils_react.suspendIfSsr)();
|
|
934
950
|
const cookieHelper = (0, _________cookie_js.createBrowserCookieHelper)();
|
|
935
951
|
return this._getOrCreateTokenStore(cookieHelper, overrideTokenStoreInit);
|
|
936
952
|
}
|
|
937
953
|
_getSessionFromTokenStore(tokenStore) {
|
|
938
954
|
const tokenObj = tokenStore.get();
|
|
939
|
-
const sessionKey =
|
|
955
|
+
const sessionKey = _hexclave_shared_dist_sessions.InternalSession.calculateSessionKey(tokenObj);
|
|
940
956
|
const existing = sessionKey ? this._sessionsByTokenStoreAndSessionKey.get(tokenStore)?.get(sessionKey) : null;
|
|
941
957
|
if (existing) return existing;
|
|
942
958
|
const session = this._interface.createSession({
|
|
@@ -980,7 +996,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
980
996
|
return react.default.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
981
997
|
}
|
|
982
998
|
async _signInToAccountWithTokens(tokens) {
|
|
983
|
-
if (!("accessToken" in tokens) || !("refreshToken" in tokens)) throw new
|
|
999
|
+
if (!("accessToken" in tokens) || !("refreshToken" in tokens)) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("Invalid tokens object; can't sign in with this", { tokens });
|
|
984
1000
|
const tokenStore = this._getOrCreateTokenStore(await this._createCookieHelper());
|
|
985
1001
|
tokenStore.set(tokens);
|
|
986
1002
|
const newSession = this._getSessionFromTokenStore(tokenStore);
|
|
@@ -1120,13 +1136,13 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1120
1136
|
await app._teamInvitationsCache.refresh([session, crud.id]);
|
|
1121
1137
|
},
|
|
1122
1138
|
async listUsers() {
|
|
1123
|
-
return
|
|
1139
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._teamMemberProfilesCache.getOrWait([session, crud.id], "write-only")).map((crud) => app._clientTeamUserFromCrud(crud));
|
|
1124
1140
|
},
|
|
1125
1141
|
useUsers() {
|
|
1126
1142
|
return (0, __common_js.useAsyncCache)(app._teamMemberProfilesCache, [session, crud.id], "team.useUsers()").map((crud) => app._clientTeamUserFromCrud(crud));
|
|
1127
1143
|
},
|
|
1128
1144
|
async listInvitations() {
|
|
1129
|
-
return
|
|
1145
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._teamInvitationsCache.getOrWait([session, crud.id], "write-only")).map((crud) => app._clientSentTeamInvitationFromCrud(session, crud));
|
|
1130
1146
|
},
|
|
1131
1147
|
useInvitations() {
|
|
1132
1148
|
return (0, __common_js.useAsyncCache)(app._teamInvitationsCache, [session, crud.id], "team.useInvitations()").map((crud) => app._clientSentTeamInvitationFromCrud(session, crud));
|
|
@@ -1146,7 +1162,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1146
1162
|
return (0, __common_js.useAsyncCache)(app._teamApiKeysCache, [session, crud.id], "team.useApiKeys()").map((crud) => app._clientApiKeyFromCrud(session, crud));
|
|
1147
1163
|
},
|
|
1148
1164
|
async listApiKeys() {
|
|
1149
|
-
return
|
|
1165
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._teamApiKeysCache.getOrWait([session, crud.id], "write-only")).map((crud) => app._clientApiKeyFromCrud(session, crud));
|
|
1150
1166
|
},
|
|
1151
1167
|
async createApiKey(options) {
|
|
1152
1168
|
const result = await app._interface.createProjectApiKey(await (0, ______api_keys_index_js.apiKeyCreationOptionsToCrud)("team", crud.id, options), session, "client");
|
|
@@ -1206,9 +1222,9 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1206
1222
|
allow_connected_accounts: data.allowConnectedAccounts
|
|
1207
1223
|
}, session);
|
|
1208
1224
|
await Promise.all([app._currentUserOAuthProvidersCache.refresh([session]), app._currentUserConnectedAccountsCache.refresh([session])]);
|
|
1209
|
-
return
|
|
1225
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
1210
1226
|
} catch (error) {
|
|
1211
|
-
if (
|
|
1227
|
+
if (_hexclave_shared.KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn.isInstance(error)) return _hexclave_shared_dist_utils_results.Result.error(error);
|
|
1212
1228
|
throw error;
|
|
1213
1229
|
}
|
|
1214
1230
|
},
|
|
@@ -1288,7 +1304,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1288
1304
|
return session.isKnownToBeInvalid() ? null : session.getAccessTokenIfNotExpiredYet(2e4, 75e3)?.token ?? null;
|
|
1289
1305
|
}, [session]);
|
|
1290
1306
|
let accessToken = react.default.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
1291
|
-
if (accessToken === null && !session.isKnownToBeInvalid()) accessToken = (0,
|
|
1307
|
+
if (accessToken === null && !session.isKnownToBeInvalid()) accessToken = (0, _hexclave_shared_dist_utils_react.use)(session.getOrFetchLikelyValidTokens(2e4, 75e3))?.accessToken.token ?? null;
|
|
1292
1308
|
return {
|
|
1293
1309
|
accessToken,
|
|
1294
1310
|
refreshToken: session.getRefreshToken()?.token ?? null
|
|
@@ -1378,11 +1394,11 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1378
1394
|
const scopeString = options?.scopes?.join(" ") ?? "";
|
|
1379
1395
|
if (typeof idOrAccount === "object" && "provider" in idOrAccount && "providerAccountId" in idOrAccount) {
|
|
1380
1396
|
const { provider, providerAccountId } = idOrAccount;
|
|
1381
|
-
const found =
|
|
1397
|
+
const found = _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserConnectedAccountsCache.getOrWait([session], "write-only")).find((a) => a.provider === provider && a.providerAccountId === providerAccountId);
|
|
1382
1398
|
if (!found) return null;
|
|
1383
1399
|
return found;
|
|
1384
1400
|
}
|
|
1385
|
-
return
|
|
1401
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserOAuthConnectionCache.getOrWait([
|
|
1386
1402
|
session,
|
|
1387
1403
|
idOrAccount,
|
|
1388
1404
|
scopeString,
|
|
@@ -1421,7 +1437,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1421
1437
|
getConnectedAccount,
|
|
1422
1438
|
useConnectedAccount,
|
|
1423
1439
|
async listConnectedAccounts() {
|
|
1424
|
-
return
|
|
1440
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserConnectedAccountsCache.getOrWait([session], "write-only"));
|
|
1425
1441
|
},
|
|
1426
1442
|
useConnectedAccounts() {
|
|
1427
1443
|
return (0, __common_js.useAsyncCache)(app._currentUserConnectedAccountsCache, [session], "user.useConnectedAccounts()");
|
|
@@ -1432,16 +1448,16 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1432
1448
|
provider,
|
|
1433
1449
|
redirectUrl: app._getOAuthCallbackRedirectUri(),
|
|
1434
1450
|
errorRedirectUrl: app.urls.error,
|
|
1435
|
-
providerScope: (0,
|
|
1451
|
+
providerScope: (0, _hexclave_shared_dist_utils_strings.mergeScopeStrings)(scopeString, (app._oauthScopesOnSignIn[provider] ?? []).join(" "))
|
|
1436
1452
|
}, session);
|
|
1437
1453
|
await app._redirectTo({ url: location });
|
|
1438
|
-
return await (0,
|
|
1454
|
+
return await (0, _hexclave_shared_dist_utils_promises.neverResolve)();
|
|
1439
1455
|
},
|
|
1440
1456
|
async getOrLinkConnectedAccount(provider, options) {
|
|
1441
|
-
const matchingAccounts =
|
|
1457
|
+
const matchingAccounts = _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserConnectedAccountsCache.getOrWait([session], "write-only")).filter((a) => a.provider === provider);
|
|
1442
1458
|
for (const account of matchingAccounts) if ((await account.getAccessToken({ scopes: options?.scopes })).status === "ok") return account;
|
|
1443
1459
|
await this.linkConnectedAccount(provider, options);
|
|
1444
|
-
return await (0,
|
|
1460
|
+
return await (0, _hexclave_shared_dist_utils_promises.neverResolve)();
|
|
1445
1461
|
},
|
|
1446
1462
|
useOrLinkConnectedAccount(provider, options) {
|
|
1447
1463
|
const scopeString = options?.scopes?.join(" ") ?? "";
|
|
@@ -1461,7 +1477,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1461
1477
|
}, [teams, teamId]);
|
|
1462
1478
|
},
|
|
1463
1479
|
async listTeams() {
|
|
1464
|
-
return
|
|
1480
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserTeamsCache.getOrWait([session], "write-only")).map((crud) => app._clientTeamFromCrud(crud, session));
|
|
1465
1481
|
},
|
|
1466
1482
|
useTeams() {
|
|
1467
1483
|
const teams = (0, __common_js.useAsyncCache)(app._currentUserTeamsCache, [session], "user.useTeams()");
|
|
@@ -1477,7 +1493,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1477
1493
|
await app._interface.leaveTeam(team.id, session);
|
|
1478
1494
|
},
|
|
1479
1495
|
async listTeamInvitations() {
|
|
1480
|
-
return
|
|
1496
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserTeamInvitationsCache.getOrWait([session], "write-only")).map((crud) => app._clientReceivedTeamInvitationFromCrud(session, crud));
|
|
1481
1497
|
},
|
|
1482
1498
|
useTeamInvitations() {
|
|
1483
1499
|
const invitations = (0, __common_js.useAsyncCache)(app._currentUserTeamInvitationsCache, [session], "user.useTeamInvitations()");
|
|
@@ -1487,14 +1503,14 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1487
1503
|
if (scopeOrOptions && "id" in scopeOrOptions) {
|
|
1488
1504
|
const scope = scopeOrOptions;
|
|
1489
1505
|
const recursive = options?.recursive ?? true;
|
|
1490
|
-
return
|
|
1506
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserPermissionsCache.getOrWait([
|
|
1491
1507
|
session,
|
|
1492
1508
|
scope.id,
|
|
1493
1509
|
recursive
|
|
1494
1510
|
], "write-only")).map((crud) => app._clientPermissionFromCrud(crud));
|
|
1495
1511
|
} else {
|
|
1496
1512
|
const recursive = scopeOrOptions?.recursive ?? true;
|
|
1497
|
-
return
|
|
1513
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserProjectPermissionsCache.getOrWait([session, recursive], "write-only")).map((crud) => app._clientPermissionFromCrud(crud));
|
|
1498
1514
|
}
|
|
1499
1515
|
},
|
|
1500
1516
|
usePermissions(scopeOrOptions, options) {
|
|
@@ -1546,7 +1562,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1546
1562
|
return await app._updateClientUser(update, session);
|
|
1547
1563
|
},
|
|
1548
1564
|
async sendVerificationEmail(options) {
|
|
1549
|
-
if (!crud.primary_email) throw new
|
|
1565
|
+
if (!crud.primary_email) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("User does not have a primary email");
|
|
1550
1566
|
return await app._interface.sendVerificationEmail(crud.primary_email, options?.callbackUrl ?? (0, ____________utils_url_js.constructRedirectUrl)(app.urls.emailVerification, "callbackUrl"), session);
|
|
1551
1567
|
},
|
|
1552
1568
|
async updatePassword(options) {
|
|
@@ -1561,7 +1577,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1561
1577
|
},
|
|
1562
1578
|
selectedTeam: crud.selected_team && this._clientTeamFromCrud(crud.selected_team, session),
|
|
1563
1579
|
async getTeamProfile(team) {
|
|
1564
|
-
const result =
|
|
1580
|
+
const result = _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserTeamProfileCache.getOrWait([session, team.id], "write-only"));
|
|
1565
1581
|
return app._editableTeamProfileFromCrud(result, session);
|
|
1566
1582
|
},
|
|
1567
1583
|
useTeamProfile(team) {
|
|
@@ -1573,7 +1589,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1573
1589
|
session.markInvalid();
|
|
1574
1590
|
},
|
|
1575
1591
|
async listContactChannels() {
|
|
1576
|
-
return
|
|
1592
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._clientContactChannelsCache.getOrWait([session], "write-only")).map((crud) => app._clientContactChannelFromCrud(crud, session));
|
|
1577
1593
|
},
|
|
1578
1594
|
useContactChannels() {
|
|
1579
1595
|
return (0, __common_js.useAsyncCache)(app._clientContactChannelsCache, [session], "user.useContactChannels()").map((crud) => app._clientContactChannelFromCrud(crud, session));
|
|
@@ -1587,7 +1603,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1587
1603
|
return (0, __common_js.useAsyncCache)(app._notificationCategoriesCache, [session], "user.useNotificationCategories()").map((crud) => app._clientNotificationCategoryFromCrud(crud, session));
|
|
1588
1604
|
},
|
|
1589
1605
|
async listNotificationCategories() {
|
|
1590
|
-
return
|
|
1606
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._notificationCategoriesCache.getOrWait([session], "write-only")).map((crud) => app._clientNotificationCategoryFromCrud(crud, session));
|
|
1591
1607
|
},
|
|
1592
1608
|
useApiKeys() {
|
|
1593
1609
|
return (0, __common_js.useAsyncCache)(app._userApiKeysCache, [session], "user.useApiKeys()").map((crud) => app._clientApiKeyFromCrud(session, crud));
|
|
@@ -1604,7 +1620,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1604
1620
|
return (0, __common_js.useAsyncCache)(app._currentUserOAuthProvidersCache, [session], "user.useOAuthProviders()").map((crud) => app._clientOAuthProviderFromCrud(crud, session));
|
|
1605
1621
|
},
|
|
1606
1622
|
async listOAuthProviders() {
|
|
1607
|
-
return
|
|
1623
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserOAuthProvidersCache.getOrWait([session], "write-only")).map((crud) => app._clientOAuthProviderFromCrud(crud, session));
|
|
1608
1624
|
},
|
|
1609
1625
|
useOAuthProvider(id) {
|
|
1610
1626
|
const providers = this.useOAuthProviders();
|
|
@@ -1615,20 +1631,20 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1615
1631
|
},
|
|
1616
1632
|
async registerPasskey(options) {
|
|
1617
1633
|
const hostname = (await app._getCurrentUrl())?.hostname;
|
|
1618
|
-
if (!hostname) throw new
|
|
1634
|
+
if (!hostname) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("hostname must be provided if the Stack App does not have a redirect method");
|
|
1619
1635
|
const initiationResult = await app._interface.initiatePasskeyRegistration({}, session);
|
|
1620
|
-
if (initiationResult.status !== "ok") return
|
|
1636
|
+
if (initiationResult.status !== "ok") return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.PasskeyRegistrationFailed("Failed to get initiation options for passkey registration"));
|
|
1621
1637
|
const { options_json, code } = initiationResult.data;
|
|
1622
|
-
if (options_json.rp.id !== "THIS_VALUE_WILL_BE_REPLACED.example.com") throw new
|
|
1638
|
+
if (options_json.rp.id !== "THIS_VALUE_WILL_BE_REPLACED.example.com") throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError(`Expected returned RP ID from server to equal sentinel, but found ${options_json.rp.id}`);
|
|
1623
1639
|
options_json.rp.id = hostname;
|
|
1624
1640
|
let attResp;
|
|
1625
1641
|
try {
|
|
1626
1642
|
attResp = await (0, _simplewebauthn_browser.startRegistration)({ optionsJSON: options_json });
|
|
1627
1643
|
} catch (error) {
|
|
1628
|
-
if (error instanceof _simplewebauthn_browser.WebAuthnError) return
|
|
1644
|
+
if (error instanceof _simplewebauthn_browser.WebAuthnError) return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.PasskeyWebAuthnError(error.message, error.name));
|
|
1629
1645
|
else {
|
|
1630
|
-
(0,
|
|
1631
|
-
return
|
|
1646
|
+
(0, _hexclave_shared_dist_utils_errors.captureError)("passkey-registration-failed", error);
|
|
1647
|
+
return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.PasskeyRegistrationFailed("Failed to start passkey registration due to unknown error"));
|
|
1632
1648
|
}
|
|
1633
1649
|
}
|
|
1634
1650
|
const registrationResult = await app._interface.registerPasskey({
|
|
@@ -1665,7 +1681,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1665
1681
|
const customerOptions = type === "user" ? { userId: userIdOrTeamId } : { teamId: userIdOrTeamId };
|
|
1666
1682
|
return {
|
|
1667
1683
|
async getBilling() {
|
|
1668
|
-
const response =
|
|
1684
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await app._customerBillingCache.getOrWait([
|
|
1669
1685
|
effectiveSession,
|
|
1670
1686
|
type,
|
|
1671
1687
|
userIdOrTeamId
|
|
@@ -1757,17 +1773,17 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1757
1773
|
async getItem(options) {
|
|
1758
1774
|
const session = await this._getSession();
|
|
1759
1775
|
let crud;
|
|
1760
|
-
if ("userId" in options) crud =
|
|
1776
|
+
if ("userId" in options) crud = _hexclave_shared_dist_utils_results.Result.orThrow(await this._userItemCache.getOrWait([
|
|
1761
1777
|
session,
|
|
1762
1778
|
options.userId,
|
|
1763
1779
|
options.itemId
|
|
1764
1780
|
], "write-only"));
|
|
1765
|
-
else if ("teamId" in options) crud =
|
|
1781
|
+
else if ("teamId" in options) crud = _hexclave_shared_dist_utils_results.Result.orThrow(await this._teamItemCache.getOrWait([
|
|
1766
1782
|
session,
|
|
1767
1783
|
options.teamId,
|
|
1768
1784
|
options.itemId
|
|
1769
1785
|
], "write-only"));
|
|
1770
|
-
else crud =
|
|
1786
|
+
else crud = _hexclave_shared_dist_utils_results.Result.orThrow(await this._customItemCache.getOrWait([
|
|
1771
1787
|
session,
|
|
1772
1788
|
options.customCustomerId,
|
|
1773
1789
|
options.itemId
|
|
@@ -1787,7 +1803,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1787
1803
|
async listProducts(options) {
|
|
1788
1804
|
const session = (await this.getUser())?._internalSession ?? await this._getSession();
|
|
1789
1805
|
if ("userId" in options) {
|
|
1790
|
-
const response =
|
|
1806
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await this._userProductsCache.getOrWait([
|
|
1791
1807
|
session,
|
|
1792
1808
|
options.userId,
|
|
1793
1809
|
options.cursor ?? null,
|
|
@@ -1795,7 +1811,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1795
1811
|
], "write-only"));
|
|
1796
1812
|
return this._customerProductsFromResponse(response);
|
|
1797
1813
|
} else if ("teamId" in options) {
|
|
1798
|
-
const response =
|
|
1814
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await this._teamProductsCache.getOrWait([
|
|
1799
1815
|
session,
|
|
1800
1816
|
options.teamId,
|
|
1801
1817
|
options.cursor ?? null,
|
|
@@ -1803,7 +1819,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1803
1819
|
], "write-only"));
|
|
1804
1820
|
return this._customerProductsFromResponse(response);
|
|
1805
1821
|
}
|
|
1806
|
-
const response =
|
|
1822
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await this._customProductsCache.getOrWait([
|
|
1807
1823
|
session,
|
|
1808
1824
|
options.customCustomerId,
|
|
1809
1825
|
options.cursor ?? null,
|
|
@@ -1814,7 +1830,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1814
1830
|
async listInvoices(options) {
|
|
1815
1831
|
const session = await this._getSession();
|
|
1816
1832
|
if ("userId" in options) {
|
|
1817
|
-
const response =
|
|
1833
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await this._userInvoicesCache.getOrWait([
|
|
1818
1834
|
session,
|
|
1819
1835
|
options.userId,
|
|
1820
1836
|
options.cursor ?? null,
|
|
@@ -1822,7 +1838,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1822
1838
|
], "write-only"));
|
|
1823
1839
|
return this._customerInvoicesFromResponse(response);
|
|
1824
1840
|
}
|
|
1825
|
-
const response =
|
|
1841
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await this._teamInvoicesCache.getOrWait([
|
|
1826
1842
|
session,
|
|
1827
1843
|
options.teamId,
|
|
1828
1844
|
options.cursor ?? null,
|
|
@@ -1833,7 +1849,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1833
1849
|
async cancelSubscription(options) {
|
|
1834
1850
|
const session = await this._getSession();
|
|
1835
1851
|
const user = await this.getUser();
|
|
1836
|
-
if (!user) throw new
|
|
1852
|
+
if (!user) throw new _hexclave_shared.KnownErrors.UserAuthenticationRequired();
|
|
1837
1853
|
const customerType = "teamId" in options ? "team" : "user";
|
|
1838
1854
|
const customerId = "teamId" in options ? options.teamId : user.id;
|
|
1839
1855
|
await this._interface.cancelSubscription({
|
|
@@ -1902,7 +1918,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1902
1918
|
return __common_js.clientVersion;
|
|
1903
1919
|
}
|
|
1904
1920
|
_getBotChallengeSiteKeys() {
|
|
1905
|
-
if (!(0,
|
|
1921
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)()) return null;
|
|
1906
1922
|
const visibleSiteKey = _________env_js.envVars.NEXT_PUBLIC_STACK_BOT_CHALLENGE_SITE_KEY;
|
|
1907
1923
|
if (!visibleSiteKey) {
|
|
1908
1924
|
if (!this._botChallengeSiteKeysWarned) {
|
|
@@ -1917,23 +1933,23 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1917
1933
|
};
|
|
1918
1934
|
}
|
|
1919
1935
|
_getBotChallengeFlowFailure(error) {
|
|
1920
|
-
if (error instanceof
|
|
1936
|
+
if (error instanceof _hexclave_shared_dist_utils_turnstile_flow.BotChallengeUserCancelledError) return {
|
|
1921
1937
|
type: "cancelled",
|
|
1922
|
-
knownError: new
|
|
1938
|
+
knownError: new _hexclave_shared.KnownErrors.BotChallengeFailed("Bot challenge cancelled by user")
|
|
1923
1939
|
};
|
|
1924
|
-
if (error instanceof
|
|
1940
|
+
if (error instanceof _hexclave_shared_dist_utils_turnstile_flow.BotChallengeExecutionFailedError) return {
|
|
1925
1941
|
type: "failed",
|
|
1926
|
-
knownError: new
|
|
1942
|
+
knownError: new _hexclave_shared.KnownErrors.BotChallengeFailed(error.message)
|
|
1927
1943
|
};
|
|
1928
1944
|
return null;
|
|
1929
1945
|
}
|
|
1930
1946
|
_normalizeBotChallengeResult(result) {
|
|
1931
1947
|
if (result.status === "ok") return result;
|
|
1932
|
-
if (
|
|
1933
|
-
(0,
|
|
1934
|
-
return
|
|
1948
|
+
if (_hexclave_shared.KnownErrors.BotChallengeRequired.isInstance(result.error)) {
|
|
1949
|
+
(0, _hexclave_shared_dist_utils_errors.captureError)("bot-challenge-unexpected-after-flow", result.error);
|
|
1950
|
+
return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.BotChallengeFailed("Unexpected bot challenge after flow completion"));
|
|
1935
1951
|
}
|
|
1936
|
-
return
|
|
1952
|
+
return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
1937
1953
|
}
|
|
1938
1954
|
_toInterfaceBotChallengeInput(challenge) {
|
|
1939
1955
|
if (challenge.unavailable) return { phase: "visible" };
|
|
@@ -1946,25 +1962,25 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1946
1962
|
const siteKeys = this._getBotChallengeSiteKeys();
|
|
1947
1963
|
let result;
|
|
1948
1964
|
try {
|
|
1949
|
-
if (siteKeys) result = await (0,
|
|
1965
|
+
if (siteKeys) result = await (0, _hexclave_shared_dist_utils_turnstile_flow.withBotChallengeFlow)({
|
|
1950
1966
|
...siteKeys,
|
|
1951
1967
|
action: options.action,
|
|
1952
1968
|
execute: options.execute,
|
|
1953
1969
|
isChallengeRequired: (flowResult) => {
|
|
1954
|
-
return flowResult.status === "error" &&
|
|
1970
|
+
return flowResult.status === "error" && _hexclave_shared.KnownErrors.BotChallengeRequired.isInstance(flowResult.error);
|
|
1955
1971
|
}
|
|
1956
1972
|
});
|
|
1957
1973
|
else result = await options.execute({});
|
|
1958
1974
|
} catch (e) {
|
|
1959
1975
|
const flowFailure = this._getBotChallengeFlowFailure(e);
|
|
1960
|
-
if (flowFailure) return
|
|
1976
|
+
if (flowFailure) return _hexclave_shared_dist_utils_results.Result.error(flowFailure.knownError);
|
|
1961
1977
|
throw e;
|
|
1962
1978
|
}
|
|
1963
1979
|
return this._normalizeBotChallengeResult(result);
|
|
1964
1980
|
}
|
|
1965
1981
|
async _isTrusted(url) {
|
|
1966
|
-
if ((0,
|
|
1967
|
-
const parsedUrl = (0,
|
|
1982
|
+
if ((0, _hexclave_shared_dist_utils_urls.isRelative)(url)) return true;
|
|
1983
|
+
const parsedUrl = (0, _hexclave_shared_dist_utils_urls.createUrlIfValid)(url);
|
|
1968
1984
|
if (parsedUrl == null) return false;
|
|
1969
1985
|
if (typeof window !== "undefined" && window.location.origin === parsedUrl.origin) return true;
|
|
1970
1986
|
if ((0, ______url_targets_js.isHostedHandlerUrlForProject)({
|
|
@@ -1972,7 +1988,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1972
1988
|
projectId: this.projectId
|
|
1973
1989
|
})) return true;
|
|
1974
1990
|
const trustedRedirectConfig = await this._getTrustedRedirectConfig();
|
|
1975
|
-
return (0,
|
|
1991
|
+
return (0, _hexclave_shared_dist_utils_redirect_urls.validateRedirectUrl)(parsedUrl, {
|
|
1976
1992
|
allowLocalhost: trustedRedirectConfig.allowLocalhost,
|
|
1977
1993
|
trustedDomains: trustedRedirectConfig.trustedDomains
|
|
1978
1994
|
});
|
|
@@ -1982,11 +1998,11 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1982
1998
|
}
|
|
1983
1999
|
_prefetchCrossDomainHandoffParamsIfNeeded() {
|
|
1984
2000
|
const canWriteOauthVerifierCookie = this._tokenStoreInit === "cookie" || this._tokenStoreInit === "nextjs-cookie";
|
|
1985
|
-
if (!(0,
|
|
2001
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)() || !canWriteOauthVerifierCookie || this._isPrefetchingCrossDomainHandoffParams || this._getFreshPrefetchedCrossDomainHandoffParams() != null) return;
|
|
1986
2002
|
this._isPrefetchingCrossDomainHandoffParams = true;
|
|
1987
|
-
(0,
|
|
2003
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
1988
2004
|
try {
|
|
1989
|
-
if (!(0,
|
|
2005
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)()) return;
|
|
1990
2006
|
const { state, codeChallenge } = await (0, _________cookie_js.saveVerifierAndState)();
|
|
1991
2007
|
this._prefetchedCrossDomainHandoffParams = {
|
|
1992
2008
|
state,
|
|
@@ -2048,10 +2064,10 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2048
2064
|
}, session);
|
|
2049
2065
|
if (!response.ok) {
|
|
2050
2066
|
const responseBody = await response.text();
|
|
2051
|
-
throw new
|
|
2067
|
+
throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError(`Cross-domain authorization endpoint failed: ${response.status} ${responseBody}`);
|
|
2052
2068
|
}
|
|
2053
2069
|
const result = await response.json();
|
|
2054
|
-
if (!("redirect_url" in result) || typeof result.redirect_url !== "string") throw new
|
|
2070
|
+
if (!("redirect_url" in result) || typeof result.redirect_url !== "string") throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("Cross-domain authorization endpoint returned an invalid payload", { result });
|
|
2055
2071
|
return result.redirect_url;
|
|
2056
2072
|
}
|
|
2057
2073
|
_getFreshPrefetchedCrossDomainHandoffParams() {
|
|
@@ -2069,14 +2085,14 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2069
2085
|
}
|
|
2070
2086
|
async _redirectTo(options) {
|
|
2071
2087
|
if (this._redirectMethod === "none") return;
|
|
2072
|
-
else if (this._redirectMethod === "tanstack-start" && !(0,
|
|
2088
|
+
else if (this._redirectMethod === "tanstack-start" && !(0, _hexclave_shared_dist_utils_env.isBrowserLike)()) throw _tanstack_react_router.redirect({
|
|
2073
2089
|
href: options.url.toString(),
|
|
2074
2090
|
replace: options.replace
|
|
2075
2091
|
});
|
|
2076
2092
|
else if (typeof this._redirectMethod === "object" && this._redirectMethod.navigate) this._redirectMethod.navigate(options.url.toString());
|
|
2077
2093
|
else if (options.replace) window.location.replace(options.url);
|
|
2078
2094
|
else window.location.assign(options.url);
|
|
2079
|
-
await (0,
|
|
2095
|
+
await (0, _hexclave_shared_dist_utils_promises.wait)(2e3);
|
|
2080
2096
|
}
|
|
2081
2097
|
useNavigate() {
|
|
2082
2098
|
if (typeof this._redirectMethod === "object") return this._redirectMethod.useNavigate();
|
|
@@ -2127,7 +2143,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2127
2143
|
await this._redirectIfTrusted(redirectUrl, options);
|
|
2128
2144
|
}
|
|
2129
2145
|
_redirectToHandlerDuringRender(handlerName, options) {
|
|
2130
|
-
if (this._redirectMethod === "tanstack-start" && !(0,
|
|
2146
|
+
if (this._redirectMethod === "tanstack-start" && !(0, _hexclave_shared_dist_utils_env.isBrowserLike)()) {
|
|
2131
2147
|
const rawHandlerUrl = (0, __common_js.getUrls)(this._urlOptions, { projectId: this.projectId })[handlerName];
|
|
2132
2148
|
if (!rawHandlerUrl) throw new Error(`No URL for handler name ${handlerName}`);
|
|
2133
2149
|
throw _tanstack_react_router.redirect({
|
|
@@ -2222,8 +2238,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2222
2238
|
code,
|
|
2223
2239
|
session: await this._getSession()
|
|
2224
2240
|
});
|
|
2225
|
-
if (result.status === "ok") return
|
|
2226
|
-
else return
|
|
2241
|
+
if (result.status === "ok") return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2242
|
+
else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2227
2243
|
}
|
|
2228
2244
|
async getTeamInvitationDetails(code) {
|
|
2229
2245
|
const result = await this._interface.acceptTeamInvitation({
|
|
@@ -2231,8 +2247,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2231
2247
|
code,
|
|
2232
2248
|
session: await this._getSession()
|
|
2233
2249
|
});
|
|
2234
|
-
if (result.status === "ok") return
|
|
2235
|
-
else return
|
|
2250
|
+
if (result.status === "ok") return _hexclave_shared_dist_utils_results.Result.ok({ teamDisplayName: result.data.team_display_name });
|
|
2251
|
+
else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2236
2252
|
}
|
|
2237
2253
|
async verifyEmail(code) {
|
|
2238
2254
|
const result = await this._interface.verifyEmail(code);
|
|
@@ -2244,7 +2260,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2244
2260
|
if (options?.or === "anonymous" && options.includeRestricted === false) throw new Error("Cannot use { or: 'anonymous' } with { includeRestricted: false }. Anonymous users implicitly include restricted users.");
|
|
2245
2261
|
this._ensurePersistentTokenStore(options?.tokenStore);
|
|
2246
2262
|
const session = await this._getSession(options?.tokenStore);
|
|
2247
|
-
let crud =
|
|
2263
|
+
let crud = _hexclave_shared_dist_utils_results.Result.orThrow(await this._currentUserCache.getOrWait([session], "write-only"));
|
|
2248
2264
|
const includeAnonymous = options?.or === "anonymous" || options?.or === "anonymous-if-exists[deprecated]";
|
|
2249
2265
|
const includeRestricted = options?.includeRestricted === true || includeAnonymous;
|
|
2250
2266
|
if (crud === null || crud.is_anonymous && !includeAnonymous || crud.is_restricted && !includeRestricted) switch (options?.or) {
|
|
@@ -2259,7 +2275,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2259
2275
|
tokenStore: tokens,
|
|
2260
2276
|
or: "anonymous-if-exists[deprecated]",
|
|
2261
2277
|
includeRestricted: true
|
|
2262
|
-
}) ?? (0,
|
|
2278
|
+
}) ?? (0, _hexclave_shared_dist_utils_errors.throwErr)("Something went wrong while signing up anonymously");
|
|
2263
2279
|
}
|
|
2264
2280
|
case void 0:
|
|
2265
2281
|
case "anonymous-if-exists[deprecated]":
|
|
@@ -2277,18 +2293,18 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2277
2293
|
if (crud === null || crud.is_anonymous && !includeAnonymous || crud.is_restricted && !includeRestricted) switch (options?.or) {
|
|
2278
2294
|
case "redirect":
|
|
2279
2295
|
if (!crud?.is_anonymous && crud?.is_restricted) {
|
|
2280
|
-
if (!this._redirectToHandlerDuringRender("onboarding", { replace: true })) (0,
|
|
2281
|
-
} else if (!this._redirectToHandlerDuringRender("signIn", { replace: true })) (0,
|
|
2282
|
-
(0,
|
|
2283
|
-
throw new
|
|
2296
|
+
if (!this._redirectToHandlerDuringRender("onboarding", { replace: true })) (0, _hexclave_shared_dist_utils_promises.runAsynchronously)(this.redirectToOnboarding({ replace: true }));
|
|
2297
|
+
} else if (!this._redirectToHandlerDuringRender("signIn", { replace: true })) (0, _hexclave_shared_dist_utils_promises.runAsynchronously)(this.redirectToSignIn({ replace: true }));
|
|
2298
|
+
(0, _hexclave_shared_dist_utils_react.suspend)();
|
|
2299
|
+
throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("suspend should never return");
|
|
2284
2300
|
case "throw": throw new Error("User is not signed in but useUser was called with { or: 'throw' }");
|
|
2285
2301
|
case "anonymous":
|
|
2286
|
-
(0,
|
|
2302
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
2287
2303
|
await this._signUpAnonymously();
|
|
2288
2304
|
if (typeof window !== "undefined") window.location.reload();
|
|
2289
2305
|
});
|
|
2290
|
-
(0,
|
|
2291
|
-
throw new
|
|
2306
|
+
(0, _hexclave_shared_dist_utils_react.suspend)();
|
|
2307
|
+
throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("suspend should never return");
|
|
2292
2308
|
case void 0:
|
|
2293
2309
|
case "anonymous-if-exists[deprecated]":
|
|
2294
2310
|
case "return-null":
|
|
@@ -2394,12 +2410,12 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2394
2410
|
};
|
|
2395
2411
|
let authorizeResult;
|
|
2396
2412
|
try {
|
|
2397
|
-
if (siteKeys) authorizeResult = await (0,
|
|
2413
|
+
if (siteKeys) authorizeResult = await (0, _hexclave_shared_dist_utils_turnstile_flow.withBotChallengeFlow)({
|
|
2398
2414
|
...siteKeys,
|
|
2399
2415
|
action: "oauth_authenticate",
|
|
2400
2416
|
execute: executeOAuth,
|
|
2401
2417
|
isChallengeRequired: (result) => {
|
|
2402
|
-
return result.status === "error" &&
|
|
2418
|
+
return result.status === "error" && _hexclave_shared.KnownErrors.BotChallengeRequired.isInstance(result.error);
|
|
2403
2419
|
}
|
|
2404
2420
|
});
|
|
2405
2421
|
else authorizeResult = await executeOAuth({});
|
|
@@ -2409,17 +2425,17 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2409
2425
|
if (flowFailure?.type === "failed") throw flowFailure.knownError;
|
|
2410
2426
|
throw e;
|
|
2411
2427
|
}
|
|
2412
|
-
const location =
|
|
2428
|
+
const location = _hexclave_shared_dist_utils_results.Result.orThrow(authorizeResult);
|
|
2413
2429
|
await this._redirectTo({ url: location });
|
|
2414
|
-
await (0,
|
|
2430
|
+
await (0, _hexclave_shared_dist_utils_promises.neverResolve)();
|
|
2415
2431
|
}
|
|
2416
2432
|
/**
|
|
2417
2433
|
* Handles MFA verification by redirecting to the OTP page
|
|
2418
2434
|
*/
|
|
2419
2435
|
async _experimentalMfa(error, session) {
|
|
2420
|
-
if (typeof window !== "undefined") window.sessionStorage.setItem("hexclave_mfa_attempt_code", error.details?.attempt_code ?? (0,
|
|
2436
|
+
if (typeof window !== "undefined") window.sessionStorage.setItem("hexclave_mfa_attempt_code", error.details?.attempt_code ?? (0, _hexclave_shared_dist_utils_errors.throwErr)("attempt code missing"));
|
|
2421
2437
|
await this.redirectToMfa();
|
|
2422
|
-
throw new
|
|
2438
|
+
throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("we should have redirected in redirectToMfa()");
|
|
2423
2439
|
}
|
|
2424
2440
|
/**
|
|
2425
2441
|
* @deprecated
|
|
@@ -2429,7 +2445,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2429
2445
|
try {
|
|
2430
2446
|
return await callback();
|
|
2431
2447
|
} catch (e) {
|
|
2432
|
-
if (
|
|
2448
|
+
if (_hexclave_shared.KnownErrors.MultiFactorAuthenticationRequired.isInstance(e)) return _hexclave_shared_dist_utils_results.Result.ok(await this._experimentalMfa(e, await this._getSession(void 0, { awaitPendingAuthResolutions: false })));
|
|
2433
2449
|
throw e;
|
|
2434
2450
|
}
|
|
2435
2451
|
}
|
|
@@ -2442,25 +2458,25 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2442
2458
|
return await this._interface.signInWithCredential(options.email, options.password, session);
|
|
2443
2459
|
});
|
|
2444
2460
|
} catch (e) {
|
|
2445
|
-
if (
|
|
2461
|
+
if (_hexclave_shared.KnownErrors.InvalidTotpCode.isInstance(e)) return _hexclave_shared_dist_utils_results.Result.error(e);
|
|
2446
2462
|
throw e;
|
|
2447
2463
|
}
|
|
2448
2464
|
if (result.status === "ok") {
|
|
2449
2465
|
await this._signInToAccountWithTokens(result.data);
|
|
2450
2466
|
if (!options.noRedirect) await this._redirectToHandler("afterSignIn", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2451
|
-
return
|
|
2452
|
-
} else return
|
|
2467
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2468
|
+
} else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2453
2469
|
}
|
|
2454
2470
|
async signUpWithCredential(options) {
|
|
2455
|
-
if (options.noVerificationCallback && options.verificationCallbackUrl) throw new
|
|
2471
|
+
if (options.noVerificationCallback && options.verificationCallbackUrl) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("verificationCallbackUrl is not allowed when noVerificationCallback is true");
|
|
2456
2472
|
this._ensurePersistentTokenStore();
|
|
2457
2473
|
const session = await this._getSession();
|
|
2458
2474
|
const emailVerificationRedirectUrl = options.noVerificationCallback ? void 0 : options.verificationCallbackUrl ?? (0, ____________utils_url_js.constructRedirectUrl)(this.urls.emailVerification, "verificationCallbackUrl");
|
|
2459
2475
|
const executeSignUp = async (challenge) => {
|
|
2460
2476
|
let result = await this._interface.signUpWithCredential(options.email, options.password, emailVerificationRedirectUrl, session, this._toInterfaceBotChallengeInput(challenge));
|
|
2461
|
-
if (result.status === "error" && result.error instanceof
|
|
2477
|
+
if (result.status === "error" && result.error instanceof _hexclave_shared.KnownErrors.RedirectUrlNotWhitelisted && emailVerificationRedirectUrl !== void 0) {
|
|
2462
2478
|
if (!options.verificationCallbackUrl) {
|
|
2463
|
-
(0,
|
|
2479
|
+
(0, _hexclave_shared_dist_utils_errors.captureError)("signup-verification-url-not-whitelisted", new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("The auto-constructed verification callback URL is not whitelisted; proceeding without email verification", { emailVerificationRedirectUrl }));
|
|
2464
2480
|
result = await this._interface.signUpWithCredential(options.email, options.password, void 0, session, this._toInterfaceBotChallengeInput(challenge));
|
|
2465
2481
|
}
|
|
2466
2482
|
}
|
|
@@ -2474,8 +2490,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2474
2490
|
if (result.status === "ok") {
|
|
2475
2491
|
await this._signInToAccountWithTokens(result.data);
|
|
2476
2492
|
if (!options.noRedirect) await this._redirectToHandler("afterSignUp", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2477
|
-
return
|
|
2478
|
-
} else return
|
|
2493
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2494
|
+
} else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2479
2495
|
}
|
|
2480
2496
|
async _signUpAnonymously() {
|
|
2481
2497
|
this._ensurePersistentTokenStore();
|
|
@@ -2484,7 +2500,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2484
2500
|
const session = await this._getSession();
|
|
2485
2501
|
const result = await this._interface.signUpAnonymously(session);
|
|
2486
2502
|
if (result.status === "ok") await this._signInToAccountWithTokens(result.data);
|
|
2487
|
-
else throw new
|
|
2503
|
+
else throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("signUpAnonymously() should never return an error");
|
|
2488
2504
|
this._anonymousSignUpInProgress = null;
|
|
2489
2505
|
return result.data;
|
|
2490
2506
|
})();
|
|
@@ -2499,7 +2515,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2499
2515
|
return await this._interface.signInWithMagicLink(code, session);
|
|
2500
2516
|
});
|
|
2501
2517
|
} catch (e) {
|
|
2502
|
-
if (
|
|
2518
|
+
if (_hexclave_shared.KnownErrors.InvalidTotpCode.isInstance(e)) return _hexclave_shared_dist_utils_results.Result.error(e);
|
|
2503
2519
|
throw e;
|
|
2504
2520
|
}
|
|
2505
2521
|
if (result.status === "ok") {
|
|
@@ -2512,8 +2528,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2512
2528
|
awaitPendingAuthResolutions: false,
|
|
2513
2529
|
overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data)
|
|
2514
2530
|
});
|
|
2515
|
-
return
|
|
2516
|
-
} else return
|
|
2531
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2532
|
+
} else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2517
2533
|
}
|
|
2518
2534
|
/**
|
|
2519
2535
|
* Initiates a CLI authentication process that allows a command line application
|
|
@@ -2544,7 +2560,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2544
2560
|
...options.anonRefreshToken != null ? { anon_refresh_token: options.anonRefreshToken } : {}
|
|
2545
2561
|
})
|
|
2546
2562
|
}, null);
|
|
2547
|
-
if (!response.ok) return
|
|
2563
|
+
if (!response.ok) return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.CliAuthError(`Failed to initiate CLI auth: ${response.status} ${await response.text()}`));
|
|
2548
2564
|
const initResult = await response.json();
|
|
2549
2565
|
const pollingCode = initResult.polling_code;
|
|
2550
2566
|
const loginCode = initResult.login_code;
|
|
@@ -2566,18 +2582,18 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2566
2582
|
headers: { "Content-Type": "application/json" },
|
|
2567
2583
|
body: JSON.stringify({ polling_code: pollingCode })
|
|
2568
2584
|
}, null);
|
|
2569
|
-
if (!pollResponse.ok) return
|
|
2585
|
+
if (!pollResponse.ok) return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.CliAuthError(`Failed to initiate CLI auth: ${pollResponse.status} ${await pollResponse.text()}`));
|
|
2570
2586
|
const pollResult = await pollResponse.json();
|
|
2571
|
-
if (pollResponse.status === 201 && pollResult.status === "success") return
|
|
2587
|
+
if (pollResponse.status === 201 && pollResult.status === "success") return _hexclave_shared_dist_utils_results.Result.ok(pollResult.refresh_token);
|
|
2572
2588
|
if (pollResult.status === "waiting") {
|
|
2573
|
-
await (0,
|
|
2589
|
+
await (0, _hexclave_shared_dist_utils_promises.wait)(options.waitTimeMillis ?? 2e3);
|
|
2574
2590
|
continue;
|
|
2575
2591
|
}
|
|
2576
|
-
if (pollResult.status === "expired") return
|
|
2577
|
-
if (pollResult.status === "used") return
|
|
2578
|
-
return
|
|
2592
|
+
if (pollResult.status === "expired") return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.CliAuthExpiredError("CLI authentication request expired. Please try again."));
|
|
2593
|
+
if (pollResult.status === "used") return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.CliAuthUsedError("This authentication token has already been used."));
|
|
2594
|
+
return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.CliAuthError(`Unexpected status from CLI auth polling: ${pollResult.status}`));
|
|
2579
2595
|
}
|
|
2580
|
-
return
|
|
2596
|
+
return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.CliAuthError("Timed out waiting for CLI authentication."));
|
|
2581
2597
|
}
|
|
2582
2598
|
async signInWithMfa(totp, code, options) {
|
|
2583
2599
|
this._ensurePersistentTokenStore();
|
|
@@ -2588,16 +2604,16 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2588
2604
|
return await this._interface.signInWithMfa(totp, code, session);
|
|
2589
2605
|
});
|
|
2590
2606
|
} catch (e) {
|
|
2591
|
-
if (e instanceof
|
|
2607
|
+
if (e instanceof _hexclave_shared.KnownErrors.InvalidTotpCode) return _hexclave_shared_dist_utils_results.Result.error(e);
|
|
2592
2608
|
throw e;
|
|
2593
2609
|
}
|
|
2594
2610
|
if (result.status === "ok") {
|
|
2595
2611
|
await this._signInToAccountWithTokens(result.data);
|
|
2596
2612
|
if (!options?.noRedirect) if (result.data.newUser) await this._redirectToHandler("afterSignUp", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2597
2613
|
else await this._redirectToHandler("afterSignIn", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2598
|
-
return
|
|
2614
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2599
2615
|
}
|
|
2600
|
-
return
|
|
2616
|
+
return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2601
2617
|
}
|
|
2602
2618
|
async signInWithPasskey() {
|
|
2603
2619
|
this._ensurePersistentTokenStore();
|
|
@@ -2606,9 +2622,9 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2606
2622
|
try {
|
|
2607
2623
|
result = await this._catchMfaRequiredError(async () => {
|
|
2608
2624
|
const initiationResult = await this._interface.initiatePasskeyAuthentication({}, session);
|
|
2609
|
-
if (initiationResult.status !== "ok") return
|
|
2625
|
+
if (initiationResult.status !== "ok") return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.PasskeyAuthenticationFailed("Failed to get initiation options for passkey authentication"));
|
|
2610
2626
|
const { options_json, code } = initiationResult.data;
|
|
2611
|
-
if (options_json.rpId !== "THIS_VALUE_WILL_BE_REPLACED.example.com") throw new
|
|
2627
|
+
if (options_json.rpId !== "THIS_VALUE_WILL_BE_REPLACED.example.com") throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError(`Expected returned RP ID from server to equal sentinel, but found ${options_json.rpId}`);
|
|
2612
2628
|
options_json.rpId = window.location.hostname;
|
|
2613
2629
|
const authentication_response = await (0, _simplewebauthn_browser.startAuthentication)({ optionsJSON: options_json });
|
|
2614
2630
|
return await this._interface.signInWithPasskey({
|
|
@@ -2617,14 +2633,14 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2617
2633
|
}, session);
|
|
2618
2634
|
});
|
|
2619
2635
|
} catch (error) {
|
|
2620
|
-
if (error instanceof _simplewebauthn_browser.WebAuthnError) return
|
|
2621
|
-
else return
|
|
2636
|
+
if (error instanceof _simplewebauthn_browser.WebAuthnError) return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.PasskeyWebAuthnError(error.message, error.name));
|
|
2637
|
+
else return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.PasskeyAuthenticationFailed("Failed to sign in with passkey"));
|
|
2622
2638
|
}
|
|
2623
2639
|
if (result.status === "ok") {
|
|
2624
2640
|
await this._signInToAccountWithTokens(result.data);
|
|
2625
2641
|
await this._redirectToHandler("afterSignIn", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2626
|
-
return
|
|
2627
|
-
} else return
|
|
2642
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2643
|
+
} else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2628
2644
|
}
|
|
2629
2645
|
async callOAuthCallback(options) {
|
|
2630
2646
|
if (typeof window === "undefined") throw new Error("callOAuthCallback can currently only be called in a browser environment");
|
|
@@ -2642,7 +2658,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2642
2658
|
return await (0, _________auth_js.callOAuthCallback)(this._interface, oauthCallbackRedirectUri, options);
|
|
2643
2659
|
});
|
|
2644
2660
|
} catch (e) {
|
|
2645
|
-
if (
|
|
2661
|
+
if (_hexclave_shared.KnownErrors.InvalidTotpCode.isInstance(e)) {
|
|
2646
2662
|
alert("Invalid TOTP code. Please try signing in again.");
|
|
2647
2663
|
return false;
|
|
2648
2664
|
} else throw e;
|
|
@@ -2675,7 +2691,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2675
2691
|
async _signOut(session, options) {
|
|
2676
2692
|
this._eventTracker?.clearBuffer();
|
|
2677
2693
|
this._sessionRecorder?.clearBuffer();
|
|
2678
|
-
await
|
|
2694
|
+
await _hexclave_shared_dist_utils_stores.storeLock.withWriteLock(async () => {
|
|
2679
2695
|
await this._interface.signOut(session);
|
|
2680
2696
|
if (options?.redirectUrl) await this._redirectTo({
|
|
2681
2697
|
url: options.redirectUrl,
|
|
@@ -2737,7 +2753,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2737
2753
|
};
|
|
2738
2754
|
}
|
|
2739
2755
|
async getProject() {
|
|
2740
|
-
const crud =
|
|
2756
|
+
const crud = _hexclave_shared_dist_utils_results.Result.orThrow(await this._currentProjectCache.getOrWait([], "write-only"));
|
|
2741
2757
|
return this._clientProjectFromCrud(crud);
|
|
2742
2758
|
}
|
|
2743
2759
|
useProject() {
|
|
@@ -2746,7 +2762,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2746
2762
|
}
|
|
2747
2763
|
async _listOwnedProjects(session) {
|
|
2748
2764
|
this._ensureInternalProject();
|
|
2749
|
-
return
|
|
2765
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await this._ownedProjectsCache.getOrWait([session], "write-only")).map((j) => this._getOwnedAdminApp(j.id, session)._adminOwnedProjectFromCrud(j, () => this._refreshOwnedProjects(session)));
|
|
2750
2766
|
}
|
|
2751
2767
|
_useOwnedProjects(session) {
|
|
2752
2768
|
this._ensureInternalProject();
|
|
@@ -2776,17 +2792,17 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2776
2792
|
}
|
|
2777
2793
|
static get [______common_js.stackAppInternalsSymbol]() {
|
|
2778
2794
|
return { fromClientJson: (json) => {
|
|
2779
|
-
const providedCheckString = JSON.stringify((0,
|
|
2795
|
+
const providedCheckString = JSON.stringify((0, _hexclave_shared_dist_utils_objects.omit)(json, []));
|
|
2780
2796
|
const existing = allClientApps.get(json.uniqueIdentifier);
|
|
2781
2797
|
if (existing) {
|
|
2782
2798
|
const [existingCheckString, clientApp] = existing;
|
|
2783
|
-
if (existingCheckString !== void 0 && existingCheckString !== providedCheckString) throw new
|
|
2799
|
+
if (existingCheckString !== void 0 && existingCheckString !== providedCheckString) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("The provided app JSON does not match the configuration of the existing client app with the same unique identifier", {
|
|
2784
2800
|
providedObj: json,
|
|
2785
2801
|
existingString: existingCheckString
|
|
2786
2802
|
});
|
|
2787
2803
|
return clientApp;
|
|
2788
2804
|
}
|
|
2789
|
-
const { analytics, ...restJson } = (0,
|
|
2805
|
+
const { analytics, ...restJson } = (0, _hexclave_shared_dist_utils_objects.omit)(json, ["uniqueIdentifier"]);
|
|
2790
2806
|
return new _StackClientAppImplIncomplete({
|
|
2791
2807
|
...restJson,
|
|
2792
2808
|
analytics: (0, __session_replay_js.analyticsOptionsFromJson)(analytics)
|
|
@@ -2799,7 +2815,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2799
2815
|
get [______common_js.stackAppInternalsSymbol]() {
|
|
2800
2816
|
return {
|
|
2801
2817
|
toClientJson: () => {
|
|
2802
|
-
if (typeof this._redirectMethod !== "string") throw new
|
|
2818
|
+
if (typeof this._redirectMethod !== "string") throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("Cannot serialize to JSON from an application with a non-string redirect method");
|
|
2803
2819
|
const publishableClientKey = "publishableClientKey" in this._interface.options ? this._interface.options.publishableClientKey : void 0;
|
|
2804
2820
|
return {
|
|
2805
2821
|
baseUrl: this._options.baseUrl,
|
|
@@ -2816,8 +2832,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2816
2832
|
};
|
|
2817
2833
|
},
|
|
2818
2834
|
setCurrentUser: (userJsonPromise) => {
|
|
2819
|
-
(0,
|
|
2820
|
-
await this._currentUserCache.forceSetCachedValueAsync([await this._getSession()],
|
|
2835
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
2836
|
+
await this._currentUserCache.forceSetCachedValueAsync([await this._getSession()], _hexclave_shared_dist_utils_results.Result.fromPromise(userJsonPromise));
|
|
2821
2837
|
});
|
|
2822
2838
|
},
|
|
2823
2839
|
getConstructorOptions: () => this._options,
|
|
@@ -2833,7 +2849,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2833
2849
|
sendRequest: async (path, requestOptions, requestType = "client") => {
|
|
2834
2850
|
return await this._interface.sendClientRequest(path, requestOptions, await this._getSession(), requestType);
|
|
2835
2851
|
},
|
|
2836
|
-
getRedirectMethod: () => this._redirectMethod ?? (0,
|
|
2852
|
+
getRedirectMethod: () => this._redirectMethod ?? (0, _hexclave_shared_dist_utils_errors.throwErr)("Redirect method should have been initialized in the Stack client app constructor"),
|
|
2837
2853
|
redirectToUrl: async (url, options) => {
|
|
2838
2854
|
await this._redirectTo({
|
|
2839
2855
|
url,
|