@hexclave/react 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -23
- package/dist/components/api-key-dialogs.js +18 -18
- package/dist/components/api-key-dialogs.js.map +1 -1
- package/dist/components/api-key-table.js +19 -19
- package/dist/components/api-key-table.js.map +1 -1
- package/dist/components/credential-sign-in.js +12 -12
- package/dist/components/credential-sign-in.js.map +1 -1
- package/dist/components/credential-sign-up.js +19 -19
- package/dist/components/credential-sign-up.js.map +1 -1
- package/dist/components/elements/separator-with-text.js +3 -3
- package/dist/components/elements/separator-with-text.js.map +1 -1
- package/dist/components/elements/sidebar-layout.js +15 -15
- package/dist/components/elements/sidebar-layout.js.map +1 -1
- package/dist/components/elements/user-avatar.js +3 -3
- package/dist/components/elements/user-avatar.js.map +1 -1
- package/dist/components/link.js +2 -2
- package/dist/components/link.js.map +1 -1
- package/dist/components/magic-link-sign-in.js +17 -17
- package/dist/components/magic-link-sign-in.js.map +1 -1
- package/dist/components/message-cards/known-error-message-card.js +2 -2
- package/dist/components/message-cards/known-error-message-card.js.map +1 -1
- package/dist/components/message-cards/message-card.js +4 -4
- package/dist/components/message-cards/message-card.js.map +1 -1
- package/dist/components/message-cards/predefined-message-card.js +2 -2
- package/dist/components/message-cards/predefined-message-card.js.map +1 -1
- package/dist/components/oauth-button.d.ts.map +1 -1
- package/dist/components/oauth-button.js +15 -15
- package/dist/components/oauth-button.js.map +1 -1
- package/dist/components/passkey-button.js +2 -2
- package/dist/components/passkey-button.js.map +1 -1
- package/dist/components/profile-image-editor.js +9 -9
- package/dist/components/profile-image-editor.js.map +1 -1
- package/dist/components/selected-team-switcher.js +4 -4
- package/dist/components/selected-team-switcher.js.map +1 -1
- package/dist/components/team-icon.js +4 -4
- package/dist/components/team-icon.js.map +1 -1
- package/dist/components/team-switcher.js +21 -21
- package/dist/components/team-switcher.js.map +1 -1
- package/dist/components/user-button.js +13 -13
- package/dist/components/user-button.js.map +1 -1
- package/dist/components-page/account-settings/active-sessions/active-sessions-page.js +32 -32
- package/dist/components-page/account-settings/active-sessions/active-sessions-page.js.map +1 -1
- package/dist/components-page/account-settings/api-keys/api-keys-page.js +2 -2
- package/dist/components-page/account-settings/api-keys/api-keys-page.js.map +1 -1
- package/dist/components-page/account-settings/editable-text.js +5 -5
- package/dist/components-page/account-settings/editable-text.js.map +1 -1
- package/dist/components-page/account-settings/email-and-auth/emails-section.js +22 -22
- package/dist/components-page/account-settings/email-and-auth/emails-section.js.map +1 -1
- package/dist/components-page/account-settings/email-and-auth/mfa-section.js +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 +14 -10
- package/dist/components-page/stack-handler-client.js.map +1 -1
- package/dist/components-page/stack-handler.d.ts +14 -9
- package/dist/components-page/stack-handler.d.ts.map +1 -1
- package/dist/components-page/stack-handler.js +8 -2
- package/dist/components-page/stack-handler.js.map +1 -1
- package/dist/components-page/team-creation.js +9 -9
- package/dist/components-page/team-creation.js.map +1 -1
- package/dist/components-page/team-invitation.js +20 -20
- package/dist/components-page/team-invitation.js.map +1 -1
- package/dist/dev-tool/dev-tool-core.d.ts.map +1 -1
- package/dist/dev-tool/dev-tool-core.js +25 -25
- package/dist/dev-tool/dev-tool-core.js.map +1 -1
- package/dist/dev-tool/dev-tool-trigger-position.test.js +1 -1
- package/dist/dev-tool/index.js +6 -6
- package/dist/dev-tool/index.js.map +1 -1
- package/dist/esm/components/api-key-dialogs.js +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.d.ts.map +1 -1
- package/dist/esm/components/oauth-button.js.map +1 -1
- package/dist/esm/components/passkey-button.js.map +1 -1
- package/dist/esm/components/profile-image-editor.js.map +1 -1
- package/dist/esm/components/selected-team-switcher.js.map +1 -1
- package/dist/esm/components/team-icon.js.map +1 -1
- package/dist/esm/components/team-switcher.js +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 +9 -5
- 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.cross-domain.test.js +67 -1
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.cross-domain.test.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.d.ts +4 -3
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.d.ts.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js +21 -5
- 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.cross-domain.test.js +66 -0
- package/dist/lib/stack-app/apps/implementations/client-app-impl.cross-domain.test.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/client-app-impl.d.ts +4 -3
- package/dist/lib/stack-app/apps/implementations/client-app-impl.d.ts.map +1 -1
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js +224 -208
- 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 +6 -6
- package/dist/esm/internal/deprecation-warning.d.ts +0 -1
- package/dist/esm/internal/deprecation-warning.js +0 -24
- package/dist/esm/internal/deprecation-warning.js.map +0 -1
- package/dist/internal/deprecation-warning.d.ts +0 -1
- package/dist/internal/deprecation-warning.js +0 -24
- package/dist/internal/deprecation-warning.js.map +0 -1
|
@@ -1,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,16 +548,29 @@ 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);
|
|
556
556
|
afterCallbackRedirectUrl.searchParams.delete(nestedCrossDomainAuthQueryParams.refreshTokenId);
|
|
557
557
|
afterCallbackRedirectUrl.searchParams.delete(nestedCrossDomainAuthQueryParams.callbackUrl);
|
|
558
|
-
const { state: newState, codeChallenge: newCodeChallenge } = await this.
|
|
558
|
+
const { state: newState, codeChallenge: newCodeChallenge } = await this._getNestedCrossDomainAuthParamsForRedirect();
|
|
559
|
+
const nestedRedirectUri = new URL(this._getOAuthCallbackRedirectUri(), currentUrl);
|
|
560
|
+
nestedRedirectUri.searchParams.delete(nestedCrossDomainAuthQueryParams.refreshTokenId);
|
|
561
|
+
nestedRedirectUri.searchParams.delete(nestedCrossDomainAuthQueryParams.callbackUrl);
|
|
562
|
+
for (const param of [
|
|
563
|
+
"after_auth_return_to",
|
|
564
|
+
__redirect_page_urls_js.crossDomainAuthQueryParams.marker,
|
|
565
|
+
__redirect_page_urls_js.crossDomainAuthQueryParams.state,
|
|
566
|
+
__redirect_page_urls_js.crossDomainAuthQueryParams.codeChallenge,
|
|
567
|
+
__redirect_page_urls_js.crossDomainAuthQueryParams.afterCallbackRedirectUrl
|
|
568
|
+
]) {
|
|
569
|
+
const value = currentUrl.searchParams.get(param);
|
|
570
|
+
if (value != null && !nestedRedirectUri.searchParams.has(param)) nestedRedirectUri.searchParams.set(param, value);
|
|
571
|
+
}
|
|
559
572
|
callbackUrl.searchParams.set(nestedCrossDomainAuthQueryParams.refreshTokenId, refreshTokenId);
|
|
560
|
-
callbackUrl.searchParams.set(nestedCrossDomainAuthQueryParams.redirectUri,
|
|
573
|
+
callbackUrl.searchParams.set(nestedCrossDomainAuthQueryParams.redirectUri, nestedRedirectUri.toString());
|
|
561
574
|
callbackUrl.searchParams.set(nestedCrossDomainAuthQueryParams.state, newState);
|
|
562
575
|
callbackUrl.searchParams.set(nestedCrossDomainAuthQueryParams.codeChallenge, newCodeChallenge);
|
|
563
576
|
callbackUrl.searchParams.set(nestedCrossDomainAuthQueryParams.codeChallengeMethod, "S256");
|
|
@@ -568,6 +581,9 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
568
581
|
});
|
|
569
582
|
return true;
|
|
570
583
|
}
|
|
584
|
+
async _getNestedCrossDomainAuthParamsForRedirect() {
|
|
585
|
+
return await (0, _________cookie_js.saveVerifierAndState)();
|
|
586
|
+
}
|
|
571
587
|
/**
|
|
572
588
|
* Cloudflare workers does not allow use of randomness on the global scope (on which the Stack app is probably
|
|
573
589
|
* initialized). For that reason, we generate the unique identifier lazily when it is first needed instead of in the
|
|
@@ -575,7 +591,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
575
591
|
*/
|
|
576
592
|
_getUniqueIdentifier() {
|
|
577
593
|
if (!this._uniqueIdentifier) {
|
|
578
|
-
this._uniqueIdentifier = (0,
|
|
594
|
+
this._uniqueIdentifier = (0, _hexclave_shared_dist_utils_uuids.generateUuid)();
|
|
579
595
|
this._initUniqueIdentifier();
|
|
580
596
|
}
|
|
581
597
|
return this._uniqueIdentifier;
|
|
@@ -587,8 +603,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
587
603
|
});
|
|
588
604
|
}
|
|
589
605
|
_useCheckFeatureSupport(name, options) {
|
|
590
|
-
(0,
|
|
591
|
-
throw new
|
|
606
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(this._checkFeatureSupport(name, options));
|
|
607
|
+
throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError(`${name} is not currently supported. Please reach out to Stack support for more information.`);
|
|
592
608
|
}
|
|
593
609
|
get _legacyRefreshTokenCookieName() {
|
|
594
610
|
return `stack-refresh-${this.projectId}`;
|
|
@@ -600,7 +616,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
600
616
|
return `${secure ? "__Host-" : ""}${this._refreshTokenCookieName}--default`;
|
|
601
617
|
}
|
|
602
618
|
_getCustomRefreshCookieName(domain) {
|
|
603
|
-
const encoded = (0,
|
|
619
|
+
const encoded = (0, _hexclave_shared_dist_utils_bytes.encodeBase32)(new TextEncoder().encode(domain.toLowerCase()));
|
|
604
620
|
return `${this._refreshTokenCookieName}--custom-${encoded}`;
|
|
605
621
|
}
|
|
606
622
|
_getDomainFromCustomRefreshCookieName(name) {
|
|
@@ -608,7 +624,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
608
624
|
const prefix = `${base}--custom-`;
|
|
609
625
|
if (!name.startsWith(prefix)) continue;
|
|
610
626
|
try {
|
|
611
|
-
return new TextDecoder().decode((0,
|
|
627
|
+
return new TextDecoder().decode((0, _hexclave_shared_dist_utils_bytes.decodeBase32)(name.slice(prefix.length)));
|
|
612
628
|
} catch {
|
|
613
629
|
return null;
|
|
614
630
|
}
|
|
@@ -626,7 +642,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
626
642
|
}
|
|
627
643
|
_parseStructuredRefreshCookie(value) {
|
|
628
644
|
if (!value) return null;
|
|
629
|
-
const parsed = (0,
|
|
645
|
+
const parsed = (0, _hexclave_shared_dist_utils_json.parseJson)(value);
|
|
630
646
|
if (parsed.status !== "ok" || typeof parsed.data !== "object" || parsed.data === null) {
|
|
631
647
|
console.warn("Failed to parse structured refresh cookie");
|
|
632
648
|
return null;
|
|
@@ -685,7 +701,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
685
701
|
const accessTokenCookie = cookies[this._accessTokenCookieName] ?? cookies[this._legacyAccessTokenCookieName] ?? null;
|
|
686
702
|
let accessToken = null;
|
|
687
703
|
if (accessTokenCookie && accessTokenCookie.startsWith("[\"")) {
|
|
688
|
-
const parsed = (0,
|
|
704
|
+
const parsed = (0, _hexclave_shared_dist_utils_json.parseJson)(accessTokenCookie);
|
|
689
705
|
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
706
|
if (parsed.data[0] === refreshToken) accessToken = parsed.data[1];
|
|
691
707
|
} else console.warn("Access token cookie has invalid format");
|
|
@@ -702,7 +718,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
702
718
|
return `stack-access`;
|
|
703
719
|
}
|
|
704
720
|
_getAllBrowserCookies() {
|
|
705
|
-
if (!(0,
|
|
721
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)()) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("Cannot get browser cookies on the server!");
|
|
706
722
|
return cookie.parseCookie(document.cookie || "");
|
|
707
723
|
}
|
|
708
724
|
_getRefreshTokenCookieNamePatterns() {
|
|
@@ -735,7 +751,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
735
751
|
};
|
|
736
752
|
}
|
|
737
753
|
_ensureCrossSubdomainCookieExists() {
|
|
738
|
-
(0,
|
|
754
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
739
755
|
const hostname = window.location.hostname;
|
|
740
756
|
const domain = await this._trustedParentDomainCache.getOrWait([hostname], "read-write");
|
|
741
757
|
if (domain.status === "error" || !domain.data) return;
|
|
@@ -750,11 +766,11 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
750
766
|
});
|
|
751
767
|
}
|
|
752
768
|
_queueCustomRefreshCookieUpdate(refreshToken, updatedAt, context) {
|
|
753
|
-
(0,
|
|
769
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
754
770
|
this._mostRecentQueuedCookieRefreshIndex++;
|
|
755
771
|
const updateIndex = this._mostRecentQueuedCookieRefreshIndex;
|
|
756
772
|
let hostname;
|
|
757
|
-
if ((0,
|
|
773
|
+
if ((0, _hexclave_shared_dist_utils_env.isBrowserLike)()) hostname = window.location.hostname;
|
|
758
774
|
else hostname = await getServerRequestHost();
|
|
759
775
|
if (!hostname) {
|
|
760
776
|
console.warn("No hostname found when queueing custom refresh cookie update");
|
|
@@ -784,7 +800,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
784
800
|
});
|
|
785
801
|
}
|
|
786
802
|
async _getTrustedRedirectConfig() {
|
|
787
|
-
const project =
|
|
803
|
+
const project = _hexclave_shared_dist_utils_results.Result.orThrow(await this._currentProjectCache.getOrWait([], "write-only"));
|
|
788
804
|
return {
|
|
789
805
|
allowLocalhost: project.config.allow_localhost,
|
|
790
806
|
trustedDomains: [...project.config.domains.map((d) => d.domain), new URL((0, ______url_targets_js.getHostedHandlerUrl)({
|
|
@@ -794,10 +810,10 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
794
810
|
};
|
|
795
811
|
}
|
|
796
812
|
async _getTrustedParentDomain(currentDomain) {
|
|
797
|
-
return (0,
|
|
813
|
+
return (0, _hexclave_shared_dist_utils_redirect_urls.getTrustedParentDomain)(currentDomain, (await this._getTrustedRedirectConfig()).trustedDomains);
|
|
798
814
|
}
|
|
799
815
|
_getBrowserCookieTokenStore() {
|
|
800
|
-
if (!(0,
|
|
816
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)()) throw new Error("Cannot use cookie token store on the server!");
|
|
801
817
|
if (this._storedBrowserCookieTokenStore === null) {
|
|
802
818
|
const getCurrentValue = (old) => {
|
|
803
819
|
const tokens = this._getTokensFromCookies(this._getAllBrowserCookies());
|
|
@@ -806,13 +822,13 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
806
822
|
accessToken: tokens.accessToken ?? (old?.refreshToken === tokens.refreshToken ? old.accessToken : null)
|
|
807
823
|
};
|
|
808
824
|
};
|
|
809
|
-
this._storedBrowserCookieTokenStore = new
|
|
825
|
+
this._storedBrowserCookieTokenStore = new _hexclave_shared_dist_utils_stores.Store(getCurrentValue(null));
|
|
810
826
|
let hasSucceededInWriting = true;
|
|
811
827
|
setInterval(() => {
|
|
812
828
|
if (hasSucceededInWriting) {
|
|
813
829
|
const oldValue = this._storedBrowserCookieTokenStore.get();
|
|
814
830
|
const currentValue = getCurrentValue(oldValue);
|
|
815
|
-
if (!(0,
|
|
831
|
+
if (!(0, _hexclave_shared_dist_utils_objects.deepPlainEquals)(currentValue, oldValue)) this._storedBrowserCookieTokenStore.set(currentValue);
|
|
816
832
|
}
|
|
817
833
|
}, 100);
|
|
818
834
|
this._storedBrowserCookieTokenStore.onChange((value) => {
|
|
@@ -833,7 +849,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
833
849
|
this._queueCustomRefreshCookieUpdate(refreshToken, updatedAt, "browser");
|
|
834
850
|
hasSucceededInWriting = true;
|
|
835
851
|
} catch (e) {
|
|
836
|
-
if (!(0,
|
|
852
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)()) hasSucceededInWriting = false;
|
|
837
853
|
else throw e;
|
|
838
854
|
}
|
|
839
855
|
});
|
|
@@ -844,11 +860,11 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
844
860
|
const tokenStoreInit = overrideTokenStoreInit === void 0 ? this._tokenStoreInit : overrideTokenStoreInit;
|
|
845
861
|
switch (tokenStoreInit) {
|
|
846
862
|
case "cookie": return this._getBrowserCookieTokenStore();
|
|
847
|
-
case "nextjs-cookie": if ((0,
|
|
863
|
+
case "nextjs-cookie": if ((0, _hexclave_shared_dist_utils_env.isBrowserLike)()) return this._getBrowserCookieTokenStore();
|
|
848
864
|
else {
|
|
849
|
-
const store = new
|
|
865
|
+
const store = new _hexclave_shared_dist_utils_stores.Store(this._getTokensFromCookies(cookieHelper.getAll()));
|
|
850
866
|
store.onChange((value) => {
|
|
851
|
-
(0,
|
|
867
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
852
868
|
const refreshToken = value.refreshToken;
|
|
853
869
|
const secure = await (0, _________cookie_js.isSecure)();
|
|
854
870
|
const defaultName = this._getRefreshTokenDefaultCookieNameForSecure(secure);
|
|
@@ -881,7 +897,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
881
897
|
if (authorizationHeader) {
|
|
882
898
|
const authJson = getAuthJsonFromAuthorizationHeaderValue(authorizationHeader);
|
|
883
899
|
if (authJson != null) {
|
|
884
|
-
const tokenStore = new
|
|
900
|
+
const tokenStore = new _hexclave_shared_dist_utils_stores.Store({
|
|
885
901
|
accessToken: authJson.accessToken,
|
|
886
902
|
refreshToken: authJson.refreshToken
|
|
887
903
|
});
|
|
@@ -906,10 +922,10 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
906
922
|
}
|
|
907
923
|
const cookieHeader = getHeaderValueFromRequestLikeHeaders(tokenStoreInit.headers, "cookie");
|
|
908
924
|
const parsed = cookie.parseCookie(cookieHeader || "");
|
|
909
|
-
const res = new
|
|
925
|
+
const res = new _hexclave_shared_dist_utils_stores.Store(this._getTokensFromCookies(parsed));
|
|
910
926
|
this._requestTokenStores.set(tokenStoreInit, res);
|
|
911
927
|
return res;
|
|
912
|
-
} else if ("accessToken" in tokenStoreInit || "refreshToken" in tokenStoreInit) return new
|
|
928
|
+
} else if ("accessToken" in tokenStoreInit || "refreshToken" in tokenStoreInit) return new _hexclave_shared_dist_utils_stores.Store({
|
|
913
929
|
refreshToken: tokenStoreInit.refreshToken,
|
|
914
930
|
accessToken: tokenStoreInit.accessToken
|
|
915
931
|
});
|
|
@@ -917,13 +933,13 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
917
933
|
}
|
|
918
934
|
}
|
|
919
935
|
_useTokenStore(overrideTokenStoreInit) {
|
|
920
|
-
(0,
|
|
936
|
+
(0, _hexclave_shared_dist_utils_react.suspendIfSsr)();
|
|
921
937
|
const cookieHelper = (0, _________cookie_js.createBrowserCookieHelper)();
|
|
922
938
|
return this._getOrCreateTokenStore(cookieHelper, overrideTokenStoreInit);
|
|
923
939
|
}
|
|
924
940
|
_getSessionFromTokenStore(tokenStore) {
|
|
925
941
|
const tokenObj = tokenStore.get();
|
|
926
|
-
const sessionKey =
|
|
942
|
+
const sessionKey = _hexclave_shared_dist_sessions.InternalSession.calculateSessionKey(tokenObj);
|
|
927
943
|
const existing = sessionKey ? this._sessionsByTokenStoreAndSessionKey.get(tokenStore)?.get(sessionKey) : null;
|
|
928
944
|
if (existing) return existing;
|
|
929
945
|
const session = this._interface.createSession({
|
|
@@ -967,7 +983,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
967
983
|
return react.default.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
968
984
|
}
|
|
969
985
|
async _signInToAccountWithTokens(tokens) {
|
|
970
|
-
if (!("accessToken" in tokens) || !("refreshToken" in tokens)) throw new
|
|
986
|
+
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
987
|
const tokenStore = this._getOrCreateTokenStore(await this._createCookieHelper());
|
|
972
988
|
tokenStore.set(tokens);
|
|
973
989
|
const newSession = this._getSessionFromTokenStore(tokenStore);
|
|
@@ -1107,13 +1123,13 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1107
1123
|
await app._teamInvitationsCache.refresh([session, crud.id]);
|
|
1108
1124
|
},
|
|
1109
1125
|
async listUsers() {
|
|
1110
|
-
return
|
|
1126
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._teamMemberProfilesCache.getOrWait([session, crud.id], "write-only")).map((crud) => app._clientTeamUserFromCrud(crud));
|
|
1111
1127
|
},
|
|
1112
1128
|
useUsers() {
|
|
1113
1129
|
return (0, __common_js.useAsyncCache)(app._teamMemberProfilesCache, [session, crud.id], "team.useUsers()").map((crud) => app._clientTeamUserFromCrud(crud));
|
|
1114
1130
|
},
|
|
1115
1131
|
async listInvitations() {
|
|
1116
|
-
return
|
|
1132
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._teamInvitationsCache.getOrWait([session, crud.id], "write-only")).map((crud) => app._clientSentTeamInvitationFromCrud(session, crud));
|
|
1117
1133
|
},
|
|
1118
1134
|
useInvitations() {
|
|
1119
1135
|
return (0, __common_js.useAsyncCache)(app._teamInvitationsCache, [session, crud.id], "team.useInvitations()").map((crud) => app._clientSentTeamInvitationFromCrud(session, crud));
|
|
@@ -1133,7 +1149,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1133
1149
|
return (0, __common_js.useAsyncCache)(app._teamApiKeysCache, [session, crud.id], "team.useApiKeys()").map((crud) => app._clientApiKeyFromCrud(session, crud));
|
|
1134
1150
|
},
|
|
1135
1151
|
async listApiKeys() {
|
|
1136
|
-
return
|
|
1152
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._teamApiKeysCache.getOrWait([session, crud.id], "write-only")).map((crud) => app._clientApiKeyFromCrud(session, crud));
|
|
1137
1153
|
},
|
|
1138
1154
|
async createApiKey(options) {
|
|
1139
1155
|
const result = await app._interface.createProjectApiKey(await (0, ______api_keys_index_js.apiKeyCreationOptionsToCrud)("team", crud.id, options), session, "client");
|
|
@@ -1193,9 +1209,9 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1193
1209
|
allow_connected_accounts: data.allowConnectedAccounts
|
|
1194
1210
|
}, session);
|
|
1195
1211
|
await Promise.all([app._currentUserOAuthProvidersCache.refresh([session]), app._currentUserConnectedAccountsCache.refresh([session])]);
|
|
1196
|
-
return
|
|
1212
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
1197
1213
|
} catch (error) {
|
|
1198
|
-
if (
|
|
1214
|
+
if (_hexclave_shared.KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn.isInstance(error)) return _hexclave_shared_dist_utils_results.Result.error(error);
|
|
1199
1215
|
throw error;
|
|
1200
1216
|
}
|
|
1201
1217
|
},
|
|
@@ -1275,7 +1291,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1275
1291
|
return session.isKnownToBeInvalid() ? null : session.getAccessTokenIfNotExpiredYet(2e4, 75e3)?.token ?? null;
|
|
1276
1292
|
}, [session]);
|
|
1277
1293
|
let accessToken = react.default.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
1278
|
-
if (accessToken === null && !session.isKnownToBeInvalid()) accessToken = (0,
|
|
1294
|
+
if (accessToken === null && !session.isKnownToBeInvalid()) accessToken = (0, _hexclave_shared_dist_utils_react.use)(session.getOrFetchLikelyValidTokens(2e4, 75e3))?.accessToken.token ?? null;
|
|
1279
1295
|
return {
|
|
1280
1296
|
accessToken,
|
|
1281
1297
|
refreshToken: session.getRefreshToken()?.token ?? null
|
|
@@ -1365,11 +1381,11 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1365
1381
|
const scopeString = options?.scopes?.join(" ") ?? "";
|
|
1366
1382
|
if (typeof idOrAccount === "object" && "provider" in idOrAccount && "providerAccountId" in idOrAccount) {
|
|
1367
1383
|
const { provider, providerAccountId } = idOrAccount;
|
|
1368
|
-
const found =
|
|
1384
|
+
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
1385
|
if (!found) return null;
|
|
1370
1386
|
return found;
|
|
1371
1387
|
}
|
|
1372
|
-
return
|
|
1388
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserOAuthConnectionCache.getOrWait([
|
|
1373
1389
|
session,
|
|
1374
1390
|
idOrAccount,
|
|
1375
1391
|
scopeString,
|
|
@@ -1408,7 +1424,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1408
1424
|
getConnectedAccount,
|
|
1409
1425
|
useConnectedAccount,
|
|
1410
1426
|
async listConnectedAccounts() {
|
|
1411
|
-
return
|
|
1427
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserConnectedAccountsCache.getOrWait([session], "write-only"));
|
|
1412
1428
|
},
|
|
1413
1429
|
useConnectedAccounts() {
|
|
1414
1430
|
return (0, __common_js.useAsyncCache)(app._currentUserConnectedAccountsCache, [session], "user.useConnectedAccounts()");
|
|
@@ -1419,16 +1435,16 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1419
1435
|
provider,
|
|
1420
1436
|
redirectUrl: app._getOAuthCallbackRedirectUri(),
|
|
1421
1437
|
errorRedirectUrl: app.urls.error,
|
|
1422
|
-
providerScope: (0,
|
|
1438
|
+
providerScope: (0, _hexclave_shared_dist_utils_strings.mergeScopeStrings)(scopeString, (app._oauthScopesOnSignIn[provider] ?? []).join(" "))
|
|
1423
1439
|
}, session);
|
|
1424
1440
|
await app._redirectTo({ url: location });
|
|
1425
|
-
return await (0,
|
|
1441
|
+
return await (0, _hexclave_shared_dist_utils_promises.neverResolve)();
|
|
1426
1442
|
},
|
|
1427
1443
|
async getOrLinkConnectedAccount(provider, options) {
|
|
1428
|
-
const matchingAccounts =
|
|
1444
|
+
const matchingAccounts = _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserConnectedAccountsCache.getOrWait([session], "write-only")).filter((a) => a.provider === provider);
|
|
1429
1445
|
for (const account of matchingAccounts) if ((await account.getAccessToken({ scopes: options?.scopes })).status === "ok") return account;
|
|
1430
1446
|
await this.linkConnectedAccount(provider, options);
|
|
1431
|
-
return await (0,
|
|
1447
|
+
return await (0, _hexclave_shared_dist_utils_promises.neverResolve)();
|
|
1432
1448
|
},
|
|
1433
1449
|
useOrLinkConnectedAccount(provider, options) {
|
|
1434
1450
|
const scopeString = options?.scopes?.join(" ") ?? "";
|
|
@@ -1448,7 +1464,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1448
1464
|
}, [teams, teamId]);
|
|
1449
1465
|
},
|
|
1450
1466
|
async listTeams() {
|
|
1451
|
-
return
|
|
1467
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserTeamsCache.getOrWait([session], "write-only")).map((crud) => app._clientTeamFromCrud(crud, session));
|
|
1452
1468
|
},
|
|
1453
1469
|
useTeams() {
|
|
1454
1470
|
const teams = (0, __common_js.useAsyncCache)(app._currentUserTeamsCache, [session], "user.useTeams()");
|
|
@@ -1464,7 +1480,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1464
1480
|
await app._interface.leaveTeam(team.id, session);
|
|
1465
1481
|
},
|
|
1466
1482
|
async listTeamInvitations() {
|
|
1467
|
-
return
|
|
1483
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserTeamInvitationsCache.getOrWait([session], "write-only")).map((crud) => app._clientReceivedTeamInvitationFromCrud(session, crud));
|
|
1468
1484
|
},
|
|
1469
1485
|
useTeamInvitations() {
|
|
1470
1486
|
const invitations = (0, __common_js.useAsyncCache)(app._currentUserTeamInvitationsCache, [session], "user.useTeamInvitations()");
|
|
@@ -1474,14 +1490,14 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1474
1490
|
if (scopeOrOptions && "id" in scopeOrOptions) {
|
|
1475
1491
|
const scope = scopeOrOptions;
|
|
1476
1492
|
const recursive = options?.recursive ?? true;
|
|
1477
|
-
return
|
|
1493
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserPermissionsCache.getOrWait([
|
|
1478
1494
|
session,
|
|
1479
1495
|
scope.id,
|
|
1480
1496
|
recursive
|
|
1481
1497
|
], "write-only")).map((crud) => app._clientPermissionFromCrud(crud));
|
|
1482
1498
|
} else {
|
|
1483
1499
|
const recursive = scopeOrOptions?.recursive ?? true;
|
|
1484
|
-
return
|
|
1500
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserProjectPermissionsCache.getOrWait([session, recursive], "write-only")).map((crud) => app._clientPermissionFromCrud(crud));
|
|
1485
1501
|
}
|
|
1486
1502
|
},
|
|
1487
1503
|
usePermissions(scopeOrOptions, options) {
|
|
@@ -1533,7 +1549,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1533
1549
|
return await app._updateClientUser(update, session);
|
|
1534
1550
|
},
|
|
1535
1551
|
async sendVerificationEmail(options) {
|
|
1536
|
-
if (!crud.primary_email) throw new
|
|
1552
|
+
if (!crud.primary_email) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("User does not have a primary email");
|
|
1537
1553
|
return await app._interface.sendVerificationEmail(crud.primary_email, options?.callbackUrl ?? (0, ____________utils_url_js.constructRedirectUrl)(app.urls.emailVerification, "callbackUrl"), session);
|
|
1538
1554
|
},
|
|
1539
1555
|
async updatePassword(options) {
|
|
@@ -1548,7 +1564,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1548
1564
|
},
|
|
1549
1565
|
selectedTeam: crud.selected_team && this._clientTeamFromCrud(crud.selected_team, session),
|
|
1550
1566
|
async getTeamProfile(team) {
|
|
1551
|
-
const result =
|
|
1567
|
+
const result = _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserTeamProfileCache.getOrWait([session, team.id], "write-only"));
|
|
1552
1568
|
return app._editableTeamProfileFromCrud(result, session);
|
|
1553
1569
|
},
|
|
1554
1570
|
useTeamProfile(team) {
|
|
@@ -1560,7 +1576,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1560
1576
|
session.markInvalid();
|
|
1561
1577
|
},
|
|
1562
1578
|
async listContactChannels() {
|
|
1563
|
-
return
|
|
1579
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._clientContactChannelsCache.getOrWait([session], "write-only")).map((crud) => app._clientContactChannelFromCrud(crud, session));
|
|
1564
1580
|
},
|
|
1565
1581
|
useContactChannels() {
|
|
1566
1582
|
return (0, __common_js.useAsyncCache)(app._clientContactChannelsCache, [session], "user.useContactChannels()").map((crud) => app._clientContactChannelFromCrud(crud, session));
|
|
@@ -1574,7 +1590,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1574
1590
|
return (0, __common_js.useAsyncCache)(app._notificationCategoriesCache, [session], "user.useNotificationCategories()").map((crud) => app._clientNotificationCategoryFromCrud(crud, session));
|
|
1575
1591
|
},
|
|
1576
1592
|
async listNotificationCategories() {
|
|
1577
|
-
return
|
|
1593
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._notificationCategoriesCache.getOrWait([session], "write-only")).map((crud) => app._clientNotificationCategoryFromCrud(crud, session));
|
|
1578
1594
|
},
|
|
1579
1595
|
useApiKeys() {
|
|
1580
1596
|
return (0, __common_js.useAsyncCache)(app._userApiKeysCache, [session], "user.useApiKeys()").map((crud) => app._clientApiKeyFromCrud(session, crud));
|
|
@@ -1591,7 +1607,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1591
1607
|
return (0, __common_js.useAsyncCache)(app._currentUserOAuthProvidersCache, [session], "user.useOAuthProviders()").map((crud) => app._clientOAuthProviderFromCrud(crud, session));
|
|
1592
1608
|
},
|
|
1593
1609
|
async listOAuthProviders() {
|
|
1594
|
-
return
|
|
1610
|
+
return _hexclave_shared_dist_utils_results.Result.orThrow(await app._currentUserOAuthProvidersCache.getOrWait([session], "write-only")).map((crud) => app._clientOAuthProviderFromCrud(crud, session));
|
|
1595
1611
|
},
|
|
1596
1612
|
useOAuthProvider(id) {
|
|
1597
1613
|
const providers = this.useOAuthProviders();
|
|
@@ -1602,20 +1618,20 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1602
1618
|
},
|
|
1603
1619
|
async registerPasskey(options) {
|
|
1604
1620
|
const hostname = (await app._getCurrentUrl())?.hostname;
|
|
1605
|
-
if (!hostname) throw new
|
|
1621
|
+
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
1622
|
const initiationResult = await app._interface.initiatePasskeyRegistration({}, session);
|
|
1607
|
-
if (initiationResult.status !== "ok") return
|
|
1623
|
+
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
1624
|
const { options_json, code } = initiationResult.data;
|
|
1609
|
-
if (options_json.rp.id !== "THIS_VALUE_WILL_BE_REPLACED.example.com") throw new
|
|
1625
|
+
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
1626
|
options_json.rp.id = hostname;
|
|
1611
1627
|
let attResp;
|
|
1612
1628
|
try {
|
|
1613
1629
|
attResp = await (0, _simplewebauthn_browser.startRegistration)({ optionsJSON: options_json });
|
|
1614
1630
|
} catch (error) {
|
|
1615
|
-
if (error instanceof _simplewebauthn_browser.WebAuthnError) return
|
|
1631
|
+
if (error instanceof _simplewebauthn_browser.WebAuthnError) return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.PasskeyWebAuthnError(error.message, error.name));
|
|
1616
1632
|
else {
|
|
1617
|
-
(0,
|
|
1618
|
-
return
|
|
1633
|
+
(0, _hexclave_shared_dist_utils_errors.captureError)("passkey-registration-failed", error);
|
|
1634
|
+
return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.PasskeyRegistrationFailed("Failed to start passkey registration due to unknown error"));
|
|
1619
1635
|
}
|
|
1620
1636
|
}
|
|
1621
1637
|
const registrationResult = await app._interface.registerPasskey({
|
|
@@ -1652,7 +1668,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1652
1668
|
const customerOptions = type === "user" ? { userId: userIdOrTeamId } : { teamId: userIdOrTeamId };
|
|
1653
1669
|
return {
|
|
1654
1670
|
async getBilling() {
|
|
1655
|
-
const response =
|
|
1671
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await app._customerBillingCache.getOrWait([
|
|
1656
1672
|
effectiveSession,
|
|
1657
1673
|
type,
|
|
1658
1674
|
userIdOrTeamId
|
|
@@ -1744,17 +1760,17 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1744
1760
|
async getItem(options) {
|
|
1745
1761
|
const session = await this._getSession();
|
|
1746
1762
|
let crud;
|
|
1747
|
-
if ("userId" in options) crud =
|
|
1763
|
+
if ("userId" in options) crud = _hexclave_shared_dist_utils_results.Result.orThrow(await this._userItemCache.getOrWait([
|
|
1748
1764
|
session,
|
|
1749
1765
|
options.userId,
|
|
1750
1766
|
options.itemId
|
|
1751
1767
|
], "write-only"));
|
|
1752
|
-
else if ("teamId" in options) crud =
|
|
1768
|
+
else if ("teamId" in options) crud = _hexclave_shared_dist_utils_results.Result.orThrow(await this._teamItemCache.getOrWait([
|
|
1753
1769
|
session,
|
|
1754
1770
|
options.teamId,
|
|
1755
1771
|
options.itemId
|
|
1756
1772
|
], "write-only"));
|
|
1757
|
-
else crud =
|
|
1773
|
+
else crud = _hexclave_shared_dist_utils_results.Result.orThrow(await this._customItemCache.getOrWait([
|
|
1758
1774
|
session,
|
|
1759
1775
|
options.customCustomerId,
|
|
1760
1776
|
options.itemId
|
|
@@ -1774,7 +1790,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1774
1790
|
async listProducts(options) {
|
|
1775
1791
|
const session = (await this.getUser())?._internalSession ?? await this._getSession();
|
|
1776
1792
|
if ("userId" in options) {
|
|
1777
|
-
const response =
|
|
1793
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await this._userProductsCache.getOrWait([
|
|
1778
1794
|
session,
|
|
1779
1795
|
options.userId,
|
|
1780
1796
|
options.cursor ?? null,
|
|
@@ -1782,7 +1798,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1782
1798
|
], "write-only"));
|
|
1783
1799
|
return this._customerProductsFromResponse(response);
|
|
1784
1800
|
} else if ("teamId" in options) {
|
|
1785
|
-
const response =
|
|
1801
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await this._teamProductsCache.getOrWait([
|
|
1786
1802
|
session,
|
|
1787
1803
|
options.teamId,
|
|
1788
1804
|
options.cursor ?? null,
|
|
@@ -1790,7 +1806,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1790
1806
|
], "write-only"));
|
|
1791
1807
|
return this._customerProductsFromResponse(response);
|
|
1792
1808
|
}
|
|
1793
|
-
const response =
|
|
1809
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await this._customProductsCache.getOrWait([
|
|
1794
1810
|
session,
|
|
1795
1811
|
options.customCustomerId,
|
|
1796
1812
|
options.cursor ?? null,
|
|
@@ -1801,7 +1817,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1801
1817
|
async listInvoices(options) {
|
|
1802
1818
|
const session = await this._getSession();
|
|
1803
1819
|
if ("userId" in options) {
|
|
1804
|
-
const response =
|
|
1820
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await this._userInvoicesCache.getOrWait([
|
|
1805
1821
|
session,
|
|
1806
1822
|
options.userId,
|
|
1807
1823
|
options.cursor ?? null,
|
|
@@ -1809,7 +1825,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1809
1825
|
], "write-only"));
|
|
1810
1826
|
return this._customerInvoicesFromResponse(response);
|
|
1811
1827
|
}
|
|
1812
|
-
const response =
|
|
1828
|
+
const response = _hexclave_shared_dist_utils_results.Result.orThrow(await this._teamInvoicesCache.getOrWait([
|
|
1813
1829
|
session,
|
|
1814
1830
|
options.teamId,
|
|
1815
1831
|
options.cursor ?? null,
|
|
@@ -1820,7 +1836,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1820
1836
|
async cancelSubscription(options) {
|
|
1821
1837
|
const session = await this._getSession();
|
|
1822
1838
|
const user = await this.getUser();
|
|
1823
|
-
if (!user) throw new
|
|
1839
|
+
if (!user) throw new _hexclave_shared.KnownErrors.UserAuthenticationRequired();
|
|
1824
1840
|
const customerType = "teamId" in options ? "team" : "user";
|
|
1825
1841
|
const customerId = "teamId" in options ? options.teamId : user.id;
|
|
1826
1842
|
await this._interface.cancelSubscription({
|
|
@@ -1889,7 +1905,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1889
1905
|
return __common_js.clientVersion;
|
|
1890
1906
|
}
|
|
1891
1907
|
_getBotChallengeSiteKeys() {
|
|
1892
|
-
if (!(0,
|
|
1908
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)()) return null;
|
|
1893
1909
|
const visibleSiteKey = _________env_js.envVars.NEXT_PUBLIC_STACK_BOT_CHALLENGE_SITE_KEY;
|
|
1894
1910
|
if (!visibleSiteKey) {
|
|
1895
1911
|
if (!this._botChallengeSiteKeysWarned) {
|
|
@@ -1904,23 +1920,23 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1904
1920
|
};
|
|
1905
1921
|
}
|
|
1906
1922
|
_getBotChallengeFlowFailure(error) {
|
|
1907
|
-
if (error instanceof
|
|
1923
|
+
if (error instanceof _hexclave_shared_dist_utils_turnstile_flow.BotChallengeUserCancelledError) return {
|
|
1908
1924
|
type: "cancelled",
|
|
1909
|
-
knownError: new
|
|
1925
|
+
knownError: new _hexclave_shared.KnownErrors.BotChallengeFailed("Bot challenge cancelled by user")
|
|
1910
1926
|
};
|
|
1911
|
-
if (error instanceof
|
|
1927
|
+
if (error instanceof _hexclave_shared_dist_utils_turnstile_flow.BotChallengeExecutionFailedError) return {
|
|
1912
1928
|
type: "failed",
|
|
1913
|
-
knownError: new
|
|
1929
|
+
knownError: new _hexclave_shared.KnownErrors.BotChallengeFailed(error.message)
|
|
1914
1930
|
};
|
|
1915
1931
|
return null;
|
|
1916
1932
|
}
|
|
1917
1933
|
_normalizeBotChallengeResult(result) {
|
|
1918
1934
|
if (result.status === "ok") return result;
|
|
1919
|
-
if (
|
|
1920
|
-
(0,
|
|
1921
|
-
return
|
|
1935
|
+
if (_hexclave_shared.KnownErrors.BotChallengeRequired.isInstance(result.error)) {
|
|
1936
|
+
(0, _hexclave_shared_dist_utils_errors.captureError)("bot-challenge-unexpected-after-flow", result.error);
|
|
1937
|
+
return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.BotChallengeFailed("Unexpected bot challenge after flow completion"));
|
|
1922
1938
|
}
|
|
1923
|
-
return
|
|
1939
|
+
return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
1924
1940
|
}
|
|
1925
1941
|
_toInterfaceBotChallengeInput(challenge) {
|
|
1926
1942
|
if (challenge.unavailable) return { phase: "visible" };
|
|
@@ -1933,25 +1949,25 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1933
1949
|
const siteKeys = this._getBotChallengeSiteKeys();
|
|
1934
1950
|
let result;
|
|
1935
1951
|
try {
|
|
1936
|
-
if (siteKeys) result = await (0,
|
|
1952
|
+
if (siteKeys) result = await (0, _hexclave_shared_dist_utils_turnstile_flow.withBotChallengeFlow)({
|
|
1937
1953
|
...siteKeys,
|
|
1938
1954
|
action: options.action,
|
|
1939
1955
|
execute: options.execute,
|
|
1940
1956
|
isChallengeRequired: (flowResult) => {
|
|
1941
|
-
return flowResult.status === "error" &&
|
|
1957
|
+
return flowResult.status === "error" && _hexclave_shared.KnownErrors.BotChallengeRequired.isInstance(flowResult.error);
|
|
1942
1958
|
}
|
|
1943
1959
|
});
|
|
1944
1960
|
else result = await options.execute({});
|
|
1945
1961
|
} catch (e) {
|
|
1946
1962
|
const flowFailure = this._getBotChallengeFlowFailure(e);
|
|
1947
|
-
if (flowFailure) return
|
|
1963
|
+
if (flowFailure) return _hexclave_shared_dist_utils_results.Result.error(flowFailure.knownError);
|
|
1948
1964
|
throw e;
|
|
1949
1965
|
}
|
|
1950
1966
|
return this._normalizeBotChallengeResult(result);
|
|
1951
1967
|
}
|
|
1952
1968
|
async _isTrusted(url) {
|
|
1953
|
-
if ((0,
|
|
1954
|
-
const parsedUrl = (0,
|
|
1969
|
+
if ((0, _hexclave_shared_dist_utils_urls.isRelative)(url)) return true;
|
|
1970
|
+
const parsedUrl = (0, _hexclave_shared_dist_utils_urls.createUrlIfValid)(url);
|
|
1955
1971
|
if (parsedUrl == null) return false;
|
|
1956
1972
|
if (typeof window !== "undefined" && window.location.origin === parsedUrl.origin) return true;
|
|
1957
1973
|
if ((0, ______url_targets_js.isHostedHandlerUrlForProject)({
|
|
@@ -1959,7 +1975,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1959
1975
|
projectId: this.projectId
|
|
1960
1976
|
})) return true;
|
|
1961
1977
|
const trustedRedirectConfig = await this._getTrustedRedirectConfig();
|
|
1962
|
-
return (0,
|
|
1978
|
+
return (0, _hexclave_shared_dist_utils_redirect_urls.validateRedirectUrl)(parsedUrl, {
|
|
1963
1979
|
allowLocalhost: trustedRedirectConfig.allowLocalhost,
|
|
1964
1980
|
trustedDomains: trustedRedirectConfig.trustedDomains
|
|
1965
1981
|
});
|
|
@@ -1969,11 +1985,11 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
1969
1985
|
}
|
|
1970
1986
|
_prefetchCrossDomainHandoffParamsIfNeeded() {
|
|
1971
1987
|
const canWriteOauthVerifierCookie = this._tokenStoreInit === "cookie" || this._tokenStoreInit === "nextjs-cookie";
|
|
1972
|
-
if (!(0,
|
|
1988
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)() || !canWriteOauthVerifierCookie || this._isPrefetchingCrossDomainHandoffParams || this._getFreshPrefetchedCrossDomainHandoffParams() != null) return;
|
|
1973
1989
|
this._isPrefetchingCrossDomainHandoffParams = true;
|
|
1974
|
-
(0,
|
|
1990
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
1975
1991
|
try {
|
|
1976
|
-
if (!(0,
|
|
1992
|
+
if (!(0, _hexclave_shared_dist_utils_env.isBrowserLike)()) return;
|
|
1977
1993
|
const { state, codeChallenge } = await (0, _________cookie_js.saveVerifierAndState)();
|
|
1978
1994
|
this._prefetchedCrossDomainHandoffParams = {
|
|
1979
1995
|
state,
|
|
@@ -2035,10 +2051,10 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2035
2051
|
}, session);
|
|
2036
2052
|
if (!response.ok) {
|
|
2037
2053
|
const responseBody = await response.text();
|
|
2038
|
-
throw new
|
|
2054
|
+
throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError(`Cross-domain authorization endpoint failed: ${response.status} ${responseBody}`);
|
|
2039
2055
|
}
|
|
2040
2056
|
const result = await response.json();
|
|
2041
|
-
if (!("redirect_url" in result) || typeof result.redirect_url !== "string") throw new
|
|
2057
|
+
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
2058
|
return result.redirect_url;
|
|
2043
2059
|
}
|
|
2044
2060
|
_getFreshPrefetchedCrossDomainHandoffParams() {
|
|
@@ -2059,7 +2075,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2059
2075
|
else if (typeof this._redirectMethod === "object" && this._redirectMethod.navigate) this._redirectMethod.navigate(options.url.toString());
|
|
2060
2076
|
else if (options.replace) window.location.replace(options.url);
|
|
2061
2077
|
else window.location.assign(options.url);
|
|
2062
|
-
await (0,
|
|
2078
|
+
await (0, _hexclave_shared_dist_utils_promises.wait)(2e3);
|
|
2063
2079
|
}
|
|
2064
2080
|
useNavigate() {
|
|
2065
2081
|
if (typeof this._redirectMethod === "object") return this._redirectMethod.useNavigate();
|
|
@@ -2196,8 +2212,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2196
2212
|
code,
|
|
2197
2213
|
session: await this._getSession()
|
|
2198
2214
|
});
|
|
2199
|
-
if (result.status === "ok") return
|
|
2200
|
-
else return
|
|
2215
|
+
if (result.status === "ok") return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2216
|
+
else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2201
2217
|
}
|
|
2202
2218
|
async getTeamInvitationDetails(code) {
|
|
2203
2219
|
const result = await this._interface.acceptTeamInvitation({
|
|
@@ -2205,8 +2221,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2205
2221
|
code,
|
|
2206
2222
|
session: await this._getSession()
|
|
2207
2223
|
});
|
|
2208
|
-
if (result.status === "ok") return
|
|
2209
|
-
else return
|
|
2224
|
+
if (result.status === "ok") return _hexclave_shared_dist_utils_results.Result.ok({ teamDisplayName: result.data.team_display_name });
|
|
2225
|
+
else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2210
2226
|
}
|
|
2211
2227
|
async verifyEmail(code) {
|
|
2212
2228
|
const result = await this._interface.verifyEmail(code);
|
|
@@ -2218,7 +2234,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2218
2234
|
if (options?.or === "anonymous" && options.includeRestricted === false) throw new Error("Cannot use { or: 'anonymous' } with { includeRestricted: false }. Anonymous users implicitly include restricted users.");
|
|
2219
2235
|
this._ensurePersistentTokenStore(options?.tokenStore);
|
|
2220
2236
|
const session = await this._getSession(options?.tokenStore);
|
|
2221
|
-
let crud =
|
|
2237
|
+
let crud = _hexclave_shared_dist_utils_results.Result.orThrow(await this._currentUserCache.getOrWait([session], "write-only"));
|
|
2222
2238
|
const includeAnonymous = options?.or === "anonymous" || options?.or === "anonymous-if-exists[deprecated]";
|
|
2223
2239
|
const includeRestricted = options?.includeRestricted === true || includeAnonymous;
|
|
2224
2240
|
if (crud === null || crud.is_anonymous && !includeAnonymous || crud.is_restricted && !includeRestricted) switch (options?.or) {
|
|
@@ -2233,7 +2249,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2233
2249
|
tokenStore: tokens,
|
|
2234
2250
|
or: "anonymous-if-exists[deprecated]",
|
|
2235
2251
|
includeRestricted: true
|
|
2236
|
-
}) ?? (0,
|
|
2252
|
+
}) ?? (0, _hexclave_shared_dist_utils_errors.throwErr)("Something went wrong while signing up anonymously");
|
|
2237
2253
|
}
|
|
2238
2254
|
case void 0:
|
|
2239
2255
|
case "anonymous-if-exists[deprecated]":
|
|
@@ -2251,18 +2267,18 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2251
2267
|
if (crud === null || crud.is_anonymous && !includeAnonymous || crud.is_restricted && !includeRestricted) switch (options?.or) {
|
|
2252
2268
|
case "redirect":
|
|
2253
2269
|
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
|
|
2270
|
+
if (!this._redirectToHandlerDuringRender("onboarding", { replace: true })) (0, _hexclave_shared_dist_utils_promises.runAsynchronously)(this.redirectToOnboarding({ replace: true }));
|
|
2271
|
+
} else if (!this._redirectToHandlerDuringRender("signIn", { replace: true })) (0, _hexclave_shared_dist_utils_promises.runAsynchronously)(this.redirectToSignIn({ replace: true }));
|
|
2272
|
+
(0, _hexclave_shared_dist_utils_react.suspend)();
|
|
2273
|
+
throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("suspend should never return");
|
|
2258
2274
|
case "throw": throw new Error("User is not signed in but useUser was called with { or: 'throw' }");
|
|
2259
2275
|
case "anonymous":
|
|
2260
|
-
(0,
|
|
2276
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
2261
2277
|
await this._signUpAnonymously();
|
|
2262
2278
|
if (typeof window !== "undefined") window.location.reload();
|
|
2263
2279
|
});
|
|
2264
|
-
(0,
|
|
2265
|
-
throw new
|
|
2280
|
+
(0, _hexclave_shared_dist_utils_react.suspend)();
|
|
2281
|
+
throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("suspend should never return");
|
|
2266
2282
|
case void 0:
|
|
2267
2283
|
case "anonymous-if-exists[deprecated]":
|
|
2268
2284
|
case "return-null":
|
|
@@ -2368,12 +2384,12 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2368
2384
|
};
|
|
2369
2385
|
let authorizeResult;
|
|
2370
2386
|
try {
|
|
2371
|
-
if (siteKeys) authorizeResult = await (0,
|
|
2387
|
+
if (siteKeys) authorizeResult = await (0, _hexclave_shared_dist_utils_turnstile_flow.withBotChallengeFlow)({
|
|
2372
2388
|
...siteKeys,
|
|
2373
2389
|
action: "oauth_authenticate",
|
|
2374
2390
|
execute: executeOAuth,
|
|
2375
2391
|
isChallengeRequired: (result) => {
|
|
2376
|
-
return result.status === "error" &&
|
|
2392
|
+
return result.status === "error" && _hexclave_shared.KnownErrors.BotChallengeRequired.isInstance(result.error);
|
|
2377
2393
|
}
|
|
2378
2394
|
});
|
|
2379
2395
|
else authorizeResult = await executeOAuth({});
|
|
@@ -2383,17 +2399,17 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2383
2399
|
if (flowFailure?.type === "failed") throw flowFailure.knownError;
|
|
2384
2400
|
throw e;
|
|
2385
2401
|
}
|
|
2386
|
-
const location =
|
|
2402
|
+
const location = _hexclave_shared_dist_utils_results.Result.orThrow(authorizeResult);
|
|
2387
2403
|
await this._redirectTo({ url: location });
|
|
2388
|
-
await (0,
|
|
2404
|
+
await (0, _hexclave_shared_dist_utils_promises.neverResolve)();
|
|
2389
2405
|
}
|
|
2390
2406
|
/**
|
|
2391
2407
|
* Handles MFA verification by redirecting to the OTP page
|
|
2392
2408
|
*/
|
|
2393
2409
|
async _experimentalMfa(error, session) {
|
|
2394
|
-
if (typeof window !== "undefined") window.sessionStorage.setItem("hexclave_mfa_attempt_code", error.details?.attempt_code ?? (0,
|
|
2410
|
+
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
2411
|
await this.redirectToMfa();
|
|
2396
|
-
throw new
|
|
2412
|
+
throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("we should have redirected in redirectToMfa()");
|
|
2397
2413
|
}
|
|
2398
2414
|
/**
|
|
2399
2415
|
* @deprecated
|
|
@@ -2403,7 +2419,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2403
2419
|
try {
|
|
2404
2420
|
return await callback();
|
|
2405
2421
|
} catch (e) {
|
|
2406
|
-
if (
|
|
2422
|
+
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
2423
|
throw e;
|
|
2408
2424
|
}
|
|
2409
2425
|
}
|
|
@@ -2416,25 +2432,25 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2416
2432
|
return await this._interface.signInWithCredential(options.email, options.password, session);
|
|
2417
2433
|
});
|
|
2418
2434
|
} catch (e) {
|
|
2419
|
-
if (
|
|
2435
|
+
if (_hexclave_shared.KnownErrors.InvalidTotpCode.isInstance(e)) return _hexclave_shared_dist_utils_results.Result.error(e);
|
|
2420
2436
|
throw e;
|
|
2421
2437
|
}
|
|
2422
2438
|
if (result.status === "ok") {
|
|
2423
2439
|
await this._signInToAccountWithTokens(result.data);
|
|
2424
2440
|
if (!options.noRedirect) await this._redirectToHandler("afterSignIn", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2425
|
-
return
|
|
2426
|
-
} else return
|
|
2441
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2442
|
+
} else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2427
2443
|
}
|
|
2428
2444
|
async signUpWithCredential(options) {
|
|
2429
|
-
if (options.noVerificationCallback && options.verificationCallbackUrl) throw new
|
|
2445
|
+
if (options.noVerificationCallback && options.verificationCallbackUrl) throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("verificationCallbackUrl is not allowed when noVerificationCallback is true");
|
|
2430
2446
|
this._ensurePersistentTokenStore();
|
|
2431
2447
|
const session = await this._getSession();
|
|
2432
2448
|
const emailVerificationRedirectUrl = options.noVerificationCallback ? void 0 : options.verificationCallbackUrl ?? (0, ____________utils_url_js.constructRedirectUrl)(this.urls.emailVerification, "verificationCallbackUrl");
|
|
2433
2449
|
const executeSignUp = async (challenge) => {
|
|
2434
2450
|
let result = await this._interface.signUpWithCredential(options.email, options.password, emailVerificationRedirectUrl, session, this._toInterfaceBotChallengeInput(challenge));
|
|
2435
|
-
if (result.status === "error" && result.error instanceof
|
|
2451
|
+
if (result.status === "error" && result.error instanceof _hexclave_shared.KnownErrors.RedirectUrlNotWhitelisted && emailVerificationRedirectUrl !== void 0) {
|
|
2436
2452
|
if (!options.verificationCallbackUrl) {
|
|
2437
|
-
(0,
|
|
2453
|
+
(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
2454
|
result = await this._interface.signUpWithCredential(options.email, options.password, void 0, session, this._toInterfaceBotChallengeInput(challenge));
|
|
2439
2455
|
}
|
|
2440
2456
|
}
|
|
@@ -2448,8 +2464,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2448
2464
|
if (result.status === "ok") {
|
|
2449
2465
|
await this._signInToAccountWithTokens(result.data);
|
|
2450
2466
|
if (!options.noRedirect) await this._redirectToHandler("afterSignUp", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2451
|
-
return
|
|
2452
|
-
} else return
|
|
2467
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2468
|
+
} else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2453
2469
|
}
|
|
2454
2470
|
async _signUpAnonymously() {
|
|
2455
2471
|
this._ensurePersistentTokenStore();
|
|
@@ -2458,7 +2474,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2458
2474
|
const session = await this._getSession();
|
|
2459
2475
|
const result = await this._interface.signUpAnonymously(session);
|
|
2460
2476
|
if (result.status === "ok") await this._signInToAccountWithTokens(result.data);
|
|
2461
|
-
else throw new
|
|
2477
|
+
else throw new _hexclave_shared_dist_utils_errors.HexclaveAssertionError("signUpAnonymously() should never return an error");
|
|
2462
2478
|
this._anonymousSignUpInProgress = null;
|
|
2463
2479
|
return result.data;
|
|
2464
2480
|
})();
|
|
@@ -2473,7 +2489,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2473
2489
|
return await this._interface.signInWithMagicLink(code, session);
|
|
2474
2490
|
});
|
|
2475
2491
|
} catch (e) {
|
|
2476
|
-
if (
|
|
2492
|
+
if (_hexclave_shared.KnownErrors.InvalidTotpCode.isInstance(e)) return _hexclave_shared_dist_utils_results.Result.error(e);
|
|
2477
2493
|
throw e;
|
|
2478
2494
|
}
|
|
2479
2495
|
if (result.status === "ok") {
|
|
@@ -2486,8 +2502,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2486
2502
|
awaitPendingAuthResolutions: false,
|
|
2487
2503
|
overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data)
|
|
2488
2504
|
});
|
|
2489
|
-
return
|
|
2490
|
-
} else return
|
|
2505
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2506
|
+
} else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2491
2507
|
}
|
|
2492
2508
|
/**
|
|
2493
2509
|
* Initiates a CLI authentication process that allows a command line application
|
|
@@ -2518,7 +2534,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2518
2534
|
...options.anonRefreshToken != null ? { anon_refresh_token: options.anonRefreshToken } : {}
|
|
2519
2535
|
})
|
|
2520
2536
|
}, null);
|
|
2521
|
-
if (!response.ok) return
|
|
2537
|
+
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
2538
|
const initResult = await response.json();
|
|
2523
2539
|
const pollingCode = initResult.polling_code;
|
|
2524
2540
|
const loginCode = initResult.login_code;
|
|
@@ -2540,18 +2556,18 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2540
2556
|
headers: { "Content-Type": "application/json" },
|
|
2541
2557
|
body: JSON.stringify({ polling_code: pollingCode })
|
|
2542
2558
|
}, null);
|
|
2543
|
-
if (!pollResponse.ok) return
|
|
2559
|
+
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
2560
|
const pollResult = await pollResponse.json();
|
|
2545
|
-
if (pollResponse.status === 201 && pollResult.status === "success") return
|
|
2561
|
+
if (pollResponse.status === 201 && pollResult.status === "success") return _hexclave_shared_dist_utils_results.Result.ok(pollResult.refresh_token);
|
|
2546
2562
|
if (pollResult.status === "waiting") {
|
|
2547
|
-
await (0,
|
|
2563
|
+
await (0, _hexclave_shared_dist_utils_promises.wait)(options.waitTimeMillis ?? 2e3);
|
|
2548
2564
|
continue;
|
|
2549
2565
|
}
|
|
2550
|
-
if (pollResult.status === "expired") return
|
|
2551
|
-
if (pollResult.status === "used") return
|
|
2552
|
-
return
|
|
2566
|
+
if (pollResult.status === "expired") return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.CliAuthExpiredError("CLI authentication request expired. Please try again."));
|
|
2567
|
+
if (pollResult.status === "used") return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.CliAuthUsedError("This authentication token has already been used."));
|
|
2568
|
+
return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.CliAuthError(`Unexpected status from CLI auth polling: ${pollResult.status}`));
|
|
2553
2569
|
}
|
|
2554
|
-
return
|
|
2570
|
+
return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.CliAuthError("Timed out waiting for CLI authentication."));
|
|
2555
2571
|
}
|
|
2556
2572
|
async signInWithMfa(totp, code, options) {
|
|
2557
2573
|
this._ensurePersistentTokenStore();
|
|
@@ -2562,16 +2578,16 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2562
2578
|
return await this._interface.signInWithMfa(totp, code, session);
|
|
2563
2579
|
});
|
|
2564
2580
|
} catch (e) {
|
|
2565
|
-
if (e instanceof
|
|
2581
|
+
if (e instanceof _hexclave_shared.KnownErrors.InvalidTotpCode) return _hexclave_shared_dist_utils_results.Result.error(e);
|
|
2566
2582
|
throw e;
|
|
2567
2583
|
}
|
|
2568
2584
|
if (result.status === "ok") {
|
|
2569
2585
|
await this._signInToAccountWithTokens(result.data);
|
|
2570
2586
|
if (!options?.noRedirect) if (result.data.newUser) await this._redirectToHandler("afterSignUp", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2571
2587
|
else await this._redirectToHandler("afterSignIn", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2572
|
-
return
|
|
2588
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2573
2589
|
}
|
|
2574
|
-
return
|
|
2590
|
+
return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2575
2591
|
}
|
|
2576
2592
|
async signInWithPasskey() {
|
|
2577
2593
|
this._ensurePersistentTokenStore();
|
|
@@ -2580,9 +2596,9 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2580
2596
|
try {
|
|
2581
2597
|
result = await this._catchMfaRequiredError(async () => {
|
|
2582
2598
|
const initiationResult = await this._interface.initiatePasskeyAuthentication({}, session);
|
|
2583
|
-
if (initiationResult.status !== "ok") return
|
|
2599
|
+
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
2600
|
const { options_json, code } = initiationResult.data;
|
|
2585
|
-
if (options_json.rpId !== "THIS_VALUE_WILL_BE_REPLACED.example.com") throw new
|
|
2601
|
+
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
2602
|
options_json.rpId = window.location.hostname;
|
|
2587
2603
|
const authentication_response = await (0, _simplewebauthn_browser.startAuthentication)({ optionsJSON: options_json });
|
|
2588
2604
|
return await this._interface.signInWithPasskey({
|
|
@@ -2591,14 +2607,14 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2591
2607
|
}, session);
|
|
2592
2608
|
});
|
|
2593
2609
|
} catch (error) {
|
|
2594
|
-
if (error instanceof _simplewebauthn_browser.WebAuthnError) return
|
|
2595
|
-
else return
|
|
2610
|
+
if (error instanceof _simplewebauthn_browser.WebAuthnError) return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.PasskeyWebAuthnError(error.message, error.name));
|
|
2611
|
+
else return _hexclave_shared_dist_utils_results.Result.error(new _hexclave_shared.KnownErrors.PasskeyAuthenticationFailed("Failed to sign in with passkey"));
|
|
2596
2612
|
}
|
|
2597
2613
|
if (result.status === "ok") {
|
|
2598
2614
|
await this._signInToAccountWithTokens(result.data);
|
|
2599
2615
|
await this._redirectToHandler("afterSignIn", { replace: true }, { overrideTokenStoreInit: this._getTokenStoreInitForFreshTokens(result.data) });
|
|
2600
|
-
return
|
|
2601
|
-
} else return
|
|
2616
|
+
return _hexclave_shared_dist_utils_results.Result.ok(void 0);
|
|
2617
|
+
} else return _hexclave_shared_dist_utils_results.Result.error(result.error);
|
|
2602
2618
|
}
|
|
2603
2619
|
async callOAuthCallback(options) {
|
|
2604
2620
|
if (typeof window === "undefined") throw new Error("callOAuthCallback can currently only be called in a browser environment");
|
|
@@ -2616,7 +2632,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2616
2632
|
return await (0, _________auth_js.callOAuthCallback)(this._interface, oauthCallbackRedirectUri, options);
|
|
2617
2633
|
});
|
|
2618
2634
|
} catch (e) {
|
|
2619
|
-
if (
|
|
2635
|
+
if (_hexclave_shared.KnownErrors.InvalidTotpCode.isInstance(e)) {
|
|
2620
2636
|
alert("Invalid TOTP code. Please try signing in again.");
|
|
2621
2637
|
return false;
|
|
2622
2638
|
} else throw e;
|
|
@@ -2649,7 +2665,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2649
2665
|
async _signOut(session, options) {
|
|
2650
2666
|
this._eventTracker?.clearBuffer();
|
|
2651
2667
|
this._sessionRecorder?.clearBuffer();
|
|
2652
|
-
await
|
|
2668
|
+
await _hexclave_shared_dist_utils_stores.storeLock.withWriteLock(async () => {
|
|
2653
2669
|
await this._interface.signOut(session);
|
|
2654
2670
|
if (options?.redirectUrl) await this._redirectTo({
|
|
2655
2671
|
url: options.redirectUrl,
|
|
@@ -2711,7 +2727,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2711
2727
|
};
|
|
2712
2728
|
}
|
|
2713
2729
|
async getProject() {
|
|
2714
|
-
const crud =
|
|
2730
|
+
const crud = _hexclave_shared_dist_utils_results.Result.orThrow(await this._currentProjectCache.getOrWait([], "write-only"));
|
|
2715
2731
|
return this._clientProjectFromCrud(crud);
|
|
2716
2732
|
}
|
|
2717
2733
|
useProject() {
|
|
@@ -2720,7 +2736,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2720
2736
|
}
|
|
2721
2737
|
async _listOwnedProjects(session) {
|
|
2722
2738
|
this._ensureInternalProject();
|
|
2723
|
-
return
|
|
2739
|
+
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
2740
|
}
|
|
2725
2741
|
_useOwnedProjects(session) {
|
|
2726
2742
|
this._ensureInternalProject();
|
|
@@ -2750,17 +2766,17 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2750
2766
|
}
|
|
2751
2767
|
static get [______common_js.stackAppInternalsSymbol]() {
|
|
2752
2768
|
return { fromClientJson: (json) => {
|
|
2753
|
-
const providedCheckString = JSON.stringify((0,
|
|
2769
|
+
const providedCheckString = JSON.stringify((0, _hexclave_shared_dist_utils_objects.omit)(json, []));
|
|
2754
2770
|
const existing = allClientApps.get(json.uniqueIdentifier);
|
|
2755
2771
|
if (existing) {
|
|
2756
2772
|
const [existingCheckString, clientApp] = existing;
|
|
2757
|
-
if (existingCheckString !== void 0 && existingCheckString !== providedCheckString) throw new
|
|
2773
|
+
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
2774
|
providedObj: json,
|
|
2759
2775
|
existingString: existingCheckString
|
|
2760
2776
|
});
|
|
2761
2777
|
return clientApp;
|
|
2762
2778
|
}
|
|
2763
|
-
const { analytics, ...restJson } = (0,
|
|
2779
|
+
const { analytics, ...restJson } = (0, _hexclave_shared_dist_utils_objects.omit)(json, ["uniqueIdentifier"]);
|
|
2764
2780
|
return new _StackClientAppImplIncomplete({
|
|
2765
2781
|
...restJson,
|
|
2766
2782
|
analytics: (0, __session_replay_js.analyticsOptionsFromJson)(analytics)
|
|
@@ -2773,7 +2789,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2773
2789
|
get [______common_js.stackAppInternalsSymbol]() {
|
|
2774
2790
|
return {
|
|
2775
2791
|
toClientJson: () => {
|
|
2776
|
-
if (typeof this._redirectMethod !== "string") throw new
|
|
2792
|
+
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
2793
|
const publishableClientKey = "publishableClientKey" in this._interface.options ? this._interface.options.publishableClientKey : void 0;
|
|
2778
2794
|
return {
|
|
2779
2795
|
baseUrl: this._options.baseUrl,
|
|
@@ -2790,8 +2806,8 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2790
2806
|
};
|
|
2791
2807
|
},
|
|
2792
2808
|
setCurrentUser: (userJsonPromise) => {
|
|
2793
|
-
(0,
|
|
2794
|
-
await this._currentUserCache.forceSetCachedValueAsync([await this._getSession()],
|
|
2809
|
+
(0, _hexclave_shared_dist_utils_promises.runAsynchronously)(async () => {
|
|
2810
|
+
await this._currentUserCache.forceSetCachedValueAsync([await this._getSession()], _hexclave_shared_dist_utils_results.Result.fromPromise(userJsonPromise));
|
|
2795
2811
|
});
|
|
2796
2812
|
},
|
|
2797
2813
|
getConstructorOptions: () => this._options,
|
|
@@ -2807,7 +2823,7 @@ var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
|
2807
2823
|
sendRequest: async (path, requestOptions, requestType = "client") => {
|
|
2808
2824
|
return await this._interface.sendClientRequest(path, requestOptions, await this._getSession(), requestType);
|
|
2809
2825
|
},
|
|
2810
|
-
getRedirectMethod: () => this._redirectMethod ?? (0,
|
|
2826
|
+
getRedirectMethod: () => this._redirectMethod ?? (0, _hexclave_shared_dist_utils_errors.throwErr)("Redirect method should have been initialized in the Stack client app constructor"),
|
|
2811
2827
|
redirectToUrl: async (url, options) => {
|
|
2812
2828
|
await this._redirectTo({
|
|
2813
2829
|
url,
|