@hexclave/next 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/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 +5 -5
- 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 +1 -1
- package/dist/esm/components-page/account-settings/payments/payments-panel.js.map +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 +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.d.ts +2 -2
- 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 +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 +20 -4
- 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 +3 -3
- 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.d.ts +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.d.ts +2 -2
- 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 +231 -215
- 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 +30 -30
- 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-DxMLntUt.d.ts → storage-kTmOAWHW.d.ts} +1 -1
- package/dist/{storage-DxMLntUt.d.ts.map → storage-kTmOAWHW.d.ts.map} +1 -1
- package/dist/utils/url.js +2 -2
- package/dist/utils/url.js.map +1 -1
- package/package.json +9 -9
- 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,31 +1,31 @@
|
|
|
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
|
|
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
11
|
let next_navigation = require("next/navigation");
|
|
12
12
|
next_navigation = require_chunk.__toESM(next_navigation);
|
|
13
|
-
let
|
|
14
|
-
let
|
|
15
|
-
let
|
|
13
|
+
let _hexclave_shared_dist_utils_results = require("@hexclave/shared/dist/utils/results");
|
|
14
|
+
let _hexclave_shared_dist_utils_strings = require("@hexclave/shared/dist/utils/strings");
|
|
15
|
+
let _hexclave_shared_dist_utils_env = require("@hexclave/shared/dist/utils/env");
|
|
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
|
|
28
|
-
let
|
|
22
|
+
let _hexclave_shared_dist_sessions = require("@hexclave/shared/dist/sessions");
|
|
23
|
+
let _hexclave_shared_dist_utils_compile_time = require("@hexclave/shared/dist/utils/compile-time");
|
|
24
|
+
let _hexclave_shared_dist_utils_json = require("@hexclave/shared/dist/utils/json");
|
|
25
|
+
let _hexclave_shared_dist_utils_maps = require("@hexclave/shared/dist/utils/maps");
|
|
26
|
+
let _hexclave_shared_dist_utils_stores = require("@hexclave/shared/dist/utils/stores");
|
|
27
|
+
let _hexclave_shared_dist_utils_turnstile_flow = require("@hexclave/shared/dist/utils/turnstile-flow");
|
|
28
|
+
let _hexclave_shared_dist_utils_uuids = require("@hexclave/shared/dist/utils/uuids");
|
|
29
29
|
let cookie = require("cookie");
|
|
30
30
|
cookie = require_chunk.__toESM(cookie);
|
|
31
31
|
let ____________utils_url_js = require("../../../../utils/url.js");
|
|
@@ -42,13 +42,13 @@ let __redirect_page_urls_js = require("./redirect-page-urls.js");
|
|
|
42
42
|
let __session_refresh_subscription_js = require("./session-refresh-subscription.js");
|
|
43
43
|
let __session_replay_js = require("./session-replay.js");
|
|
44
44
|
let ____________dev_tool_index_js = require("../../../../dev-tool/index.js");
|
|
45
|
-
let
|
|
46
|
-
|
|
45
|
+
let _hexclave_sc = require("@hexclave/sc");
|
|
46
|
+
_hexclave_sc = require_chunk.__toESM(_hexclave_sc);
|
|
47
47
|
|
|
48
48
|
//#region src/lib/stack-app/apps/implementations/client-app-impl.ts
|
|
49
49
|
let isReactServer = false;
|
|
50
|
-
isReactServer =
|
|
51
|
-
const NextNavigation = (0,
|
|
50
|
+
isReactServer = _hexclave_sc.isReactServer;
|
|
51
|
+
const NextNavigation = (0, _hexclave_shared_dist_utils_compile_time.scrambleDuringCompileTime)(next_navigation);
|
|
52
52
|
const prefetchedCrossDomainHandoffTtlMs = 3300 * 1e3;
|
|
53
53
|
const nestedCrossDomainAuthQueryParams = {
|
|
54
54
|
refreshTokenId: "stack_nested_cross_domain_auth_refresh_token_id",
|
|
@@ -73,7 +73,7 @@ const STACK_AUTHORIZATION_VALUE_PREFIX = "stackauth_";
|
|
|
73
73
|
const HEXCLAVE_AUTHORIZATION_VALUE_PREFIX = "hexclave_";
|
|
74
74
|
function getAuthorizationHeaderValueFromAuthJson(authJson) {
|
|
75
75
|
if (authJson.accessToken == null && authJson.refreshToken == null) return null;
|
|
76
|
-
return `Bearer ${STACK_AUTHORIZATION_VALUE_PREFIX}${(0,
|
|
76
|
+
return `Bearer ${STACK_AUTHORIZATION_VALUE_PREFIX}${(0, _hexclave_shared_dist_utils_bytes.encodeBase64)(new TextEncoder().encode(JSON.stringify(authJson)))}`;
|
|
77
77
|
}
|
|
78
78
|
function getAuthJsonFromAuthorizationHeaderValue(authorizationHeaderValue) {
|
|
79
79
|
const match = authorizationHeaderValue.match(/^Bearer\s+(.+)$/i);
|
|
@@ -85,7 +85,7 @@ function getAuthJsonFromAuthorizationHeaderValue(authorizationHeaderValue) {
|
|
|
85
85
|
if (encodedAuthJson.length === 0) throw new Error("Invalid Authorization header format. Expected `Bearer stackauth_<base64(getAuthJson())>`.");
|
|
86
86
|
let parsed;
|
|
87
87
|
try {
|
|
88
|
-
const decodedAuthJson = new TextDecoder().decode((0,
|
|
88
|
+
const decodedAuthJson = new TextDecoder().decode((0, _hexclave_shared_dist_utils_bytes.decodeBase64)(encodedAuthJson));
|
|
89
89
|
parsed = JSON.parse(decodedAuthJson);
|
|
90
90
|
} catch (e) {
|
|
91
91
|
throw new Error("Invalid stackauth authorization header.", { cause: e });
|
|
@@ -107,7 +107,7 @@ function getHeaderValueFromRequestLikeHeaders(headers, name) {
|
|
|
107
107
|
return null;
|
|
108
108
|
}
|
|
109
109
|
async function getServerRequestHost() {
|
|
110
|
-
return (await
|
|
110
|
+
return (await _hexclave_sc.headers?.())?.get("host") ?? null;
|
|
111
111
|
}
|
|
112
112
|
var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
113
113
|
static {
|
|
@@ -125,7 +125,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
125
125
|
if (!user || !user.oauth_providers.find((p) => p.id === options.providerId)) hasConnection = false;
|
|
126
126
|
if (!await options.getOrWaitOAuthToken()) hasConnection = false;
|
|
127
127
|
if (!hasConnection && options.redirect) {
|
|
128
|
-
if (!options.session) throw new Error(
|
|
128
|
+
if (!options.session) throw new Error(_hexclave_shared_dist_utils_strings.deindent`
|
|
129
129
|
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.
|
|
130
130
|
|
|
131
131
|
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.
|
|
@@ -134,10 +134,10 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
134
134
|
provider: options.providerId,
|
|
135
135
|
redirectUrl: this._getOAuthCallbackRedirectUri(),
|
|
136
136
|
errorRedirectUrl: this.urls.error,
|
|
137
|
-
providerScope: (0,
|
|
137
|
+
providerScope: (0, _hexclave_shared_dist_utils_strings.mergeScopeStrings)(options.scope || "", (this._oauthScopesOnSignIn[options.providerId] ?? []).join(" "))
|
|
138
138
|
}, options.session);
|
|
139
139
|
await this._redirectTo({ url: location });
|
|
140
|
-
return await (0,
|
|
140
|
+
return await (0, _hexclave_shared_dist_utils_promises.neverResolve)();
|
|
141
141
|
} else if (!hasConnection) return null;
|
|
142
142
|
const providerAccountId = user.oauth_providers.find((p) => p.id === options.providerId)?.account_id ?? "";
|
|
143
143
|
return {
|
|
@@ -146,12 +146,12 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
146
146
|
providerAccountId,
|
|
147
147
|
async getAccessToken() {
|
|
148
148
|
const result = await options.getOrWaitOAuthToken();
|
|
149
|
-
if (!result) throw new
|
|
149
|
+
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\`.`);
|
|
150
150
|
return result;
|
|
151
151
|
},
|
|
152
152
|
useAccessToken() {
|
|
153
153
|
const result = options.useOAuthToken();
|
|
154
|
-
if (!result) throw new
|
|
154
|
+
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\`.`);
|
|
155
155
|
return result;
|
|
156
156
|
}
|
|
157
157
|
};
|
|
@@ -166,7 +166,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
166
166
|
providerAccountId,
|
|
167
167
|
async getAccessToken(options) {
|
|
168
168
|
const scopeString = options?.scopes?.join(" ") ?? "";
|
|
169
|
-
const result =
|
|
169
|
+
const result = _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserOAuthConnectionAccessTokensByAccountCache.getOrWait([
|
|
170
170
|
session,
|
|
171
171
|
providerId,
|
|
172
172
|
providerAccountId,
|
|
@@ -174,9 +174,9 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
174
174
|
], "write-only"));
|
|
175
175
|
if (!result) {
|
|
176
176
|
const scopeDetail = scopeString ? `The requested scopes [${scopeString}] are not available on the existing token.` : "The OAuth refresh token has likely been revoked or expired.";
|
|
177
|
-
return
|
|
177
|
+
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\`.`));
|
|
178
178
|
}
|
|
179
|
-
return
|
|
179
|
+
return _hexclave_shared_dist_utils_results.Result.ok(result);
|
|
180
180
|
},
|
|
181
181
|
useAccessToken(options) {
|
|
182
182
|
const scopeString = options?.scopes?.join(" ") ?? "";
|
|
@@ -188,9 +188,9 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
188
188
|
], "connection.useAccessToken()");
|
|
189
189
|
if (!result) {
|
|
190
190
|
const scopeDetail = scopeString ? `The requested scopes [${scopeString}] are not available on the existing token.` : "The OAuth refresh token has likely been revoked or expired.";
|
|
191
|
-
return
|
|
191
|
+
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\`.`));
|
|
192
192
|
}
|
|
193
|
-
return
|
|
193
|
+
return _hexclave_shared_dist_utils_results.Result.ok(result);
|
|
194
194
|
}
|
|
195
195
|
};
|
|
196
196
|
}
|
|
@@ -199,14 +199,14 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
199
199
|
this._sessionRecorder = null;
|
|
200
200
|
this._eventTracker = null;
|
|
201
201
|
this.__DEMO_ENABLE_SLIGHT_FETCH_DELAY = false;
|
|
202
|
-
this._ownedAdminApps = new
|
|
202
|
+
this._ownedAdminApps = new _hexclave_shared_dist_utils_maps.DependenciesMap();
|
|
203
203
|
this._currentUserCache = (0, __common_js.createCacheBySession)(async (session) => {
|
|
204
|
-
if (this.__DEMO_ENABLE_SLIGHT_FETCH_DELAY) await (0,
|
|
204
|
+
if (this.__DEMO_ENABLE_SLIGHT_FETCH_DELAY) await (0, _hexclave_shared_dist_utils_promises.wait)(2e3);
|
|
205
205
|
if (session.isKnownToBeInvalid()) return null;
|
|
206
206
|
return await this._interface.getClientUserByToken(session);
|
|
207
207
|
});
|
|
208
208
|
this._currentProjectCache = (0, __common_js.createCache)(async () => {
|
|
209
|
-
return
|
|
209
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await this._interface.getClientProject());
|
|
210
210
|
});
|
|
211
211
|
this._ownedProjectsCache = (0, __common_js.createCacheBySession)(async (session) => {
|
|
212
212
|
return await this._interface.listProjects(session);
|
|
@@ -227,14 +227,14 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
227
227
|
try {
|
|
228
228
|
return { accessToken: (await this._interface.createProviderAccessToken(providerId, scope || "", session)).access_token };
|
|
229
229
|
} catch (err) {
|
|
230
|
-
if (!(
|
|
230
|
+
if (!(_hexclave_shared.KnownErrors.OAuthAccessTokenNotAvailable.isInstance(err) || _hexclave_shared.KnownErrors.OAuthConnectionDoesNotHaveRequiredScope.isInstance(err) || _hexclave_shared.KnownErrors.OAuthConnectionNotConnectedToUser.isInstance(err))) throw err;
|
|
231
231
|
}
|
|
232
232
|
return null;
|
|
233
233
|
});
|
|
234
234
|
this._currentUserOAuthConnectionCache = (0, __common_js.createCacheBySession)(async (session, [providerId, scope, redirect]) => {
|
|
235
235
|
return await this._getUserOAuthConnectionCacheFn({
|
|
236
|
-
getUser: async () =>
|
|
237
|
-
getOrWaitOAuthToken: async () =>
|
|
236
|
+
getUser: async () => _hexclave_shared_dist_utils_results.Result.orThrow(await this._currentUserCache.getOrWait([session], "write-only")),
|
|
237
|
+
getOrWaitOAuthToken: async () => _hexclave_shared_dist_utils_results.Result.orThrow(await this._currentUserOAuthConnectionAccessTokensCache.getOrWait([
|
|
238
238
|
session,
|
|
239
239
|
providerId,
|
|
240
240
|
scope || ""
|
|
@@ -257,22 +257,22 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
257
257
|
try {
|
|
258
258
|
return { accessToken: (await this._interface.createProviderAccessTokenByAccount(providerId, providerAccountId, scope, session)).access_token };
|
|
259
259
|
} catch (err) {
|
|
260
|
-
if (
|
|
260
|
+
if (_hexclave_shared.KnownErrors.OAuthAccessTokenNotAvailable.isInstance(err) || _hexclave_shared.KnownErrors.OAuthConnectionDoesNotHaveRequiredScope.isInstance(err) || _hexclave_shared.KnownErrors.OAuthConnectionNotConnectedToUser.isInstance(err)) return null;
|
|
261
261
|
throw err;
|
|
262
262
|
}
|
|
263
263
|
});
|
|
264
264
|
this._currentUserValidConnectedAccountForProviderCache = (0, __common_js.createCacheBySession)(async (session, [provider, scopeString]) => {
|
|
265
|
-
const matchingAccounts =
|
|
265
|
+
const matchingAccounts = _hexclave_shared_dist_utils_results.Result.orThrow(await this._currentUserConnectedAccountsCache.getOrWait([session], "write-only")).filter((a) => a.provider === provider);
|
|
266
266
|
const scopes = scopeString ? scopeString.split(" ") : void 0;
|
|
267
267
|
for (const account of matchingAccounts) if ((await account.getAccessToken({ scopes })).status === "ok") return account;
|
|
268
268
|
const location = await (0, _________auth_js.getNewOAuthProviderOrScopeUrl)(this._interface, {
|
|
269
269
|
provider,
|
|
270
270
|
redirectUrl: this._getOAuthCallbackRedirectUri(),
|
|
271
271
|
errorRedirectUrl: this.urls.error,
|
|
272
|
-
providerScope: (0,
|
|
272
|
+
providerScope: (0, _hexclave_shared_dist_utils_strings.mergeScopeStrings)(scopeString, (this._oauthScopesOnSignIn[provider] ?? []).join(" "))
|
|
273
273
|
}, session);
|
|
274
274
|
await this._redirectTo({ url: location });
|
|
275
|
-
return await (0,
|
|
275
|
+
return await (0, _hexclave_shared_dist_utils_promises.neverResolve)();
|
|
276
276
|
});
|
|
277
277
|
this._teamMemberProfilesCache = (0, __common_js.createCacheBySession)(async (session, [teamId]) => {
|
|
278
278
|
return await this._interface.listTeamMemberProfiles({ teamId }, session);
|
|
@@ -380,7 +380,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
380
380
|
this._sessionsByTokenStoreAndSessionKey = /* @__PURE__ */ new WeakMap();
|
|
381
381
|
this._botChallengeSiteKeysWarned = false;
|
|
382
382
|
const resolvedOptions = (0, __common_js.resolveConstructorOptions)(options);
|
|
383
|
-
if (!_StackClientAppImplIncomplete.LazyStackAdminAppImpl.value) throw new
|
|
383
|
+
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).");
|
|
384
384
|
this._options = resolvedOptions;
|
|
385
385
|
this._extraOptions = extraOptions;
|
|
386
386
|
const projectId = resolvedOptions.projectId ?? (0, __common_js.getDefaultProjectId)();
|
|
@@ -389,7 +389,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
389
389
|
if (extraOptions && extraOptions.interface) this._interface = extraOptions.interface;
|
|
390
390
|
else {
|
|
391
391
|
const apiUrls = (0, __common_js.resolveApiUrls)(resolvedOptions.baseUrl);
|
|
392
|
-
this._interface = new
|
|
392
|
+
this._interface = new _hexclave_shared.HexclaveClientInterface({
|
|
393
393
|
getBaseUrl: () => apiUrls()[0],
|
|
394
394
|
getAnalyticsBaseUrl: () => (0, __common_js.getAnalyticsBaseUrl)(apiUrls()[0]),
|
|
395
395
|
getApiUrls: apiUrls,
|
|
@@ -398,17 +398,17 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
398
398
|
clientVersion: __common_js.clientVersion,
|
|
399
399
|
...publishableClientKey != null ? { publishableClientKey } : {},
|
|
400
400
|
prepareRequest: async () => {
|
|
401
|
-
await
|
|
401
|
+
await _hexclave_sc.cookies?.();
|
|
402
402
|
}
|
|
403
403
|
});
|
|
404
404
|
}
|
|
405
405
|
this._tokenStoreInit = resolvedOptions.tokenStore;
|
|
406
|
-
this._redirectMethod = resolvedOptions.redirectMethod || ((0,
|
|
406
|
+
this._redirectMethod = resolvedOptions.redirectMethod || ((0, _hexclave_shared_dist_utils_env.isBrowserLike)() ? "window" : "none");
|
|
407
407
|
this._redirectMethod = resolvedOptions.redirectMethod || "nextjs";
|
|
408
408
|
this._urlOptions = resolvedOptions.urls ?? {};
|
|
409
409
|
this._oauthScopesOnSignIn = resolvedOptions.oauthScopesOnSignIn ?? {};
|
|
410
|
-
if ((0,
|
|
411
|
-
(0,
|
|
410
|
+
if ((0, _hexclave_shared_dist_utils_env.isBrowserLike)() && (resolvedOptions.tokenStore === "cookie" || resolvedOptions.tokenStore === "nextjs-cookie")) {
|
|
411
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(this._trustedParentDomainCache.getOrWait([window.location.hostname], "write-only"));
|
|
412
412
|
this._ensureCrossSubdomainCookieExists();
|
|
413
413
|
}
|
|
414
414
|
if (extraOptions && extraOptions.uniqueIdentifier) {
|
|
@@ -425,7 +425,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
425
425
|
return (await this.getUser({ or: "anonymous" }))._internalSession;
|
|
426
426
|
};
|
|
427
427
|
const analyticsEnabled = this._analyticsOptions?.enabled !== false;
|
|
428
|
-
if (analyticsEnabled && (0,
|
|
428
|
+
if (analyticsEnabled && (0, _hexclave_shared_dist_utils_env.isBrowserLike)() && this._hasPersistentTokenStore() && this._analyticsOptions?.replays?.enabled === true) {
|
|
429
429
|
this._sessionRecorder = new __session_replay_js.SessionRecorder({
|
|
430
430
|
projectId: this.projectId,
|
|
431
431
|
sendBatch: async (body, opts) => {
|
|
@@ -434,7 +434,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
434
434
|
}, this._analyticsOptions.replays);
|
|
435
435
|
this._sessionRecorder.start();
|
|
436
436
|
}
|
|
437
|
-
if (analyticsEnabled && (0,
|
|
437
|
+
if (analyticsEnabled && (0, _hexclave_shared_dist_utils_env.isBrowserLike)() && this._hasPersistentTokenStore()) {
|
|
438
438
|
this._eventTracker = new __event_tracker_js.EventTracker({
|
|
439
439
|
projectId: this.projectId,
|
|
440
440
|
sendBatch: async (body, opts) => {
|
|
@@ -443,17 +443,17 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
443
443
|
});
|
|
444
444
|
this._eventTracker.start();
|
|
445
445
|
}
|
|
446
|
-
if ((0,
|
|
447
|
-
if ((0,
|
|
446
|
+
if ((0, _hexclave_shared_dist_utils_env.isBrowserLike)() && this._isOAuthCallbackUrlHosted() && this._currentUrlLooksLikeStackOAuthCallback()) this._trackPendingAuthResolution(async () => {
|
|
447
|
+
if ((0, _hexclave_shared_dist_utils_env.isBrowserLike)()) await this.callOAuthCallback({ dontWarnAboutMissingQueryParams: true });
|
|
448
448
|
});
|
|
449
|
-
if ((0,
|
|
449
|
+
if ((0, _hexclave_shared_dist_utils_env.isBrowserLike)()) this._trackPendingAuthResolution(async () => {
|
|
450
450
|
await this._maybeHandleNestedCrossDomainAuth();
|
|
451
451
|
});
|
|
452
|
-
if ((0,
|
|
452
|
+
if ((0, _hexclave_shared_dist_utils_env.isBrowserLike)() && resolvedOptions.devTool !== false) (0, ____________dev_tool_index_js.mountDevTool)(this);
|
|
453
453
|
}
|
|
454
454
|
_initUniqueIdentifier() {
|
|
455
|
-
if (!this._uniqueIdentifier) throw new
|
|
456
|
-
if (allClientApps.has(this._uniqueIdentifier)) throw new
|
|
455
|
+
if (!this._uniqueIdentifier) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("Unique identifier not initialized");
|
|
456
|
+
if (allClientApps.has(this._uniqueIdentifier)) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("A Stack client app with the same unique identifier already exists");
|
|
457
457
|
allClientApps.set(this._uniqueIdentifier, [this._extraOptions?.checkString ?? void 0, this]);
|
|
458
458
|
}
|
|
459
459
|
_trackPendingAuthResolution(callback) {
|
|
@@ -462,11 +462,11 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
462
462
|
try {
|
|
463
463
|
await callback();
|
|
464
464
|
} catch (error) {
|
|
465
|
-
(0,
|
|
465
|
+
(0, _hexclave_shared_dist_utils_errors.captureError)("pending-auth-resolution-failed", error);
|
|
466
466
|
}
|
|
467
467
|
})();
|
|
468
468
|
this._pendingAuthResolutionPromises.push(promise);
|
|
469
|
-
(0,
|
|
469
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
470
470
|
try {
|
|
471
471
|
await promise;
|
|
472
472
|
} finally {
|
|
@@ -480,7 +480,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
480
480
|
}
|
|
481
481
|
_usePendingAuthResolutions(overrideTokenStoreInit) {
|
|
482
482
|
if (overrideTokenStoreInit !== void 0 || !this._hasPersistentTokenStore() || this._pendingAuthResolutionPromises.length === 0) return;
|
|
483
|
-
(0,
|
|
483
|
+
(0, _hexclave_shared_dist_utils_react.use)(Promise.all(this._pendingAuthResolutionPromises));
|
|
484
484
|
}
|
|
485
485
|
_isOAuthCallbackUrlHosted() {
|
|
486
486
|
const oauthCallbackTarget = this._urlOptions.oauthCallback ?? this._urlOptions.default;
|
|
@@ -500,7 +500,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
500
500
|
}
|
|
501
501
|
_getOAuthCallbackRedirectUri() {
|
|
502
502
|
if (!this._isOAuthCallbackUrlHosted()) return this.urls.oauthCallback;
|
|
503
|
-
if (typeof window === "undefined") throw new
|
|
503
|
+
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");
|
|
504
504
|
const currentUrl = new URL(window.location.href);
|
|
505
505
|
for (const param of oauthCallbackResponseQueryParams) currentUrl.searchParams.delete(param);
|
|
506
506
|
return currentUrl.toString();
|
|
@@ -532,13 +532,13 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
532
532
|
const state = currentUrl.searchParams.get(nestedCrossDomainAuthQueryParams.state);
|
|
533
533
|
const codeChallenge = currentUrl.searchParams.get(nestedCrossDomainAuthQueryParams.codeChallenge);
|
|
534
534
|
if (redirectUri != null || state != null || codeChallenge != null) {
|
|
535
|
-
if (redirectUri == null || state == null || codeChallenge == null) throw new
|
|
535
|
+
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", {
|
|
536
536
|
redirectUri,
|
|
537
537
|
state,
|
|
538
538
|
codeChallenge
|
|
539
539
|
});
|
|
540
|
-
if ((currentUrl.searchParams.get(nestedCrossDomainAuthQueryParams.codeChallengeMethod) ?? "S256") !== "S256") throw new
|
|
541
|
-
if ((0,
|
|
540
|
+
if ((currentUrl.searchParams.get(nestedCrossDomainAuthQueryParams.codeChallengeMethod) ?? "S256") !== "S256") throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("Nested cross-domain auth only supports S256 PKCE");
|
|
541
|
+
if ((0, _hexclave_shared_dist_utils_urls.isRelative)(redirectUri)) throw new Error("Nested cross-domain auth redirect URI must be absolute.");
|
|
542
542
|
const redirectUriUrl = new URL(redirectUri);
|
|
543
543
|
if (!await this._isTrusted(redirectUriUrl.toString())) throw new Error(`Nested cross-domain auth redirect URI ${redirectUri} is not trusted.`);
|
|
544
544
|
const afterCallbackRedirectUrlString = currentUrl.searchParams.get(nestedCrossDomainAuthQueryParams.afterCallbackRedirectUrl);
|
|
@@ -559,16 +559,29 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
559
559
|
}
|
|
560
560
|
if (await this._getCurrentRefreshTokenIdIfSignedIn({ awaitPendingAuthResolutions: false }) === refreshTokenId) return false;
|
|
561
561
|
const callbackUrlString = currentUrl.searchParams.get(nestedCrossDomainAuthQueryParams.callbackUrl);
|
|
562
|
-
if (callbackUrlString == null) throw new
|
|
563
|
-
if ((0,
|
|
562
|
+
if (callbackUrlString == null) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("Nested cross-domain auth URL is missing callback URL");
|
|
563
|
+
if ((0, _hexclave_shared_dist_utils_urls.isRelative)(callbackUrlString)) throw new Error("Nested cross-domain auth callback URL must be absolute.");
|
|
564
564
|
const callbackUrl = new URL(callbackUrlString);
|
|
565
565
|
if (!await this._isTrusted(callbackUrl.toString())) throw new Error(`Nested cross-domain auth callback URL ${callbackUrlString} is not trusted.`);
|
|
566
566
|
const afterCallbackRedirectUrl = new URL(currentUrl);
|
|
567
567
|
afterCallbackRedirectUrl.searchParams.delete(nestedCrossDomainAuthQueryParams.refreshTokenId);
|
|
568
568
|
afterCallbackRedirectUrl.searchParams.delete(nestedCrossDomainAuthQueryParams.callbackUrl);
|
|
569
|
-
const { state: newState, codeChallenge: newCodeChallenge } = await this.
|
|
569
|
+
const { state: newState, codeChallenge: newCodeChallenge } = await this._getNestedCrossDomainAuthParamsForRedirect();
|
|
570
|
+
const nestedRedirectUri = new URL(this._getOAuthCallbackRedirectUri(), currentUrl);
|
|
571
|
+
nestedRedirectUri.searchParams.delete(nestedCrossDomainAuthQueryParams.refreshTokenId);
|
|
572
|
+
nestedRedirectUri.searchParams.delete(nestedCrossDomainAuthQueryParams.callbackUrl);
|
|
573
|
+
for (const param of [
|
|
574
|
+
"after_auth_return_to",
|
|
575
|
+
__redirect_page_urls_js.crossDomainAuthQueryParams.marker,
|
|
576
|
+
__redirect_page_urls_js.crossDomainAuthQueryParams.state,
|
|
577
|
+
__redirect_page_urls_js.crossDomainAuthQueryParams.codeChallenge,
|
|
578
|
+
__redirect_page_urls_js.crossDomainAuthQueryParams.afterCallbackRedirectUrl
|
|
579
|
+
]) {
|
|
580
|
+
const value = currentUrl.searchParams.get(param);
|
|
581
|
+
if (value != null && !nestedRedirectUri.searchParams.has(param)) nestedRedirectUri.searchParams.set(param, value);
|
|
582
|
+
}
|
|
570
583
|
callbackUrl.searchParams.set(nestedCrossDomainAuthQueryParams.refreshTokenId, refreshTokenId);
|
|
571
|
-
callbackUrl.searchParams.set(nestedCrossDomainAuthQueryParams.redirectUri,
|
|
584
|
+
callbackUrl.searchParams.set(nestedCrossDomainAuthQueryParams.redirectUri, nestedRedirectUri.toString());
|
|
572
585
|
callbackUrl.searchParams.set(nestedCrossDomainAuthQueryParams.state, newState);
|
|
573
586
|
callbackUrl.searchParams.set(nestedCrossDomainAuthQueryParams.codeChallenge, newCodeChallenge);
|
|
574
587
|
callbackUrl.searchParams.set(nestedCrossDomainAuthQueryParams.codeChallengeMethod, "S256");
|
|
@@ -579,6 +592,9 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
579
592
|
});
|
|
580
593
|
return true;
|
|
581
594
|
}
|
|
595
|
+
async _getNestedCrossDomainAuthParamsForRedirect() {
|
|
596
|
+
return await (0, _________cookie_js.saveVerifierAndState)();
|
|
597
|
+
}
|
|
582
598
|
/**
|
|
583
599
|
* Cloudflare workers does not allow use of randomness on the global scope (on which the Stack app is probably
|
|
584
600
|
* initialized). For that reason, we generate the unique identifier lazily when it is first needed instead of in the
|
|
@@ -586,7 +602,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
586
602
|
*/
|
|
587
603
|
_getUniqueIdentifier() {
|
|
588
604
|
if (!this._uniqueIdentifier) {
|
|
589
|
-
this._uniqueIdentifier = (0,
|
|
605
|
+
this._uniqueIdentifier = (0, _hexclave_shared_dist_utils_uuids.generateUuid)();
|
|
590
606
|
this._initUniqueIdentifier();
|
|
591
607
|
}
|
|
592
608
|
return this._uniqueIdentifier;
|
|
@@ -598,8 +614,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
598
614
|
});
|
|
599
615
|
}
|
|
600
616
|
_useCheckFeatureSupport(name, options) {
|
|
601
|
-
(0,
|
|
602
|
-
throw new
|
|
617
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(this._checkFeatureSupport(name, options));
|
|
618
|
+
throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError(`${name} is not currently supported. Please reach out to Stack support for more information.`);
|
|
603
619
|
}
|
|
604
620
|
get _legacyRefreshTokenCookieName() {
|
|
605
621
|
return `stack-refresh-${this.projectId}`;
|
|
@@ -611,7 +627,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
611
627
|
return `${secure ? "__Host-" : ""}${this._refreshTokenCookieName}--default`;
|
|
612
628
|
}
|
|
613
629
|
_getCustomRefreshCookieName(domain) {
|
|
614
|
-
const encoded = (0,
|
|
630
|
+
const encoded = (0, _hexclave_shared_dist_utils_bytes.encodeBase32)(new TextEncoder().encode(domain.toLowerCase()));
|
|
615
631
|
return `${this._refreshTokenCookieName}--custom-${encoded}`;
|
|
616
632
|
}
|
|
617
633
|
_getDomainFromCustomRefreshCookieName(name) {
|
|
@@ -619,7 +635,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
619
635
|
const prefix = `${base}--custom-`;
|
|
620
636
|
if (!name.startsWith(prefix)) continue;
|
|
621
637
|
try {
|
|
622
|
-
return new TextDecoder().decode((0,
|
|
638
|
+
return new TextDecoder().decode((0, _hexclave_shared_dist_utils_bytes.decodeBase32)(name.slice(prefix.length)));
|
|
623
639
|
} catch {
|
|
624
640
|
return null;
|
|
625
641
|
}
|
|
@@ -637,7 +653,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
637
653
|
}
|
|
638
654
|
_parseStructuredRefreshCookie(value) {
|
|
639
655
|
if (!value) return null;
|
|
640
|
-
const parsed = (0,
|
|
656
|
+
const parsed = (0, _hexclave_shared_dist_utils_json.parseJson)(value);
|
|
641
657
|
if (parsed.status !== "ok" || typeof parsed.data !== "object" || parsed.data === null) {
|
|
642
658
|
console.warn("Failed to parse structured refresh cookie");
|
|
643
659
|
return null;
|
|
@@ -696,7 +712,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
696
712
|
const accessTokenCookie = cookies[this._accessTokenCookieName] ?? cookies[this._legacyAccessTokenCookieName] ?? null;
|
|
697
713
|
let accessToken = null;
|
|
698
714
|
if (accessTokenCookie && accessTokenCookie.startsWith("[\"")) {
|
|
699
|
-
const parsed = (0,
|
|
715
|
+
const parsed = (0, _hexclave_shared_dist_utils_json.parseJson)(accessTokenCookie);
|
|
700
716
|
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") {
|
|
701
717
|
if (parsed.data[0] === refreshToken) accessToken = parsed.data[1];
|
|
702
718
|
} else console.warn("Access token cookie has invalid format");
|
|
@@ -713,7 +729,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
713
729
|
return `stack-access`;
|
|
714
730
|
}
|
|
715
731
|
_getAllBrowserCookies() {
|
|
716
|
-
if (!(0,
|
|
732
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)()) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("Cannot get browser cookies on the server!");
|
|
717
733
|
return cookie.parseCookie(document.cookie || "");
|
|
718
734
|
}
|
|
719
735
|
_getRefreshTokenCookieNamePatterns() {
|
|
@@ -746,7 +762,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
746
762
|
};
|
|
747
763
|
}
|
|
748
764
|
_ensureCrossSubdomainCookieExists() {
|
|
749
|
-
(0,
|
|
765
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
750
766
|
const hostname = window.location.hostname;
|
|
751
767
|
const domain = await this._trustedParentDomainCache.getOrWait([hostname], "read-write");
|
|
752
768
|
if (domain.status === "error" || !domain.data) return;
|
|
@@ -761,11 +777,11 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
761
777
|
});
|
|
762
778
|
}
|
|
763
779
|
_queueCustomRefreshCookieUpdate(refreshToken, updatedAt, context) {
|
|
764
|
-
(0,
|
|
780
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
765
781
|
this._mostRecentQueuedCookieRefreshIndex++;
|
|
766
782
|
const updateIndex = this._mostRecentQueuedCookieRefreshIndex;
|
|
767
783
|
let hostname;
|
|
768
|
-
if ((0,
|
|
784
|
+
if ((0, _hexclave_shared_dist_utils_env.isBrowserLike)()) hostname = window.location.hostname;
|
|
769
785
|
else hostname = await getServerRequestHost();
|
|
770
786
|
if (!hostname) {
|
|
771
787
|
console.warn("No hostname found when queueing custom refresh cookie update");
|
|
@@ -795,7 +811,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
795
811
|
});
|
|
796
812
|
}
|
|
797
813
|
async _getTrustedRedirectConfig() {
|
|
798
|
-
const project =
|
|
814
|
+
const project = _hexclave_shared_dist_utils_results.Result.orThrow(await this._currentProjectCache.getOrWait([], "write-only"));
|
|
799
815
|
return {
|
|
800
816
|
allowLocalhost: project.config.allow_localhost,
|
|
801
817
|
trustedDomains: [...project.config.domains.map((d) => d.domain), new URL((0, ______url_targets_js.getHostedHandlerUrl)({
|
|
@@ -805,10 +821,10 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
805
821
|
};
|
|
806
822
|
}
|
|
807
823
|
async _getTrustedParentDomain(currentDomain) {
|
|
808
|
-
return (0,
|
|
824
|
+
return (0, _hexclave_shared_dist_utils_redirect_urls.getTrustedParentDomain)(currentDomain, (await this._getTrustedRedirectConfig()).trustedDomains);
|
|
809
825
|
}
|
|
810
826
|
_getBrowserCookieTokenStore() {
|
|
811
|
-
if (!(0,
|
|
827
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)()) throw new Error("Cannot use cookie token store on the server!");
|
|
812
828
|
if (this._storedBrowserCookieTokenStore === null) {
|
|
813
829
|
const getCurrentValue = (old) => {
|
|
814
830
|
const tokens = this._getTokensFromCookies(this._getAllBrowserCookies());
|
|
@@ -817,13 +833,13 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
817
833
|
accessToken: tokens.accessToken ?? (old?.refreshToken === tokens.refreshToken ? old.accessToken : null)
|
|
818
834
|
};
|
|
819
835
|
};
|
|
820
|
-
this._storedBrowserCookieTokenStore = new
|
|
836
|
+
this._storedBrowserCookieTokenStore = new _hexclave_shared_dist_utils_stores.Store(getCurrentValue(null));
|
|
821
837
|
let hasSucceededInWriting = true;
|
|
822
838
|
setInterval(() => {
|
|
823
839
|
if (hasSucceededInWriting) {
|
|
824
840
|
const oldValue = this._storedBrowserCookieTokenStore.get();
|
|
825
841
|
const currentValue = getCurrentValue(oldValue);
|
|
826
|
-
if (!(0,
|
|
842
|
+
if (!(0, _hexclave_shared_dist_utils_objects.deepPlainEquals)(currentValue, oldValue)) this._storedBrowserCookieTokenStore.set(currentValue);
|
|
827
843
|
}
|
|
828
844
|
}, 100);
|
|
829
845
|
this._storedBrowserCookieTokenStore.onChange((value) => {
|
|
@@ -844,7 +860,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
844
860
|
this._queueCustomRefreshCookieUpdate(refreshToken, updatedAt, "browser");
|
|
845
861
|
hasSucceededInWriting = true;
|
|
846
862
|
} catch (e) {
|
|
847
|
-
if (!(0,
|
|
863
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)()) hasSucceededInWriting = false;
|
|
848
864
|
else throw e;
|
|
849
865
|
}
|
|
850
866
|
});
|
|
@@ -855,11 +871,11 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
855
871
|
const tokenStoreInit = overrideTokenStoreInit === void 0 ? this._tokenStoreInit : overrideTokenStoreInit;
|
|
856
872
|
switch (tokenStoreInit) {
|
|
857
873
|
case "cookie": return this._getBrowserCookieTokenStore();
|
|
858
|
-
case "nextjs-cookie": if ((0,
|
|
874
|
+
case "nextjs-cookie": if ((0, _hexclave_shared_dist_utils_env.isBrowserLike)()) return this._getBrowserCookieTokenStore();
|
|
859
875
|
else {
|
|
860
|
-
const store = new
|
|
876
|
+
const store = new _hexclave_shared_dist_utils_stores.Store(this._getTokensFromCookies(cookieHelper.getAll()));
|
|
861
877
|
store.onChange((value) => {
|
|
862
|
-
(0,
|
|
878
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
863
879
|
const refreshToken = value.refreshToken;
|
|
864
880
|
const secure = await (0, _________cookie_js.isSecure)();
|
|
865
881
|
const defaultName = this._getRefreshTokenDefaultCookieNameForSecure(secure);
|
|
@@ -892,7 +908,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
892
908
|
if (authorizationHeader) {
|
|
893
909
|
const authJson = getAuthJsonFromAuthorizationHeaderValue(authorizationHeader);
|
|
894
910
|
if (authJson != null) {
|
|
895
|
-
const tokenStore = new
|
|
911
|
+
const tokenStore = new _hexclave_shared_dist_utils_stores.Store({
|
|
896
912
|
accessToken: authJson.accessToken,
|
|
897
913
|
refreshToken: authJson.refreshToken
|
|
898
914
|
});
|
|
@@ -917,10 +933,10 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
917
933
|
}
|
|
918
934
|
const cookieHeader = getHeaderValueFromRequestLikeHeaders(tokenStoreInit.headers, "cookie");
|
|
919
935
|
const parsed = cookie.parseCookie(cookieHeader || "");
|
|
920
|
-
const res = new
|
|
936
|
+
const res = new _hexclave_shared_dist_utils_stores.Store(this._getTokensFromCookies(parsed));
|
|
921
937
|
this._requestTokenStores.set(tokenStoreInit, res);
|
|
922
938
|
return res;
|
|
923
|
-
} else if ("accessToken" in tokenStoreInit || "refreshToken" in tokenStoreInit) return new
|
|
939
|
+
} else if ("accessToken" in tokenStoreInit || "refreshToken" in tokenStoreInit) return new _hexclave_shared_dist_utils_stores.Store({
|
|
924
940
|
refreshToken: tokenStoreInit.refreshToken,
|
|
925
941
|
accessToken: tokenStoreInit.accessToken
|
|
926
942
|
});
|
|
@@ -928,13 +944,13 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
928
944
|
}
|
|
929
945
|
}
|
|
930
946
|
_useTokenStore(overrideTokenStoreInit) {
|
|
931
|
-
(0,
|
|
947
|
+
(0, _hexclave_shared_dist_utils_react.suspendIfSsr)();
|
|
932
948
|
const cookieHelper = (0, _________cookie_js.createBrowserCookieHelper)();
|
|
933
949
|
return this._getOrCreateTokenStore(cookieHelper, overrideTokenStoreInit);
|
|
934
950
|
}
|
|
935
951
|
_getSessionFromTokenStore(tokenStore) {
|
|
936
952
|
const tokenObj = tokenStore.get();
|
|
937
|
-
const sessionKey =
|
|
953
|
+
const sessionKey = _hexclave_shared_dist_sessions.InternalSession.calculateSessionKey(tokenObj);
|
|
938
954
|
const existing = sessionKey ? this._sessionsByTokenStoreAndSessionKey.get(tokenStore)?.get(sessionKey) : null;
|
|
939
955
|
if (existing) return existing;
|
|
940
956
|
const session = this._interface.createSession({
|
|
@@ -978,7 +994,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
978
994
|
return react.default.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
979
995
|
}
|
|
980
996
|
async _signInToAccountWithTokens(tokens) {
|
|
981
|
-
if (!("accessToken" in tokens) || !("refreshToken" in tokens)) throw new
|
|
997
|
+
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 });
|
|
982
998
|
const tokenStore = this._getOrCreateTokenStore(await this._createCookieHelper());
|
|
983
999
|
tokenStore.set(tokens);
|
|
984
1000
|
const newSession = this._getSessionFromTokenStore(tokenStore);
|
|
@@ -1118,13 +1134,13 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1118
1134
|
await app._teamInvitationsCache.refresh([session, crud.id]);
|
|
1119
1135
|
},
|
|
1120
1136
|
async listUsers() {
|
|
1121
|
-
return
|
|
1137
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._teamMemberProfilesCache.getOrWait([session, crud.id], "write-only")).map((crud) => app._clientTeamUserFromCrud(crud));
|
|
1122
1138
|
},
|
|
1123
1139
|
useUsers() {
|
|
1124
1140
|
return (0, __common_js.useAsyncCache)(app._teamMemberProfilesCache, [session, crud.id], "team.useUsers()").map((crud) => app._clientTeamUserFromCrud(crud));
|
|
1125
1141
|
},
|
|
1126
1142
|
async listInvitations() {
|
|
1127
|
-
return
|
|
1143
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._teamInvitationsCache.getOrWait([session, crud.id], "write-only")).map((crud) => app._clientSentTeamInvitationFromCrud(session, crud));
|
|
1128
1144
|
},
|
|
1129
1145
|
useInvitations() {
|
|
1130
1146
|
return (0, __common_js.useAsyncCache)(app._teamInvitationsCache, [session, crud.id], "team.useInvitations()").map((crud) => app._clientSentTeamInvitationFromCrud(session, crud));
|
|
@@ -1144,7 +1160,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1144
1160
|
return (0, __common_js.useAsyncCache)(app._teamApiKeysCache, [session, crud.id], "team.useApiKeys()").map((crud) => app._clientApiKeyFromCrud(session, crud));
|
|
1145
1161
|
},
|
|
1146
1162
|
async listApiKeys() {
|
|
1147
|
-
return
|
|
1163
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._teamApiKeysCache.getOrWait([session, crud.id], "write-only")).map((crud) => app._clientApiKeyFromCrud(session, crud));
|
|
1148
1164
|
},
|
|
1149
1165
|
async createApiKey(options) {
|
|
1150
1166
|
const result = await app._interface.createProjectApiKey(await (0, ______api_keys_index_js.apiKeyCreationOptionsToCrud)("team", crud.id, options), session, "client");
|
|
@@ -1204,9 +1220,9 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1204
1220
|
allow_connected_accounts: data.allowConnectedAccounts
|
|
1205
1221
|
}, session);
|
|
1206
1222
|
await Promise.all([app._currentUserOAuthProvidersCache.refresh([session]), app._currentUserConnectedAccountsCache.refresh([session])]);
|
|
1207
|
-
return
|
|
1223
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
1208
1224
|
} catch (error) {
|
|
1209
|
-
if (
|
|
1225
|
+
if (_hexclave_shared.KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn.isInstance(error)) return _hexclave_shared_dist_utils_results.Result.error(error);
|
|
1210
1226
|
throw error;
|
|
1211
1227
|
}
|
|
1212
1228
|
},
|
|
@@ -1286,7 +1302,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1286
1302
|
return session.isKnownToBeInvalid() ? null : session.getAccessTokenIfNotExpiredYet(2e4, 75e3)?.token ?? null;
|
|
1287
1303
|
}, [session]);
|
|
1288
1304
|
let accessToken = react.default.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
1289
|
-
if (accessToken === null && !session.isKnownToBeInvalid()) accessToken = (0,
|
|
1305
|
+
if (accessToken === null && !session.isKnownToBeInvalid()) accessToken = (0, _hexclave_shared_dist_utils_react.use)(session.getOrFetchLikelyValidTokens(2e4, 75e3))?.accessToken.token ?? null;
|
|
1290
1306
|
return {
|
|
1291
1307
|
accessToken,
|
|
1292
1308
|
refreshToken: session.getRefreshToken()?.token ?? null
|
|
@@ -1376,11 +1392,11 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1376
1392
|
const scopeString = options?.scopes?.join(" ") ?? "";
|
|
1377
1393
|
if (typeof idOrAccount === "object" && "provider" in idOrAccount && "providerAccountId" in idOrAccount) {
|
|
1378
1394
|
const { provider, providerAccountId } = idOrAccount;
|
|
1379
|
-
const found =
|
|
1395
|
+
const found = _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserConnectedAccountsCache.getOrWait([session], "write-only")).find((a) => a.provider === provider && a.providerAccountId === providerAccountId);
|
|
1380
1396
|
if (!found) return null;
|
|
1381
1397
|
return found;
|
|
1382
1398
|
}
|
|
1383
|
-
return
|
|
1399
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserOAuthConnectionCache.getOrWait([
|
|
1384
1400
|
session,
|
|
1385
1401
|
idOrAccount,
|
|
1386
1402
|
scopeString,
|
|
@@ -1419,7 +1435,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1419
1435
|
getConnectedAccount,
|
|
1420
1436
|
useConnectedAccount,
|
|
1421
1437
|
async listConnectedAccounts() {
|
|
1422
|
-
return
|
|
1438
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserConnectedAccountsCache.getOrWait([session], "write-only"));
|
|
1423
1439
|
},
|
|
1424
1440
|
useConnectedAccounts() {
|
|
1425
1441
|
return (0, __common_js.useAsyncCache)(app._currentUserConnectedAccountsCache, [session], "user.useConnectedAccounts()");
|
|
@@ -1430,16 +1446,16 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1430
1446
|
provider,
|
|
1431
1447
|
redirectUrl: app._getOAuthCallbackRedirectUri(),
|
|
1432
1448
|
errorRedirectUrl: app.urls.error,
|
|
1433
|
-
providerScope: (0,
|
|
1449
|
+
providerScope: (0, _hexclave_shared_dist_utils_strings.mergeScopeStrings)(scopeString, (app._oauthScopesOnSignIn[provider] ?? []).join(" "))
|
|
1434
1450
|
}, session);
|
|
1435
1451
|
await app._redirectTo({ url: location });
|
|
1436
|
-
return await (0,
|
|
1452
|
+
return await (0, _hexclave_shared_dist_utils_promises.neverResolve)();
|
|
1437
1453
|
},
|
|
1438
1454
|
async getOrLinkConnectedAccount(provider, options) {
|
|
1439
|
-
const matchingAccounts =
|
|
1455
|
+
const matchingAccounts = _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserConnectedAccountsCache.getOrWait([session], "write-only")).filter((a) => a.provider === provider);
|
|
1440
1456
|
for (const account of matchingAccounts) if ((await account.getAccessToken({ scopes: options?.scopes })).status === "ok") return account;
|
|
1441
1457
|
await this.linkConnectedAccount(provider, options);
|
|
1442
|
-
return await (0,
|
|
1458
|
+
return await (0, _hexclave_shared_dist_utils_promises.neverResolve)();
|
|
1443
1459
|
},
|
|
1444
1460
|
useOrLinkConnectedAccount(provider, options) {
|
|
1445
1461
|
const scopeString = options?.scopes?.join(" ") ?? "";
|
|
@@ -1459,7 +1475,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1459
1475
|
}, [teams, teamId]);
|
|
1460
1476
|
},
|
|
1461
1477
|
async listTeams() {
|
|
1462
|
-
return
|
|
1478
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserTeamsCache.getOrWait([session], "write-only")).map((crud) => app._clientTeamFromCrud(crud, session));
|
|
1463
1479
|
},
|
|
1464
1480
|
useTeams() {
|
|
1465
1481
|
const teams = (0, __common_js.useAsyncCache)(app._currentUserTeamsCache, [session], "user.useTeams()");
|
|
@@ -1475,7 +1491,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1475
1491
|
await app._interface.leaveTeam(team.id, session);
|
|
1476
1492
|
},
|
|
1477
1493
|
async listTeamInvitations() {
|
|
1478
|
-
return
|
|
1494
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserTeamInvitationsCache.getOrWait([session], "write-only")).map((crud) => app._clientReceivedTeamInvitationFromCrud(session, crud));
|
|
1479
1495
|
},
|
|
1480
1496
|
useTeamInvitations() {
|
|
1481
1497
|
const invitations = (0, __common_js.useAsyncCache)(app._currentUserTeamInvitationsCache, [session], "user.useTeamInvitations()");
|
|
@@ -1485,14 +1501,14 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1485
1501
|
if (scopeOrOptions && "id" in scopeOrOptions) {
|
|
1486
1502
|
const scope = scopeOrOptions;
|
|
1487
1503
|
const recursive = options?.recursive ?? true;
|
|
1488
|
-
return
|
|
1504
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserPermissionsCache.getOrWait([
|
|
1489
1505
|
session,
|
|
1490
1506
|
scope.id,
|
|
1491
1507
|
recursive
|
|
1492
1508
|
], "write-only")).map((crud) => app._clientPermissionFromCrud(crud));
|
|
1493
1509
|
} else {
|
|
1494
1510
|
const recursive = scopeOrOptions?.recursive ?? true;
|
|
1495
|
-
return
|
|
1511
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserProjectPermissionsCache.getOrWait([session, recursive], "write-only")).map((crud) => app._clientPermissionFromCrud(crud));
|
|
1496
1512
|
}
|
|
1497
1513
|
},
|
|
1498
1514
|
usePermissions(scopeOrOptions, options) {
|
|
@@ -1544,7 +1560,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1544
1560
|
return await app._updateClientUser(update, session);
|
|
1545
1561
|
},
|
|
1546
1562
|
async sendVerificationEmail(options) {
|
|
1547
|
-
if (!crud.primary_email) throw new
|
|
1563
|
+
if (!crud.primary_email) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("User does not have a primary email");
|
|
1548
1564
|
return await app._interface.sendVerificationEmail(crud.primary_email, options?.callbackUrl ?? (0, ____________utils_url_js.constructRedirectUrl)(app.urls.emailVerification, "callbackUrl"), session);
|
|
1549
1565
|
},
|
|
1550
1566
|
async updatePassword(options) {
|
|
@@ -1559,7 +1575,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1559
1575
|
},
|
|
1560
1576
|
selectedTeam: crud.selected_team && this._clientTeamFromCrud(crud.selected_team, session),
|
|
1561
1577
|
async getTeamProfile(team) {
|
|
1562
|
-
const result =
|
|
1578
|
+
const result = _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserTeamProfileCache.getOrWait([session, team.id], "write-only"));
|
|
1563
1579
|
return app._editableTeamProfileFromCrud(result, session);
|
|
1564
1580
|
},
|
|
1565
1581
|
useTeamProfile(team) {
|
|
@@ -1571,7 +1587,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1571
1587
|
session.markInvalid();
|
|
1572
1588
|
},
|
|
1573
1589
|
async listContactChannels() {
|
|
1574
|
-
return
|
|
1590
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._clientContactChannelsCache.getOrWait([session], "write-only")).map((crud) => app._clientContactChannelFromCrud(crud, session));
|
|
1575
1591
|
},
|
|
1576
1592
|
useContactChannels() {
|
|
1577
1593
|
return (0, __common_js.useAsyncCache)(app._clientContactChannelsCache, [session], "user.useContactChannels()").map((crud) => app._clientContactChannelFromCrud(crud, session));
|
|
@@ -1585,7 +1601,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1585
1601
|
return (0, __common_js.useAsyncCache)(app._notificationCategoriesCache, [session], "user.useNotificationCategories()").map((crud) => app._clientNotificationCategoryFromCrud(crud, session));
|
|
1586
1602
|
},
|
|
1587
1603
|
async listNotificationCategories() {
|
|
1588
|
-
return
|
|
1604
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._notificationCategoriesCache.getOrWait([session], "write-only")).map((crud) => app._clientNotificationCategoryFromCrud(crud, session));
|
|
1589
1605
|
},
|
|
1590
1606
|
useApiKeys() {
|
|
1591
1607
|
return (0, __common_js.useAsyncCache)(app._userApiKeysCache, [session], "user.useApiKeys()").map((crud) => app._clientApiKeyFromCrud(session, crud));
|
|
@@ -1602,7 +1618,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1602
1618
|
return (0, __common_js.useAsyncCache)(app._currentUserOAuthProvidersCache, [session], "user.useOAuthProviders()").map((crud) => app._clientOAuthProviderFromCrud(crud, session));
|
|
1603
1619
|
},
|
|
1604
1620
|
async listOAuthProviders() {
|
|
1605
|
-
return
|
|
1621
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserOAuthProvidersCache.getOrWait([session], "write-only")).map((crud) => app._clientOAuthProviderFromCrud(crud, session));
|
|
1606
1622
|
},
|
|
1607
1623
|
useOAuthProvider(id) {
|
|
1608
1624
|
const providers = this.useOAuthProviders();
|
|
@@ -1613,20 +1629,20 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1613
1629
|
},
|
|
1614
1630
|
async registerPasskey(options) {
|
|
1615
1631
|
const hostname = (await app._getCurrentUrl())?.hostname;
|
|
1616
|
-
if (!hostname) throw new
|
|
1632
|
+
if (!hostname) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("hostname must be provided if the Stack App does not have a redirect method");
|
|
1617
1633
|
const initiationResult = await app._interface.initiatePasskeyRegistration({}, session);
|
|
1618
|
-
if (initiationResult.status !== "ok") return
|
|
1634
|
+
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"));
|
|
1619
1635
|
const { options_json, code } = initiationResult.data;
|
|
1620
|
-
if (options_json.rp.id !== "THIS_VALUE_WILL_BE_REPLACED.example.com") throw new
|
|
1636
|
+
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}`);
|
|
1621
1637
|
options_json.rp.id = hostname;
|
|
1622
1638
|
let attResp;
|
|
1623
1639
|
try {
|
|
1624
1640
|
attResp = await (0, _simplewebauthn_browser.startRegistration)({ optionsJSON: options_json });
|
|
1625
1641
|
} catch (error) {
|
|
1626
|
-
if (error instanceof _simplewebauthn_browser.WebAuthnError) return
|
|
1642
|
+
if (error instanceof _simplewebauthn_browser.WebAuthnError) return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.PasskeyWebAuthnError(error.message, error.name));
|
|
1627
1643
|
else {
|
|
1628
|
-
(0,
|
|
1629
|
-
return
|
|
1644
|
+
(0, _hexclave_shared_dist_utils_errors.captureError)("passkey-registration-failed", error);
|
|
1645
|
+
return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.PasskeyRegistrationFailed("Failed to start passkey registration due to unknown error"));
|
|
1630
1646
|
}
|
|
1631
1647
|
}
|
|
1632
1648
|
const registrationResult = await app._interface.registerPasskey({
|
|
@@ -1663,7 +1679,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1663
1679
|
const customerOptions = type === "user" ? { userId: userIdOrTeamId } : { teamId: userIdOrTeamId };
|
|
1664
1680
|
return {
|
|
1665
1681
|
async getBilling() {
|
|
1666
|
-
const response =
|
|
1682
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await app._customerBillingCache.getOrWait([
|
|
1667
1683
|
effectiveSession,
|
|
1668
1684
|
type,
|
|
1669
1685
|
userIdOrTeamId
|
|
@@ -1755,17 +1771,17 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1755
1771
|
async getItem(options) {
|
|
1756
1772
|
const session = await this._getSession();
|
|
1757
1773
|
let crud;
|
|
1758
|
-
if ("userId" in options) crud =
|
|
1774
|
+
if ("userId" in options) crud = _hexclave_shared_dist_utils_results.Result.orThrow(await this._userItemCache.getOrWait([
|
|
1759
1775
|
session,
|
|
1760
1776
|
options.userId,
|
|
1761
1777
|
options.itemId
|
|
1762
1778
|
], "write-only"));
|
|
1763
|
-
else if ("teamId" in options) crud =
|
|
1779
|
+
else if ("teamId" in options) crud = _hexclave_shared_dist_utils_results.Result.orThrow(await this._teamItemCache.getOrWait([
|
|
1764
1780
|
session,
|
|
1765
1781
|
options.teamId,
|
|
1766
1782
|
options.itemId
|
|
1767
1783
|
], "write-only"));
|
|
1768
|
-
else crud =
|
|
1784
|
+
else crud = _hexclave_shared_dist_utils_results.Result.orThrow(await this._customItemCache.getOrWait([
|
|
1769
1785
|
session,
|
|
1770
1786
|
options.customCustomerId,
|
|
1771
1787
|
options.itemId
|
|
@@ -1785,7 +1801,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1785
1801
|
async listProducts(options) {
|
|
1786
1802
|
const session = (await this.getUser())?._internalSession ?? await this._getSession();
|
|
1787
1803
|
if ("userId" in options) {
|
|
1788
|
-
const response =
|
|
1804
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await this._userProductsCache.getOrWait([
|
|
1789
1805
|
session,
|
|
1790
1806
|
options.userId,
|
|
1791
1807
|
options.cursor ?? null,
|
|
@@ -1793,7 +1809,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1793
1809
|
], "write-only"));
|
|
1794
1810
|
return this._customerProductsFromResponse(response);
|
|
1795
1811
|
} else if ("teamId" in options) {
|
|
1796
|
-
const response =
|
|
1812
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await this._teamProductsCache.getOrWait([
|
|
1797
1813
|
session,
|
|
1798
1814
|
options.teamId,
|
|
1799
1815
|
options.cursor ?? null,
|
|
@@ -1801,7 +1817,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1801
1817
|
], "write-only"));
|
|
1802
1818
|
return this._customerProductsFromResponse(response);
|
|
1803
1819
|
}
|
|
1804
|
-
const response =
|
|
1820
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await this._customProductsCache.getOrWait([
|
|
1805
1821
|
session,
|
|
1806
1822
|
options.customCustomerId,
|
|
1807
1823
|
options.cursor ?? null,
|
|
@@ -1812,7 +1828,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1812
1828
|
async listInvoices(options) {
|
|
1813
1829
|
const session = await this._getSession();
|
|
1814
1830
|
if ("userId" in options) {
|
|
1815
|
-
const response =
|
|
1831
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await this._userInvoicesCache.getOrWait([
|
|
1816
1832
|
session,
|
|
1817
1833
|
options.userId,
|
|
1818
1834
|
options.cursor ?? null,
|
|
@@ -1820,7 +1836,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1820
1836
|
], "write-only"));
|
|
1821
1837
|
return this._customerInvoicesFromResponse(response);
|
|
1822
1838
|
}
|
|
1823
|
-
const response =
|
|
1839
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await this._teamInvoicesCache.getOrWait([
|
|
1824
1840
|
session,
|
|
1825
1841
|
options.teamId,
|
|
1826
1842
|
options.cursor ?? null,
|
|
@@ -1831,7 +1847,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1831
1847
|
async cancelSubscription(options) {
|
|
1832
1848
|
const session = await this._getSession();
|
|
1833
1849
|
const user = await this.getUser();
|
|
1834
|
-
if (!user) throw new
|
|
1850
|
+
if (!user) throw new _hexclave_shared.KnownErrors.UserAuthenticationRequired();
|
|
1835
1851
|
const customerType = "teamId" in options ? "team" : "user";
|
|
1836
1852
|
const customerId = "teamId" in options ? options.teamId : user.id;
|
|
1837
1853
|
await this._interface.cancelSubscription({
|
|
@@ -1900,7 +1916,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1900
1916
|
return __common_js.clientVersion;
|
|
1901
1917
|
}
|
|
1902
1918
|
_getBotChallengeSiteKeys() {
|
|
1903
|
-
if (!(0,
|
|
1919
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)()) return null;
|
|
1904
1920
|
const visibleSiteKey = _________env_js.envVars.NEXT_PUBLIC_STACK_BOT_CHALLENGE_SITE_KEY;
|
|
1905
1921
|
if (!visibleSiteKey) {
|
|
1906
1922
|
if (!this._botChallengeSiteKeysWarned) {
|
|
@@ -1915,23 +1931,23 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1915
1931
|
};
|
|
1916
1932
|
}
|
|
1917
1933
|
_getBotChallengeFlowFailure(error) {
|
|
1918
|
-
if (error instanceof
|
|
1934
|
+
if (error instanceof _hexclave_shared_dist_utils_turnstile_flow.BotChallengeUserCancelledError) return {
|
|
1919
1935
|
type: "cancelled",
|
|
1920
|
-
knownError: new
|
|
1936
|
+
knownError: new _hexclave_shared.KnownErrors.BotChallengeFailed("Bot challenge cancelled by user")
|
|
1921
1937
|
};
|
|
1922
|
-
if (error instanceof
|
|
1938
|
+
if (error instanceof _hexclave_shared_dist_utils_turnstile_flow.BotChallengeExecutionFailedError) return {
|
|
1923
1939
|
type: "failed",
|
|
1924
|
-
knownError: new
|
|
1940
|
+
knownError: new _hexclave_shared.KnownErrors.BotChallengeFailed(error.message)
|
|
1925
1941
|
};
|
|
1926
1942
|
return null;
|
|
1927
1943
|
}
|
|
1928
1944
|
_normalizeBotChallengeResult(result) {
|
|
1929
1945
|
if (result.status === "ok") return result;
|
|
1930
|
-
if (
|
|
1931
|
-
(0,
|
|
1932
|
-
return
|
|
1946
|
+
if (_hexclave_shared.KnownErrors.BotChallengeRequired.isInstance(result.error)) {
|
|
1947
|
+
(0, _hexclave_shared_dist_utils_errors.captureError)("bot-challenge-unexpected-after-flow", result.error);
|
|
1948
|
+
return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.BotChallengeFailed("Unexpected bot challenge after flow completion"));
|
|
1933
1949
|
}
|
|
1934
|
-
return
|
|
1950
|
+
return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
1935
1951
|
}
|
|
1936
1952
|
_toInterfaceBotChallengeInput(challenge) {
|
|
1937
1953
|
if (challenge.unavailable) return { phase: "visible" };
|
|
@@ -1944,25 +1960,25 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1944
1960
|
const siteKeys = this._getBotChallengeSiteKeys();
|
|
1945
1961
|
let result;
|
|
1946
1962
|
try {
|
|
1947
|
-
if (siteKeys) result = await (0,
|
|
1963
|
+
if (siteKeys) result = await (0, _hexclave_shared_dist_utils_turnstile_flow.withBotChallengeFlow)({
|
|
1948
1964
|
...siteKeys,
|
|
1949
1965
|
action: options.action,
|
|
1950
1966
|
execute: options.execute,
|
|
1951
1967
|
isChallengeRequired: (flowResult) => {
|
|
1952
|
-
return flowResult.status === "error" &&
|
|
1968
|
+
return flowResult.status === "error" && _hexclave_shared.KnownErrors.BotChallengeRequired.isInstance(flowResult.error);
|
|
1953
1969
|
}
|
|
1954
1970
|
});
|
|
1955
1971
|
else result = await options.execute({});
|
|
1956
1972
|
} catch (e) {
|
|
1957
1973
|
const flowFailure = this._getBotChallengeFlowFailure(e);
|
|
1958
|
-
if (flowFailure) return
|
|
1974
|
+
if (flowFailure) return _hexclave_shared_dist_utils_results.Result.error(flowFailure.knownError);
|
|
1959
1975
|
throw e;
|
|
1960
1976
|
}
|
|
1961
1977
|
return this._normalizeBotChallengeResult(result);
|
|
1962
1978
|
}
|
|
1963
1979
|
async _isTrusted(url) {
|
|
1964
|
-
if ((0,
|
|
1965
|
-
const parsedUrl = (0,
|
|
1980
|
+
if ((0, _hexclave_shared_dist_utils_urls.isRelative)(url)) return true;
|
|
1981
|
+
const parsedUrl = (0, _hexclave_shared_dist_utils_urls.createUrlIfValid)(url);
|
|
1966
1982
|
if (parsedUrl == null) return false;
|
|
1967
1983
|
if (typeof window !== "undefined" && window.location.origin === parsedUrl.origin) return true;
|
|
1968
1984
|
if ((0, ______url_targets_js.isHostedHandlerUrlForProject)({
|
|
@@ -1970,7 +1986,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1970
1986
|
projectId: this.projectId
|
|
1971
1987
|
})) return true;
|
|
1972
1988
|
const trustedRedirectConfig = await this._getTrustedRedirectConfig();
|
|
1973
|
-
return (0,
|
|
1989
|
+
return (0, _hexclave_shared_dist_utils_redirect_urls.validateRedirectUrl)(parsedUrl, {
|
|
1974
1990
|
allowLocalhost: trustedRedirectConfig.allowLocalhost,
|
|
1975
1991
|
trustedDomains: trustedRedirectConfig.trustedDomains
|
|
1976
1992
|
});
|
|
@@ -1980,11 +1996,11 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1980
1996
|
}
|
|
1981
1997
|
_prefetchCrossDomainHandoffParamsIfNeeded() {
|
|
1982
1998
|
const canWriteOauthVerifierCookie = this._tokenStoreInit === "cookie" || this._tokenStoreInit === "nextjs-cookie";
|
|
1983
|
-
if (!(0,
|
|
1999
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)() || !canWriteOauthVerifierCookie || this._isPrefetchingCrossDomainHandoffParams || this._getFreshPrefetchedCrossDomainHandoffParams() != null) return;
|
|
1984
2000
|
this._isPrefetchingCrossDomainHandoffParams = true;
|
|
1985
|
-
(0,
|
|
2001
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
1986
2002
|
try {
|
|
1987
|
-
if (!(0,
|
|
2003
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)()) return;
|
|
1988
2004
|
const { state, codeChallenge } = await (0, _________cookie_js.saveVerifierAndState)();
|
|
1989
2005
|
this._prefetchedCrossDomainHandoffParams = {
|
|
1990
2006
|
state,
|
|
@@ -2046,10 +2062,10 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2046
2062
|
}, session);
|
|
2047
2063
|
if (!response.ok) {
|
|
2048
2064
|
const responseBody = await response.text();
|
|
2049
|
-
throw new
|
|
2065
|
+
throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError(`Cross-domain authorization endpoint failed: ${response.status} ${responseBody}`);
|
|
2050
2066
|
}
|
|
2051
2067
|
const result = await response.json();
|
|
2052
|
-
if (!("redirect_url" in result) || typeof result.redirect_url !== "string") throw new
|
|
2068
|
+
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 });
|
|
2053
2069
|
return result.redirect_url;
|
|
2054
2070
|
}
|
|
2055
2071
|
_getFreshPrefetchedCrossDomainHandoffParams() {
|
|
@@ -2071,7 +2087,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2071
2087
|
else if (typeof this._redirectMethod === "object" && this._redirectMethod.navigate) this._redirectMethod.navigate(options.url.toString());
|
|
2072
2088
|
else if (options.replace) window.location.replace(options.url);
|
|
2073
2089
|
else window.location.assign(options.url);
|
|
2074
|
-
await (0,
|
|
2090
|
+
await (0, _hexclave_shared_dist_utils_promises.wait)(2e3);
|
|
2075
2091
|
}
|
|
2076
2092
|
useNavigate() {
|
|
2077
2093
|
if (typeof this._redirectMethod === "object") return this._redirectMethod.useNavigate();
|
|
@@ -2211,8 +2227,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2211
2227
|
code,
|
|
2212
2228
|
session: await this._getSession()
|
|
2213
2229
|
});
|
|
2214
|
-
if (result.status === "ok") return
|
|
2215
|
-
else return
|
|
2230
|
+
if (result.status === "ok") return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2231
|
+
else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2216
2232
|
}
|
|
2217
2233
|
async getTeamInvitationDetails(code) {
|
|
2218
2234
|
const result = await this._interface.acceptTeamInvitation({
|
|
@@ -2220,8 +2236,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2220
2236
|
code,
|
|
2221
2237
|
session: await this._getSession()
|
|
2222
2238
|
});
|
|
2223
|
-
if (result.status === "ok") return
|
|
2224
|
-
else return
|
|
2239
|
+
if (result.status === "ok") return _hexclave_shared_dist_utils_results.Result.ok({ teamDisplayName: result.data.team_display_name });
|
|
2240
|
+
else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2225
2241
|
}
|
|
2226
2242
|
async verifyEmail(code) {
|
|
2227
2243
|
const result = await this._interface.verifyEmail(code);
|
|
@@ -2233,7 +2249,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2233
2249
|
if (options?.or === "anonymous" && options.includeRestricted === false) throw new Error("Cannot use { or: 'anonymous' } with { includeRestricted: false }. Anonymous users implicitly include restricted users.");
|
|
2234
2250
|
this._ensurePersistentTokenStore(options?.tokenStore);
|
|
2235
2251
|
const session = await this._getSession(options?.tokenStore);
|
|
2236
|
-
let crud =
|
|
2252
|
+
let crud = _hexclave_shared_dist_utils_results.Result.orThrow(await this._currentUserCache.getOrWait([session], "write-only"));
|
|
2237
2253
|
const includeAnonymous = options?.or === "anonymous" || options?.or === "anonymous-if-exists[deprecated]";
|
|
2238
2254
|
const includeRestricted = options?.includeRestricted === true || includeAnonymous;
|
|
2239
2255
|
if (crud === null || crud.is_anonymous && !includeAnonymous || crud.is_restricted && !includeRestricted) switch (options?.or) {
|
|
@@ -2248,7 +2264,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2248
2264
|
tokenStore: tokens,
|
|
2249
2265
|
or: "anonymous-if-exists[deprecated]",
|
|
2250
2266
|
includeRestricted: true
|
|
2251
|
-
}) ?? (0,
|
|
2267
|
+
}) ?? (0, _hexclave_shared_dist_utils_errors.throwErr)("Something went wrong while signing up anonymously");
|
|
2252
2268
|
}
|
|
2253
2269
|
case void 0:
|
|
2254
2270
|
case "anonymous-if-exists[deprecated]":
|
|
@@ -2266,18 +2282,18 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2266
2282
|
if (crud === null || crud.is_anonymous && !includeAnonymous || crud.is_restricted && !includeRestricted) switch (options?.or) {
|
|
2267
2283
|
case "redirect":
|
|
2268
2284
|
if (!crud?.is_anonymous && crud?.is_restricted) {
|
|
2269
|
-
if (!this._redirectToHandlerDuringRender("onboarding", { replace: true })) (0,
|
|
2270
|
-
} else if (!this._redirectToHandlerDuringRender("signIn", { replace: true })) (0,
|
|
2271
|
-
(0,
|
|
2272
|
-
throw new
|
|
2285
|
+
if (!this._redirectToHandlerDuringRender("onboarding", { replace: true })) (0, _hexclave_shared_dist_utils_promises.runAsynchronously)(this.redirectToOnboarding({ replace: true }));
|
|
2286
|
+
} else if (!this._redirectToHandlerDuringRender("signIn", { replace: true })) (0, _hexclave_shared_dist_utils_promises.runAsynchronously)(this.redirectToSignIn({ replace: true }));
|
|
2287
|
+
(0, _hexclave_shared_dist_utils_react.suspend)();
|
|
2288
|
+
throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("suspend should never return");
|
|
2273
2289
|
case "throw": throw new Error("User is not signed in but useUser was called with { or: 'throw' }");
|
|
2274
2290
|
case "anonymous":
|
|
2275
|
-
(0,
|
|
2291
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
2276
2292
|
await this._signUpAnonymously();
|
|
2277
2293
|
if (typeof window !== "undefined") window.location.reload();
|
|
2278
2294
|
});
|
|
2279
|
-
(0,
|
|
2280
|
-
throw new
|
|
2295
|
+
(0, _hexclave_shared_dist_utils_react.suspend)();
|
|
2296
|
+
throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("suspend should never return");
|
|
2281
2297
|
case void 0:
|
|
2282
2298
|
case "anonymous-if-exists[deprecated]":
|
|
2283
2299
|
case "return-null":
|
|
@@ -2383,12 +2399,12 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2383
2399
|
};
|
|
2384
2400
|
let authorizeResult;
|
|
2385
2401
|
try {
|
|
2386
|
-
if (siteKeys) authorizeResult = await (0,
|
|
2402
|
+
if (siteKeys) authorizeResult = await (0, _hexclave_shared_dist_utils_turnstile_flow.withBotChallengeFlow)({
|
|
2387
2403
|
...siteKeys,
|
|
2388
2404
|
action: "oauth_authenticate",
|
|
2389
2405
|
execute: executeOAuth,
|
|
2390
2406
|
isChallengeRequired: (result) => {
|
|
2391
|
-
return result.status === "error" &&
|
|
2407
|
+
return result.status === "error" && _hexclave_shared.KnownErrors.BotChallengeRequired.isInstance(result.error);
|
|
2392
2408
|
}
|
|
2393
2409
|
});
|
|
2394
2410
|
else authorizeResult = await executeOAuth({});
|
|
@@ -2398,17 +2414,17 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2398
2414
|
if (flowFailure?.type === "failed") throw flowFailure.knownError;
|
|
2399
2415
|
throw e;
|
|
2400
2416
|
}
|
|
2401
|
-
const location =
|
|
2417
|
+
const location = _hexclave_shared_dist_utils_results.Result.orThrow(authorizeResult);
|
|
2402
2418
|
await this._redirectTo({ url: location });
|
|
2403
|
-
await (0,
|
|
2419
|
+
await (0, _hexclave_shared_dist_utils_promises.neverResolve)();
|
|
2404
2420
|
}
|
|
2405
2421
|
/**
|
|
2406
2422
|
* Handles MFA verification by redirecting to the OTP page
|
|
2407
2423
|
*/
|
|
2408
2424
|
async _experimentalMfa(error, session) {
|
|
2409
|
-
if (typeof window !== "undefined") window.sessionStorage.setItem("hexclave_mfa_attempt_code", error.details?.attempt_code ?? (0,
|
|
2425
|
+
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"));
|
|
2410
2426
|
await this.redirectToMfa();
|
|
2411
|
-
throw new
|
|
2427
|
+
throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("we should have redirected in redirectToMfa()");
|
|
2412
2428
|
}
|
|
2413
2429
|
/**
|
|
2414
2430
|
* @deprecated
|
|
@@ -2418,7 +2434,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2418
2434
|
try {
|
|
2419
2435
|
return await callback();
|
|
2420
2436
|
} catch (e) {
|
|
2421
|
-
if (
|
|
2437
|
+
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 })));
|
|
2422
2438
|
throw e;
|
|
2423
2439
|
}
|
|
2424
2440
|
}
|
|
@@ -2431,25 +2447,25 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2431
2447
|
return await this._interface.signInWithCredential(options.email, options.password, session);
|
|
2432
2448
|
});
|
|
2433
2449
|
} catch (e) {
|
|
2434
|
-
if (
|
|
2450
|
+
if (_hexclave_shared.KnownErrors.InvalidTotpCode.isInstance(e)) return _hexclave_shared_dist_utils_results.Result.error(e);
|
|
2435
2451
|
throw e;
|
|
2436
2452
|
}
|
|
2437
2453
|
if (result.status === "ok") {
|
|
2438
2454
|
await this._signInToAccountWithTokens(result.data);
|
|
2439
2455
|
if (!options.noRedirect) await this._redirectToHandler("afterSignIn", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2440
|
-
return
|
|
2441
|
-
} else return
|
|
2456
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2457
|
+
} else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2442
2458
|
}
|
|
2443
2459
|
async signUpWithCredential(options) {
|
|
2444
|
-
if (options.noVerificationCallback && options.verificationCallbackUrl) throw new
|
|
2460
|
+
if (options.noVerificationCallback && options.verificationCallbackUrl) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("verificationCallbackUrl is not allowed when noVerificationCallback is true");
|
|
2445
2461
|
this._ensurePersistentTokenStore();
|
|
2446
2462
|
const session = await this._getSession();
|
|
2447
2463
|
const emailVerificationRedirectUrl = options.noVerificationCallback ? void 0 : options.verificationCallbackUrl ?? (0, ____________utils_url_js.constructRedirectUrl)(this.urls.emailVerification, "verificationCallbackUrl");
|
|
2448
2464
|
const executeSignUp = async (challenge) => {
|
|
2449
2465
|
let result = await this._interface.signUpWithCredential(options.email, options.password, emailVerificationRedirectUrl, session, this._toInterfaceBotChallengeInput(challenge));
|
|
2450
|
-
if (result.status === "error" && result.error instanceof
|
|
2466
|
+
if (result.status === "error" && result.error instanceof _hexclave_shared.KnownErrors.RedirectUrlNotWhitelisted && emailVerificationRedirectUrl !== void 0) {
|
|
2451
2467
|
if (!options.verificationCallbackUrl) {
|
|
2452
|
-
(0,
|
|
2468
|
+
(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 }));
|
|
2453
2469
|
result = await this._interface.signUpWithCredential(options.email, options.password, void 0, session, this._toInterfaceBotChallengeInput(challenge));
|
|
2454
2470
|
}
|
|
2455
2471
|
}
|
|
@@ -2463,8 +2479,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2463
2479
|
if (result.status === "ok") {
|
|
2464
2480
|
await this._signInToAccountWithTokens(result.data);
|
|
2465
2481
|
if (!options.noRedirect) await this._redirectToHandler("afterSignUp", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2466
|
-
return
|
|
2467
|
-
} else return
|
|
2482
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2483
|
+
} else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2468
2484
|
}
|
|
2469
2485
|
async _signUpAnonymously() {
|
|
2470
2486
|
this._ensurePersistentTokenStore();
|
|
@@ -2473,7 +2489,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2473
2489
|
const session = await this._getSession();
|
|
2474
2490
|
const result = await this._interface.signUpAnonymously(session);
|
|
2475
2491
|
if (result.status === "ok") await this._signInToAccountWithTokens(result.data);
|
|
2476
|
-
else throw new
|
|
2492
|
+
else throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("signUpAnonymously() should never return an error");
|
|
2477
2493
|
this._anonymousSignUpInProgress = null;
|
|
2478
2494
|
return result.data;
|
|
2479
2495
|
})();
|
|
@@ -2488,7 +2504,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2488
2504
|
return await this._interface.signInWithMagicLink(code, session);
|
|
2489
2505
|
});
|
|
2490
2506
|
} catch (e) {
|
|
2491
|
-
if (
|
|
2507
|
+
if (_hexclave_shared.KnownErrors.InvalidTotpCode.isInstance(e)) return _hexclave_shared_dist_utils_results.Result.error(e);
|
|
2492
2508
|
throw e;
|
|
2493
2509
|
}
|
|
2494
2510
|
if (result.status === "ok") {
|
|
@@ -2501,8 +2517,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2501
2517
|
awaitPendingAuthResolutions: false,
|
|
2502
2518
|
overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data)
|
|
2503
2519
|
});
|
|
2504
|
-
return
|
|
2505
|
-
} else return
|
|
2520
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2521
|
+
} else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2506
2522
|
}
|
|
2507
2523
|
/**
|
|
2508
2524
|
* Initiates a CLI authentication process that allows a command line application
|
|
@@ -2533,7 +2549,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2533
2549
|
...options.anonRefreshToken != null ? { anon_refresh_token: options.anonRefreshToken } : {}
|
|
2534
2550
|
})
|
|
2535
2551
|
}, null);
|
|
2536
|
-
if (!response.ok) return
|
|
2552
|
+
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()}`));
|
|
2537
2553
|
const initResult = await response.json();
|
|
2538
2554
|
const pollingCode = initResult.polling_code;
|
|
2539
2555
|
const loginCode = initResult.login_code;
|
|
@@ -2555,18 +2571,18 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2555
2571
|
headers: { "Content-Type": "application/json" },
|
|
2556
2572
|
body: JSON.stringify({ polling_code: pollingCode })
|
|
2557
2573
|
}, null);
|
|
2558
|
-
if (!pollResponse.ok) return
|
|
2574
|
+
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()}`));
|
|
2559
2575
|
const pollResult = await pollResponse.json();
|
|
2560
|
-
if (pollResponse.status === 201 && pollResult.status === "success") return
|
|
2576
|
+
if (pollResponse.status === 201 && pollResult.status === "success") return _hexclave_shared_dist_utils_results.Result.ok(pollResult.refresh_token);
|
|
2561
2577
|
if (pollResult.status === "waiting") {
|
|
2562
|
-
await (0,
|
|
2578
|
+
await (0, _hexclave_shared_dist_utils_promises.wait)(options.waitTimeMillis ?? 2e3);
|
|
2563
2579
|
continue;
|
|
2564
2580
|
}
|
|
2565
|
-
if (pollResult.status === "expired") return
|
|
2566
|
-
if (pollResult.status === "used") return
|
|
2567
|
-
return
|
|
2581
|
+
if (pollResult.status === "expired") return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.CliAuthExpiredError("CLI authentication request expired. Please try again."));
|
|
2582
|
+
if (pollResult.status === "used") return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.CliAuthUsedError("This authentication token has already been used."));
|
|
2583
|
+
return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.CliAuthError(`Unexpected status from CLI auth polling: ${pollResult.status}`));
|
|
2568
2584
|
}
|
|
2569
|
-
return
|
|
2585
|
+
return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.CliAuthError("Timed out waiting for CLI authentication."));
|
|
2570
2586
|
}
|
|
2571
2587
|
async signInWithMfa(totp, code, options) {
|
|
2572
2588
|
this._ensurePersistentTokenStore();
|
|
@@ -2577,16 +2593,16 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2577
2593
|
return await this._interface.signInWithMfa(totp, code, session);
|
|
2578
2594
|
});
|
|
2579
2595
|
} catch (e) {
|
|
2580
|
-
if (e instanceof
|
|
2596
|
+
if (e instanceof _hexclave_shared.KnownErrors.InvalidTotpCode) return _hexclave_shared_dist_utils_results.Result.error(e);
|
|
2581
2597
|
throw e;
|
|
2582
2598
|
}
|
|
2583
2599
|
if (result.status === "ok") {
|
|
2584
2600
|
await this._signInToAccountWithTokens(result.data);
|
|
2585
2601
|
if (!options?.noRedirect) if (result.data.newUser) await this._redirectToHandler("afterSignUp", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2586
2602
|
else await this._redirectToHandler("afterSignIn", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2587
|
-
return
|
|
2603
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2588
2604
|
}
|
|
2589
|
-
return
|
|
2605
|
+
return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2590
2606
|
}
|
|
2591
2607
|
async signInWithPasskey() {
|
|
2592
2608
|
this._ensurePersistentTokenStore();
|
|
@@ -2595,9 +2611,9 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2595
2611
|
try {
|
|
2596
2612
|
result = await this._catchMfaRequiredError(async () => {
|
|
2597
2613
|
const initiationResult = await this._interface.initiatePasskeyAuthentication({}, session);
|
|
2598
|
-
if (initiationResult.status !== "ok") return
|
|
2614
|
+
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"));
|
|
2599
2615
|
const { options_json, code } = initiationResult.data;
|
|
2600
|
-
if (options_json.rpId !== "THIS_VALUE_WILL_BE_REPLACED.example.com") throw new
|
|
2616
|
+
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}`);
|
|
2601
2617
|
options_json.rpId = window.location.hostname;
|
|
2602
2618
|
const authentication_response = await (0, _simplewebauthn_browser.startAuthentication)({ optionsJSON: options_json });
|
|
2603
2619
|
return await this._interface.signInWithPasskey({
|
|
@@ -2606,14 +2622,14 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2606
2622
|
}, session);
|
|
2607
2623
|
});
|
|
2608
2624
|
} catch (error) {
|
|
2609
|
-
if (error instanceof _simplewebauthn_browser.WebAuthnError) return
|
|
2610
|
-
else return
|
|
2625
|
+
if (error instanceof _simplewebauthn_browser.WebAuthnError) return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.PasskeyWebAuthnError(error.message, error.name));
|
|
2626
|
+
else return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.PasskeyAuthenticationFailed("Failed to sign in with passkey"));
|
|
2611
2627
|
}
|
|
2612
2628
|
if (result.status === "ok") {
|
|
2613
2629
|
await this._signInToAccountWithTokens(result.data);
|
|
2614
2630
|
await this._redirectToHandler("afterSignIn", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2615
|
-
return
|
|
2616
|
-
} else return
|
|
2631
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2632
|
+
} else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2617
2633
|
}
|
|
2618
2634
|
async callOAuthCallback(options) {
|
|
2619
2635
|
if (typeof window === "undefined") throw new Error("callOAuthCallback can currently only be called in a browser environment");
|
|
@@ -2631,7 +2647,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2631
2647
|
return await (0, _________auth_js.callOAuthCallback)(this._interface, oauthCallbackRedirectUri, options);
|
|
2632
2648
|
});
|
|
2633
2649
|
} catch (e) {
|
|
2634
|
-
if (
|
|
2650
|
+
if (_hexclave_shared.KnownErrors.InvalidTotpCode.isInstance(e)) {
|
|
2635
2651
|
alert("Invalid TOTP code. Please try signing in again.");
|
|
2636
2652
|
return false;
|
|
2637
2653
|
} else throw e;
|
|
@@ -2664,7 +2680,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2664
2680
|
async _signOut(session, options) {
|
|
2665
2681
|
this._eventTracker?.clearBuffer();
|
|
2666
2682
|
this._sessionRecorder?.clearBuffer();
|
|
2667
|
-
await
|
|
2683
|
+
await _hexclave_shared_dist_utils_stores.storeLock.withWriteLock(async () => {
|
|
2668
2684
|
await this._interface.signOut(session);
|
|
2669
2685
|
if (options?.redirectUrl) await this._redirectTo({
|
|
2670
2686
|
url: options.redirectUrl,
|
|
@@ -2726,7 +2742,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2726
2742
|
};
|
|
2727
2743
|
}
|
|
2728
2744
|
async getProject() {
|
|
2729
|
-
const crud =
|
|
2745
|
+
const crud = _hexclave_shared_dist_utils_results.Result.orThrow(await this._currentProjectCache.getOrWait([], "write-only"));
|
|
2730
2746
|
return this._clientProjectFromCrud(crud);
|
|
2731
2747
|
}
|
|
2732
2748
|
useProject() {
|
|
@@ -2735,7 +2751,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2735
2751
|
}
|
|
2736
2752
|
async _listOwnedProjects(session) {
|
|
2737
2753
|
this._ensureInternalProject();
|
|
2738
|
-
return
|
|
2754
|
+
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)));
|
|
2739
2755
|
}
|
|
2740
2756
|
_useOwnedProjects(session) {
|
|
2741
2757
|
this._ensureInternalProject();
|
|
@@ -2765,17 +2781,17 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2765
2781
|
}
|
|
2766
2782
|
static get [______common_js.stackAppInternalsSymbol]() {
|
|
2767
2783
|
return { fromClientJson: (json) => {
|
|
2768
|
-
const providedCheckString = JSON.stringify((0,
|
|
2784
|
+
const providedCheckString = JSON.stringify((0, _hexclave_shared_dist_utils_objects.omit)(json, []));
|
|
2769
2785
|
const existing = allClientApps.get(json.uniqueIdentifier);
|
|
2770
2786
|
if (existing) {
|
|
2771
2787
|
const [existingCheckString, clientApp] = existing;
|
|
2772
|
-
if (existingCheckString !== void 0 && existingCheckString !== providedCheckString) throw new
|
|
2788
|
+
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", {
|
|
2773
2789
|
providedObj: json,
|
|
2774
2790
|
existingString: existingCheckString
|
|
2775
2791
|
});
|
|
2776
2792
|
return clientApp;
|
|
2777
2793
|
}
|
|
2778
|
-
const { analytics, ...restJson } = (0,
|
|
2794
|
+
const { analytics, ...restJson } = (0, _hexclave_shared_dist_utils_objects.omit)(json, ["uniqueIdentifier"]);
|
|
2779
2795
|
return new _StackClientAppImplIncomplete({
|
|
2780
2796
|
...restJson,
|
|
2781
2797
|
analytics: (0, __session_replay_js.analyticsOptionsFromJson)(analytics)
|
|
@@ -2788,7 +2804,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2788
2804
|
get [______common_js.stackAppInternalsSymbol]() {
|
|
2789
2805
|
return {
|
|
2790
2806
|
toClientJson: () => {
|
|
2791
|
-
if (typeof this._redirectMethod !== "string") throw new
|
|
2807
|
+
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");
|
|
2792
2808
|
const publishableClientKey = "publishableClientKey" in this._interface.options ? this._interface.options.publishableClientKey : void 0;
|
|
2793
2809
|
return {
|
|
2794
2810
|
baseUrl: this._options.baseUrl,
|
|
@@ -2805,8 +2821,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2805
2821
|
};
|
|
2806
2822
|
},
|
|
2807
2823
|
setCurrentUser: (userJsonPromise) => {
|
|
2808
|
-
(0,
|
|
2809
|
-
await this._currentUserCache.forceSetCachedValueAsync([await this._getSession()],
|
|
2824
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
2825
|
+
await this._currentUserCache.forceSetCachedValueAsync([await this._getSession()], _hexclave_shared_dist_utils_results.Result.fromPromise(userJsonPromise));
|
|
2810
2826
|
});
|
|
2811
2827
|
},
|
|
2812
2828
|
getConstructorOptions: () => this._options,
|
|
@@ -2822,7 +2838,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2822
2838
|
sendRequest: async (path, requestOptions, requestType = "client") => {
|
|
2823
2839
|
return await this._interface.sendClientRequest(path, requestOptions, await this._getSession(), requestType);
|
|
2824
2840
|
},
|
|
2825
|
-
getRedirectMethod: () => this._redirectMethod ?? (0,
|
|
2841
|
+
getRedirectMethod: () => this._redirectMethod ?? (0, _hexclave_shared_dist_utils_errors.throwErr)("Redirect method should have been initialized in the Stack client app constructor"),
|
|
2826
2842
|
redirectToUrl: async (url, options) => {
|
|
2827
2843
|
await this._redirectTo({
|
|
2828
2844
|
url,
|