@hexclave/next 1.0.0 → 1.0.1
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.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 +9 -9
- 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.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 +2 -2
- package/dist/esm/components-page/stack-handler-client.js.map +1 -1
- package/dist/esm/components-page/stack-handler.d.ts +13 -9
- package/dist/esm/components-page/stack-handler.d.ts.map +1 -1
- package/dist/esm/components-page/stack-handler.js +5 -2
- package/dist/esm/components-page/stack-handler.js.map +1 -1
- package/dist/esm/components-page/team-creation.js.map +1 -1
- package/dist/esm/components-page/team-invitation.js.map +1 -1
- package/dist/esm/dev-tool/dev-tool-core.d.ts.map +1 -1
- package/dist/esm/dev-tool/dev-tool-core.js +4 -4
- package/dist/esm/dev-tool/dev-tool-core.js.map +1 -1
- package/dist/esm/dev-tool/dev-tool-trigger-position.test.js +1 -1
- package/dist/esm/dev-tool/index.js.map +1 -1
- package/dist/esm/generated/global-css.d.ts +1 -1
- package/dist/esm/generated/global-css.js +1 -1
- package/dist/esm/generated/global-css.js.map +1 -1
- package/dist/esm/generated/quetzal-translations.js.map +1 -1
- package/dist/esm/index.d.ts +5 -5
- package/dist/esm/index.js +5 -6
- package/dist/esm/integrations/convex.js.map +1 -1
- package/dist/esm/lib/auth.js +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.d.ts +3 -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 +2 -2
- 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.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.d.ts +3 -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 +213 -213
- 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 +5 -5
- 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,8 +559,8 @@ 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);
|
|
@@ -586,7 +586,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
586
586
|
*/
|
|
587
587
|
_getUniqueIdentifier() {
|
|
588
588
|
if (!this._uniqueIdentifier) {
|
|
589
|
-
this._uniqueIdentifier = (0,
|
|
589
|
+
this._uniqueIdentifier = (0, _hexclave_shared_dist_utils_uuids.generateUuid)();
|
|
590
590
|
this._initUniqueIdentifier();
|
|
591
591
|
}
|
|
592
592
|
return this._uniqueIdentifier;
|
|
@@ -598,8 +598,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
598
598
|
});
|
|
599
599
|
}
|
|
600
600
|
_useCheckFeatureSupport(name, options) {
|
|
601
|
-
(0,
|
|
602
|
-
throw new
|
|
601
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(this._checkFeatureSupport(name, options));
|
|
602
|
+
throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError(`${name} is not currently supported. Please reach out to Stack support for more information.`);
|
|
603
603
|
}
|
|
604
604
|
get _legacyRefreshTokenCookieName() {
|
|
605
605
|
return `stack-refresh-${this.projectId}`;
|
|
@@ -611,7 +611,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
611
611
|
return `${secure ? "__Host-" : ""}${this._refreshTokenCookieName}--default`;
|
|
612
612
|
}
|
|
613
613
|
_getCustomRefreshCookieName(domain) {
|
|
614
|
-
const encoded = (0,
|
|
614
|
+
const encoded = (0, _hexclave_shared_dist_utils_bytes.encodeBase32)(new TextEncoder().encode(domain.toLowerCase()));
|
|
615
615
|
return `${this._refreshTokenCookieName}--custom-${encoded}`;
|
|
616
616
|
}
|
|
617
617
|
_getDomainFromCustomRefreshCookieName(name) {
|
|
@@ -619,7 +619,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
619
619
|
const prefix = `${base}--custom-`;
|
|
620
620
|
if (!name.startsWith(prefix)) continue;
|
|
621
621
|
try {
|
|
622
|
-
return new TextDecoder().decode((0,
|
|
622
|
+
return new TextDecoder().decode((0, _hexclave_shared_dist_utils_bytes.decodeBase32)(name.slice(prefix.length)));
|
|
623
623
|
} catch {
|
|
624
624
|
return null;
|
|
625
625
|
}
|
|
@@ -637,7 +637,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
637
637
|
}
|
|
638
638
|
_parseStructuredRefreshCookie(value) {
|
|
639
639
|
if (!value) return null;
|
|
640
|
-
const parsed = (0,
|
|
640
|
+
const parsed = (0, _hexclave_shared_dist_utils_json.parseJson)(value);
|
|
641
641
|
if (parsed.status !== "ok" || typeof parsed.data !== "object" || parsed.data === null) {
|
|
642
642
|
console.warn("Failed to parse structured refresh cookie");
|
|
643
643
|
return null;
|
|
@@ -696,7 +696,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
696
696
|
const accessTokenCookie = cookies[this._accessTokenCookieName] ?? cookies[this._legacyAccessTokenCookieName] ?? null;
|
|
697
697
|
let accessToken = null;
|
|
698
698
|
if (accessTokenCookie && accessTokenCookie.startsWith("[\"")) {
|
|
699
|
-
const parsed = (0,
|
|
699
|
+
const parsed = (0, _hexclave_shared_dist_utils_json.parseJson)(accessTokenCookie);
|
|
700
700
|
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
701
|
if (parsed.data[0] === refreshToken) accessToken = parsed.data[1];
|
|
702
702
|
} else console.warn("Access token cookie has invalid format");
|
|
@@ -713,7 +713,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
713
713
|
return `stack-access`;
|
|
714
714
|
}
|
|
715
715
|
_getAllBrowserCookies() {
|
|
716
|
-
if (!(0,
|
|
716
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)()) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("Cannot get browser cookies on the server!");
|
|
717
717
|
return cookie.parseCookie(document.cookie || "");
|
|
718
718
|
}
|
|
719
719
|
_getRefreshTokenCookieNamePatterns() {
|
|
@@ -746,7 +746,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
746
746
|
};
|
|
747
747
|
}
|
|
748
748
|
_ensureCrossSubdomainCookieExists() {
|
|
749
|
-
(0,
|
|
749
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
750
750
|
const hostname = window.location.hostname;
|
|
751
751
|
const domain = await this._trustedParentDomainCache.getOrWait([hostname], "read-write");
|
|
752
752
|
if (domain.status === "error" || !domain.data) return;
|
|
@@ -761,11 +761,11 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
761
761
|
});
|
|
762
762
|
}
|
|
763
763
|
_queueCustomRefreshCookieUpdate(refreshToken, updatedAt, context) {
|
|
764
|
-
(0,
|
|
764
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
765
765
|
this._mostRecentQueuedCookieRefreshIndex++;
|
|
766
766
|
const updateIndex = this._mostRecentQueuedCookieRefreshIndex;
|
|
767
767
|
let hostname;
|
|
768
|
-
if ((0,
|
|
768
|
+
if ((0, _hexclave_shared_dist_utils_env.isBrowserLike)()) hostname = window.location.hostname;
|
|
769
769
|
else hostname = await getServerRequestHost();
|
|
770
770
|
if (!hostname) {
|
|
771
771
|
console.warn("No hostname found when queueing custom refresh cookie update");
|
|
@@ -795,7 +795,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
795
795
|
});
|
|
796
796
|
}
|
|
797
797
|
async _getTrustedRedirectConfig() {
|
|
798
|
-
const project =
|
|
798
|
+
const project = _hexclave_shared_dist_utils_results.Result.orThrow(await this._currentProjectCache.getOrWait([], "write-only"));
|
|
799
799
|
return {
|
|
800
800
|
allowLocalhost: project.config.allow_localhost,
|
|
801
801
|
trustedDomains: [...project.config.domains.map((d) => d.domain), new URL((0, ______url_targets_js.getHostedHandlerUrl)({
|
|
@@ -805,10 +805,10 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
805
805
|
};
|
|
806
806
|
}
|
|
807
807
|
async _getTrustedParentDomain(currentDomain) {
|
|
808
|
-
return (0,
|
|
808
|
+
return (0, _hexclave_shared_dist_utils_redirect_urls.getTrustedParentDomain)(currentDomain, (await this._getTrustedRedirectConfig()).trustedDomains);
|
|
809
809
|
}
|
|
810
810
|
_getBrowserCookieTokenStore() {
|
|
811
|
-
if (!(0,
|
|
811
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)()) throw new Error("Cannot use cookie token store on the server!");
|
|
812
812
|
if (this._storedBrowserCookieTokenStore === null) {
|
|
813
813
|
const getCurrentValue = (old) => {
|
|
814
814
|
const tokens = this._getTokensFromCookies(this._getAllBrowserCookies());
|
|
@@ -817,13 +817,13 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
817
817
|
accessToken: tokens.accessToken ?? (old?.refreshToken === tokens.refreshToken ? old.accessToken : null)
|
|
818
818
|
};
|
|
819
819
|
};
|
|
820
|
-
this._storedBrowserCookieTokenStore = new
|
|
820
|
+
this._storedBrowserCookieTokenStore = new _hexclave_shared_dist_utils_stores.Store(getCurrentValue(null));
|
|
821
821
|
let hasSucceededInWriting = true;
|
|
822
822
|
setInterval(() => {
|
|
823
823
|
if (hasSucceededInWriting) {
|
|
824
824
|
const oldValue = this._storedBrowserCookieTokenStore.get();
|
|
825
825
|
const currentValue = getCurrentValue(oldValue);
|
|
826
|
-
if (!(0,
|
|
826
|
+
if (!(0, _hexclave_shared_dist_utils_objects.deepPlainEquals)(currentValue, oldValue)) this._storedBrowserCookieTokenStore.set(currentValue);
|
|
827
827
|
}
|
|
828
828
|
}, 100);
|
|
829
829
|
this._storedBrowserCookieTokenStore.onChange((value) => {
|
|
@@ -844,7 +844,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
844
844
|
this._queueCustomRefreshCookieUpdate(refreshToken, updatedAt, "browser");
|
|
845
845
|
hasSucceededInWriting = true;
|
|
846
846
|
} catch (e) {
|
|
847
|
-
if (!(0,
|
|
847
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)()) hasSucceededInWriting = false;
|
|
848
848
|
else throw e;
|
|
849
849
|
}
|
|
850
850
|
});
|
|
@@ -855,11 +855,11 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
855
855
|
const tokenStoreInit = overrideTokenStoreInit === void 0 ? this._tokenStoreInit : overrideTokenStoreInit;
|
|
856
856
|
switch (tokenStoreInit) {
|
|
857
857
|
case "cookie": return this._getBrowserCookieTokenStore();
|
|
858
|
-
case "nextjs-cookie": if ((0,
|
|
858
|
+
case "nextjs-cookie": if ((0, _hexclave_shared_dist_utils_env.isBrowserLike)()) return this._getBrowserCookieTokenStore();
|
|
859
859
|
else {
|
|
860
|
-
const store = new
|
|
860
|
+
const store = new _hexclave_shared_dist_utils_stores.Store(this._getTokensFromCookies(cookieHelper.getAll()));
|
|
861
861
|
store.onChange((value) => {
|
|
862
|
-
(0,
|
|
862
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
863
863
|
const refreshToken = value.refreshToken;
|
|
864
864
|
const secure = await (0, _________cookie_js.isSecure)();
|
|
865
865
|
const defaultName = this._getRefreshTokenDefaultCookieNameForSecure(secure);
|
|
@@ -892,7 +892,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
892
892
|
if (authorizationHeader) {
|
|
893
893
|
const authJson = getAuthJsonFromAuthorizationHeaderValue(authorizationHeader);
|
|
894
894
|
if (authJson != null) {
|
|
895
|
-
const tokenStore = new
|
|
895
|
+
const tokenStore = new _hexclave_shared_dist_utils_stores.Store({
|
|
896
896
|
accessToken: authJson.accessToken,
|
|
897
897
|
refreshToken: authJson.refreshToken
|
|
898
898
|
});
|
|
@@ -917,10 +917,10 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
917
917
|
}
|
|
918
918
|
const cookieHeader = getHeaderValueFromRequestLikeHeaders(tokenStoreInit.headers, "cookie");
|
|
919
919
|
const parsed = cookie.parseCookie(cookieHeader || "");
|
|
920
|
-
const res = new
|
|
920
|
+
const res = new _hexclave_shared_dist_utils_stores.Store(this._getTokensFromCookies(parsed));
|
|
921
921
|
this._requestTokenStores.set(tokenStoreInit, res);
|
|
922
922
|
return res;
|
|
923
|
-
} else if ("accessToken" in tokenStoreInit || "refreshToken" in tokenStoreInit) return new
|
|
923
|
+
} else if ("accessToken" in tokenStoreInit || "refreshToken" in tokenStoreInit) return new _hexclave_shared_dist_utils_stores.Store({
|
|
924
924
|
refreshToken: tokenStoreInit.refreshToken,
|
|
925
925
|
accessToken: tokenStoreInit.accessToken
|
|
926
926
|
});
|
|
@@ -928,13 +928,13 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
928
928
|
}
|
|
929
929
|
}
|
|
930
930
|
_useTokenStore(overrideTokenStoreInit) {
|
|
931
|
-
(0,
|
|
931
|
+
(0, _hexclave_shared_dist_utils_react.suspendIfSsr)();
|
|
932
932
|
const cookieHelper = (0, _________cookie_js.createBrowserCookieHelper)();
|
|
933
933
|
return this._getOrCreateTokenStore(cookieHelper, overrideTokenStoreInit);
|
|
934
934
|
}
|
|
935
935
|
_getSessionFromTokenStore(tokenStore) {
|
|
936
936
|
const tokenObj = tokenStore.get();
|
|
937
|
-
const sessionKey =
|
|
937
|
+
const sessionKey = _hexclave_shared_dist_sessions.InternalSession.calculateSessionKey(tokenObj);
|
|
938
938
|
const existing = sessionKey ? this._sessionsByTokenStoreAndSessionKey.get(tokenStore)?.get(sessionKey) : null;
|
|
939
939
|
if (existing) return existing;
|
|
940
940
|
const session = this._interface.createSession({
|
|
@@ -978,7 +978,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
978
978
|
return react.default.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
979
979
|
}
|
|
980
980
|
async _signInToAccountWithTokens(tokens) {
|
|
981
|
-
if (!("accessToken" in tokens) || !("refreshToken" in tokens)) throw new
|
|
981
|
+
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
982
|
const tokenStore = this._getOrCreateTokenStore(await this._createCookieHelper());
|
|
983
983
|
tokenStore.set(tokens);
|
|
984
984
|
const newSession = this._getSessionFromTokenStore(tokenStore);
|
|
@@ -1118,13 +1118,13 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1118
1118
|
await app._teamInvitationsCache.refresh([session, crud.id]);
|
|
1119
1119
|
},
|
|
1120
1120
|
async listUsers() {
|
|
1121
|
-
return
|
|
1121
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._teamMemberProfilesCache.getOrWait([session, crud.id], "write-only")).map((crud) => app._clientTeamUserFromCrud(crud));
|
|
1122
1122
|
},
|
|
1123
1123
|
useUsers() {
|
|
1124
1124
|
return (0, __common_js.useAsyncCache)(app._teamMemberProfilesCache, [session, crud.id], "team.useUsers()").map((crud) => app._clientTeamUserFromCrud(crud));
|
|
1125
1125
|
},
|
|
1126
1126
|
async listInvitations() {
|
|
1127
|
-
return
|
|
1127
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._teamInvitationsCache.getOrWait([session, crud.id], "write-only")).map((crud) => app._clientSentTeamInvitationFromCrud(session, crud));
|
|
1128
1128
|
},
|
|
1129
1129
|
useInvitations() {
|
|
1130
1130
|
return (0, __common_js.useAsyncCache)(app._teamInvitationsCache, [session, crud.id], "team.useInvitations()").map((crud) => app._clientSentTeamInvitationFromCrud(session, crud));
|
|
@@ -1144,7 +1144,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1144
1144
|
return (0, __common_js.useAsyncCache)(app._teamApiKeysCache, [session, crud.id], "team.useApiKeys()").map((crud) => app._clientApiKeyFromCrud(session, crud));
|
|
1145
1145
|
},
|
|
1146
1146
|
async listApiKeys() {
|
|
1147
|
-
return
|
|
1147
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._teamApiKeysCache.getOrWait([session, crud.id], "write-only")).map((crud) => app._clientApiKeyFromCrud(session, crud));
|
|
1148
1148
|
},
|
|
1149
1149
|
async createApiKey(options) {
|
|
1150
1150
|
const result = await app._interface.createProjectApiKey(await (0, ______api_keys_index_js.apiKeyCreationOptionsToCrud)("team", crud.id, options), session, "client");
|
|
@@ -1204,9 +1204,9 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1204
1204
|
allow_connected_accounts: data.allowConnectedAccounts
|
|
1205
1205
|
}, session);
|
|
1206
1206
|
await Promise.all([app._currentUserOAuthProvidersCache.refresh([session]), app._currentUserConnectedAccountsCache.refresh([session])]);
|
|
1207
|
-
return
|
|
1207
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
1208
1208
|
} catch (error) {
|
|
1209
|
-
if (
|
|
1209
|
+
if (_hexclave_shared.KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn.isInstance(error)) return _hexclave_shared_dist_utils_results.Result.error(error);
|
|
1210
1210
|
throw error;
|
|
1211
1211
|
}
|
|
1212
1212
|
},
|
|
@@ -1286,7 +1286,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1286
1286
|
return session.isKnownToBeInvalid() ? null : session.getAccessTokenIfNotExpiredYet(2e4, 75e3)?.token ?? null;
|
|
1287
1287
|
}, [session]);
|
|
1288
1288
|
let accessToken = react.default.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
1289
|
-
if (accessToken === null && !session.isKnownToBeInvalid()) accessToken = (0,
|
|
1289
|
+
if (accessToken === null && !session.isKnownToBeInvalid()) accessToken = (0, _hexclave_shared_dist_utils_react.use)(session.getOrFetchLikelyValidTokens(2e4, 75e3))?.accessToken.token ?? null;
|
|
1290
1290
|
return {
|
|
1291
1291
|
accessToken,
|
|
1292
1292
|
refreshToken: session.getRefreshToken()?.token ?? null
|
|
@@ -1376,11 +1376,11 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1376
1376
|
const scopeString = options?.scopes?.join(" ") ?? "";
|
|
1377
1377
|
if (typeof idOrAccount === "object" && "provider" in idOrAccount && "providerAccountId" in idOrAccount) {
|
|
1378
1378
|
const { provider, providerAccountId } = idOrAccount;
|
|
1379
|
-
const found =
|
|
1379
|
+
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
1380
|
if (!found) return null;
|
|
1381
1381
|
return found;
|
|
1382
1382
|
}
|
|
1383
|
-
return
|
|
1383
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserOAuthConnectionCache.getOrWait([
|
|
1384
1384
|
session,
|
|
1385
1385
|
idOrAccount,
|
|
1386
1386
|
scopeString,
|
|
@@ -1419,7 +1419,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1419
1419
|
getConnectedAccount,
|
|
1420
1420
|
useConnectedAccount,
|
|
1421
1421
|
async listConnectedAccounts() {
|
|
1422
|
-
return
|
|
1422
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserConnectedAccountsCache.getOrWait([session], "write-only"));
|
|
1423
1423
|
},
|
|
1424
1424
|
useConnectedAccounts() {
|
|
1425
1425
|
return (0, __common_js.useAsyncCache)(app._currentUserConnectedAccountsCache, [session], "user.useConnectedAccounts()");
|
|
@@ -1430,16 +1430,16 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1430
1430
|
provider,
|
|
1431
1431
|
redirectUrl: app._getOAuthCallbackRedirectUri(),
|
|
1432
1432
|
errorRedirectUrl: app.urls.error,
|
|
1433
|
-
providerScope: (0,
|
|
1433
|
+
providerScope: (0, _hexclave_shared_dist_utils_strings.mergeScopeStrings)(scopeString, (app._oauthScopesOnSignIn[provider] ?? []).join(" "))
|
|
1434
1434
|
}, session);
|
|
1435
1435
|
await app._redirectTo({ url: location });
|
|
1436
|
-
return await (0,
|
|
1436
|
+
return await (0, _hexclave_shared_dist_utils_promises.neverResolve)();
|
|
1437
1437
|
},
|
|
1438
1438
|
async getOrLinkConnectedAccount(provider, options) {
|
|
1439
|
-
const matchingAccounts =
|
|
1439
|
+
const matchingAccounts = _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserConnectedAccountsCache.getOrWait([session], "write-only")).filter((a) => a.provider === provider);
|
|
1440
1440
|
for (const account of matchingAccounts) if ((await account.getAccessToken({ scopes: options?.scopes })).status === "ok") return account;
|
|
1441
1441
|
await this.linkConnectedAccount(provider, options);
|
|
1442
|
-
return await (0,
|
|
1442
|
+
return await (0, _hexclave_shared_dist_utils_promises.neverResolve)();
|
|
1443
1443
|
},
|
|
1444
1444
|
useOrLinkConnectedAccount(provider, options) {
|
|
1445
1445
|
const scopeString = options?.scopes?.join(" ") ?? "";
|
|
@@ -1459,7 +1459,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1459
1459
|
}, [teams, teamId]);
|
|
1460
1460
|
},
|
|
1461
1461
|
async listTeams() {
|
|
1462
|
-
return
|
|
1462
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserTeamsCache.getOrWait([session], "write-only")).map((crud) => app._clientTeamFromCrud(crud, session));
|
|
1463
1463
|
},
|
|
1464
1464
|
useTeams() {
|
|
1465
1465
|
const teams = (0, __common_js.useAsyncCache)(app._currentUserTeamsCache, [session], "user.useTeams()");
|
|
@@ -1475,7 +1475,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1475
1475
|
await app._interface.leaveTeam(team.id, session);
|
|
1476
1476
|
},
|
|
1477
1477
|
async listTeamInvitations() {
|
|
1478
|
-
return
|
|
1478
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserTeamInvitationsCache.getOrWait([session], "write-only")).map((crud) => app._clientReceivedTeamInvitationFromCrud(session, crud));
|
|
1479
1479
|
},
|
|
1480
1480
|
useTeamInvitations() {
|
|
1481
1481
|
const invitations = (0, __common_js.useAsyncCache)(app._currentUserTeamInvitationsCache, [session], "user.useTeamInvitations()");
|
|
@@ -1485,14 +1485,14 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1485
1485
|
if (scopeOrOptions && "id" in scopeOrOptions) {
|
|
1486
1486
|
const scope = scopeOrOptions;
|
|
1487
1487
|
const recursive = options?.recursive ?? true;
|
|
1488
|
-
return
|
|
1488
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserPermissionsCache.getOrWait([
|
|
1489
1489
|
session,
|
|
1490
1490
|
scope.id,
|
|
1491
1491
|
recursive
|
|
1492
1492
|
], "write-only")).map((crud) => app._clientPermissionFromCrud(crud));
|
|
1493
1493
|
} else {
|
|
1494
1494
|
const recursive = scopeOrOptions?.recursive ?? true;
|
|
1495
|
-
return
|
|
1495
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserProjectPermissionsCache.getOrWait([session, recursive], "write-only")).map((crud) => app._clientPermissionFromCrud(crud));
|
|
1496
1496
|
}
|
|
1497
1497
|
},
|
|
1498
1498
|
usePermissions(scopeOrOptions, options) {
|
|
@@ -1544,7 +1544,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1544
1544
|
return await app._updateClientUser(update, session);
|
|
1545
1545
|
},
|
|
1546
1546
|
async sendVerificationEmail(options) {
|
|
1547
|
-
if (!crud.primary_email) throw new
|
|
1547
|
+
if (!crud.primary_email) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("User does not have a primary email");
|
|
1548
1548
|
return await app._interface.sendVerificationEmail(crud.primary_email, options?.callbackUrl ?? (0, ____________utils_url_js.constructRedirectUrl)(app.urls.emailVerification, "callbackUrl"), session);
|
|
1549
1549
|
},
|
|
1550
1550
|
async updatePassword(options) {
|
|
@@ -1559,7 +1559,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1559
1559
|
},
|
|
1560
1560
|
selectedTeam: crud.selected_team && this._clientTeamFromCrud(crud.selected_team, session),
|
|
1561
1561
|
async getTeamProfile(team) {
|
|
1562
|
-
const result =
|
|
1562
|
+
const result = _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserTeamProfileCache.getOrWait([session, team.id], "write-only"));
|
|
1563
1563
|
return app._editableTeamProfileFromCrud(result, session);
|
|
1564
1564
|
},
|
|
1565
1565
|
useTeamProfile(team) {
|
|
@@ -1571,7 +1571,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1571
1571
|
session.markInvalid();
|
|
1572
1572
|
},
|
|
1573
1573
|
async listContactChannels() {
|
|
1574
|
-
return
|
|
1574
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._clientContactChannelsCache.getOrWait([session], "write-only")).map((crud) => app._clientContactChannelFromCrud(crud, session));
|
|
1575
1575
|
},
|
|
1576
1576
|
useContactChannels() {
|
|
1577
1577
|
return (0, __common_js.useAsyncCache)(app._clientContactChannelsCache, [session], "user.useContactChannels()").map((crud) => app._clientContactChannelFromCrud(crud, session));
|
|
@@ -1585,7 +1585,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1585
1585
|
return (0, __common_js.useAsyncCache)(app._notificationCategoriesCache, [session], "user.useNotificationCategories()").map((crud) => app._clientNotificationCategoryFromCrud(crud, session));
|
|
1586
1586
|
},
|
|
1587
1587
|
async listNotificationCategories() {
|
|
1588
|
-
return
|
|
1588
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._notificationCategoriesCache.getOrWait([session], "write-only")).map((crud) => app._clientNotificationCategoryFromCrud(crud, session));
|
|
1589
1589
|
},
|
|
1590
1590
|
useApiKeys() {
|
|
1591
1591
|
return (0, __common_js.useAsyncCache)(app._userApiKeysCache, [session], "user.useApiKeys()").map((crud) => app._clientApiKeyFromCrud(session, crud));
|
|
@@ -1602,7 +1602,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1602
1602
|
return (0, __common_js.useAsyncCache)(app._currentUserOAuthProvidersCache, [session], "user.useOAuthProviders()").map((crud) => app._clientOAuthProviderFromCrud(crud, session));
|
|
1603
1603
|
},
|
|
1604
1604
|
async listOAuthProviders() {
|
|
1605
|
-
return
|
|
1605
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserOAuthProvidersCache.getOrWait([session], "write-only")).map((crud) => app._clientOAuthProviderFromCrud(crud, session));
|
|
1606
1606
|
},
|
|
1607
1607
|
useOAuthProvider(id) {
|
|
1608
1608
|
const providers = this.useOAuthProviders();
|
|
@@ -1613,20 +1613,20 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1613
1613
|
},
|
|
1614
1614
|
async registerPasskey(options) {
|
|
1615
1615
|
const hostname = (await app._getCurrentUrl())?.hostname;
|
|
1616
|
-
if (!hostname) throw new
|
|
1616
|
+
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
1617
|
const initiationResult = await app._interface.initiatePasskeyRegistration({}, session);
|
|
1618
|
-
if (initiationResult.status !== "ok") return
|
|
1618
|
+
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
1619
|
const { options_json, code } = initiationResult.data;
|
|
1620
|
-
if (options_json.rp.id !== "THIS_VALUE_WILL_BE_REPLACED.example.com") throw new
|
|
1620
|
+
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
1621
|
options_json.rp.id = hostname;
|
|
1622
1622
|
let attResp;
|
|
1623
1623
|
try {
|
|
1624
1624
|
attResp = await (0, _simplewebauthn_browser.startRegistration)({ optionsJSON: options_json });
|
|
1625
1625
|
} catch (error) {
|
|
1626
|
-
if (error instanceof _simplewebauthn_browser.WebAuthnError) return
|
|
1626
|
+
if (error instanceof _simplewebauthn_browser.WebAuthnError) return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.PasskeyWebAuthnError(error.message, error.name));
|
|
1627
1627
|
else {
|
|
1628
|
-
(0,
|
|
1629
|
-
return
|
|
1628
|
+
(0, _hexclave_shared_dist_utils_errors.captureError)("passkey-registration-failed", error);
|
|
1629
|
+
return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.PasskeyRegistrationFailed("Failed to start passkey registration due to unknown error"));
|
|
1630
1630
|
}
|
|
1631
1631
|
}
|
|
1632
1632
|
const registrationResult = await app._interface.registerPasskey({
|
|
@@ -1663,7 +1663,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1663
1663
|
const customerOptions = type === "user" ? { userId: userIdOrTeamId } : { teamId: userIdOrTeamId };
|
|
1664
1664
|
return {
|
|
1665
1665
|
async getBilling() {
|
|
1666
|
-
const response =
|
|
1666
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await app._customerBillingCache.getOrWait([
|
|
1667
1667
|
effectiveSession,
|
|
1668
1668
|
type,
|
|
1669
1669
|
userIdOrTeamId
|
|
@@ -1755,17 +1755,17 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1755
1755
|
async getItem(options) {
|
|
1756
1756
|
const session = await this._getSession();
|
|
1757
1757
|
let crud;
|
|
1758
|
-
if ("userId" in options) crud =
|
|
1758
|
+
if ("userId" in options) crud = _hexclave_shared_dist_utils_results.Result.orThrow(await this._userItemCache.getOrWait([
|
|
1759
1759
|
session,
|
|
1760
1760
|
options.userId,
|
|
1761
1761
|
options.itemId
|
|
1762
1762
|
], "write-only"));
|
|
1763
|
-
else if ("teamId" in options) crud =
|
|
1763
|
+
else if ("teamId" in options) crud = _hexclave_shared_dist_utils_results.Result.orThrow(await this._teamItemCache.getOrWait([
|
|
1764
1764
|
session,
|
|
1765
1765
|
options.teamId,
|
|
1766
1766
|
options.itemId
|
|
1767
1767
|
], "write-only"));
|
|
1768
|
-
else crud =
|
|
1768
|
+
else crud = _hexclave_shared_dist_utils_results.Result.orThrow(await this._customItemCache.getOrWait([
|
|
1769
1769
|
session,
|
|
1770
1770
|
options.customCustomerId,
|
|
1771
1771
|
options.itemId
|
|
@@ -1785,7 +1785,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1785
1785
|
async listProducts(options) {
|
|
1786
1786
|
const session = (await this.getUser())?._internalSession ?? await this._getSession();
|
|
1787
1787
|
if ("userId" in options) {
|
|
1788
|
-
const response =
|
|
1788
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await this._userProductsCache.getOrWait([
|
|
1789
1789
|
session,
|
|
1790
1790
|
options.userId,
|
|
1791
1791
|
options.cursor ?? null,
|
|
@@ -1793,7 +1793,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1793
1793
|
], "write-only"));
|
|
1794
1794
|
return this._customerProductsFromResponse(response);
|
|
1795
1795
|
} else if ("teamId" in options) {
|
|
1796
|
-
const response =
|
|
1796
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await this._teamProductsCache.getOrWait([
|
|
1797
1797
|
session,
|
|
1798
1798
|
options.teamId,
|
|
1799
1799
|
options.cursor ?? null,
|
|
@@ -1801,7 +1801,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1801
1801
|
], "write-only"));
|
|
1802
1802
|
return this._customerProductsFromResponse(response);
|
|
1803
1803
|
}
|
|
1804
|
-
const response =
|
|
1804
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await this._customProductsCache.getOrWait([
|
|
1805
1805
|
session,
|
|
1806
1806
|
options.customCustomerId,
|
|
1807
1807
|
options.cursor ?? null,
|
|
@@ -1812,7 +1812,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1812
1812
|
async listInvoices(options) {
|
|
1813
1813
|
const session = await this._getSession();
|
|
1814
1814
|
if ("userId" in options) {
|
|
1815
|
-
const response =
|
|
1815
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await this._userInvoicesCache.getOrWait([
|
|
1816
1816
|
session,
|
|
1817
1817
|
options.userId,
|
|
1818
1818
|
options.cursor ?? null,
|
|
@@ -1820,7 +1820,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1820
1820
|
], "write-only"));
|
|
1821
1821
|
return this._customerInvoicesFromResponse(response);
|
|
1822
1822
|
}
|
|
1823
|
-
const response =
|
|
1823
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await this._teamInvoicesCache.getOrWait([
|
|
1824
1824
|
session,
|
|
1825
1825
|
options.teamId,
|
|
1826
1826
|
options.cursor ?? null,
|
|
@@ -1831,7 +1831,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1831
1831
|
async cancelSubscription(options) {
|
|
1832
1832
|
const session = await this._getSession();
|
|
1833
1833
|
const user = await this.getUser();
|
|
1834
|
-
if (!user) throw new
|
|
1834
|
+
if (!user) throw new _hexclave_shared.KnownErrors.UserAuthenticationRequired();
|
|
1835
1835
|
const customerType = "teamId" in options ? "team" : "user";
|
|
1836
1836
|
const customerId = "teamId" in options ? options.teamId : user.id;
|
|
1837
1837
|
await this._interface.cancelSubscription({
|
|
@@ -1900,7 +1900,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1900
1900
|
return __common_js.clientVersion;
|
|
1901
1901
|
}
|
|
1902
1902
|
_getBotChallengeSiteKeys() {
|
|
1903
|
-
if (!(0,
|
|
1903
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)()) return null;
|
|
1904
1904
|
const visibleSiteKey = _________env_js.envVars.NEXT_PUBLIC_STACK_BOT_CHALLENGE_SITE_KEY;
|
|
1905
1905
|
if (!visibleSiteKey) {
|
|
1906
1906
|
if (!this._botChallengeSiteKeysWarned) {
|
|
@@ -1915,23 +1915,23 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1915
1915
|
};
|
|
1916
1916
|
}
|
|
1917
1917
|
_getBotChallengeFlowFailure(error) {
|
|
1918
|
-
if (error instanceof
|
|
1918
|
+
if (error instanceof _hexclave_shared_dist_utils_turnstile_flow.BotChallengeUserCancelledError) return {
|
|
1919
1919
|
type: "cancelled",
|
|
1920
|
-
knownError: new
|
|
1920
|
+
knownError: new _hexclave_shared.KnownErrors.BotChallengeFailed("Bot challenge cancelled by user")
|
|
1921
1921
|
};
|
|
1922
|
-
if (error instanceof
|
|
1922
|
+
if (error instanceof _hexclave_shared_dist_utils_turnstile_flow.BotChallengeExecutionFailedError) return {
|
|
1923
1923
|
type: "failed",
|
|
1924
|
-
knownError: new
|
|
1924
|
+
knownError: new _hexclave_shared.KnownErrors.BotChallengeFailed(error.message)
|
|
1925
1925
|
};
|
|
1926
1926
|
return null;
|
|
1927
1927
|
}
|
|
1928
1928
|
_normalizeBotChallengeResult(result) {
|
|
1929
1929
|
if (result.status === "ok") return result;
|
|
1930
|
-
if (
|
|
1931
|
-
(0,
|
|
1932
|
-
return
|
|
1930
|
+
if (_hexclave_shared.KnownErrors.BotChallengeRequired.isInstance(result.error)) {
|
|
1931
|
+
(0, _hexclave_shared_dist_utils_errors.captureError)("bot-challenge-unexpected-after-flow", result.error);
|
|
1932
|
+
return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.BotChallengeFailed("Unexpected bot challenge after flow completion"));
|
|
1933
1933
|
}
|
|
1934
|
-
return
|
|
1934
|
+
return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
1935
1935
|
}
|
|
1936
1936
|
_toInterfaceBotChallengeInput(challenge) {
|
|
1937
1937
|
if (challenge.unavailable) return { phase: "visible" };
|
|
@@ -1944,25 +1944,25 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1944
1944
|
const siteKeys = this._getBotChallengeSiteKeys();
|
|
1945
1945
|
let result;
|
|
1946
1946
|
try {
|
|
1947
|
-
if (siteKeys) result = await (0,
|
|
1947
|
+
if (siteKeys) result = await (0, _hexclave_shared_dist_utils_turnstile_flow.withBotChallengeFlow)({
|
|
1948
1948
|
...siteKeys,
|
|
1949
1949
|
action: options.action,
|
|
1950
1950
|
execute: options.execute,
|
|
1951
1951
|
isChallengeRequired: (flowResult) => {
|
|
1952
|
-
return flowResult.status === "error" &&
|
|
1952
|
+
return flowResult.status === "error" && _hexclave_shared.KnownErrors.BotChallengeRequired.isInstance(flowResult.error);
|
|
1953
1953
|
}
|
|
1954
1954
|
});
|
|
1955
1955
|
else result = await options.execute({});
|
|
1956
1956
|
} catch (e) {
|
|
1957
1957
|
const flowFailure = this._getBotChallengeFlowFailure(e);
|
|
1958
|
-
if (flowFailure) return
|
|
1958
|
+
if (flowFailure) return _hexclave_shared_dist_utils_results.Result.error(flowFailure.knownError);
|
|
1959
1959
|
throw e;
|
|
1960
1960
|
}
|
|
1961
1961
|
return this._normalizeBotChallengeResult(result);
|
|
1962
1962
|
}
|
|
1963
1963
|
async _isTrusted(url) {
|
|
1964
|
-
if ((0,
|
|
1965
|
-
const parsedUrl = (0,
|
|
1964
|
+
if ((0, _hexclave_shared_dist_utils_urls.isRelative)(url)) return true;
|
|
1965
|
+
const parsedUrl = (0, _hexclave_shared_dist_utils_urls.createUrlIfValid)(url);
|
|
1966
1966
|
if (parsedUrl == null) return false;
|
|
1967
1967
|
if (typeof window !== "undefined" && window.location.origin === parsedUrl.origin) return true;
|
|
1968
1968
|
if ((0, ______url_targets_js.isHostedHandlerUrlForProject)({
|
|
@@ -1970,7 +1970,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1970
1970
|
projectId: this.projectId
|
|
1971
1971
|
})) return true;
|
|
1972
1972
|
const trustedRedirectConfig = await this._getTrustedRedirectConfig();
|
|
1973
|
-
return (0,
|
|
1973
|
+
return (0, _hexclave_shared_dist_utils_redirect_urls.validateRedirectUrl)(parsedUrl, {
|
|
1974
1974
|
allowLocalhost: trustedRedirectConfig.allowLocalhost,
|
|
1975
1975
|
trustedDomains: trustedRedirectConfig.trustedDomains
|
|
1976
1976
|
});
|
|
@@ -1980,11 +1980,11 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1980
1980
|
}
|
|
1981
1981
|
_prefetchCrossDomainHandoffParamsIfNeeded() {
|
|
1982
1982
|
const canWriteOauthVerifierCookie = this._tokenStoreInit === "cookie" || this._tokenStoreInit === "nextjs-cookie";
|
|
1983
|
-
if (!(0,
|
|
1983
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)() || !canWriteOauthVerifierCookie || this._isPrefetchingCrossDomainHandoffParams || this._getFreshPrefetchedCrossDomainHandoffParams() != null) return;
|
|
1984
1984
|
this._isPrefetchingCrossDomainHandoffParams = true;
|
|
1985
|
-
(0,
|
|
1985
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
1986
1986
|
try {
|
|
1987
|
-
if (!(0,
|
|
1987
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)()) return;
|
|
1988
1988
|
const { state, codeChallenge } = await (0, _________cookie_js.saveVerifierAndState)();
|
|
1989
1989
|
this._prefetchedCrossDomainHandoffParams = {
|
|
1990
1990
|
state,
|
|
@@ -2046,10 +2046,10 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2046
2046
|
}, session);
|
|
2047
2047
|
if (!response.ok) {
|
|
2048
2048
|
const responseBody = await response.text();
|
|
2049
|
-
throw new
|
|
2049
|
+
throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError(`Cross-domain authorization endpoint failed: ${response.status} ${responseBody}`);
|
|
2050
2050
|
}
|
|
2051
2051
|
const result = await response.json();
|
|
2052
|
-
if (!("redirect_url" in result) || typeof result.redirect_url !== "string") throw new
|
|
2052
|
+
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
2053
|
return result.redirect_url;
|
|
2054
2054
|
}
|
|
2055
2055
|
_getFreshPrefetchedCrossDomainHandoffParams() {
|
|
@@ -2071,7 +2071,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2071
2071
|
else if (typeof this._redirectMethod === "object" && this._redirectMethod.navigate) this._redirectMethod.navigate(options.url.toString());
|
|
2072
2072
|
else if (options.replace) window.location.replace(options.url);
|
|
2073
2073
|
else window.location.assign(options.url);
|
|
2074
|
-
await (0,
|
|
2074
|
+
await (0, _hexclave_shared_dist_utils_promises.wait)(2e3);
|
|
2075
2075
|
}
|
|
2076
2076
|
useNavigate() {
|
|
2077
2077
|
if (typeof this._redirectMethod === "object") return this._redirectMethod.useNavigate();
|
|
@@ -2211,8 +2211,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2211
2211
|
code,
|
|
2212
2212
|
session: await this._getSession()
|
|
2213
2213
|
});
|
|
2214
|
-
if (result.status === "ok") return
|
|
2215
|
-
else return
|
|
2214
|
+
if (result.status === "ok") return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2215
|
+
else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2216
2216
|
}
|
|
2217
2217
|
async getTeamInvitationDetails(code) {
|
|
2218
2218
|
const result = await this._interface.acceptTeamInvitation({
|
|
@@ -2220,8 +2220,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2220
2220
|
code,
|
|
2221
2221
|
session: await this._getSession()
|
|
2222
2222
|
});
|
|
2223
|
-
if (result.status === "ok") return
|
|
2224
|
-
else return
|
|
2223
|
+
if (result.status === "ok") return _hexclave_shared_dist_utils_results.Result.ok({ teamDisplayName: result.data.team_display_name });
|
|
2224
|
+
else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2225
2225
|
}
|
|
2226
2226
|
async verifyEmail(code) {
|
|
2227
2227
|
const result = await this._interface.verifyEmail(code);
|
|
@@ -2233,7 +2233,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2233
2233
|
if (options?.or === "anonymous" && options.includeRestricted === false) throw new Error("Cannot use { or: 'anonymous' } with { includeRestricted: false }. Anonymous users implicitly include restricted users.");
|
|
2234
2234
|
this._ensurePersistentTokenStore(options?.tokenStore);
|
|
2235
2235
|
const session = await this._getSession(options?.tokenStore);
|
|
2236
|
-
let crud =
|
|
2236
|
+
let crud = _hexclave_shared_dist_utils_results.Result.orThrow(await this._currentUserCache.getOrWait([session], "write-only"));
|
|
2237
2237
|
const includeAnonymous = options?.or === "anonymous" || options?.or === "anonymous-if-exists[deprecated]";
|
|
2238
2238
|
const includeRestricted = options?.includeRestricted === true || includeAnonymous;
|
|
2239
2239
|
if (crud === null || crud.is_anonymous && !includeAnonymous || crud.is_restricted && !includeRestricted) switch (options?.or) {
|
|
@@ -2248,7 +2248,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2248
2248
|
tokenStore: tokens,
|
|
2249
2249
|
or: "anonymous-if-exists[deprecated]",
|
|
2250
2250
|
includeRestricted: true
|
|
2251
|
-
}) ?? (0,
|
|
2251
|
+
}) ?? (0, _hexclave_shared_dist_utils_errors.throwErr)("Something went wrong while signing up anonymously");
|
|
2252
2252
|
}
|
|
2253
2253
|
case void 0:
|
|
2254
2254
|
case "anonymous-if-exists[deprecated]":
|
|
@@ -2266,18 +2266,18 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2266
2266
|
if (crud === null || crud.is_anonymous && !includeAnonymous || crud.is_restricted && !includeRestricted) switch (options?.or) {
|
|
2267
2267
|
case "redirect":
|
|
2268
2268
|
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
|
|
2269
|
+
if (!this._redirectToHandlerDuringRender("onboarding", { replace: true })) (0, _hexclave_shared_dist_utils_promises.runAsynchronously)(this.redirectToOnboarding({ replace: true }));
|
|
2270
|
+
} else if (!this._redirectToHandlerDuringRender("signIn", { replace: true })) (0, _hexclave_shared_dist_utils_promises.runAsynchronously)(this.redirectToSignIn({ replace: true }));
|
|
2271
|
+
(0, _hexclave_shared_dist_utils_react.suspend)();
|
|
2272
|
+
throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("suspend should never return");
|
|
2273
2273
|
case "throw": throw new Error("User is not signed in but useUser was called with { or: 'throw' }");
|
|
2274
2274
|
case "anonymous":
|
|
2275
|
-
(0,
|
|
2275
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
2276
2276
|
await this._signUpAnonymously();
|
|
2277
2277
|
if (typeof window !== "undefined") window.location.reload();
|
|
2278
2278
|
});
|
|
2279
|
-
(0,
|
|
2280
|
-
throw new
|
|
2279
|
+
(0, _hexclave_shared_dist_utils_react.suspend)();
|
|
2280
|
+
throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("suspend should never return");
|
|
2281
2281
|
case void 0:
|
|
2282
2282
|
case "anonymous-if-exists[deprecated]":
|
|
2283
2283
|
case "return-null":
|
|
@@ -2383,12 +2383,12 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2383
2383
|
};
|
|
2384
2384
|
let authorizeResult;
|
|
2385
2385
|
try {
|
|
2386
|
-
if (siteKeys) authorizeResult = await (0,
|
|
2386
|
+
if (siteKeys) authorizeResult = await (0, _hexclave_shared_dist_utils_turnstile_flow.withBotChallengeFlow)({
|
|
2387
2387
|
...siteKeys,
|
|
2388
2388
|
action: "oauth_authenticate",
|
|
2389
2389
|
execute: executeOAuth,
|
|
2390
2390
|
isChallengeRequired: (result) => {
|
|
2391
|
-
return result.status === "error" &&
|
|
2391
|
+
return result.status === "error" && _hexclave_shared.KnownErrors.BotChallengeRequired.isInstance(result.error);
|
|
2392
2392
|
}
|
|
2393
2393
|
});
|
|
2394
2394
|
else authorizeResult = await executeOAuth({});
|
|
@@ -2398,17 +2398,17 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2398
2398
|
if (flowFailure?.type === "failed") throw flowFailure.knownError;
|
|
2399
2399
|
throw e;
|
|
2400
2400
|
}
|
|
2401
|
-
const location =
|
|
2401
|
+
const location = _hexclave_shared_dist_utils_results.Result.orThrow(authorizeResult);
|
|
2402
2402
|
await this._redirectTo({ url: location });
|
|
2403
|
-
await (0,
|
|
2403
|
+
await (0, _hexclave_shared_dist_utils_promises.neverResolve)();
|
|
2404
2404
|
}
|
|
2405
2405
|
/**
|
|
2406
2406
|
* Handles MFA verification by redirecting to the OTP page
|
|
2407
2407
|
*/
|
|
2408
2408
|
async _experimentalMfa(error, session) {
|
|
2409
|
-
if (typeof window !== "undefined") window.sessionStorage.setItem("hexclave_mfa_attempt_code", error.details?.attempt_code ?? (0,
|
|
2409
|
+
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
2410
|
await this.redirectToMfa();
|
|
2411
|
-
throw new
|
|
2411
|
+
throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("we should have redirected in redirectToMfa()");
|
|
2412
2412
|
}
|
|
2413
2413
|
/**
|
|
2414
2414
|
* @deprecated
|
|
@@ -2418,7 +2418,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2418
2418
|
try {
|
|
2419
2419
|
return await callback();
|
|
2420
2420
|
} catch (e) {
|
|
2421
|
-
if (
|
|
2421
|
+
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
2422
|
throw e;
|
|
2423
2423
|
}
|
|
2424
2424
|
}
|
|
@@ -2431,25 +2431,25 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2431
2431
|
return await this._interface.signInWithCredential(options.email, options.password, session);
|
|
2432
2432
|
});
|
|
2433
2433
|
} catch (e) {
|
|
2434
|
-
if (
|
|
2434
|
+
if (_hexclave_shared.KnownErrors.InvalidTotpCode.isInstance(e)) return _hexclave_shared_dist_utils_results.Result.error(e);
|
|
2435
2435
|
throw e;
|
|
2436
2436
|
}
|
|
2437
2437
|
if (result.status === "ok") {
|
|
2438
2438
|
await this._signInToAccountWithTokens(result.data);
|
|
2439
2439
|
if (!options.noRedirect) await this._redirectToHandler("afterSignIn", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2440
|
-
return
|
|
2441
|
-
} else return
|
|
2440
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2441
|
+
} else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2442
2442
|
}
|
|
2443
2443
|
async signUpWithCredential(options) {
|
|
2444
|
-
if (options.noVerificationCallback && options.verificationCallbackUrl) throw new
|
|
2444
|
+
if (options.noVerificationCallback && options.verificationCallbackUrl) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("verificationCallbackUrl is not allowed when noVerificationCallback is true");
|
|
2445
2445
|
this._ensurePersistentTokenStore();
|
|
2446
2446
|
const session = await this._getSession();
|
|
2447
2447
|
const emailVerificationRedirectUrl = options.noVerificationCallback ? void 0 : options.verificationCallbackUrl ?? (0, ____________utils_url_js.constructRedirectUrl)(this.urls.emailVerification, "verificationCallbackUrl");
|
|
2448
2448
|
const executeSignUp = async (challenge) => {
|
|
2449
2449
|
let result = await this._interface.signUpWithCredential(options.email, options.password, emailVerificationRedirectUrl, session, this._toInterfaceBotChallengeInput(challenge));
|
|
2450
|
-
if (result.status === "error" && result.error instanceof
|
|
2450
|
+
if (result.status === "error" && result.error instanceof _hexclave_shared.KnownErrors.RedirectUrlNotWhitelisted && emailVerificationRedirectUrl !== void 0) {
|
|
2451
2451
|
if (!options.verificationCallbackUrl) {
|
|
2452
|
-
(0,
|
|
2452
|
+
(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
2453
|
result = await this._interface.signUpWithCredential(options.email, options.password, void 0, session, this._toInterfaceBotChallengeInput(challenge));
|
|
2454
2454
|
}
|
|
2455
2455
|
}
|
|
@@ -2463,8 +2463,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2463
2463
|
if (result.status === "ok") {
|
|
2464
2464
|
await this._signInToAccountWithTokens(result.data);
|
|
2465
2465
|
if (!options.noRedirect) await this._redirectToHandler("afterSignUp", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2466
|
-
return
|
|
2467
|
-
} else return
|
|
2466
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2467
|
+
} else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2468
2468
|
}
|
|
2469
2469
|
async _signUpAnonymously() {
|
|
2470
2470
|
this._ensurePersistentTokenStore();
|
|
@@ -2473,7 +2473,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2473
2473
|
const session = await this._getSession();
|
|
2474
2474
|
const result = await this._interface.signUpAnonymously(session);
|
|
2475
2475
|
if (result.status === "ok") await this._signInToAccountWithTokens(result.data);
|
|
2476
|
-
else throw new
|
|
2476
|
+
else throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("signUpAnonymously() should never return an error");
|
|
2477
2477
|
this._anonymousSignUpInProgress = null;
|
|
2478
2478
|
return result.data;
|
|
2479
2479
|
})();
|
|
@@ -2488,7 +2488,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2488
2488
|
return await this._interface.signInWithMagicLink(code, session);
|
|
2489
2489
|
});
|
|
2490
2490
|
} catch (e) {
|
|
2491
|
-
if (
|
|
2491
|
+
if (_hexclave_shared.KnownErrors.InvalidTotpCode.isInstance(e)) return _hexclave_shared_dist_utils_results.Result.error(e);
|
|
2492
2492
|
throw e;
|
|
2493
2493
|
}
|
|
2494
2494
|
if (result.status === "ok") {
|
|
@@ -2501,8 +2501,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2501
2501
|
awaitPendingAuthResolutions: false,
|
|
2502
2502
|
overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data)
|
|
2503
2503
|
});
|
|
2504
|
-
return
|
|
2505
|
-
} else return
|
|
2504
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2505
|
+
} else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2506
2506
|
}
|
|
2507
2507
|
/**
|
|
2508
2508
|
* Initiates a CLI authentication process that allows a command line application
|
|
@@ -2533,7 +2533,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2533
2533
|
...options.anonRefreshToken != null ? { anon_refresh_token: options.anonRefreshToken } : {}
|
|
2534
2534
|
})
|
|
2535
2535
|
}, null);
|
|
2536
|
-
if (!response.ok) return
|
|
2536
|
+
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
2537
|
const initResult = await response.json();
|
|
2538
2538
|
const pollingCode = initResult.polling_code;
|
|
2539
2539
|
const loginCode = initResult.login_code;
|
|
@@ -2555,18 +2555,18 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2555
2555
|
headers: { "Content-Type": "application/json" },
|
|
2556
2556
|
body: JSON.stringify({ polling_code: pollingCode })
|
|
2557
2557
|
}, null);
|
|
2558
|
-
if (!pollResponse.ok) return
|
|
2558
|
+
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
2559
|
const pollResult = await pollResponse.json();
|
|
2560
|
-
if (pollResponse.status === 201 && pollResult.status === "success") return
|
|
2560
|
+
if (pollResponse.status === 201 && pollResult.status === "success") return _hexclave_shared_dist_utils_results.Result.ok(pollResult.refresh_token);
|
|
2561
2561
|
if (pollResult.status === "waiting") {
|
|
2562
|
-
await (0,
|
|
2562
|
+
await (0, _hexclave_shared_dist_utils_promises.wait)(options.waitTimeMillis ?? 2e3);
|
|
2563
2563
|
continue;
|
|
2564
2564
|
}
|
|
2565
|
-
if (pollResult.status === "expired") return
|
|
2566
|
-
if (pollResult.status === "used") return
|
|
2567
|
-
return
|
|
2565
|
+
if (pollResult.status === "expired") return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.CliAuthExpiredError("CLI authentication request expired. Please try again."));
|
|
2566
|
+
if (pollResult.status === "used") return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.CliAuthUsedError("This authentication token has already been used."));
|
|
2567
|
+
return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.CliAuthError(`Unexpected status from CLI auth polling: ${pollResult.status}`));
|
|
2568
2568
|
}
|
|
2569
|
-
return
|
|
2569
|
+
return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.CliAuthError("Timed out waiting for CLI authentication."));
|
|
2570
2570
|
}
|
|
2571
2571
|
async signInWithMfa(totp, code, options) {
|
|
2572
2572
|
this._ensurePersistentTokenStore();
|
|
@@ -2577,16 +2577,16 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2577
2577
|
return await this._interface.signInWithMfa(totp, code, session);
|
|
2578
2578
|
});
|
|
2579
2579
|
} catch (e) {
|
|
2580
|
-
if (e instanceof
|
|
2580
|
+
if (e instanceof _hexclave_shared.KnownErrors.InvalidTotpCode) return _hexclave_shared_dist_utils_results.Result.error(e);
|
|
2581
2581
|
throw e;
|
|
2582
2582
|
}
|
|
2583
2583
|
if (result.status === "ok") {
|
|
2584
2584
|
await this._signInToAccountWithTokens(result.data);
|
|
2585
2585
|
if (!options?.noRedirect) if (result.data.newUser) await this._redirectToHandler("afterSignUp", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2586
2586
|
else await this._redirectToHandler("afterSignIn", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2587
|
-
return
|
|
2587
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2588
2588
|
}
|
|
2589
|
-
return
|
|
2589
|
+
return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2590
2590
|
}
|
|
2591
2591
|
async signInWithPasskey() {
|
|
2592
2592
|
this._ensurePersistentTokenStore();
|
|
@@ -2595,9 +2595,9 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2595
2595
|
try {
|
|
2596
2596
|
result = await this._catchMfaRequiredError(async () => {
|
|
2597
2597
|
const initiationResult = await this._interface.initiatePasskeyAuthentication({}, session);
|
|
2598
|
-
if (initiationResult.status !== "ok") return
|
|
2598
|
+
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
2599
|
const { options_json, code } = initiationResult.data;
|
|
2600
|
-
if (options_json.rpId !== "THIS_VALUE_WILL_BE_REPLACED.example.com") throw new
|
|
2600
|
+
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
2601
|
options_json.rpId = window.location.hostname;
|
|
2602
2602
|
const authentication_response = await (0, _simplewebauthn_browser.startAuthentication)({ optionsJSON: options_json });
|
|
2603
2603
|
return await this._interface.signInWithPasskey({
|
|
@@ -2606,14 +2606,14 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2606
2606
|
}, session);
|
|
2607
2607
|
});
|
|
2608
2608
|
} catch (error) {
|
|
2609
|
-
if (error instanceof _simplewebauthn_browser.WebAuthnError) return
|
|
2610
|
-
else return
|
|
2609
|
+
if (error instanceof _simplewebauthn_browser.WebAuthnError) return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.PasskeyWebAuthnError(error.message, error.name));
|
|
2610
|
+
else return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.PasskeyAuthenticationFailed("Failed to sign in with passkey"));
|
|
2611
2611
|
}
|
|
2612
2612
|
if (result.status === "ok") {
|
|
2613
2613
|
await this._signInToAccountWithTokens(result.data);
|
|
2614
2614
|
await this._redirectToHandler("afterSignIn", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2615
|
-
return
|
|
2616
|
-
} else return
|
|
2615
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2616
|
+
} else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2617
2617
|
}
|
|
2618
2618
|
async callOAuthCallback(options) {
|
|
2619
2619
|
if (typeof window === "undefined") throw new Error("callOAuthCallback can currently only be called in a browser environment");
|
|
@@ -2631,7 +2631,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2631
2631
|
return await (0, _________auth_js.callOAuthCallback)(this._interface, oauthCallbackRedirectUri, options);
|
|
2632
2632
|
});
|
|
2633
2633
|
} catch (e) {
|
|
2634
|
-
if (
|
|
2634
|
+
if (_hexclave_shared.KnownErrors.InvalidTotpCode.isInstance(e)) {
|
|
2635
2635
|
alert("Invalid TOTP code. Please try signing in again.");
|
|
2636
2636
|
return false;
|
|
2637
2637
|
} else throw e;
|
|
@@ -2664,7 +2664,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2664
2664
|
async _signOut(session, options) {
|
|
2665
2665
|
this._eventTracker?.clearBuffer();
|
|
2666
2666
|
this._sessionRecorder?.clearBuffer();
|
|
2667
|
-
await
|
|
2667
|
+
await _hexclave_shared_dist_utils_stores.storeLock.withWriteLock(async () => {
|
|
2668
2668
|
await this._interface.signOut(session);
|
|
2669
2669
|
if (options?.redirectUrl) await this._redirectTo({
|
|
2670
2670
|
url: options.redirectUrl,
|
|
@@ -2726,7 +2726,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2726
2726
|
};
|
|
2727
2727
|
}
|
|
2728
2728
|
async getProject() {
|
|
2729
|
-
const crud =
|
|
2729
|
+
const crud = _hexclave_shared_dist_utils_results.Result.orThrow(await this._currentProjectCache.getOrWait([], "write-only"));
|
|
2730
2730
|
return this._clientProjectFromCrud(crud);
|
|
2731
2731
|
}
|
|
2732
2732
|
useProject() {
|
|
@@ -2735,7 +2735,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2735
2735
|
}
|
|
2736
2736
|
async _listOwnedProjects(session) {
|
|
2737
2737
|
this._ensureInternalProject();
|
|
2738
|
-
return
|
|
2738
|
+
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
2739
|
}
|
|
2740
2740
|
_useOwnedProjects(session) {
|
|
2741
2741
|
this._ensureInternalProject();
|
|
@@ -2765,17 +2765,17 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2765
2765
|
}
|
|
2766
2766
|
static get [______common_js.stackAppInternalsSymbol]() {
|
|
2767
2767
|
return { fromClientJson: (json) => {
|
|
2768
|
-
const providedCheckString = JSON.stringify((0,
|
|
2768
|
+
const providedCheckString = JSON.stringify((0, _hexclave_shared_dist_utils_objects.omit)(json, []));
|
|
2769
2769
|
const existing = allClientApps.get(json.uniqueIdentifier);
|
|
2770
2770
|
if (existing) {
|
|
2771
2771
|
const [existingCheckString, clientApp] = existing;
|
|
2772
|
-
if (existingCheckString !== void 0 && existingCheckString !== providedCheckString) throw new
|
|
2772
|
+
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
2773
|
providedObj: json,
|
|
2774
2774
|
existingString: existingCheckString
|
|
2775
2775
|
});
|
|
2776
2776
|
return clientApp;
|
|
2777
2777
|
}
|
|
2778
|
-
const { analytics, ...restJson } = (0,
|
|
2778
|
+
const { analytics, ...restJson } = (0, _hexclave_shared_dist_utils_objects.omit)(json, ["uniqueIdentifier"]);
|
|
2779
2779
|
return new _StackClientAppImplIncomplete({
|
|
2780
2780
|
...restJson,
|
|
2781
2781
|
analytics: (0, __session_replay_js.analyticsOptionsFromJson)(analytics)
|
|
@@ -2788,7 +2788,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2788
2788
|
get [______common_js.stackAppInternalsSymbol]() {
|
|
2789
2789
|
return {
|
|
2790
2790
|
toClientJson: () => {
|
|
2791
|
-
if (typeof this._redirectMethod !== "string") throw new
|
|
2791
|
+
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
2792
|
const publishableClientKey = "publishableClientKey" in this._interface.options ? this._interface.options.publishableClientKey : void 0;
|
|
2793
2793
|
return {
|
|
2794
2794
|
baseUrl: this._options.baseUrl,
|
|
@@ -2805,8 +2805,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2805
2805
|
};
|
|
2806
2806
|
},
|
|
2807
2807
|
setCurrentUser: (userJsonPromise) => {
|
|
2808
|
-
(0,
|
|
2809
|
-
await this._currentUserCache.forceSetCachedValueAsync([await this._getSession()],
|
|
2808
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
2809
|
+
await this._currentUserCache.forceSetCachedValueAsync([await this._getSession()], _hexclave_shared_dist_utils_results.Result.fromPromise(userJsonPromise));
|
|
2810
2810
|
});
|
|
2811
2811
|
},
|
|
2812
2812
|
getConstructorOptions: () => this._options,
|
|
@@ -2822,7 +2822,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2822
2822
|
sendRequest: async (path, requestOptions, requestType = "client") => {
|
|
2823
2823
|
return await this._interface.sendClientRequest(path, requestOptions, await this._getSession(), requestType);
|
|
2824
2824
|
},
|
|
2825
|
-
getRedirectMethod: () => this._redirectMethod ?? (0,
|
|
2825
|
+
getRedirectMethod: () => this._redirectMethod ?? (0, _hexclave_shared_dist_utils_errors.throwErr)("Redirect method should have been initialized in the Stack client app constructor"),
|
|
2826
2826
|
redirectToUrl: async (url, options) => {
|
|
2827
2827
|
await this._redirectTo({
|
|
2828
2828
|
url,
|