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