@hexclave/react 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 +18 -18
- 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 +10 -10
- 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 +25 -25
- 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 +53 -53
- package/dist/components-page/account-settings/payments/payments-panel.js.map +1 -1
- package/dist/components-page/account-settings/profile-page/profile-page.js +1 -1
- package/dist/components-page/account-settings/section.js +4 -4
- package/dist/components-page/account-settings/section.js.map +1 -1
- package/dist/components-page/account-settings/settings/delete-account-section.js +7 -7
- package/dist/components-page/account-settings/settings/delete-account-section.js.map +1 -1
- package/dist/components-page/account-settings/settings/sign-out-section.js +2 -2
- package/dist/components-page/account-settings/settings/sign-out-section.js.map +1 -1
- package/dist/components-page/account-settings/teams/leave-team-section.js +5 -5
- package/dist/components-page/account-settings/teams/leave-team-section.js.map +1 -1
- package/dist/components-page/account-settings/teams/team-api-keys-section.js +4 -4
- package/dist/components-page/account-settings/teams/team-api-keys-section.js.map +1 -1
- package/dist/components-page/account-settings/teams/team-creation-page.js +8 -8
- 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 +21 -21
- 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 +10 -10
- 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 +2 -2
- 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 +1 -1
- package/dist/esm/components/credential-sign-in.js.map +1 -1
- package/dist/esm/components/credential-sign-up.js +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 +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 +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 +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 +2 -2
- 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 +2 -2
- 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 +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 +3 -3
- 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/profile-page/profile-page.js +1 -1
- package/dist/esm/components-page/account-settings/section.js.map +1 -1
- package/dist/esm/components-page/account-settings/settings/delete-account-section.js.map +1 -1
- package/dist/esm/components-page/account-settings/settings/sign-out-section.js.map +1 -1
- package/dist/esm/components-page/account-settings/teams/leave-team-section.js.map +1 -1
- package/dist/esm/components-page/account-settings/teams/team-api-keys-section.js.map +1 -1
- package/dist/esm/components-page/account-settings/teams/team-creation-page.js +2 -2
- 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 +2 -2
- 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 +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 +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 +1 -1
- package/dist/esm/components-page/oauth-callback.js.map +1 -1
- package/dist/esm/components-page/onboarding.js +1 -1
- package/dist/esm/components-page/onboarding.js.map +1 -1
- package/dist/esm/components-page/password-reset.js +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 +3 -3
- 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 +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 +1 -1
- package/dist/esm/dev-tool/index.js.map +1 -1
- package/dist/esm/generated/global-css.d.ts +1 -1
- package/dist/esm/generated/global-css.js +1 -1
- package/dist/esm/generated/global-css.js.map +1 -1
- package/dist/esm/generated/quetzal-translations.d.ts +2 -2
- package/dist/esm/generated/quetzal-translations.js.map +1 -1
- package/dist/esm/index.d.ts +5 -5
- package/dist/esm/index.js +5 -6
- package/dist/esm/integrations/convex.js.map +1 -1
- package/dist/esm/lib/auth.js +1 -1
- package/dist/esm/lib/auth.js.map +1 -1
- package/dist/esm/lib/auth.test.js +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 +3 -3
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/common.d.ts.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/common.js +4 -4
- 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 +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 +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/session-replay.d.ts.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/session-replay.js +3 -2
- package/dist/esm/lib/stack-app/apps/implementations/session-replay.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/admin-app.d.ts +4 -0
- package/dist/esm/lib/stack-app/apps/interfaces/admin-app.d.ts.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/admin-app.js +1 -0
- package/dist/esm/lib/stack-app/apps/interfaces/admin-app.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/client-app.d.ts +5 -0
- package/dist/esm/lib/stack-app/apps/interfaces/client-app.d.ts.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/client-app.js +1 -0
- package/dist/esm/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/server-app.d.ts +4 -0
- package/dist/esm/lib/stack-app/apps/interfaces/server-app.d.ts.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/server-app.js +1 -0
- package/dist/esm/lib/stack-app/apps/interfaces/server-app.js.map +1 -1
- package/dist/esm/lib/stack-app/common.js.map +1 -1
- package/dist/esm/lib/stack-app/contact-channels/index.js.map +1 -1
- package/dist/esm/lib/stack-app/email-templates/index.js.map +1 -1
- package/dist/esm/lib/stack-app/internal-api-keys/index.js.map +1 -1
- package/dist/esm/lib/stack-app/permissions/index.js.map +1 -1
- package/dist/esm/lib/stack-app/projects/index.js.map +1 -1
- package/dist/esm/lib/stack-app/teams/index.js.map +1 -1
- package/dist/esm/lib/stack-app/url-targets.js.map +1 -1
- package/dist/esm/lib/stack-app/url-targets.test.js +1 -1
- package/dist/esm/lib/stack-app/url-targets.test.js.map +1 -1
- package/dist/esm/lib/stack-app/users/index.js.map +1 -1
- package/dist/esm/providers/stack-context.d.ts +3 -2
- package/dist/esm/providers/stack-context.d.ts.map +1 -1
- package/dist/esm/providers/stack-context.js +3 -1
- package/dist/esm/providers/stack-context.js.map +1 -1
- package/dist/esm/providers/stack-provider-client.js.map +1 -1
- package/dist/esm/providers/stack-provider.d.ts +5 -1
- package/dist/esm/providers/stack-provider.d.ts.map +1 -1
- package/dist/esm/providers/stack-provider.js +5 -1
- package/dist/esm/providers/stack-provider.js.map +1 -1
- package/dist/esm/providers/theme-provider.d.ts +6 -2
- package/dist/esm/providers/theme-provider.d.ts.map +1 -1
- package/dist/esm/providers/theme-provider.js +6 -2
- package/dist/esm/providers/theme-provider.js.map +1 -1
- package/dist/esm/providers/translation-provider-client.d.ts +4 -3
- package/dist/esm/providers/translation-provider-client.d.ts.map +1 -1
- package/dist/esm/providers/translation-provider-client.js +4 -2
- package/dist/esm/providers/translation-provider-client.js.map +1 -1
- package/dist/esm/providers/translation-provider.js.map +1 -1
- package/dist/esm/utils/url.js.map +1 -1
- package/dist/generated/global-css.d.ts +1 -1
- package/dist/generated/global-css.js +1 -1
- package/dist/generated/global-css.js.map +1 -1
- package/dist/generated/quetzal-translations.d.ts +2 -2
- package/dist/generated/quetzal-translations.js +16 -16
- package/dist/generated/quetzal-translations.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +9 -12
- package/dist/integrations/convex/component/convex.config.d.ts +1 -1
- package/dist/integrations/convex.js +5 -5
- package/dist/integrations/convex.js.map +1 -1
- package/dist/lib/auth.js +12 -12
- package/dist/lib/auth.js.map +1 -1
- package/dist/lib/auth.test.js +2 -2
- package/dist/lib/auth.test.js.map +1 -1
- package/dist/lib/cookie.js +9 -9
- 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 +206 -206
- 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 +4 -4
- 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,28 +1,28 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_chunk = require('../../../../chunk-BE-pF4vm.js');
|
|
3
|
-
let
|
|
4
|
-
let
|
|
5
|
-
let _stackframe_stack_shared_dist_utils_errors = require("@hexclave/shared/dist/utils/errors");
|
|
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");
|
|
6
5
|
let react = require("react");
|
|
7
6
|
react = require_chunk.__toESM(react);
|
|
8
|
-
let
|
|
9
|
-
let
|
|
10
|
-
let
|
|
11
|
-
let
|
|
12
|
-
let
|
|
13
|
-
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
|
+
let _hexclave_shared_dist_utils_results = require("@hexclave/shared/dist/utils/results");
|
|
12
|
+
let _hexclave_shared_dist_utils_strings = require("@hexclave/shared/dist/utils/strings");
|
|
13
|
+
let _hexclave_shared_dist_utils_env = require("@hexclave/shared/dist/utils/env");
|
|
14
14
|
let __common_js = require("./common.js");
|
|
15
|
-
let
|
|
16
|
-
let
|
|
15
|
+
let _hexclave_shared_dist_utils_redirect_urls = require("@hexclave/shared/dist/utils/redirect-urls");
|
|
16
|
+
let _hexclave_shared_dist_utils_bytes = require("@hexclave/shared/dist/utils/bytes");
|
|
17
17
|
let ______common_js = require("../../common.js");
|
|
18
18
|
let ______projects_index_js = require("../../projects/index.js");
|
|
19
19
|
let _simplewebauthn_browser = require("@simplewebauthn/browser");
|
|
20
|
-
let
|
|
21
|
-
let
|
|
22
|
-
let
|
|
23
|
-
let
|
|
24
|
-
let
|
|
25
|
-
let
|
|
20
|
+
let _hexclave_shared_dist_sessions = require("@hexclave/shared/dist/sessions");
|
|
21
|
+
let _hexclave_shared_dist_utils_json = require("@hexclave/shared/dist/utils/json");
|
|
22
|
+
let _hexclave_shared_dist_utils_maps = require("@hexclave/shared/dist/utils/maps");
|
|
23
|
+
let _hexclave_shared_dist_utils_stores = require("@hexclave/shared/dist/utils/stores");
|
|
24
|
+
let _hexclave_shared_dist_utils_turnstile_flow = require("@hexclave/shared/dist/utils/turnstile-flow");
|
|
25
|
+
let _hexclave_shared_dist_utils_uuids = require("@hexclave/shared/dist/utils/uuids");
|
|
26
26
|
let cookie = require("cookie");
|
|
27
27
|
cookie = require_chunk.__toESM(cookie);
|
|
28
28
|
let ____________utils_url_js = require("../../../../utils/url.js");
|
|
@@ -65,7 +65,7 @@ const STACK_AUTHORIZATION_VALUE_PREFIX = "stackauth_";
|
|
|
65
65
|
const HEXCLAVE_AUTHORIZATION_VALUE_PREFIX = "hexclave_";
|
|
66
66
|
function getAuthorizationHeaderValueFromAuthJson(authJson) {
|
|
67
67
|
if (authJson.accessToken == null && authJson.refreshToken == null) return null;
|
|
68
|
-
return `Bearer ${STACK_AUTHORIZATION_VALUE_PREFIX}${(0,
|
|
68
|
+
return `Bearer ${STACK_AUTHORIZATION_VALUE_PREFIX}${(0, _hexclave_shared_dist_utils_bytes.encodeBase64)(new TextEncoder().encode(JSON.stringify(authJson)))}`;
|
|
69
69
|
}
|
|
70
70
|
function getAuthJsonFromAuthorizationHeaderValue(authorizationHeaderValue) {
|
|
71
71
|
const match = authorizationHeaderValue.match(/^Bearer\s+(.+)$/i);
|
|
@@ -77,7 +77,7 @@ function getAuthJsonFromAuthorizationHeaderValue(authorizationHeaderValue) {
|
|
|
77
77
|
if (encodedAuthJson.length === 0) throw new Error("Invalid Authorization header format. Expected `Bearer stackauth_<base64(getAuthJson())>`.");
|
|
78
78
|
let parsed;
|
|
79
79
|
try {
|
|
80
|
-
const decodedAuthJson = new TextDecoder().decode((0,
|
|
80
|
+
const decodedAuthJson = new TextDecoder().decode((0, _hexclave_shared_dist_utils_bytes.decodeBase64)(encodedAuthJson));
|
|
81
81
|
parsed = JSON.parse(decodedAuthJson);
|
|
82
82
|
} catch (e) {
|
|
83
83
|
throw new Error("Invalid stackauth authorization header.", { cause: e });
|
|
@@ -117,7 +117,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
117
117
|
if (!user || !user.oauth_providers.find((p) => p.id === options.providerId)) hasConnection = false;
|
|
118
118
|
if (!await options.getOrWaitOAuthToken()) hasConnection = false;
|
|
119
119
|
if (!hasConnection && options.redirect) {
|
|
120
|
-
if (!options.session) throw new Error(
|
|
120
|
+
if (!options.session) throw new Error(_hexclave_shared_dist_utils_strings.deindent`
|
|
121
121
|
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.
|
|
122
122
|
|
|
123
123
|
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.
|
|
@@ -126,10 +126,10 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
126
126
|
provider: options.providerId,
|
|
127
127
|
redirectUrl: this._getOAuthCallbackRedirectUri(),
|
|
128
128
|
errorRedirectUrl: this.urls.error,
|
|
129
|
-
providerScope: (0,
|
|
129
|
+
providerScope: (0, _hexclave_shared_dist_utils_strings.mergeScopeStrings)(options.scope || "", (this._oauthScopesOnSignIn[options.providerId] ?? []).join(" "))
|
|
130
130
|
}, options.session);
|
|
131
131
|
await this._redirectTo({ url: location });
|
|
132
|
-
return await (0,
|
|
132
|
+
return await (0, _hexclave_shared_dist_utils_promises.neverResolve)();
|
|
133
133
|
} else if (!hasConnection) return null;
|
|
134
134
|
const providerAccountId = user.oauth_providers.find((p) => p.id === options.providerId)?.account_id ?? "";
|
|
135
135
|
return {
|
|
@@ -138,12 +138,12 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
138
138
|
providerAccountId,
|
|
139
139
|
async getAccessToken() {
|
|
140
140
|
const result = await options.getOrWaitOAuthToken();
|
|
141
|
-
if (!result) throw new
|
|
141
|
+
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\`.`);
|
|
142
142
|
return result;
|
|
143
143
|
},
|
|
144
144
|
useAccessToken() {
|
|
145
145
|
const result = options.useOAuthToken();
|
|
146
|
-
if (!result) throw new
|
|
146
|
+
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\`.`);
|
|
147
147
|
return result;
|
|
148
148
|
}
|
|
149
149
|
};
|
|
@@ -158,7 +158,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
158
158
|
providerAccountId,
|
|
159
159
|
async getAccessToken(options) {
|
|
160
160
|
const scopeString = options?.scopes?.join(" ") ?? "";
|
|
161
|
-
const result =
|
|
161
|
+
const result = _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserOAuthConnectionAccessTokensByAccountCache.getOrWait([
|
|
162
162
|
session,
|
|
163
163
|
providerId,
|
|
164
164
|
providerAccountId,
|
|
@@ -166,9 +166,9 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
166
166
|
], "write-only"));
|
|
167
167
|
if (!result) {
|
|
168
168
|
const scopeDetail = scopeString ? `The requested scopes [${scopeString}] are not available on the existing token.` : "The OAuth refresh token has likely been revoked or expired.";
|
|
169
|
-
return
|
|
169
|
+
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\`.`));
|
|
170
170
|
}
|
|
171
|
-
return
|
|
171
|
+
return _hexclave_shared_dist_utils_results.Result.ok(result);
|
|
172
172
|
},
|
|
173
173
|
useAccessToken(options) {
|
|
174
174
|
const scopeString = options?.scopes?.join(" ") ?? "";
|
|
@@ -180,9 +180,9 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
180
180
|
], "connection.useAccessToken()");
|
|
181
181
|
if (!result) {
|
|
182
182
|
const scopeDetail = scopeString ? `The requested scopes [${scopeString}] are not available on the existing token.` : "The OAuth refresh token has likely been revoked or expired.";
|
|
183
|
-
return
|
|
183
|
+
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\`.`));
|
|
184
184
|
}
|
|
185
|
-
return
|
|
185
|
+
return _hexclave_shared_dist_utils_results.Result.ok(result);
|
|
186
186
|
}
|
|
187
187
|
};
|
|
188
188
|
}
|
|
@@ -191,14 +191,14 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
191
191
|
this._sessionRecorder = null;
|
|
192
192
|
this._eventTracker = null;
|
|
193
193
|
this.__DEMO_ENABLE_SLIGHT_FETCH_DELAY = false;
|
|
194
|
-
this._ownedAdminApps = new
|
|
194
|
+
this._ownedAdminApps = new _hexclave_shared_dist_utils_maps.DependenciesMap();
|
|
195
195
|
this._currentUserCache = (0, __common_js.createCacheBySession)(async (session) => {
|
|
196
|
-
if (this.__DEMO_ENABLE_SLIGHT_FETCH_DELAY) await (0,
|
|
196
|
+
if (this.__DEMO_ENABLE_SLIGHT_FETCH_DELAY) await (0, _hexclave_shared_dist_utils_promises.wait)(2e3);
|
|
197
197
|
if (session.isKnownToBeInvalid()) return null;
|
|
198
198
|
return await this._interface.getClientUserByToken(session);
|
|
199
199
|
});
|
|
200
200
|
this._currentProjectCache = (0, __common_js.createCache)(async () => {
|
|
201
|
-
return
|
|
201
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await this._interface.getClientProject());
|
|
202
202
|
});
|
|
203
203
|
this._ownedProjectsCache = (0, __common_js.createCacheBySession)(async (session) => {
|
|
204
204
|
return await this._interface.listProjects(session);
|
|
@@ -219,14 +219,14 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
219
219
|
try {
|
|
220
220
|
return { accessToken: (await this._interface.createProviderAccessToken(providerId, scope || "", session)).access_token };
|
|
221
221
|
} catch (err) {
|
|
222
|
-
if (!(
|
|
222
|
+
if (!(_hexclave_shared.KnownErrors.OAuthAccessTokenNotAvailable.isInstance(err) || _hexclave_shared.KnownErrors.OAuthConnectionDoesNotHaveRequiredScope.isInstance(err) || _hexclave_shared.KnownErrors.OAuthConnectionNotConnectedToUser.isInstance(err))) throw err;
|
|
223
223
|
}
|
|
224
224
|
return null;
|
|
225
225
|
});
|
|
226
226
|
this._currentUserOAuthConnectionCache = (0, __common_js.createCacheBySession)(async (session, [providerId, scope, redirect]) => {
|
|
227
227
|
return await this._getUserOAuthConnectionCacheFn({
|
|
228
|
-
getUser: async () =>
|
|
229
|
-
getOrWaitOAuthToken: async () =>
|
|
228
|
+
getUser: async () => _hexclave_shared_dist_utils_results.Result.orThrow(await this._currentUserCache.getOrWait([session], "write-only")),
|
|
229
|
+
getOrWaitOAuthToken: async () => _hexclave_shared_dist_utils_results.Result.orThrow(await this._currentUserOAuthConnectionAccessTokensCache.getOrWait([
|
|
230
230
|
session,
|
|
231
231
|
providerId,
|
|
232
232
|
scope || ""
|
|
@@ -249,22 +249,22 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
249
249
|
try {
|
|
250
250
|
return { accessToken: (await this._interface.createProviderAccessTokenByAccount(providerId, providerAccountId, scope, session)).access_token };
|
|
251
251
|
} catch (err) {
|
|
252
|
-
if (
|
|
252
|
+
if (_hexclave_shared.KnownErrors.OAuthAccessTokenNotAvailable.isInstance(err) || _hexclave_shared.KnownErrors.OAuthConnectionDoesNotHaveRequiredScope.isInstance(err) || _hexclave_shared.KnownErrors.OAuthConnectionNotConnectedToUser.isInstance(err)) return null;
|
|
253
253
|
throw err;
|
|
254
254
|
}
|
|
255
255
|
});
|
|
256
256
|
this._currentUserValidConnectedAccountForProviderCache = (0, __common_js.createCacheBySession)(async (session, [provider, scopeString]) => {
|
|
257
|
-
const matchingAccounts =
|
|
257
|
+
const matchingAccounts = _hexclave_shared_dist_utils_results.Result.orThrow(await this._currentUserConnectedAccountsCache.getOrWait([session], "write-only")).filter((a) => a.provider === provider);
|
|
258
258
|
const scopes = scopeString ? scopeString.split(" ") : void 0;
|
|
259
259
|
for (const account of matchingAccounts) if ((await account.getAccessToken({ scopes })).status === "ok") return account;
|
|
260
260
|
const location = await (0, _________auth_js.getNewOAuthProviderOrScopeUrl)(this._interface, {
|
|
261
261
|
provider,
|
|
262
262
|
redirectUrl: this._getOAuthCallbackRedirectUri(),
|
|
263
263
|
errorRedirectUrl: this.urls.error,
|
|
264
|
-
providerScope: (0,
|
|
264
|
+
providerScope: (0, _hexclave_shared_dist_utils_strings.mergeScopeStrings)(scopeString, (this._oauthScopesOnSignIn[provider] ?? []).join(" "))
|
|
265
265
|
}, session);
|
|
266
266
|
await this._redirectTo({ url: location });
|
|
267
|
-
return await (0,
|
|
267
|
+
return await (0, _hexclave_shared_dist_utils_promises.neverResolve)();
|
|
268
268
|
});
|
|
269
269
|
this._teamMemberProfilesCache = (0, __common_js.createCacheBySession)(async (session, [teamId]) => {
|
|
270
270
|
return await this._interface.listTeamMemberProfiles({ teamId }, session);
|
|
@@ -372,7 +372,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
372
372
|
this._sessionsByTokenStoreAndSessionKey = /* @__PURE__ */ new WeakMap();
|
|
373
373
|
this._botChallengeSiteKeysWarned = false;
|
|
374
374
|
const resolvedOptions = (0, __common_js.resolveConstructorOptions)(options);
|
|
375
|
-
if (!_StackClientAppImplIncomplete.LazyStackAdminAppImpl.value) throw new
|
|
375
|
+
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).");
|
|
376
376
|
this._options = resolvedOptions;
|
|
377
377
|
this._extraOptions = extraOptions;
|
|
378
378
|
const projectId = resolvedOptions.projectId ?? (0, __common_js.getDefaultProjectId)();
|
|
@@ -381,7 +381,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
381
381
|
if (extraOptions && extraOptions.interface) this._interface = extraOptions.interface;
|
|
382
382
|
else {
|
|
383
383
|
const apiUrls = (0, __common_js.resolveApiUrls)(resolvedOptions.baseUrl);
|
|
384
|
-
this._interface = new
|
|
384
|
+
this._interface = new _hexclave_shared.HexclaveClientInterface({
|
|
385
385
|
getBaseUrl: () => apiUrls()[0],
|
|
386
386
|
getAnalyticsBaseUrl: () => (0, __common_js.getAnalyticsBaseUrl)(apiUrls()[0]),
|
|
387
387
|
getApiUrls: apiUrls,
|
|
@@ -393,11 +393,11 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
393
393
|
});
|
|
394
394
|
}
|
|
395
395
|
this._tokenStoreInit = resolvedOptions.tokenStore;
|
|
396
|
-
this._redirectMethod = resolvedOptions.redirectMethod || ((0,
|
|
396
|
+
this._redirectMethod = resolvedOptions.redirectMethod || ((0, _hexclave_shared_dist_utils_env.isBrowserLike)() ? "window" : "none");
|
|
397
397
|
this._urlOptions = resolvedOptions.urls ?? {};
|
|
398
398
|
this._oauthScopesOnSignIn = resolvedOptions.oauthScopesOnSignIn ?? {};
|
|
399
|
-
if ((0,
|
|
400
|
-
(0,
|
|
399
|
+
if ((0, _hexclave_shared_dist_utils_env.isBrowserLike)() && (resolvedOptions.tokenStore === "cookie" || resolvedOptions.tokenStore === "nextjs-cookie")) {
|
|
400
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(this._trustedParentDomainCache.getOrWait([window.location.hostname], "write-only"));
|
|
401
401
|
this._ensureCrossSubdomainCookieExists();
|
|
402
402
|
}
|
|
403
403
|
if (extraOptions && extraOptions.uniqueIdentifier) {
|
|
@@ -414,7 +414,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
414
414
|
return (await this.getUser({ or: "anonymous" }))._internalSession;
|
|
415
415
|
};
|
|
416
416
|
const analyticsEnabled = this._analyticsOptions?.enabled !== false;
|
|
417
|
-
if (analyticsEnabled && (0,
|
|
417
|
+
if (analyticsEnabled && (0, _hexclave_shared_dist_utils_env.isBrowserLike)() && this._hasPersistentTokenStore() && this._analyticsOptions?.replays?.enabled === true) {
|
|
418
418
|
this._sessionRecorder = new __session_replay_js.SessionRecorder({
|
|
419
419
|
projectId: this.projectId,
|
|
420
420
|
sendBatch: async (body, opts) => {
|
|
@@ -423,7 +423,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
423
423
|
}, this._analyticsOptions.replays);
|
|
424
424
|
this._sessionRecorder.start();
|
|
425
425
|
}
|
|
426
|
-
if (analyticsEnabled && (0,
|
|
426
|
+
if (analyticsEnabled && (0, _hexclave_shared_dist_utils_env.isBrowserLike)() && this._hasPersistentTokenStore()) {
|
|
427
427
|
this._eventTracker = new __event_tracker_js.EventTracker({
|
|
428
428
|
projectId: this.projectId,
|
|
429
429
|
sendBatch: async (body, opts) => {
|
|
@@ -432,17 +432,17 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
432
432
|
});
|
|
433
433
|
this._eventTracker.start();
|
|
434
434
|
}
|
|
435
|
-
if ((0,
|
|
436
|
-
if ((0,
|
|
435
|
+
if ((0, _hexclave_shared_dist_utils_env.isBrowserLike)() && this._isOAuthCallbackUrlHosted() && this._currentUrlLooksLikeStackOAuthCallback()) this._trackPendingAuthResolution(async () => {
|
|
436
|
+
if ((0, _hexclave_shared_dist_utils_env.isBrowserLike)()) await this.callOAuthCallback({ dontWarnAboutMissingQueryParams: true });
|
|
437
437
|
});
|
|
438
|
-
if ((0,
|
|
438
|
+
if ((0, _hexclave_shared_dist_utils_env.isBrowserLike)()) this._trackPendingAuthResolution(async () => {
|
|
439
439
|
await this._maybeHandleNestedCrossDomainAuth();
|
|
440
440
|
});
|
|
441
|
-
if ((0,
|
|
441
|
+
if ((0, _hexclave_shared_dist_utils_env.isBrowserLike)() && resolvedOptions.devTool !== false) (0, ____________dev_tool_index_js.mountDevTool)(this);
|
|
442
442
|
}
|
|
443
443
|
_initUniqueIdentifier() {
|
|
444
|
-
if (!this._uniqueIdentifier) throw new
|
|
445
|
-
if (allClientApps.has(this._uniqueIdentifier)) throw new
|
|
444
|
+
if (!this._uniqueIdentifier) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("Unique identifier not initialized");
|
|
445
|
+
if (allClientApps.has(this._uniqueIdentifier)) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("A Stack client app with the same unique identifier already exists");
|
|
446
446
|
allClientApps.set(this._uniqueIdentifier, [this._extraOptions?.checkString ?? void 0, this]);
|
|
447
447
|
}
|
|
448
448
|
_trackPendingAuthResolution(callback) {
|
|
@@ -451,11 +451,11 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
451
451
|
try {
|
|
452
452
|
await callback();
|
|
453
453
|
} catch (error) {
|
|
454
|
-
(0,
|
|
454
|
+
(0, _hexclave_shared_dist_utils_errors.captureError)("pending-auth-resolution-failed", error);
|
|
455
455
|
}
|
|
456
456
|
})();
|
|
457
457
|
this._pendingAuthResolutionPromises.push(promise);
|
|
458
|
-
(0,
|
|
458
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
459
459
|
try {
|
|
460
460
|
await promise;
|
|
461
461
|
} finally {
|
|
@@ -469,7 +469,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
469
469
|
}
|
|
470
470
|
_usePendingAuthResolutions(overrideTokenStoreInit) {
|
|
471
471
|
if (overrideTokenStoreInit !== void 0 || !this._hasPersistentTokenStore() || this._pendingAuthResolutionPromises.length === 0) return;
|
|
472
|
-
(0,
|
|
472
|
+
(0, _hexclave_shared_dist_utils_react.use)(Promise.all(this._pendingAuthResolutionPromises));
|
|
473
473
|
}
|
|
474
474
|
_isOAuthCallbackUrlHosted() {
|
|
475
475
|
const oauthCallbackTarget = this._urlOptions.oauthCallback ?? this._urlOptions.default;
|
|
@@ -489,7 +489,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
489
489
|
}
|
|
490
490
|
_getOAuthCallbackRedirectUri() {
|
|
491
491
|
if (!this._isOAuthCallbackUrlHosted()) return this.urls.oauthCallback;
|
|
492
|
-
if (typeof window === "undefined") throw new
|
|
492
|
+
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");
|
|
493
493
|
const currentUrl = new URL(window.location.href);
|
|
494
494
|
for (const param of oauthCallbackResponseQueryParams) currentUrl.searchParams.delete(param);
|
|
495
495
|
return currentUrl.toString();
|
|
@@ -521,13 +521,13 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
521
521
|
const state = currentUrl.searchParams.get(nestedCrossDomainAuthQueryParams.state);
|
|
522
522
|
const codeChallenge = currentUrl.searchParams.get(nestedCrossDomainAuthQueryParams.codeChallenge);
|
|
523
523
|
if (redirectUri != null || state != null || codeChallenge != null) {
|
|
524
|
-
if (redirectUri == null || state == null || codeChallenge == null) throw new
|
|
524
|
+
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", {
|
|
525
525
|
redirectUri,
|
|
526
526
|
state,
|
|
527
527
|
codeChallenge
|
|
528
528
|
});
|
|
529
|
-
if ((currentUrl.searchParams.get(nestedCrossDomainAuthQueryParams.codeChallengeMethod) ?? "S256") !== "S256") throw new
|
|
530
|
-
if ((0,
|
|
529
|
+
if ((currentUrl.searchParams.get(nestedCrossDomainAuthQueryParams.codeChallengeMethod) ?? "S256") !== "S256") throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("Nested cross-domain auth only supports S256 PKCE");
|
|
530
|
+
if ((0, _hexclave_shared_dist_utils_urls.isRelative)(redirectUri)) throw new Error("Nested cross-domain auth redirect URI must be absolute.");
|
|
531
531
|
const redirectUriUrl = new URL(redirectUri);
|
|
532
532
|
if (!await this._isTrusted(redirectUriUrl.toString())) throw new Error(`Nested cross-domain auth redirect URI ${redirectUri} is not trusted.`);
|
|
533
533
|
const afterCallbackRedirectUrlString = currentUrl.searchParams.get(nestedCrossDomainAuthQueryParams.afterCallbackRedirectUrl);
|
|
@@ -548,8 +548,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
548
548
|
}
|
|
549
549
|
if (await this._getCurrentRefreshTokenIdIfSignedIn({ awaitPendingAuthResolutions: false }) === refreshTokenId) return false;
|
|
550
550
|
const callbackUrlString = currentUrl.searchParams.get(nestedCrossDomainAuthQueryParams.callbackUrl);
|
|
551
|
-
if (callbackUrlString == null) throw new
|
|
552
|
-
if ((0,
|
|
551
|
+
if (callbackUrlString == null) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("Nested cross-domain auth URL is missing callback URL");
|
|
552
|
+
if ((0, _hexclave_shared_dist_utils_urls.isRelative)(callbackUrlString)) throw new Error("Nested cross-domain auth callback URL must be absolute.");
|
|
553
553
|
const callbackUrl = new URL(callbackUrlString);
|
|
554
554
|
if (!await this._isTrusted(callbackUrl.toString())) throw new Error(`Nested cross-domain auth callback URL ${callbackUrlString} is not trusted.`);
|
|
555
555
|
const afterCallbackRedirectUrl = new URL(currentUrl);
|
|
@@ -575,7 +575,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
575
575
|
*/
|
|
576
576
|
_getUniqueIdentifier() {
|
|
577
577
|
if (!this._uniqueIdentifier) {
|
|
578
|
-
this._uniqueIdentifier = (0,
|
|
578
|
+
this._uniqueIdentifier = (0, _hexclave_shared_dist_utils_uuids.generateUuid)();
|
|
579
579
|
this._initUniqueIdentifier();
|
|
580
580
|
}
|
|
581
581
|
return this._uniqueIdentifier;
|
|
@@ -587,8 +587,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
587
587
|
});
|
|
588
588
|
}
|
|
589
589
|
_useCheckFeatureSupport(name, options) {
|
|
590
|
-
(0,
|
|
591
|
-
throw new
|
|
590
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(this._checkFeatureSupport(name, options));
|
|
591
|
+
throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError(`${name} is not currently supported. Please reach out to Stack support for more information.`);
|
|
592
592
|
}
|
|
593
593
|
get _legacyRefreshTokenCookieName() {
|
|
594
594
|
return `stack-refresh-${this.projectId}`;
|
|
@@ -600,7 +600,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
600
600
|
return `${secure ? "__Host-" : ""}${this._refreshTokenCookieName}--default`;
|
|
601
601
|
}
|
|
602
602
|
_getCustomRefreshCookieName(domain) {
|
|
603
|
-
const encoded = (0,
|
|
603
|
+
const encoded = (0, _hexclave_shared_dist_utils_bytes.encodeBase32)(new TextEncoder().encode(domain.toLowerCase()));
|
|
604
604
|
return `${this._refreshTokenCookieName}--custom-${encoded}`;
|
|
605
605
|
}
|
|
606
606
|
_getDomainFromCustomRefreshCookieName(name) {
|
|
@@ -608,7 +608,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
608
608
|
const prefix = `${base}--custom-`;
|
|
609
609
|
if (!name.startsWith(prefix)) continue;
|
|
610
610
|
try {
|
|
611
|
-
return new TextDecoder().decode((0,
|
|
611
|
+
return new TextDecoder().decode((0, _hexclave_shared_dist_utils_bytes.decodeBase32)(name.slice(prefix.length)));
|
|
612
612
|
} catch {
|
|
613
613
|
return null;
|
|
614
614
|
}
|
|
@@ -626,7 +626,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
626
626
|
}
|
|
627
627
|
_parseStructuredRefreshCookie(value) {
|
|
628
628
|
if (!value) return null;
|
|
629
|
-
const parsed = (0,
|
|
629
|
+
const parsed = (0, _hexclave_shared_dist_utils_json.parseJson)(value);
|
|
630
630
|
if (parsed.status !== "ok" || typeof parsed.data !== "object" || parsed.data === null) {
|
|
631
631
|
console.warn("Failed to parse structured refresh cookie");
|
|
632
632
|
return null;
|
|
@@ -685,7 +685,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
685
685
|
const accessTokenCookie = cookies[this._accessTokenCookieName] ?? cookies[this._legacyAccessTokenCookieName] ?? null;
|
|
686
686
|
let accessToken = null;
|
|
687
687
|
if (accessTokenCookie && accessTokenCookie.startsWith("[\"")) {
|
|
688
|
-
const parsed = (0,
|
|
688
|
+
const parsed = (0, _hexclave_shared_dist_utils_json.parseJson)(accessTokenCookie);
|
|
689
689
|
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") {
|
|
690
690
|
if (parsed.data[0] === refreshToken) accessToken = parsed.data[1];
|
|
691
691
|
} else console.warn("Access token cookie has invalid format");
|
|
@@ -702,7 +702,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
702
702
|
return `stack-access`;
|
|
703
703
|
}
|
|
704
704
|
_getAllBrowserCookies() {
|
|
705
|
-
if (!(0,
|
|
705
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)()) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("Cannot get browser cookies on the server!");
|
|
706
706
|
return cookie.parseCookie(document.cookie || "");
|
|
707
707
|
}
|
|
708
708
|
_getRefreshTokenCookieNamePatterns() {
|
|
@@ -735,7 +735,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
735
735
|
};
|
|
736
736
|
}
|
|
737
737
|
_ensureCrossSubdomainCookieExists() {
|
|
738
|
-
(0,
|
|
738
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
739
739
|
const hostname = window.location.hostname;
|
|
740
740
|
const domain = await this._trustedParentDomainCache.getOrWait([hostname], "read-write");
|
|
741
741
|
if (domain.status === "error" || !domain.data) return;
|
|
@@ -750,11 +750,11 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
750
750
|
});
|
|
751
751
|
}
|
|
752
752
|
_queueCustomRefreshCookieUpdate(refreshToken, updatedAt, context) {
|
|
753
|
-
(0,
|
|
753
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
754
754
|
this._mostRecentQueuedCookieRefreshIndex++;
|
|
755
755
|
const updateIndex = this._mostRecentQueuedCookieRefreshIndex;
|
|
756
756
|
let hostname;
|
|
757
|
-
if ((0,
|
|
757
|
+
if ((0, _hexclave_shared_dist_utils_env.isBrowserLike)()) hostname = window.location.hostname;
|
|
758
758
|
else hostname = await getServerRequestHost();
|
|
759
759
|
if (!hostname) {
|
|
760
760
|
console.warn("No hostname found when queueing custom refresh cookie update");
|
|
@@ -784,7 +784,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
784
784
|
});
|
|
785
785
|
}
|
|
786
786
|
async _getTrustedRedirectConfig() {
|
|
787
|
-
const project =
|
|
787
|
+
const project = _hexclave_shared_dist_utils_results.Result.orThrow(await this._currentProjectCache.getOrWait([], "write-only"));
|
|
788
788
|
return {
|
|
789
789
|
allowLocalhost: project.config.allow_localhost,
|
|
790
790
|
trustedDomains: [...project.config.domains.map((d) => d.domain), new URL((0, ______url_targets_js.getHostedHandlerUrl)({
|
|
@@ -794,10 +794,10 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
794
794
|
};
|
|
795
795
|
}
|
|
796
796
|
async _getTrustedParentDomain(currentDomain) {
|
|
797
|
-
return (0,
|
|
797
|
+
return (0, _hexclave_shared_dist_utils_redirect_urls.getTrustedParentDomain)(currentDomain, (await this._getTrustedRedirectConfig()).trustedDomains);
|
|
798
798
|
}
|
|
799
799
|
_getBrowserCookieTokenStore() {
|
|
800
|
-
if (!(0,
|
|
800
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)()) throw new Error("Cannot use cookie token store on the server!");
|
|
801
801
|
if (this._storedBrowserCookieTokenStore === null) {
|
|
802
802
|
const getCurrentValue = (old) => {
|
|
803
803
|
const tokens = this._getTokensFromCookies(this._getAllBrowserCookies());
|
|
@@ -806,13 +806,13 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
806
806
|
accessToken: tokens.accessToken ?? (old?.refreshToken === tokens.refreshToken ? old.accessToken : null)
|
|
807
807
|
};
|
|
808
808
|
};
|
|
809
|
-
this._storedBrowserCookieTokenStore = new
|
|
809
|
+
this._storedBrowserCookieTokenStore = new _hexclave_shared_dist_utils_stores.Store(getCurrentValue(null));
|
|
810
810
|
let hasSucceededInWriting = true;
|
|
811
811
|
setInterval(() => {
|
|
812
812
|
if (hasSucceededInWriting) {
|
|
813
813
|
const oldValue = this._storedBrowserCookieTokenStore.get();
|
|
814
814
|
const currentValue = getCurrentValue(oldValue);
|
|
815
|
-
if (!(0,
|
|
815
|
+
if (!(0, _hexclave_shared_dist_utils_objects.deepPlainEquals)(currentValue, oldValue)) this._storedBrowserCookieTokenStore.set(currentValue);
|
|
816
816
|
}
|
|
817
817
|
}, 100);
|
|
818
818
|
this._storedBrowserCookieTokenStore.onChange((value) => {
|
|
@@ -833,7 +833,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
833
833
|
this._queueCustomRefreshCookieUpdate(refreshToken, updatedAt, "browser");
|
|
834
834
|
hasSucceededInWriting = true;
|
|
835
835
|
} catch (e) {
|
|
836
|
-
if (!(0,
|
|
836
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)()) hasSucceededInWriting = false;
|
|
837
837
|
else throw e;
|
|
838
838
|
}
|
|
839
839
|
});
|
|
@@ -844,11 +844,11 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
844
844
|
const tokenStoreInit = overrideTokenStoreInit === void 0 ? this._tokenStoreInit : overrideTokenStoreInit;
|
|
845
845
|
switch (tokenStoreInit) {
|
|
846
846
|
case "cookie": return this._getBrowserCookieTokenStore();
|
|
847
|
-
case "nextjs-cookie": if ((0,
|
|
847
|
+
case "nextjs-cookie": if ((0, _hexclave_shared_dist_utils_env.isBrowserLike)()) return this._getBrowserCookieTokenStore();
|
|
848
848
|
else {
|
|
849
|
-
const store = new
|
|
849
|
+
const store = new _hexclave_shared_dist_utils_stores.Store(this._getTokensFromCookies(cookieHelper.getAll()));
|
|
850
850
|
store.onChange((value) => {
|
|
851
|
-
(0,
|
|
851
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
852
852
|
const refreshToken = value.refreshToken;
|
|
853
853
|
const secure = await (0, _________cookie_js.isSecure)();
|
|
854
854
|
const defaultName = this._getRefreshTokenDefaultCookieNameForSecure(secure);
|
|
@@ -881,7 +881,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
881
881
|
if (authorizationHeader) {
|
|
882
882
|
const authJson = getAuthJsonFromAuthorizationHeaderValue(authorizationHeader);
|
|
883
883
|
if (authJson != null) {
|
|
884
|
-
const tokenStore = new
|
|
884
|
+
const tokenStore = new _hexclave_shared_dist_utils_stores.Store({
|
|
885
885
|
accessToken: authJson.accessToken,
|
|
886
886
|
refreshToken: authJson.refreshToken
|
|
887
887
|
});
|
|
@@ -906,10 +906,10 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
906
906
|
}
|
|
907
907
|
const cookieHeader = getHeaderValueFromRequestLikeHeaders(tokenStoreInit.headers, "cookie");
|
|
908
908
|
const parsed = cookie.parseCookie(cookieHeader || "");
|
|
909
|
-
const res = new
|
|
909
|
+
const res = new _hexclave_shared_dist_utils_stores.Store(this._getTokensFromCookies(parsed));
|
|
910
910
|
this._requestTokenStores.set(tokenStoreInit, res);
|
|
911
911
|
return res;
|
|
912
|
-
} else if ("accessToken" in tokenStoreInit || "refreshToken" in tokenStoreInit) return new
|
|
912
|
+
} else if ("accessToken" in tokenStoreInit || "refreshToken" in tokenStoreInit) return new _hexclave_shared_dist_utils_stores.Store({
|
|
913
913
|
refreshToken: tokenStoreInit.refreshToken,
|
|
914
914
|
accessToken: tokenStoreInit.accessToken
|
|
915
915
|
});
|
|
@@ -917,13 +917,13 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
917
917
|
}
|
|
918
918
|
}
|
|
919
919
|
_useTokenStore(overrideTokenStoreInit) {
|
|
920
|
-
(0,
|
|
920
|
+
(0, _hexclave_shared_dist_utils_react.suspendIfSsr)();
|
|
921
921
|
const cookieHelper = (0, _________cookie_js.createBrowserCookieHelper)();
|
|
922
922
|
return this._getOrCreateTokenStore(cookieHelper, overrideTokenStoreInit);
|
|
923
923
|
}
|
|
924
924
|
_getSessionFromTokenStore(tokenStore) {
|
|
925
925
|
const tokenObj = tokenStore.get();
|
|
926
|
-
const sessionKey =
|
|
926
|
+
const sessionKey = _hexclave_shared_dist_sessions.InternalSession.calculateSessionKey(tokenObj);
|
|
927
927
|
const existing = sessionKey ? this._sessionsByTokenStoreAndSessionKey.get(tokenStore)?.get(sessionKey) : null;
|
|
928
928
|
if (existing) return existing;
|
|
929
929
|
const session = this._interface.createSession({
|
|
@@ -967,7 +967,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
967
967
|
return react.default.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
968
968
|
}
|
|
969
969
|
async _signInToAccountWithTokens(tokens) {
|
|
970
|
-
if (!("accessToken" in tokens) || !("refreshToken" in tokens)) throw new
|
|
970
|
+
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 });
|
|
971
971
|
const tokenStore = this._getOrCreateTokenStore(await this._createCookieHelper());
|
|
972
972
|
tokenStore.set(tokens);
|
|
973
973
|
const newSession = this._getSessionFromTokenStore(tokenStore);
|
|
@@ -1107,13 +1107,13 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1107
1107
|
await app._teamInvitationsCache.refresh([session, crud.id]);
|
|
1108
1108
|
},
|
|
1109
1109
|
async listUsers() {
|
|
1110
|
-
return
|
|
1110
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._teamMemberProfilesCache.getOrWait([session, crud.id], "write-only")).map((crud) => app._clientTeamUserFromCrud(crud));
|
|
1111
1111
|
},
|
|
1112
1112
|
useUsers() {
|
|
1113
1113
|
return (0, __common_js.useAsyncCache)(app._teamMemberProfilesCache, [session, crud.id], "team.useUsers()").map((crud) => app._clientTeamUserFromCrud(crud));
|
|
1114
1114
|
},
|
|
1115
1115
|
async listInvitations() {
|
|
1116
|
-
return
|
|
1116
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._teamInvitationsCache.getOrWait([session, crud.id], "write-only")).map((crud) => app._clientSentTeamInvitationFromCrud(session, crud));
|
|
1117
1117
|
},
|
|
1118
1118
|
useInvitations() {
|
|
1119
1119
|
return (0, __common_js.useAsyncCache)(app._teamInvitationsCache, [session, crud.id], "team.useInvitations()").map((crud) => app._clientSentTeamInvitationFromCrud(session, crud));
|
|
@@ -1133,7 +1133,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1133
1133
|
return (0, __common_js.useAsyncCache)(app._teamApiKeysCache, [session, crud.id], "team.useApiKeys()").map((crud) => app._clientApiKeyFromCrud(session, crud));
|
|
1134
1134
|
},
|
|
1135
1135
|
async listApiKeys() {
|
|
1136
|
-
return
|
|
1136
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._teamApiKeysCache.getOrWait([session, crud.id], "write-only")).map((crud) => app._clientApiKeyFromCrud(session, crud));
|
|
1137
1137
|
},
|
|
1138
1138
|
async createApiKey(options) {
|
|
1139
1139
|
const result = await app._interface.createProjectApiKey(await (0, ______api_keys_index_js.apiKeyCreationOptionsToCrud)("team", crud.id, options), session, "client");
|
|
@@ -1193,9 +1193,9 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1193
1193
|
allow_connected_accounts: data.allowConnectedAccounts
|
|
1194
1194
|
}, session);
|
|
1195
1195
|
await Promise.all([app._currentUserOAuthProvidersCache.refresh([session]), app._currentUserConnectedAccountsCache.refresh([session])]);
|
|
1196
|
-
return
|
|
1196
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
1197
1197
|
} catch (error) {
|
|
1198
|
-
if (
|
|
1198
|
+
if (_hexclave_shared.KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn.isInstance(error)) return _hexclave_shared_dist_utils_results.Result.error(error);
|
|
1199
1199
|
throw error;
|
|
1200
1200
|
}
|
|
1201
1201
|
},
|
|
@@ -1275,7 +1275,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1275
1275
|
return session.isKnownToBeInvalid() ? null : session.getAccessTokenIfNotExpiredYet(2e4, 75e3)?.token ?? null;
|
|
1276
1276
|
}, [session]);
|
|
1277
1277
|
let accessToken = react.default.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
1278
|
-
if (accessToken === null && !session.isKnownToBeInvalid()) accessToken = (0,
|
|
1278
|
+
if (accessToken === null && !session.isKnownToBeInvalid()) accessToken = (0, _hexclave_shared_dist_utils_react.use)(session.getOrFetchLikelyValidTokens(2e4, 75e3))?.accessToken.token ?? null;
|
|
1279
1279
|
return {
|
|
1280
1280
|
accessToken,
|
|
1281
1281
|
refreshToken: session.getRefreshToken()?.token ?? null
|
|
@@ -1365,11 +1365,11 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1365
1365
|
const scopeString = options?.scopes?.join(" ") ?? "";
|
|
1366
1366
|
if (typeof idOrAccount === "object" && "provider" in idOrAccount && "providerAccountId" in idOrAccount) {
|
|
1367
1367
|
const { provider, providerAccountId } = idOrAccount;
|
|
1368
|
-
const found =
|
|
1368
|
+
const found = _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserConnectedAccountsCache.getOrWait([session], "write-only")).find((a) => a.provider === provider && a.providerAccountId === providerAccountId);
|
|
1369
1369
|
if (!found) return null;
|
|
1370
1370
|
return found;
|
|
1371
1371
|
}
|
|
1372
|
-
return
|
|
1372
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserOAuthConnectionCache.getOrWait([
|
|
1373
1373
|
session,
|
|
1374
1374
|
idOrAccount,
|
|
1375
1375
|
scopeString,
|
|
@@ -1408,7 +1408,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1408
1408
|
getConnectedAccount,
|
|
1409
1409
|
useConnectedAccount,
|
|
1410
1410
|
async listConnectedAccounts() {
|
|
1411
|
-
return
|
|
1411
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserConnectedAccountsCache.getOrWait([session], "write-only"));
|
|
1412
1412
|
},
|
|
1413
1413
|
useConnectedAccounts() {
|
|
1414
1414
|
return (0, __common_js.useAsyncCache)(app._currentUserConnectedAccountsCache, [session], "user.useConnectedAccounts()");
|
|
@@ -1419,16 +1419,16 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1419
1419
|
provider,
|
|
1420
1420
|
redirectUrl: app._getOAuthCallbackRedirectUri(),
|
|
1421
1421
|
errorRedirectUrl: app.urls.error,
|
|
1422
|
-
providerScope: (0,
|
|
1422
|
+
providerScope: (0, _hexclave_shared_dist_utils_strings.mergeScopeStrings)(scopeString, (app._oauthScopesOnSignIn[provider] ?? []).join(" "))
|
|
1423
1423
|
}, session);
|
|
1424
1424
|
await app._redirectTo({ url: location });
|
|
1425
|
-
return await (0,
|
|
1425
|
+
return await (0, _hexclave_shared_dist_utils_promises.neverResolve)();
|
|
1426
1426
|
},
|
|
1427
1427
|
async getOrLinkConnectedAccount(provider, options) {
|
|
1428
|
-
const matchingAccounts =
|
|
1428
|
+
const matchingAccounts = _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserConnectedAccountsCache.getOrWait([session], "write-only")).filter((a) => a.provider === provider);
|
|
1429
1429
|
for (const account of matchingAccounts) if ((await account.getAccessToken({ scopes: options?.scopes })).status === "ok") return account;
|
|
1430
1430
|
await this.linkConnectedAccount(provider, options);
|
|
1431
|
-
return await (0,
|
|
1431
|
+
return await (0, _hexclave_shared_dist_utils_promises.neverResolve)();
|
|
1432
1432
|
},
|
|
1433
1433
|
useOrLinkConnectedAccount(provider, options) {
|
|
1434
1434
|
const scopeString = options?.scopes?.join(" ") ?? "";
|
|
@@ -1448,7 +1448,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1448
1448
|
}, [teams, teamId]);
|
|
1449
1449
|
},
|
|
1450
1450
|
async listTeams() {
|
|
1451
|
-
return
|
|
1451
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserTeamsCache.getOrWait([session], "write-only")).map((crud) => app._clientTeamFromCrud(crud, session));
|
|
1452
1452
|
},
|
|
1453
1453
|
useTeams() {
|
|
1454
1454
|
const teams = (0, __common_js.useAsyncCache)(app._currentUserTeamsCache, [session], "user.useTeams()");
|
|
@@ -1464,7 +1464,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1464
1464
|
await app._interface.leaveTeam(team.id, session);
|
|
1465
1465
|
},
|
|
1466
1466
|
async listTeamInvitations() {
|
|
1467
|
-
return
|
|
1467
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserTeamInvitationsCache.getOrWait([session], "write-only")).map((crud) => app._clientReceivedTeamInvitationFromCrud(session, crud));
|
|
1468
1468
|
},
|
|
1469
1469
|
useTeamInvitations() {
|
|
1470
1470
|
const invitations = (0, __common_js.useAsyncCache)(app._currentUserTeamInvitationsCache, [session], "user.useTeamInvitations()");
|
|
@@ -1474,14 +1474,14 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1474
1474
|
if (scopeOrOptions && "id" in scopeOrOptions) {
|
|
1475
1475
|
const scope = scopeOrOptions;
|
|
1476
1476
|
const recursive = options?.recursive ?? true;
|
|
1477
|
-
return
|
|
1477
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserPermissionsCache.getOrWait([
|
|
1478
1478
|
session,
|
|
1479
1479
|
scope.id,
|
|
1480
1480
|
recursive
|
|
1481
1481
|
], "write-only")).map((crud) => app._clientPermissionFromCrud(crud));
|
|
1482
1482
|
} else {
|
|
1483
1483
|
const recursive = scopeOrOptions?.recursive ?? true;
|
|
1484
|
-
return
|
|
1484
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserProjectPermissionsCache.getOrWait([session, recursive], "write-only")).map((crud) => app._clientPermissionFromCrud(crud));
|
|
1485
1485
|
}
|
|
1486
1486
|
},
|
|
1487
1487
|
usePermissions(scopeOrOptions, options) {
|
|
@@ -1533,7 +1533,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1533
1533
|
return await app._updateClientUser(update, session);
|
|
1534
1534
|
},
|
|
1535
1535
|
async sendVerificationEmail(options) {
|
|
1536
|
-
if (!crud.primary_email) throw new
|
|
1536
|
+
if (!crud.primary_email) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("User does not have a primary email");
|
|
1537
1537
|
return await app._interface.sendVerificationEmail(crud.primary_email, options?.callbackUrl ?? (0, ____________utils_url_js.constructRedirectUrl)(app.urls.emailVerification, "callbackUrl"), session);
|
|
1538
1538
|
},
|
|
1539
1539
|
async updatePassword(options) {
|
|
@@ -1548,7 +1548,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1548
1548
|
},
|
|
1549
1549
|
selectedTeam: crud.selected_team && this._clientTeamFromCrud(crud.selected_team, session),
|
|
1550
1550
|
async getTeamProfile(team) {
|
|
1551
|
-
const result =
|
|
1551
|
+
const result = _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserTeamProfileCache.getOrWait([session, team.id], "write-only"));
|
|
1552
1552
|
return app._editableTeamProfileFromCrud(result, session);
|
|
1553
1553
|
},
|
|
1554
1554
|
useTeamProfile(team) {
|
|
@@ -1560,7 +1560,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1560
1560
|
session.markInvalid();
|
|
1561
1561
|
},
|
|
1562
1562
|
async listContactChannels() {
|
|
1563
|
-
return
|
|
1563
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._clientContactChannelsCache.getOrWait([session], "write-only")).map((crud) => app._clientContactChannelFromCrud(crud, session));
|
|
1564
1564
|
},
|
|
1565
1565
|
useContactChannels() {
|
|
1566
1566
|
return (0, __common_js.useAsyncCache)(app._clientContactChannelsCache, [session], "user.useContactChannels()").map((crud) => app._clientContactChannelFromCrud(crud, session));
|
|
@@ -1574,7 +1574,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1574
1574
|
return (0, __common_js.useAsyncCache)(app._notificationCategoriesCache, [session], "user.useNotificationCategories()").map((crud) => app._clientNotificationCategoryFromCrud(crud, session));
|
|
1575
1575
|
},
|
|
1576
1576
|
async listNotificationCategories() {
|
|
1577
|
-
return
|
|
1577
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._notificationCategoriesCache.getOrWait([session], "write-only")).map((crud) => app._clientNotificationCategoryFromCrud(crud, session));
|
|
1578
1578
|
},
|
|
1579
1579
|
useApiKeys() {
|
|
1580
1580
|
return (0, __common_js.useAsyncCache)(app._userApiKeysCache, [session], "user.useApiKeys()").map((crud) => app._clientApiKeyFromCrud(session, crud));
|
|
@@ -1591,7 +1591,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1591
1591
|
return (0, __common_js.useAsyncCache)(app._currentUserOAuthProvidersCache, [session], "user.useOAuthProviders()").map((crud) => app._clientOAuthProviderFromCrud(crud, session));
|
|
1592
1592
|
},
|
|
1593
1593
|
async listOAuthProviders() {
|
|
1594
|
-
return
|
|
1594
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserOAuthProvidersCache.getOrWait([session], "write-only")).map((crud) => app._clientOAuthProviderFromCrud(crud, session));
|
|
1595
1595
|
},
|
|
1596
1596
|
useOAuthProvider(id) {
|
|
1597
1597
|
const providers = this.useOAuthProviders();
|
|
@@ -1602,20 +1602,20 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1602
1602
|
},
|
|
1603
1603
|
async registerPasskey(options) {
|
|
1604
1604
|
const hostname = (await app._getCurrentUrl())?.hostname;
|
|
1605
|
-
if (!hostname) throw new
|
|
1605
|
+
if (!hostname) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("hostname must be provided if the Stack App does not have a redirect method");
|
|
1606
1606
|
const initiationResult = await app._interface.initiatePasskeyRegistration({}, session);
|
|
1607
|
-
if (initiationResult.status !== "ok") return
|
|
1607
|
+
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"));
|
|
1608
1608
|
const { options_json, code } = initiationResult.data;
|
|
1609
|
-
if (options_json.rp.id !== "THIS_VALUE_WILL_BE_REPLACED.example.com") throw new
|
|
1609
|
+
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}`);
|
|
1610
1610
|
options_json.rp.id = hostname;
|
|
1611
1611
|
let attResp;
|
|
1612
1612
|
try {
|
|
1613
1613
|
attResp = await (0, _simplewebauthn_browser.startRegistration)({ optionsJSON: options_json });
|
|
1614
1614
|
} catch (error) {
|
|
1615
|
-
if (error instanceof _simplewebauthn_browser.WebAuthnError) return
|
|
1615
|
+
if (error instanceof _simplewebauthn_browser.WebAuthnError) return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.PasskeyWebAuthnError(error.message, error.name));
|
|
1616
1616
|
else {
|
|
1617
|
-
(0,
|
|
1618
|
-
return
|
|
1617
|
+
(0, _hexclave_shared_dist_utils_errors.captureError)("passkey-registration-failed", error);
|
|
1618
|
+
return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.PasskeyRegistrationFailed("Failed to start passkey registration due to unknown error"));
|
|
1619
1619
|
}
|
|
1620
1620
|
}
|
|
1621
1621
|
const registrationResult = await app._interface.registerPasskey({
|
|
@@ -1652,7 +1652,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1652
1652
|
const customerOptions = type === "user" ? { userId: userIdOrTeamId } : { teamId: userIdOrTeamId };
|
|
1653
1653
|
return {
|
|
1654
1654
|
async getBilling() {
|
|
1655
|
-
const response =
|
|
1655
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await app._customerBillingCache.getOrWait([
|
|
1656
1656
|
effectiveSession,
|
|
1657
1657
|
type,
|
|
1658
1658
|
userIdOrTeamId
|
|
@@ -1744,17 +1744,17 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1744
1744
|
async getItem(options) {
|
|
1745
1745
|
const session = await this._getSession();
|
|
1746
1746
|
let crud;
|
|
1747
|
-
if ("userId" in options) crud =
|
|
1747
|
+
if ("userId" in options) crud = _hexclave_shared_dist_utils_results.Result.orThrow(await this._userItemCache.getOrWait([
|
|
1748
1748
|
session,
|
|
1749
1749
|
options.userId,
|
|
1750
1750
|
options.itemId
|
|
1751
1751
|
], "write-only"));
|
|
1752
|
-
else if ("teamId" in options) crud =
|
|
1752
|
+
else if ("teamId" in options) crud = _hexclave_shared_dist_utils_results.Result.orThrow(await this._teamItemCache.getOrWait([
|
|
1753
1753
|
session,
|
|
1754
1754
|
options.teamId,
|
|
1755
1755
|
options.itemId
|
|
1756
1756
|
], "write-only"));
|
|
1757
|
-
else crud =
|
|
1757
|
+
else crud = _hexclave_shared_dist_utils_results.Result.orThrow(await this._customItemCache.getOrWait([
|
|
1758
1758
|
session,
|
|
1759
1759
|
options.customCustomerId,
|
|
1760
1760
|
options.itemId
|
|
@@ -1774,7 +1774,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1774
1774
|
async listProducts(options) {
|
|
1775
1775
|
const session = (await this.getUser())?._internalSession ?? await this._getSession();
|
|
1776
1776
|
if ("userId" in options) {
|
|
1777
|
-
const response =
|
|
1777
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await this._userProductsCache.getOrWait([
|
|
1778
1778
|
session,
|
|
1779
1779
|
options.userId,
|
|
1780
1780
|
options.cursor ?? null,
|
|
@@ -1782,7 +1782,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1782
1782
|
], "write-only"));
|
|
1783
1783
|
return this._customerProductsFromResponse(response);
|
|
1784
1784
|
} else if ("teamId" in options) {
|
|
1785
|
-
const response =
|
|
1785
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await this._teamProductsCache.getOrWait([
|
|
1786
1786
|
session,
|
|
1787
1787
|
options.teamId,
|
|
1788
1788
|
options.cursor ?? null,
|
|
@@ -1790,7 +1790,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1790
1790
|
], "write-only"));
|
|
1791
1791
|
return this._customerProductsFromResponse(response);
|
|
1792
1792
|
}
|
|
1793
|
-
const response =
|
|
1793
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await this._customProductsCache.getOrWait([
|
|
1794
1794
|
session,
|
|
1795
1795
|
options.customCustomerId,
|
|
1796
1796
|
options.cursor ?? null,
|
|
@@ -1801,7 +1801,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1801
1801
|
async listInvoices(options) {
|
|
1802
1802
|
const session = await this._getSession();
|
|
1803
1803
|
if ("userId" in options) {
|
|
1804
|
-
const response =
|
|
1804
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await this._userInvoicesCache.getOrWait([
|
|
1805
1805
|
session,
|
|
1806
1806
|
options.userId,
|
|
1807
1807
|
options.cursor ?? null,
|
|
@@ -1809,7 +1809,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1809
1809
|
], "write-only"));
|
|
1810
1810
|
return this._customerInvoicesFromResponse(response);
|
|
1811
1811
|
}
|
|
1812
|
-
const response =
|
|
1812
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await this._teamInvoicesCache.getOrWait([
|
|
1813
1813
|
session,
|
|
1814
1814
|
options.teamId,
|
|
1815
1815
|
options.cursor ?? null,
|
|
@@ -1820,7 +1820,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1820
1820
|
async cancelSubscription(options) {
|
|
1821
1821
|
const session = await this._getSession();
|
|
1822
1822
|
const user = await this.getUser();
|
|
1823
|
-
if (!user) throw new
|
|
1823
|
+
if (!user) throw new _hexclave_shared.KnownErrors.UserAuthenticationRequired();
|
|
1824
1824
|
const customerType = "teamId" in options ? "team" : "user";
|
|
1825
1825
|
const customerId = "teamId" in options ? options.teamId : user.id;
|
|
1826
1826
|
await this._interface.cancelSubscription({
|
|
@@ -1889,7 +1889,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1889
1889
|
return __common_js.clientVersion;
|
|
1890
1890
|
}
|
|
1891
1891
|
_getBotChallengeSiteKeys() {
|
|
1892
|
-
if (!(0,
|
|
1892
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)()) return null;
|
|
1893
1893
|
const visibleSiteKey = _________env_js.envVars.NEXT_PUBLIC_STACK_BOT_CHALLENGE_SITE_KEY;
|
|
1894
1894
|
if (!visibleSiteKey) {
|
|
1895
1895
|
if (!this._botChallengeSiteKeysWarned) {
|
|
@@ -1904,23 +1904,23 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1904
1904
|
};
|
|
1905
1905
|
}
|
|
1906
1906
|
_getBotChallengeFlowFailure(error) {
|
|
1907
|
-
if (error instanceof
|
|
1907
|
+
if (error instanceof _hexclave_shared_dist_utils_turnstile_flow.BotChallengeUserCancelledError) return {
|
|
1908
1908
|
type: "cancelled",
|
|
1909
|
-
knownError: new
|
|
1909
|
+
knownError: new _hexclave_shared.KnownErrors.BotChallengeFailed("Bot challenge cancelled by user")
|
|
1910
1910
|
};
|
|
1911
|
-
if (error instanceof
|
|
1911
|
+
if (error instanceof _hexclave_shared_dist_utils_turnstile_flow.BotChallengeExecutionFailedError) return {
|
|
1912
1912
|
type: "failed",
|
|
1913
|
-
knownError: new
|
|
1913
|
+
knownError: new _hexclave_shared.KnownErrors.BotChallengeFailed(error.message)
|
|
1914
1914
|
};
|
|
1915
1915
|
return null;
|
|
1916
1916
|
}
|
|
1917
1917
|
_normalizeBotChallengeResult(result) {
|
|
1918
1918
|
if (result.status === "ok") return result;
|
|
1919
|
-
if (
|
|
1920
|
-
(0,
|
|
1921
|
-
return
|
|
1919
|
+
if (_hexclave_shared.KnownErrors.BotChallengeRequired.isInstance(result.error)) {
|
|
1920
|
+
(0, _hexclave_shared_dist_utils_errors.captureError)("bot-challenge-unexpected-after-flow", result.error);
|
|
1921
|
+
return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.BotChallengeFailed("Unexpected bot challenge after flow completion"));
|
|
1922
1922
|
}
|
|
1923
|
-
return
|
|
1923
|
+
return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
1924
1924
|
}
|
|
1925
1925
|
_toInterfaceBotChallengeInput(challenge) {
|
|
1926
1926
|
if (challenge.unavailable) return { phase: "visible" };
|
|
@@ -1933,25 +1933,25 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1933
1933
|
const siteKeys = this._getBotChallengeSiteKeys();
|
|
1934
1934
|
let result;
|
|
1935
1935
|
try {
|
|
1936
|
-
if (siteKeys) result = await (0,
|
|
1936
|
+
if (siteKeys) result = await (0, _hexclave_shared_dist_utils_turnstile_flow.withBotChallengeFlow)({
|
|
1937
1937
|
...siteKeys,
|
|
1938
1938
|
action: options.action,
|
|
1939
1939
|
execute: options.execute,
|
|
1940
1940
|
isChallengeRequired: (flowResult) => {
|
|
1941
|
-
return flowResult.status === "error" &&
|
|
1941
|
+
return flowResult.status === "error" && _hexclave_shared.KnownErrors.BotChallengeRequired.isInstance(flowResult.error);
|
|
1942
1942
|
}
|
|
1943
1943
|
});
|
|
1944
1944
|
else result = await options.execute({});
|
|
1945
1945
|
} catch (e) {
|
|
1946
1946
|
const flowFailure = this._getBotChallengeFlowFailure(e);
|
|
1947
|
-
if (flowFailure) return
|
|
1947
|
+
if (flowFailure) return _hexclave_shared_dist_utils_results.Result.error(flowFailure.knownError);
|
|
1948
1948
|
throw e;
|
|
1949
1949
|
}
|
|
1950
1950
|
return this._normalizeBotChallengeResult(result);
|
|
1951
1951
|
}
|
|
1952
1952
|
async _isTrusted(url) {
|
|
1953
|
-
if ((0,
|
|
1954
|
-
const parsedUrl = (0,
|
|
1953
|
+
if ((0, _hexclave_shared_dist_utils_urls.isRelative)(url)) return true;
|
|
1954
|
+
const parsedUrl = (0, _hexclave_shared_dist_utils_urls.createUrlIfValid)(url);
|
|
1955
1955
|
if (parsedUrl == null) return false;
|
|
1956
1956
|
if (typeof window !== "undefined" && window.location.origin === parsedUrl.origin) return true;
|
|
1957
1957
|
if ((0, ______url_targets_js.isHostedHandlerUrlForProject)({
|
|
@@ -1959,7 +1959,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1959
1959
|
projectId: this.projectId
|
|
1960
1960
|
})) return true;
|
|
1961
1961
|
const trustedRedirectConfig = await this._getTrustedRedirectConfig();
|
|
1962
|
-
return (0,
|
|
1962
|
+
return (0, _hexclave_shared_dist_utils_redirect_urls.validateRedirectUrl)(parsedUrl, {
|
|
1963
1963
|
allowLocalhost: trustedRedirectConfig.allowLocalhost,
|
|
1964
1964
|
trustedDomains: trustedRedirectConfig.trustedDomains
|
|
1965
1965
|
});
|
|
@@ -1969,11 +1969,11 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1969
1969
|
}
|
|
1970
1970
|
_prefetchCrossDomainHandoffParamsIfNeeded() {
|
|
1971
1971
|
const canWriteOauthVerifierCookie = this._tokenStoreInit === "cookie" || this._tokenStoreInit === "nextjs-cookie";
|
|
1972
|
-
if (!(0,
|
|
1972
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)() || !canWriteOauthVerifierCookie || this._isPrefetchingCrossDomainHandoffParams || this._getFreshPrefetchedCrossDomainHandoffParams() != null) return;
|
|
1973
1973
|
this._isPrefetchingCrossDomainHandoffParams = true;
|
|
1974
|
-
(0,
|
|
1974
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
1975
1975
|
try {
|
|
1976
|
-
if (!(0,
|
|
1976
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)()) return;
|
|
1977
1977
|
const { state, codeChallenge } = await (0, _________cookie_js.saveVerifierAndState)();
|
|
1978
1978
|
this._prefetchedCrossDomainHandoffParams = {
|
|
1979
1979
|
state,
|
|
@@ -2035,10 +2035,10 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2035
2035
|
}, session);
|
|
2036
2036
|
if (!response.ok) {
|
|
2037
2037
|
const responseBody = await response.text();
|
|
2038
|
-
throw new
|
|
2038
|
+
throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError(`Cross-domain authorization endpoint failed: ${response.status} ${responseBody}`);
|
|
2039
2039
|
}
|
|
2040
2040
|
const result = await response.json();
|
|
2041
|
-
if (!("redirect_url" in result) || typeof result.redirect_url !== "string") throw new
|
|
2041
|
+
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 });
|
|
2042
2042
|
return result.redirect_url;
|
|
2043
2043
|
}
|
|
2044
2044
|
_getFreshPrefetchedCrossDomainHandoffParams() {
|
|
@@ -2059,7 +2059,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2059
2059
|
else if (typeof this._redirectMethod === "object" && this._redirectMethod.navigate) this._redirectMethod.navigate(options.url.toString());
|
|
2060
2060
|
else if (options.replace) window.location.replace(options.url);
|
|
2061
2061
|
else window.location.assign(options.url);
|
|
2062
|
-
await (0,
|
|
2062
|
+
await (0, _hexclave_shared_dist_utils_promises.wait)(2e3);
|
|
2063
2063
|
}
|
|
2064
2064
|
useNavigate() {
|
|
2065
2065
|
if (typeof this._redirectMethod === "object") return this._redirectMethod.useNavigate();
|
|
@@ -2196,8 +2196,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2196
2196
|
code,
|
|
2197
2197
|
session: await this._getSession()
|
|
2198
2198
|
});
|
|
2199
|
-
if (result.status === "ok") return
|
|
2200
|
-
else return
|
|
2199
|
+
if (result.status === "ok") return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2200
|
+
else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2201
2201
|
}
|
|
2202
2202
|
async getTeamInvitationDetails(code) {
|
|
2203
2203
|
const result = await this._interface.acceptTeamInvitation({
|
|
@@ -2205,8 +2205,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2205
2205
|
code,
|
|
2206
2206
|
session: await this._getSession()
|
|
2207
2207
|
});
|
|
2208
|
-
if (result.status === "ok") return
|
|
2209
|
-
else return
|
|
2208
|
+
if (result.status === "ok") return _hexclave_shared_dist_utils_results.Result.ok({ teamDisplayName: result.data.team_display_name });
|
|
2209
|
+
else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2210
2210
|
}
|
|
2211
2211
|
async verifyEmail(code) {
|
|
2212
2212
|
const result = await this._interface.verifyEmail(code);
|
|
@@ -2218,7 +2218,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2218
2218
|
if (options?.or === "anonymous" && options.includeRestricted === false) throw new Error("Cannot use { or: 'anonymous' } with { includeRestricted: false }. Anonymous users implicitly include restricted users.");
|
|
2219
2219
|
this._ensurePersistentTokenStore(options?.tokenStore);
|
|
2220
2220
|
const session = await this._getSession(options?.tokenStore);
|
|
2221
|
-
let crud =
|
|
2221
|
+
let crud = _hexclave_shared_dist_utils_results.Result.orThrow(await this._currentUserCache.getOrWait([session], "write-only"));
|
|
2222
2222
|
const includeAnonymous = options?.or === "anonymous" || options?.or === "anonymous-if-exists[deprecated]";
|
|
2223
2223
|
const includeRestricted = options?.includeRestricted === true || includeAnonymous;
|
|
2224
2224
|
if (crud === null || crud.is_anonymous && !includeAnonymous || crud.is_restricted && !includeRestricted) switch (options?.or) {
|
|
@@ -2233,7 +2233,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2233
2233
|
tokenStore: tokens,
|
|
2234
2234
|
or: "anonymous-if-exists[deprecated]",
|
|
2235
2235
|
includeRestricted: true
|
|
2236
|
-
}) ?? (0,
|
|
2236
|
+
}) ?? (0, _hexclave_shared_dist_utils_errors.throwErr)("Something went wrong while signing up anonymously");
|
|
2237
2237
|
}
|
|
2238
2238
|
case void 0:
|
|
2239
2239
|
case "anonymous-if-exists[deprecated]":
|
|
@@ -2251,18 +2251,18 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2251
2251
|
if (crud === null || crud.is_anonymous && !includeAnonymous || crud.is_restricted && !includeRestricted) switch (options?.or) {
|
|
2252
2252
|
case "redirect":
|
|
2253
2253
|
if (!crud?.is_anonymous && crud?.is_restricted) {
|
|
2254
|
-
if (!this._redirectToHandlerDuringRender("onboarding", { replace: true })) (0,
|
|
2255
|
-
} else if (!this._redirectToHandlerDuringRender("signIn", { replace: true })) (0,
|
|
2256
|
-
(0,
|
|
2257
|
-
throw new
|
|
2254
|
+
if (!this._redirectToHandlerDuringRender("onboarding", { replace: true })) (0, _hexclave_shared_dist_utils_promises.runAsynchronously)(this.redirectToOnboarding({ replace: true }));
|
|
2255
|
+
} else if (!this._redirectToHandlerDuringRender("signIn", { replace: true })) (0, _hexclave_shared_dist_utils_promises.runAsynchronously)(this.redirectToSignIn({ replace: true }));
|
|
2256
|
+
(0, _hexclave_shared_dist_utils_react.suspend)();
|
|
2257
|
+
throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("suspend should never return");
|
|
2258
2258
|
case "throw": throw new Error("User is not signed in but useUser was called with { or: 'throw' }");
|
|
2259
2259
|
case "anonymous":
|
|
2260
|
-
(0,
|
|
2260
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
2261
2261
|
await this._signUpAnonymously();
|
|
2262
2262
|
if (typeof window !== "undefined") window.location.reload();
|
|
2263
2263
|
});
|
|
2264
|
-
(0,
|
|
2265
|
-
throw new
|
|
2264
|
+
(0, _hexclave_shared_dist_utils_react.suspend)();
|
|
2265
|
+
throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("suspend should never return");
|
|
2266
2266
|
case void 0:
|
|
2267
2267
|
case "anonymous-if-exists[deprecated]":
|
|
2268
2268
|
case "return-null":
|
|
@@ -2368,12 +2368,12 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2368
2368
|
};
|
|
2369
2369
|
let authorizeResult;
|
|
2370
2370
|
try {
|
|
2371
|
-
if (siteKeys) authorizeResult = await (0,
|
|
2371
|
+
if (siteKeys) authorizeResult = await (0, _hexclave_shared_dist_utils_turnstile_flow.withBotChallengeFlow)({
|
|
2372
2372
|
...siteKeys,
|
|
2373
2373
|
action: "oauth_authenticate",
|
|
2374
2374
|
execute: executeOAuth,
|
|
2375
2375
|
isChallengeRequired: (result) => {
|
|
2376
|
-
return result.status === "error" &&
|
|
2376
|
+
return result.status === "error" && _hexclave_shared.KnownErrors.BotChallengeRequired.isInstance(result.error);
|
|
2377
2377
|
}
|
|
2378
2378
|
});
|
|
2379
2379
|
else authorizeResult = await executeOAuth({});
|
|
@@ -2383,17 +2383,17 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2383
2383
|
if (flowFailure?.type === "failed") throw flowFailure.knownError;
|
|
2384
2384
|
throw e;
|
|
2385
2385
|
}
|
|
2386
|
-
const location =
|
|
2386
|
+
const location = _hexclave_shared_dist_utils_results.Result.orThrow(authorizeResult);
|
|
2387
2387
|
await this._redirectTo({ url: location });
|
|
2388
|
-
await (0,
|
|
2388
|
+
await (0, _hexclave_shared_dist_utils_promises.neverResolve)();
|
|
2389
2389
|
}
|
|
2390
2390
|
/**
|
|
2391
2391
|
* Handles MFA verification by redirecting to the OTP page
|
|
2392
2392
|
*/
|
|
2393
2393
|
async _experimentalMfa(error, session) {
|
|
2394
|
-
if (typeof window !== "undefined") window.sessionStorage.setItem("hexclave_mfa_attempt_code", error.details?.attempt_code ?? (0,
|
|
2394
|
+
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"));
|
|
2395
2395
|
await this.redirectToMfa();
|
|
2396
|
-
throw new
|
|
2396
|
+
throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("we should have redirected in redirectToMfa()");
|
|
2397
2397
|
}
|
|
2398
2398
|
/**
|
|
2399
2399
|
* @deprecated
|
|
@@ -2403,7 +2403,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2403
2403
|
try {
|
|
2404
2404
|
return await callback();
|
|
2405
2405
|
} catch (e) {
|
|
2406
|
-
if (
|
|
2406
|
+
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 })));
|
|
2407
2407
|
throw e;
|
|
2408
2408
|
}
|
|
2409
2409
|
}
|
|
@@ -2416,25 +2416,25 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2416
2416
|
return await this._interface.signInWithCredential(options.email, options.password, session);
|
|
2417
2417
|
});
|
|
2418
2418
|
} catch (e) {
|
|
2419
|
-
if (
|
|
2419
|
+
if (_hexclave_shared.KnownErrors.InvalidTotpCode.isInstance(e)) return _hexclave_shared_dist_utils_results.Result.error(e);
|
|
2420
2420
|
throw e;
|
|
2421
2421
|
}
|
|
2422
2422
|
if (result.status === "ok") {
|
|
2423
2423
|
await this._signInToAccountWithTokens(result.data);
|
|
2424
2424
|
if (!options.noRedirect) await this._redirectToHandler("afterSignIn", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2425
|
-
return
|
|
2426
|
-
} else return
|
|
2425
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2426
|
+
} else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2427
2427
|
}
|
|
2428
2428
|
async signUpWithCredential(options) {
|
|
2429
|
-
if (options.noVerificationCallback && options.verificationCallbackUrl) throw new
|
|
2429
|
+
if (options.noVerificationCallback && options.verificationCallbackUrl) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("verificationCallbackUrl is not allowed when noVerificationCallback is true");
|
|
2430
2430
|
this._ensurePersistentTokenStore();
|
|
2431
2431
|
const session = await this._getSession();
|
|
2432
2432
|
const emailVerificationRedirectUrl = options.noVerificationCallback ? void 0 : options.verificationCallbackUrl ?? (0, ____________utils_url_js.constructRedirectUrl)(this.urls.emailVerification, "verificationCallbackUrl");
|
|
2433
2433
|
const executeSignUp = async (challenge) => {
|
|
2434
2434
|
let result = await this._interface.signUpWithCredential(options.email, options.password, emailVerificationRedirectUrl, session, this._toInterfaceBotChallengeInput(challenge));
|
|
2435
|
-
if (result.status === "error" && result.error instanceof
|
|
2435
|
+
if (result.status === "error" && result.error instanceof _hexclave_shared.KnownErrors.RedirectUrlNotWhitelisted && emailVerificationRedirectUrl !== void 0) {
|
|
2436
2436
|
if (!options.verificationCallbackUrl) {
|
|
2437
|
-
(0,
|
|
2437
|
+
(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 }));
|
|
2438
2438
|
result = await this._interface.signUpWithCredential(options.email, options.password, void 0, session, this._toInterfaceBotChallengeInput(challenge));
|
|
2439
2439
|
}
|
|
2440
2440
|
}
|
|
@@ -2448,8 +2448,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2448
2448
|
if (result.status === "ok") {
|
|
2449
2449
|
await this._signInToAccountWithTokens(result.data);
|
|
2450
2450
|
if (!options.noRedirect) await this._redirectToHandler("afterSignUp", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2451
|
-
return
|
|
2452
|
-
} else return
|
|
2451
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2452
|
+
} else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2453
2453
|
}
|
|
2454
2454
|
async _signUpAnonymously() {
|
|
2455
2455
|
this._ensurePersistentTokenStore();
|
|
@@ -2458,7 +2458,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2458
2458
|
const session = await this._getSession();
|
|
2459
2459
|
const result = await this._interface.signUpAnonymously(session);
|
|
2460
2460
|
if (result.status === "ok") await this._signInToAccountWithTokens(result.data);
|
|
2461
|
-
else throw new
|
|
2461
|
+
else throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("signUpAnonymously() should never return an error");
|
|
2462
2462
|
this._anonymousSignUpInProgress = null;
|
|
2463
2463
|
return result.data;
|
|
2464
2464
|
})();
|
|
@@ -2473,7 +2473,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2473
2473
|
return await this._interface.signInWithMagicLink(code, session);
|
|
2474
2474
|
});
|
|
2475
2475
|
} catch (e) {
|
|
2476
|
-
if (
|
|
2476
|
+
if (_hexclave_shared.KnownErrors.InvalidTotpCode.isInstance(e)) return _hexclave_shared_dist_utils_results.Result.error(e);
|
|
2477
2477
|
throw e;
|
|
2478
2478
|
}
|
|
2479
2479
|
if (result.status === "ok") {
|
|
@@ -2486,8 +2486,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2486
2486
|
awaitPendingAuthResolutions: false,
|
|
2487
2487
|
overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data)
|
|
2488
2488
|
});
|
|
2489
|
-
return
|
|
2490
|
-
} else return
|
|
2489
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2490
|
+
} else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2491
2491
|
}
|
|
2492
2492
|
/**
|
|
2493
2493
|
* Initiates a CLI authentication process that allows a command line application
|
|
@@ -2518,7 +2518,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2518
2518
|
...options.anonRefreshToken != null ? { anon_refresh_token: options.anonRefreshToken } : {}
|
|
2519
2519
|
})
|
|
2520
2520
|
}, null);
|
|
2521
|
-
if (!response.ok) return
|
|
2521
|
+
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()}`));
|
|
2522
2522
|
const initResult = await response.json();
|
|
2523
2523
|
const pollingCode = initResult.polling_code;
|
|
2524
2524
|
const loginCode = initResult.login_code;
|
|
@@ -2540,18 +2540,18 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2540
2540
|
headers: { "Content-Type": "application/json" },
|
|
2541
2541
|
body: JSON.stringify({ polling_code: pollingCode })
|
|
2542
2542
|
}, null);
|
|
2543
|
-
if (!pollResponse.ok) return
|
|
2543
|
+
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()}`));
|
|
2544
2544
|
const pollResult = await pollResponse.json();
|
|
2545
|
-
if (pollResponse.status === 201 && pollResult.status === "success") return
|
|
2545
|
+
if (pollResponse.status === 201 && pollResult.status === "success") return _hexclave_shared_dist_utils_results.Result.ok(pollResult.refresh_token);
|
|
2546
2546
|
if (pollResult.status === "waiting") {
|
|
2547
|
-
await (0,
|
|
2547
|
+
await (0, _hexclave_shared_dist_utils_promises.wait)(options.waitTimeMillis ?? 2e3);
|
|
2548
2548
|
continue;
|
|
2549
2549
|
}
|
|
2550
|
-
if (pollResult.status === "expired") return
|
|
2551
|
-
if (pollResult.status === "used") return
|
|
2552
|
-
return
|
|
2550
|
+
if (pollResult.status === "expired") return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.CliAuthExpiredError("CLI authentication request expired. Please try again."));
|
|
2551
|
+
if (pollResult.status === "used") return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.CliAuthUsedError("This authentication token has already been used."));
|
|
2552
|
+
return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.CliAuthError(`Unexpected status from CLI auth polling: ${pollResult.status}`));
|
|
2553
2553
|
}
|
|
2554
|
-
return
|
|
2554
|
+
return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.CliAuthError("Timed out waiting for CLI authentication."));
|
|
2555
2555
|
}
|
|
2556
2556
|
async signInWithMfa(totp, code, options) {
|
|
2557
2557
|
this._ensurePersistentTokenStore();
|
|
@@ -2562,16 +2562,16 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2562
2562
|
return await this._interface.signInWithMfa(totp, code, session);
|
|
2563
2563
|
});
|
|
2564
2564
|
} catch (e) {
|
|
2565
|
-
if (e instanceof
|
|
2565
|
+
if (e instanceof _hexclave_shared.KnownErrors.InvalidTotpCode) return _hexclave_shared_dist_utils_results.Result.error(e);
|
|
2566
2566
|
throw e;
|
|
2567
2567
|
}
|
|
2568
2568
|
if (result.status === "ok") {
|
|
2569
2569
|
await this._signInToAccountWithTokens(result.data);
|
|
2570
2570
|
if (!options?.noRedirect) if (result.data.newUser) await this._redirectToHandler("afterSignUp", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2571
2571
|
else await this._redirectToHandler("afterSignIn", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2572
|
-
return
|
|
2572
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2573
2573
|
}
|
|
2574
|
-
return
|
|
2574
|
+
return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2575
2575
|
}
|
|
2576
2576
|
async signInWithPasskey() {
|
|
2577
2577
|
this._ensurePersistentTokenStore();
|
|
@@ -2580,9 +2580,9 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2580
2580
|
try {
|
|
2581
2581
|
result = await this._catchMfaRequiredError(async () => {
|
|
2582
2582
|
const initiationResult = await this._interface.initiatePasskeyAuthentication({}, session);
|
|
2583
|
-
if (initiationResult.status !== "ok") return
|
|
2583
|
+
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"));
|
|
2584
2584
|
const { options_json, code } = initiationResult.data;
|
|
2585
|
-
if (options_json.rpId !== "THIS_VALUE_WILL_BE_REPLACED.example.com") throw new
|
|
2585
|
+
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}`);
|
|
2586
2586
|
options_json.rpId = window.location.hostname;
|
|
2587
2587
|
const authentication_response = await (0, _simplewebauthn_browser.startAuthentication)({ optionsJSON: options_json });
|
|
2588
2588
|
return await this._interface.signInWithPasskey({
|
|
@@ -2591,14 +2591,14 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2591
2591
|
}, session);
|
|
2592
2592
|
});
|
|
2593
2593
|
} catch (error) {
|
|
2594
|
-
if (error instanceof _simplewebauthn_browser.WebAuthnError) return
|
|
2595
|
-
else return
|
|
2594
|
+
if (error instanceof _simplewebauthn_browser.WebAuthnError) return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.PasskeyWebAuthnError(error.message, error.name));
|
|
2595
|
+
else return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.PasskeyAuthenticationFailed("Failed to sign in with passkey"));
|
|
2596
2596
|
}
|
|
2597
2597
|
if (result.status === "ok") {
|
|
2598
2598
|
await this._signInToAccountWithTokens(result.data);
|
|
2599
2599
|
await this._redirectToHandler("afterSignIn", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2600
|
-
return
|
|
2601
|
-
} else return
|
|
2600
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2601
|
+
} else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2602
2602
|
}
|
|
2603
2603
|
async callOAuthCallback(options) {
|
|
2604
2604
|
if (typeof window === "undefined") throw new Error("callOAuthCallback can currently only be called in a browser environment");
|
|
@@ -2616,7 +2616,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2616
2616
|
return await (0, _________auth_js.callOAuthCallback)(this._interface, oauthCallbackRedirectUri, options);
|
|
2617
2617
|
});
|
|
2618
2618
|
} catch (e) {
|
|
2619
|
-
if (
|
|
2619
|
+
if (_hexclave_shared.KnownErrors.InvalidTotpCode.isInstance(e)) {
|
|
2620
2620
|
alert("Invalid TOTP code. Please try signing in again.");
|
|
2621
2621
|
return false;
|
|
2622
2622
|
} else throw e;
|
|
@@ -2649,7 +2649,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2649
2649
|
async _signOut(session, options) {
|
|
2650
2650
|
this._eventTracker?.clearBuffer();
|
|
2651
2651
|
this._sessionRecorder?.clearBuffer();
|
|
2652
|
-
await
|
|
2652
|
+
await _hexclave_shared_dist_utils_stores.storeLock.withWriteLock(async () => {
|
|
2653
2653
|
await this._interface.signOut(session);
|
|
2654
2654
|
if (options?.redirectUrl) await this._redirectTo({
|
|
2655
2655
|
url: options.redirectUrl,
|
|
@@ -2711,7 +2711,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2711
2711
|
};
|
|
2712
2712
|
}
|
|
2713
2713
|
async getProject() {
|
|
2714
|
-
const crud =
|
|
2714
|
+
const crud = _hexclave_shared_dist_utils_results.Result.orThrow(await this._currentProjectCache.getOrWait([], "write-only"));
|
|
2715
2715
|
return this._clientProjectFromCrud(crud);
|
|
2716
2716
|
}
|
|
2717
2717
|
useProject() {
|
|
@@ -2720,7 +2720,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2720
2720
|
}
|
|
2721
2721
|
async _listOwnedProjects(session) {
|
|
2722
2722
|
this._ensureInternalProject();
|
|
2723
|
-
return
|
|
2723
|
+
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)));
|
|
2724
2724
|
}
|
|
2725
2725
|
_useOwnedProjects(session) {
|
|
2726
2726
|
this._ensureInternalProject();
|
|
@@ -2750,17 +2750,17 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2750
2750
|
}
|
|
2751
2751
|
static get [______common_js.stackAppInternalsSymbol]() {
|
|
2752
2752
|
return { fromClientJson: (json) => {
|
|
2753
|
-
const providedCheckString = JSON.stringify((0,
|
|
2753
|
+
const providedCheckString = JSON.stringify((0, _hexclave_shared_dist_utils_objects.omit)(json, []));
|
|
2754
2754
|
const existing = allClientApps.get(json.uniqueIdentifier);
|
|
2755
2755
|
if (existing) {
|
|
2756
2756
|
const [existingCheckString, clientApp] = existing;
|
|
2757
|
-
if (existingCheckString !== void 0 && existingCheckString !== providedCheckString) throw new
|
|
2757
|
+
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", {
|
|
2758
2758
|
providedObj: json,
|
|
2759
2759
|
existingString: existingCheckString
|
|
2760
2760
|
});
|
|
2761
2761
|
return clientApp;
|
|
2762
2762
|
}
|
|
2763
|
-
const { analytics, ...restJson } = (0,
|
|
2763
|
+
const { analytics, ...restJson } = (0, _hexclave_shared_dist_utils_objects.omit)(json, ["uniqueIdentifier"]);
|
|
2764
2764
|
return new _StackClientAppImplIncomplete({
|
|
2765
2765
|
...restJson,
|
|
2766
2766
|
analytics: (0, __session_replay_js.analyticsOptionsFromJson)(analytics)
|
|
@@ -2773,7 +2773,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2773
2773
|
get [______common_js.stackAppInternalsSymbol]() {
|
|
2774
2774
|
return {
|
|
2775
2775
|
toClientJson: () => {
|
|
2776
|
-
if (typeof this._redirectMethod !== "string") throw new
|
|
2776
|
+
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");
|
|
2777
2777
|
const publishableClientKey = "publishableClientKey" in this._interface.options ? this._interface.options.publishableClientKey : void 0;
|
|
2778
2778
|
return {
|
|
2779
2779
|
baseUrl: this._options.baseUrl,
|
|
@@ -2790,8 +2790,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2790
2790
|
};
|
|
2791
2791
|
},
|
|
2792
2792
|
setCurrentUser: (userJsonPromise) => {
|
|
2793
|
-
(0,
|
|
2794
|
-
await this._currentUserCache.forceSetCachedValueAsync([await this._getSession()],
|
|
2793
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
2794
|
+
await this._currentUserCache.forceSetCachedValueAsync([await this._getSession()], _hexclave_shared_dist_utils_results.Result.fromPromise(userJsonPromise));
|
|
2795
2795
|
});
|
|
2796
2796
|
},
|
|
2797
2797
|
getConstructorOptions: () => this._options,
|
|
@@ -2807,7 +2807,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2807
2807
|
sendRequest: async (path, requestOptions, requestType = "client") => {
|
|
2808
2808
|
return await this._interface.sendClientRequest(path, requestOptions, await this._getSession(), requestType);
|
|
2809
2809
|
},
|
|
2810
|
-
getRedirectMethod: () => this._redirectMethod ?? (0,
|
|
2810
|
+
getRedirectMethod: () => this._redirectMethod ?? (0, _hexclave_shared_dist_utils_errors.throwErr)("Redirect method should have been initialized in the Stack client app constructor"),
|
|
2811
2811
|
redirectToUrl: async (url, options) => {
|
|
2812
2812
|
await this._redirectTo({
|
|
2813
2813
|
url,
|