@stackframe/tanstack-start 0.0.1 → 2.8.91
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/LICENSE +7 -0
- package/README.md +26 -0
- package/dist/chunk-BE-pF4vm.js +34 -0
- package/dist/components/api-key-dialogs.d.ts +28 -0
- package/dist/components/api-key-dialogs.d.ts.map +1 -0
- package/dist/components/api-key-dialogs.js +163 -0
- package/dist/components/api-key-dialogs.js.map +1 -0
- package/dist/components/api-key-table.d.ts +10 -0
- package/dist/components/api-key-table.d.ts.map +1 -0
- package/dist/components/api-key-table.js +144 -0
- package/dist/components/api-key-table.js.map +1 -0
- package/dist/components/credential-sign-in.d.ts +7 -0
- package/dist/components/credential-sign-in.d.ts.map +1 -0
- package/dist/components/credential-sign-in.js +87 -0
- package/dist/components/credential-sign-in.js.map +1 -0
- package/dist/components/credential-sign-up.d.ts +9 -0
- package/dist/components/credential-sign-up.d.ts.map +1 -0
- package/dist/components/credential-sign-up.js +121 -0
- package/dist/components/credential-sign-up.js.map +1 -0
- package/dist/components/elements/form-warning.d.ts +11 -0
- package/dist/components/elements/form-warning.d.ts.map +1 -0
- package/dist/components/elements/form-warning.js +18 -0
- package/dist/components/elements/form-warning.js.map +1 -0
- package/dist/components/elements/maybe-full-page.d.ts +16 -0
- package/dist/components/elements/maybe-full-page.d.ts.map +1 -0
- package/dist/components/elements/maybe-full-page.js +41 -0
- package/dist/components/elements/maybe-full-page.js.map +1 -0
- package/dist/components/elements/separator-with-text.d.ts +11 -0
- package/dist/components/elements/separator-with-text.d.ts.map +1 -0
- package/dist/components/elements/separator-with-text.js +31 -0
- package/dist/components/elements/separator-with-text.js.map +1 -0
- package/dist/components/elements/sidebar-layout.d.ts +21 -0
- package/dist/components/elements/sidebar-layout.d.ts.map +1 -0
- package/dist/components/elements/sidebar-layout.js +135 -0
- package/dist/components/elements/sidebar-layout.js.map +1 -0
- package/dist/components/elements/ssr-layout-effect.d.ts +10 -0
- package/dist/components/elements/ssr-layout-effect.d.ts.map +1 -0
- package/dist/components/elements/ssr-layout-effect.js +22 -0
- package/dist/components/elements/ssr-layout-effect.js.map +1 -0
- package/dist/components/elements/user-avatar.d.ts +15 -0
- package/dist/components/elements/user-avatar.d.ts.map +1 -0
- package/dist/components/elements/user-avatar.js +30 -0
- package/dist/components/elements/user-avatar.js.map +1 -0
- package/dist/components/link.d.ts +16 -0
- package/dist/components/link.d.ts.map +1 -0
- package/dist/components/link.js +29 -0
- package/dist/components/link.js.map +1 -0
- package/dist/components/magic-link-sign-in.d.ts +7 -0
- package/dist/components/magic-link-sign-in.d.ts.map +1 -0
- package/dist/components/magic-link-sign-in.js +138 -0
- package/dist/components/magic-link-sign-in.js.map +1 -0
- package/dist/components/message-cards/known-error-message-card.d.ts +14 -0
- package/dist/components/message-cards/known-error-message-card.d.ts.map +1 -0
- package/dist/components/message-cards/known-error-message-card.js +24 -0
- package/dist/components/message-cards/known-error-message-card.js.map +1 -0
- package/dist/components/message-cards/message-card.d.ts +19 -0
- package/dist/components/message-cards/message-card.d.ts.map +1 -0
- package/dist/components/message-cards/message-card.js +46 -0
- package/dist/components/message-cards/message-card.js.map +1 -0
- package/dist/components/message-cards/predefined-message-card.d.ts +13 -0
- package/dist/components/message-cards/predefined-message-card.d.ts.map +1 -0
- package/dist/components/message-cards/predefined-message-card.js +73 -0
- package/dist/components/message-cards/predefined-message-card.js.map +1 -0
- package/dist/components/oauth-button-group.d.ts +19 -0
- package/dist/components/oauth-button-group.d.ts.map +1 -0
- package/dist/components/oauth-button-group.js +24 -0
- package/dist/components/oauth-button-group.js.map +1 -0
- package/dist/components/oauth-button.d.ts +17 -0
- package/dist/components/oauth-button.d.ts.map +1 -0
- package/dist/components/oauth-button.js +173 -0
- package/dist/components/oauth-button.js.map +1 -0
- package/dist/components/passkey-button.d.ts +11 -0
- package/dist/components/passkey-button.d.ts.map +1 -0
- package/dist/components/passkey-button.js +33 -0
- package/dist/components/passkey-button.js.map +1 -0
- package/dist/components/profile-image-editor.d.ts +15 -0
- package/dist/components/profile-image-editor.d.ts.map +1 -0
- package/dist/components/profile-image-editor.js +171 -0
- package/dist/components/profile-image-editor.js.map +1 -0
- package/dist/components/selected-team-switcher.d.ts +31 -0
- package/dist/components/selected-team-switcher.d.ts.map +1 -0
- package/dist/components/selected-team-switcher.js +59 -0
- package/dist/components/selected-team-switcher.js.map +1 -0
- package/dist/components/team-icon.d.ts +10 -0
- package/dist/components/team-icon.d.ts.map +1 -0
- package/dist/components/team-icon.js +31 -0
- package/dist/components/team-icon.js.map +1 -0
- package/dist/components/team-switcher.d.ts +31 -0
- package/dist/components/team-switcher.d.ts.map +1 -0
- package/dist/components/team-switcher.js +123 -0
- package/dist/components/team-switcher.js.map +1 -0
- package/dist/components/use-in-iframe.d.ts +5 -0
- package/dist/components/use-in-iframe.d.ts.map +1 -0
- package/dist/components/use-in-iframe.js +18 -0
- package/dist/components/use-in-iframe.js.map +1 -0
- package/dist/components/user-button.d.ts +22 -0
- package/dist/components/user-button.d.ts.map +1 -0
- package/dist/components/user-button.js +134 -0
- package/dist/components/user-button.js.map +1 -0
- package/dist/components-page/account-settings/active-sessions/active-sessions-page.d.ts +20 -0
- package/dist/components-page/account-settings/active-sessions/active-sessions-page.d.ts.map +1 -0
- package/dist/components-page/account-settings/active-sessions/active-sessions-page.js +208 -0
- package/dist/components-page/account-settings/active-sessions/active-sessions-page.js.map +1 -0
- package/dist/components-page/account-settings/api-keys/api-keys-page.d.ts +16 -0
- package/dist/components-page/account-settings/api-keys/api-keys-page.d.ts.map +1 -0
- package/dist/components-page/account-settings/api-keys/api-keys-page.js +115 -0
- package/dist/components-page/account-settings/api-keys/api-keys-page.js.map +1 -0
- package/dist/components-page/account-settings/editable-text.d.ts +10 -0
- package/dist/components-page/account-settings/editable-text.d.ts.map +1 -0
- package/dist/components-page/account-settings/editable-text.js +49 -0
- package/dist/components-page/account-settings/editable-text.js.map +1 -0
- package/dist/components-page/account-settings/email-and-auth/email-and-auth-page.d.ts +9 -0
- package/dist/components-page/account-settings/email-and-auth/email-and-auth-page.d.ts.map +1 -0
- package/dist/components-page/account-settings/email-and-auth/email-and-auth-page.js +24 -0
- package/dist/components-page/account-settings/email-and-auth/email-and-auth-page.js.map +1 -0
- package/dist/components-page/account-settings/email-and-auth/emails-section.d.ts +9 -0
- package/dist/components-page/account-settings/email-and-auth/emails-section.d.ts.map +1 -0
- package/dist/components-page/account-settings/email-and-auth/emails-section.js +181 -0
- package/dist/components-page/account-settings/email-and-auth/emails-section.js.map +1 -0
- package/dist/components-page/account-settings/email-and-auth/mfa-section.d.ts +9 -0
- package/dist/components-page/account-settings/email-and-auth/mfa-section.d.ts.map +1 -0
- package/dist/components-page/account-settings/email-and-auth/mfa-section.js +121 -0
- package/dist/components-page/account-settings/email-and-auth/mfa-section.js.map +1 -0
- package/dist/components-page/account-settings/email-and-auth/otp-section.d.ts +9 -0
- package/dist/components-page/account-settings/email-and-auth/otp-section.d.ts.map +1 -0
- package/dist/components-page/account-settings/email-and-auth/otp-section.js +80 -0
- package/dist/components-page/account-settings/email-and-auth/otp-section.js.map +1 -0
- package/dist/components-page/account-settings/email-and-auth/passkey-section.d.ts +9 -0
- package/dist/components-page/account-settings/email-and-auth/passkey-section.d.ts.map +1 -0
- package/dist/components-page/account-settings/email-and-auth/passkey-section.js +89 -0
- package/dist/components-page/account-settings/email-and-auth/passkey-section.js.map +1 -0
- package/dist/components-page/account-settings/email-and-auth/password-section.d.ts +9 -0
- package/dist/components-page/account-settings/email-and-auth/password-section.d.ts.map +1 -0
- package/dist/components-page/account-settings/email-and-auth/password-section.js +161 -0
- package/dist/components-page/account-settings/email-and-auth/password-section.js.map +1 -0
- package/dist/components-page/account-settings/notifications/notifications-page.d.ts +7 -0
- package/dist/components-page/account-settings/notifications/notifications-page.d.ts.map +1 -0
- package/dist/components-page/account-settings/notifications/notifications-page.js +42 -0
- package/dist/components-page/account-settings/notifications/notifications-page.js.map +1 -0
- package/dist/components-page/account-settings/page-layout.d.ts +9 -0
- package/dist/components-page/account-settings/page-layout.d.ts.map +1 -0
- package/dist/components-page/account-settings/page-layout.js +15 -0
- package/dist/components-page/account-settings/page-layout.js.map +1 -0
- package/dist/components-page/account-settings/payments/payments-page.d.ts +12 -0
- package/dist/components-page/account-settings/payments/payments-page.d.ts.map +1 -0
- package/dist/components-page/account-settings/payments/payments-page.js +55 -0
- package/dist/components-page/account-settings/payments/payments-page.js.map +1 -0
- package/dist/components-page/account-settings/payments/payments-panel.d.ts +61 -0
- package/dist/components-page/account-settings/payments/payments-panel.d.ts.map +1 -0
- package/dist/components-page/account-settings/payments/payments-panel.js +466 -0
- package/dist/components-page/account-settings/payments/payments-panel.js.map +1 -0
- package/dist/components-page/account-settings/profile-page/profile-page.d.ts +12 -0
- package/dist/components-page/account-settings/profile-page/profile-page.d.ts.map +1 -0
- package/dist/components-page/account-settings/profile-page/profile-page.js +46 -0
- package/dist/components-page/account-settings/profile-page/profile-page.js.map +1 -0
- package/dist/components-page/account-settings/section.d.ts +11 -0
- package/dist/components-page/account-settings/section.d.ts.map +1 -0
- package/dist/components-page/account-settings/section.js +29 -0
- package/dist/components-page/account-settings/section.js.map +1 -0
- package/dist/components-page/account-settings/settings/delete-account-section.d.ts +9 -0
- package/dist/components-page/account-settings/settings/delete-account-section.d.ts.map +1 -0
- package/dist/components-page/account-settings/settings/delete-account-section.js +70 -0
- package/dist/components-page/account-settings/settings/delete-account-section.js.map +1 -0
- package/dist/components-page/account-settings/settings/settings-page.d.ts +9 -0
- package/dist/components-page/account-settings/settings/settings-page.d.ts.map +1 -0
- package/dist/components-page/account-settings/settings/settings-page.js +15 -0
- package/dist/components-page/account-settings/settings/settings-page.js.map +1 -0
- package/dist/components-page/account-settings/settings/sign-out-section.d.ts +9 -0
- package/dist/components-page/account-settings/settings/sign-out-section.d.ts.map +1 -0
- package/dist/components-page/account-settings/settings/sign-out-section.js +33 -0
- package/dist/components-page/account-settings/settings/sign-out-section.js.map +1 -0
- package/dist/components-page/account-settings/teams/leave-team-section.d.ts +10 -0
- package/dist/components-page/account-settings/teams/leave-team-section.d.ts.map +1 -0
- package/dist/components-page/account-settings/teams/leave-team-section.js +48 -0
- package/dist/components-page/account-settings/teams/leave-team-section.js.map +1 -0
- package/dist/components-page/account-settings/teams/team-api-keys-section.d.ts +10 -0
- package/dist/components-page/account-settings/teams/team-api-keys-section.d.ts.map +1 -0
- package/dist/components-page/account-settings/teams/team-api-keys-section.js +57 -0
- package/dist/components-page/account-settings/teams/team-api-keys-section.js.map +1 -0
- package/dist/components-page/account-settings/teams/team-creation-page.d.ts +9 -0
- package/dist/components-page/account-settings/teams/team-creation-page.d.ts.map +1 -0
- package/dist/components-page/account-settings/teams/team-creation-page.js +67 -0
- package/dist/components-page/account-settings/teams/team-creation-page.js.map +1 -0
- package/dist/components-page/account-settings/teams/team-display-name-section.d.ts +10 -0
- package/dist/components-page/account-settings/teams/team-display-name-section.d.ts.map +1 -0
- package/dist/components-page/account-settings/teams/team-display-name-section.js +25 -0
- package/dist/components-page/account-settings/teams/team-display-name-section.js.map +1 -0
- package/dist/components-page/account-settings/teams/team-member-invitation-section.d.ts +10 -0
- package/dist/components-page/account-settings/teams/team-member-invitation-section.d.ts.map +1 -0
- package/dist/components-page/account-settings/teams/team-member-invitation-section.js +114 -0
- package/dist/components-page/account-settings/teams/team-member-invitation-section.js.map +1 -0
- package/dist/components-page/account-settings/teams/team-member-list-section.d.ts +10 -0
- package/dist/components-page/account-settings/teams/team-member-list-section.d.ts.map +1 -0
- package/dist/components-page/account-settings/teams/team-member-list-section.js +40 -0
- package/dist/components-page/account-settings/teams/team-member-list-section.js.map +1 -0
- package/dist/components-page/account-settings/teams/team-page.d.ts +10 -0
- package/dist/components-page/account-settings/teams/team-page.d.ts.map +1 -0
- package/dist/components-page/account-settings/teams/team-page.js +28 -0
- package/dist/components-page/account-settings/teams/team-page.js.map +1 -0
- package/dist/components-page/account-settings/teams/team-profile-image-section.d.ts +10 -0
- package/dist/components-page/account-settings/teams/team-profile-image-section.d.ts.map +1 -0
- package/dist/components-page/account-settings/teams/team-profile-image-section.js +27 -0
- package/dist/components-page/account-settings/teams/team-profile-image-section.js.map +1 -0
- package/dist/components-page/account-settings/teams/team-profile-user-section.d.ts +10 -0
- package/dist/components-page/account-settings/teams/team-profile-user-section.d.ts.map +1 -0
- package/dist/components-page/account-settings/teams/team-profile-user-section.js +27 -0
- package/dist/components-page/account-settings/teams/team-profile-user-section.js.map +1 -0
- package/dist/components-page/account-settings.d.ts +58 -0
- package/dist/components-page/account-settings.d.ts.map +1 -0
- package/dist/components-page/account-settings.js +267 -0
- package/dist/components-page/account-settings.js.map +1 -0
- package/dist/components-page/auth-page.d.ts +26 -0
- package/dist/components-page/auth-page.d.ts.map +1 -0
- package/dist/components-page/auth-page.js +163 -0
- package/dist/components-page/auth-page.js.map +1 -0
- package/dist/components-page/cli-auth-confirm.d.ts +21 -0
- package/dist/components-page/cli-auth-confirm.d.ts.map +1 -0
- package/dist/components-page/cli-auth-confirm.js +216 -0
- package/dist/components-page/cli-auth-confirm.js.map +1 -0
- package/dist/components-page/cli-auth-confirm.test.d.ts +1 -0
- package/dist/components-page/cli-auth-confirm.test.js +176 -0
- package/dist/components-page/cli-auth-confirm.test.js.map +1 -0
- package/dist/components-page/email-verification.d.ts +10 -0
- package/dist/components-page/email-verification.d.ts.map +1 -0
- package/dist/components-page/email-verification.js +60 -0
- package/dist/components-page/email-verification.js.map +1 -0
- package/dist/components-page/error-page.d.ts +10 -0
- package/dist/components-page/error-page.d.ts.map +1 -0
- package/dist/components-page/error-page.js +77 -0
- package/dist/components-page/error-page.js.map +1 -0
- package/dist/components-page/forgot-password.d.ts +14 -0
- package/dist/components-page/forgot-password.d.ts.map +1 -0
- package/dist/components-page/forgot-password.js +103 -0
- package/dist/components-page/forgot-password.js.map +1 -0
- package/dist/components-page/magic-link-callback.d.ts +10 -0
- package/dist/components-page/magic-link-callback.d.ts.map +1 -0
- package/dist/components-page/magic-link-callback.js +75 -0
- package/dist/components-page/magic-link-callback.js.map +1 -0
- package/dist/components-page/mfa.d.ts +11 -0
- package/dist/components-page/mfa.d.ts.map +1 -0
- package/dist/components-page/mfa.js +166 -0
- package/dist/components-page/mfa.js.map +1 -0
- package/dist/components-page/oauth-callback.d.ts +11 -0
- package/dist/components-page/oauth-callback.d.ts.map +1 -0
- package/dist/components-page/oauth-callback.js +72 -0
- package/dist/components-page/oauth-callback.js.map +1 -0
- package/dist/components-page/onboarding.d.ts +9 -0
- package/dist/components-page/onboarding.d.ts.map +1 -0
- package/dist/components-page/onboarding.js +140 -0
- package/dist/components-page/onboarding.js.map +1 -0
- package/dist/components-page/password-reset.d.ts +17 -0
- package/dist/components-page/password-reset.d.ts.map +1 -0
- package/dist/components-page/password-reset.js +161 -0
- package/dist/components-page/password-reset.js.map +1 -0
- package/dist/components-page/section.d.ts +1 -0
- package/dist/components-page/section.js +2 -0
- package/dist/components-page/sign-in.d.ts +23 -0
- package/dist/components-page/sign-in.d.ts.map +1 -0
- package/dist/components-page/sign-in.js +20 -0
- package/dist/components-page/sign-in.js.map +1 -0
- package/dist/components-page/sign-out.d.ts +9 -0
- package/dist/components-page/sign-out.d.ts.map +1 -0
- package/dist/components-page/sign-out.js +26 -0
- package/dist/components-page/sign-out.js.map +1 -0
- package/dist/components-page/sign-up.d.ts +13 -0
- package/dist/components-page/sign-up.d.ts.map +1 -0
- package/dist/components-page/sign-up.js +22 -0
- package/dist/components-page/sign-up.js.map +1 -0
- package/dist/components-page/stack-handler-client.d.ts +50 -0
- package/dist/components-page/stack-handler-client.d.ts.map +1 -0
- package/dist/components-page/stack-handler-client.js +235 -0
- package/dist/components-page/stack-handler-client.js.map +1 -0
- package/dist/components-page/stack-handler.d.ts +32 -0
- package/dist/components-page/stack-handler.d.ts.map +1 -0
- package/dist/components-page/stack-handler.js +12 -0
- package/dist/components-page/stack-handler.js.map +1 -0
- package/dist/components-page/team-creation.d.ts +9 -0
- package/dist/components-page/team-creation.d.ts.map +1 -0
- package/dist/components-page/team-creation.js +80 -0
- package/dist/components-page/team-creation.js.map +1 -0
- package/dist/components-page/team-invitation.d.ts +13 -0
- package/dist/components-page/team-invitation.d.ts.map +1 -0
- package/dist/components-page/team-invitation.js +109 -0
- package/dist/components-page/team-invitation.js.map +1 -0
- package/dist/dev-tool/dev-tool-core.d.ts +7 -0
- package/dist/dev-tool/dev-tool-core.d.ts.map +1 -0
- package/dist/dev-tool/dev-tool-core.js +2107 -0
- package/dist/dev-tool/dev-tool-core.js.map +1 -0
- package/dist/dev-tool/dev-tool-styles.d.ts +5 -0
- package/dist/dev-tool/dev-tool-styles.d.ts.map +1 -0
- package/dist/dev-tool/dev-tool-styles.js +2757 -0
- package/dist/dev-tool/dev-tool-styles.js.map +1 -0
- package/dist/dev-tool/dev-tool-trigger-position.d.ts +36 -0
- package/dist/dev-tool/dev-tool-trigger-position.d.ts.map +1 -0
- package/dist/dev-tool/dev-tool-trigger-position.js +70 -0
- package/dist/dev-tool/dev-tool-trigger-position.js.map +1 -0
- package/dist/dev-tool/dev-tool-trigger-position.test.d.ts +1 -0
- package/dist/dev-tool/dev-tool-trigger-position.test.js +155 -0
- package/dist/dev-tool/dev-tool-trigger-position.test.js.map +1 -0
- package/dist/dev-tool/index.d.ts +19 -0
- package/dist/dev-tool/index.d.ts.map +1 -0
- package/dist/dev-tool/index.js +119 -0
- package/dist/dev-tool/index.js.map +1 -0
- package/dist/esm/components/api-key-dialogs.d.ts +28 -0
- package/dist/esm/components/api-key-dialogs.d.ts.map +1 -0
- package/dist/esm/components/api-key-dialogs.js +158 -0
- package/dist/esm/components/api-key-dialogs.js.map +1 -0
- package/dist/esm/components/api-key-table.d.ts +10 -0
- package/dist/esm/components/api-key-table.d.ts.map +1 -0
- package/dist/esm/components/api-key-table.js +142 -0
- package/dist/esm/components/api-key-table.js.map +1 -0
- package/dist/esm/components/credential-sign-in.d.ts +7 -0
- package/dist/esm/components/credential-sign-in.d.ts.map +1 -0
- package/dist/esm/components/credential-sign-in.js +85 -0
- package/dist/esm/components/credential-sign-in.js.map +1 -0
- package/dist/esm/components/credential-sign-up.d.ts +9 -0
- package/dist/esm/components/credential-sign-up.d.ts.map +1 -0
- package/dist/esm/components/credential-sign-up.js +117 -0
- package/dist/esm/components/credential-sign-up.js.map +1 -0
- package/dist/esm/components/elements/form-warning.d.ts +11 -0
- package/dist/esm/components/elements/form-warning.d.ts.map +1 -0
- package/dist/esm/components/elements/form-warning.js +16 -0
- package/dist/esm/components/elements/form-warning.js.map +1 -0
- package/dist/esm/components/elements/maybe-full-page.d.ts +16 -0
- package/dist/esm/components/elements/maybe-full-page.d.ts.map +1 -0
- package/dist/esm/components/elements/maybe-full-page.js +38 -0
- package/dist/esm/components/elements/maybe-full-page.js.map +1 -0
- package/dist/esm/components/elements/separator-with-text.d.ts +11 -0
- package/dist/esm/components/elements/separator-with-text.d.ts.map +1 -0
- package/dist/esm/components/elements/separator-with-text.js +29 -0
- package/dist/esm/components/elements/separator-with-text.js.map +1 -0
- package/dist/esm/components/elements/sidebar-layout.d.ts +21 -0
- package/dist/esm/components/elements/sidebar-layout.d.ts.map +1 -0
- package/dist/esm/components/elements/sidebar-layout.js +132 -0
- package/dist/esm/components/elements/sidebar-layout.js.map +1 -0
- package/dist/esm/components/elements/ssr-layout-effect.d.ts +10 -0
- package/dist/esm/components/elements/ssr-layout-effect.d.ts.map +1 -0
- package/dist/esm/components/elements/ssr-layout-effect.js +20 -0
- package/dist/esm/components/elements/ssr-layout-effect.js.map +1 -0
- package/dist/esm/components/elements/user-avatar.d.ts +15 -0
- package/dist/esm/components/elements/user-avatar.d.ts.map +1 -0
- package/dist/esm/components/elements/user-avatar.js +28 -0
- package/dist/esm/components/elements/user-avatar.js.map +1 -0
- package/dist/esm/components/link.d.ts +16 -0
- package/dist/esm/components/link.d.ts.map +1 -0
- package/dist/esm/components/link.js +26 -0
- package/dist/esm/components/link.js.map +1 -0
- package/dist/esm/components/magic-link-sign-in.d.ts +7 -0
- package/dist/esm/components/magic-link-sign-in.d.ts.map +1 -0
- package/dist/esm/components/magic-link-sign-in.js +136 -0
- package/dist/esm/components/magic-link-sign-in.js.map +1 -0
- package/dist/esm/components/message-cards/known-error-message-card.d.ts +14 -0
- package/dist/esm/components/message-cards/known-error-message-card.d.ts.map +1 -0
- package/dist/esm/components/message-cards/known-error-message-card.js +22 -0
- package/dist/esm/components/message-cards/known-error-message-card.js.map +1 -0
- package/dist/esm/components/message-cards/message-card.d.ts +19 -0
- package/dist/esm/components/message-cards/message-card.d.ts.map +1 -0
- package/dist/esm/components/message-cards/message-card.js +43 -0
- package/dist/esm/components/message-cards/message-card.js.map +1 -0
- package/dist/esm/components/message-cards/predefined-message-card.d.ts +13 -0
- package/dist/esm/components/message-cards/predefined-message-card.d.ts.map +1 -0
- package/dist/esm/components/message-cards/predefined-message-card.js +71 -0
- package/dist/esm/components/message-cards/predefined-message-card.js.map +1 -0
- package/dist/esm/components/oauth-button-group.d.ts +19 -0
- package/dist/esm/components/oauth-button-group.d.ts.map +1 -0
- package/dist/esm/components/oauth-button-group.js +22 -0
- package/dist/esm/components/oauth-button-group.js.map +1 -0
- package/dist/esm/components/oauth-button.d.ts +17 -0
- package/dist/esm/components/oauth-button.d.ts.map +1 -0
- package/dist/esm/components/oauth-button.js +170 -0
- package/dist/esm/components/oauth-button.js.map +1 -0
- package/dist/esm/components/passkey-button.d.ts +11 -0
- package/dist/esm/components/passkey-button.d.ts.map +1 -0
- package/dist/esm/components/passkey-button.js +31 -0
- package/dist/esm/components/passkey-button.js.map +1 -0
- package/dist/esm/components/profile-image-editor.d.ts +15 -0
- package/dist/esm/components/profile-image-editor.d.ts.map +1 -0
- package/dist/esm/components/profile-image-editor.js +165 -0
- package/dist/esm/components/profile-image-editor.js.map +1 -0
- package/dist/esm/components/selected-team-switcher.d.ts +31 -0
- package/dist/esm/components/selected-team-switcher.d.ts.map +1 -0
- package/dist/esm/components/selected-team-switcher.js +57 -0
- package/dist/esm/components/selected-team-switcher.js.map +1 -0
- package/dist/esm/components/team-icon.d.ts +10 -0
- package/dist/esm/components/team-icon.d.ts.map +1 -0
- package/dist/esm/components/team-icon.js +29 -0
- package/dist/esm/components/team-icon.js.map +1 -0
- package/dist/esm/components/team-switcher.d.ts +31 -0
- package/dist/esm/components/team-switcher.d.ts.map +1 -0
- package/dist/esm/components/team-switcher.js +121 -0
- package/dist/esm/components/team-switcher.js.map +1 -0
- package/dist/esm/components/use-in-iframe.d.ts +5 -0
- package/dist/esm/components/use-in-iframe.d.ts.map +1 -0
- package/dist/esm/components/use-in-iframe.js +16 -0
- package/dist/esm/components/use-in-iframe.js.map +1 -0
- package/dist/esm/components/user-button.d.ts +22 -0
- package/dist/esm/components/user-button.d.ts.map +1 -0
- package/dist/esm/components/user-button.js +131 -0
- package/dist/esm/components/user-button.js.map +1 -0
- package/dist/esm/components-page/account-settings/active-sessions/active-sessions-page.d.ts +20 -0
- package/dist/esm/components-page/account-settings/active-sessions/active-sessions-page.d.ts.map +1 -0
- package/dist/esm/components-page/account-settings/active-sessions/active-sessions-page.js +206 -0
- package/dist/esm/components-page/account-settings/active-sessions/active-sessions-page.js.map +1 -0
- package/dist/esm/components-page/account-settings/api-keys/api-keys-page.d.ts +16 -0
- package/dist/esm/components-page/account-settings/api-keys/api-keys-page.d.ts.map +1 -0
- package/dist/esm/components-page/account-settings/api-keys/api-keys-page.js +113 -0
- package/dist/esm/components-page/account-settings/api-keys/api-keys-page.js.map +1 -0
- package/dist/esm/components-page/account-settings/editable-text.d.ts +10 -0
- package/dist/esm/components-page/account-settings/editable-text.d.ts.map +1 -0
- package/dist/esm/components-page/account-settings/editable-text.js +47 -0
- package/dist/esm/components-page/account-settings/editable-text.js.map +1 -0
- package/dist/esm/components-page/account-settings/email-and-auth/email-and-auth-page.d.ts +9 -0
- package/dist/esm/components-page/account-settings/email-and-auth/email-and-auth-page.d.ts.map +1 -0
- package/dist/esm/components-page/account-settings/email-and-auth/email-and-auth-page.js +22 -0
- package/dist/esm/components-page/account-settings/email-and-auth/email-and-auth-page.js.map +1 -0
- package/dist/esm/components-page/account-settings/email-and-auth/emails-section.d.ts +9 -0
- package/dist/esm/components-page/account-settings/email-and-auth/emails-section.d.ts.map +1 -0
- package/dist/esm/components-page/account-settings/email-and-auth/emails-section.js +179 -0
- package/dist/esm/components-page/account-settings/email-and-auth/emails-section.js.map +1 -0
- package/dist/esm/components-page/account-settings/email-and-auth/mfa-section.d.ts +9 -0
- package/dist/esm/components-page/account-settings/email-and-auth/mfa-section.d.ts.map +1 -0
- package/dist/esm/components-page/account-settings/email-and-auth/mfa-section.js +118 -0
- package/dist/esm/components-page/account-settings/email-and-auth/mfa-section.js.map +1 -0
- package/dist/esm/components-page/account-settings/email-and-auth/otp-section.d.ts +9 -0
- package/dist/esm/components-page/account-settings/email-and-auth/otp-section.d.ts.map +1 -0
- package/dist/esm/components-page/account-settings/email-and-auth/otp-section.js +78 -0
- package/dist/esm/components-page/account-settings/email-and-auth/otp-section.js.map +1 -0
- package/dist/esm/components-page/account-settings/email-and-auth/passkey-section.d.ts +9 -0
- package/dist/esm/components-page/account-settings/email-and-auth/passkey-section.d.ts.map +1 -0
- package/dist/esm/components-page/account-settings/email-and-auth/passkey-section.js +87 -0
- package/dist/esm/components-page/account-settings/email-and-auth/passkey-section.js.map +1 -0
- package/dist/esm/components-page/account-settings/email-and-auth/password-section.d.ts +9 -0
- package/dist/esm/components-page/account-settings/email-and-auth/password-section.d.ts.map +1 -0
- package/dist/esm/components-page/account-settings/email-and-auth/password-section.js +158 -0
- package/dist/esm/components-page/account-settings/email-and-auth/password-section.js.map +1 -0
- package/dist/esm/components-page/account-settings/notifications/notifications-page.d.ts +7 -0
- package/dist/esm/components-page/account-settings/notifications/notifications-page.d.ts.map +1 -0
- package/dist/esm/components-page/account-settings/notifications/notifications-page.js +40 -0
- package/dist/esm/components-page/account-settings/notifications/notifications-page.js.map +1 -0
- package/dist/esm/components-page/account-settings/page-layout.d.ts +9 -0
- package/dist/esm/components-page/account-settings/page-layout.d.ts.map +1 -0
- package/dist/esm/components-page/account-settings/page-layout.js +13 -0
- package/dist/esm/components-page/account-settings/page-layout.js.map +1 -0
- package/dist/esm/components-page/account-settings/payments/payments-page.d.ts +12 -0
- package/dist/esm/components-page/account-settings/payments/payments-page.d.ts.map +1 -0
- package/dist/esm/components-page/account-settings/payments/payments-page.js +53 -0
- package/dist/esm/components-page/account-settings/payments/payments-page.js.map +1 -0
- package/dist/esm/components-page/account-settings/payments/payments-panel.d.ts +61 -0
- package/dist/esm/components-page/account-settings/payments/payments-panel.d.ts.map +1 -0
- package/dist/esm/components-page/account-settings/payments/payments-panel.js +464 -0
- package/dist/esm/components-page/account-settings/payments/payments-panel.js.map +1 -0
- package/dist/esm/components-page/account-settings/profile-page/profile-page.d.ts +12 -0
- package/dist/esm/components-page/account-settings/profile-page/profile-page.d.ts.map +1 -0
- package/dist/esm/components-page/account-settings/profile-page/profile-page.js +44 -0
- package/dist/esm/components-page/account-settings/profile-page/profile-page.js.map +1 -0
- package/dist/esm/components-page/account-settings/section.d.ts +11 -0
- package/dist/esm/components-page/account-settings/section.d.ts.map +1 -0
- package/dist/esm/components-page/account-settings/section.js +27 -0
- package/dist/esm/components-page/account-settings/section.js.map +1 -0
- package/dist/esm/components-page/account-settings/settings/delete-account-section.d.ts +9 -0
- package/dist/esm/components-page/account-settings/settings/delete-account-section.d.ts.map +1 -0
- package/dist/esm/components-page/account-settings/settings/delete-account-section.js +68 -0
- package/dist/esm/components-page/account-settings/settings/delete-account-section.js.map +1 -0
- package/dist/esm/components-page/account-settings/settings/settings-page.d.ts +9 -0
- package/dist/esm/components-page/account-settings/settings/settings-page.d.ts.map +1 -0
- package/dist/esm/components-page/account-settings/settings/settings-page.js +13 -0
- package/dist/esm/components-page/account-settings/settings/settings-page.js.map +1 -0
- package/dist/esm/components-page/account-settings/settings/sign-out-section.d.ts +9 -0
- package/dist/esm/components-page/account-settings/settings/sign-out-section.d.ts.map +1 -0
- package/dist/esm/components-page/account-settings/settings/sign-out-section.js +31 -0
- package/dist/esm/components-page/account-settings/settings/sign-out-section.js.map +1 -0
- package/dist/esm/components-page/account-settings/teams/leave-team-section.d.ts +10 -0
- package/dist/esm/components-page/account-settings/teams/leave-team-section.d.ts.map +1 -0
- package/dist/esm/components-page/account-settings/teams/leave-team-section.js +46 -0
- package/dist/esm/components-page/account-settings/teams/leave-team-section.js.map +1 -0
- package/dist/esm/components-page/account-settings/teams/team-api-keys-section.d.ts +10 -0
- package/dist/esm/components-page/account-settings/teams/team-api-keys-section.d.ts.map +1 -0
- package/dist/esm/components-page/account-settings/teams/team-api-keys-section.js +55 -0
- package/dist/esm/components-page/account-settings/teams/team-api-keys-section.js.map +1 -0
- package/dist/esm/components-page/account-settings/teams/team-creation-page.d.ts +9 -0
- package/dist/esm/components-page/account-settings/teams/team-creation-page.d.ts.map +1 -0
- package/dist/esm/components-page/account-settings/teams/team-creation-page.js +65 -0
- package/dist/esm/components-page/account-settings/teams/team-creation-page.js.map +1 -0
- package/dist/esm/components-page/account-settings/teams/team-display-name-section.d.ts +10 -0
- package/dist/esm/components-page/account-settings/teams/team-display-name-section.d.ts.map +1 -0
- package/dist/esm/components-page/account-settings/teams/team-display-name-section.js +23 -0
- package/dist/esm/components-page/account-settings/teams/team-display-name-section.js.map +1 -0
- package/dist/esm/components-page/account-settings/teams/team-member-invitation-section.d.ts +10 -0
- package/dist/esm/components-page/account-settings/teams/team-member-invitation-section.d.ts.map +1 -0
- package/dist/esm/components-page/account-settings/teams/team-member-invitation-section.js +112 -0
- package/dist/esm/components-page/account-settings/teams/team-member-invitation-section.js.map +1 -0
- package/dist/esm/components-page/account-settings/teams/team-member-list-section.d.ts +10 -0
- package/dist/esm/components-page/account-settings/teams/team-member-list-section.d.ts.map +1 -0
- package/dist/esm/components-page/account-settings/teams/team-member-list-section.js +38 -0
- package/dist/esm/components-page/account-settings/teams/team-member-list-section.js.map +1 -0
- package/dist/esm/components-page/account-settings/teams/team-page.d.ts +10 -0
- package/dist/esm/components-page/account-settings/teams/team-page.d.ts.map +1 -0
- package/dist/esm/components-page/account-settings/teams/team-page.js +26 -0
- package/dist/esm/components-page/account-settings/teams/team-page.js.map +1 -0
- package/dist/esm/components-page/account-settings/teams/team-profile-image-section.d.ts +10 -0
- package/dist/esm/components-page/account-settings/teams/team-profile-image-section.d.ts.map +1 -0
- package/dist/esm/components-page/account-settings/teams/team-profile-image-section.js +25 -0
- package/dist/esm/components-page/account-settings/teams/team-profile-image-section.js.map +1 -0
- package/dist/esm/components-page/account-settings/teams/team-profile-user-section.d.ts +10 -0
- package/dist/esm/components-page/account-settings/teams/team-profile-user-section.d.ts.map +1 -0
- package/dist/esm/components-page/account-settings/teams/team-profile-user-section.js +25 -0
- package/dist/esm/components-page/account-settings/teams/team-profile-user-section.js.map +1 -0
- package/dist/esm/components-page/account-settings.d.ts +58 -0
- package/dist/esm/components-page/account-settings.d.ts.map +1 -0
- package/dist/esm/components-page/account-settings.js +264 -0
- package/dist/esm/components-page/account-settings.js.map +1 -0
- package/dist/esm/components-page/auth-page.d.ts +26 -0
- package/dist/esm/components-page/auth-page.d.ts.map +1 -0
- package/dist/esm/components-page/auth-page.js +161 -0
- package/dist/esm/components-page/auth-page.js.map +1 -0
- package/dist/esm/components-page/cli-auth-confirm.d.ts +21 -0
- package/dist/esm/components-page/cli-auth-confirm.d.ts.map +1 -0
- package/dist/esm/components-page/cli-auth-confirm.js +213 -0
- package/dist/esm/components-page/cli-auth-confirm.js.map +1 -0
- package/dist/esm/components-page/cli-auth-confirm.test.d.ts +1 -0
- package/dist/esm/components-page/cli-auth-confirm.test.js +175 -0
- package/dist/esm/components-page/cli-auth-confirm.test.js.map +1 -0
- package/dist/esm/components-page/email-verification.d.ts +10 -0
- package/dist/esm/components-page/email-verification.d.ts.map +1 -0
- package/dist/esm/components-page/email-verification.js +57 -0
- package/dist/esm/components-page/email-verification.js.map +1 -0
- package/dist/esm/components-page/error-page.d.ts +10 -0
- package/dist/esm/components-page/error-page.d.ts.map +1 -0
- package/dist/esm/components-page/error-page.js +75 -0
- package/dist/esm/components-page/error-page.js.map +1 -0
- package/dist/esm/components-page/forgot-password.d.ts +14 -0
- package/dist/esm/components-page/forgot-password.d.ts.map +1 -0
- package/dist/esm/components-page/forgot-password.js +100 -0
- package/dist/esm/components-page/forgot-password.js.map +1 -0
- package/dist/esm/components-page/magic-link-callback.d.ts +10 -0
- package/dist/esm/components-page/magic-link-callback.d.ts.map +1 -0
- package/dist/esm/components-page/magic-link-callback.js +72 -0
- package/dist/esm/components-page/magic-link-callback.js.map +1 -0
- package/dist/esm/components-page/mfa.d.ts +11 -0
- package/dist/esm/components-page/mfa.d.ts.map +1 -0
- package/dist/esm/components-page/mfa.js +164 -0
- package/dist/esm/components-page/mfa.js.map +1 -0
- package/dist/esm/components-page/oauth-callback.d.ts +11 -0
- package/dist/esm/components-page/oauth-callback.d.ts.map +1 -0
- package/dist/esm/components-page/oauth-callback.js +70 -0
- package/dist/esm/components-page/oauth-callback.js.map +1 -0
- package/dist/esm/components-page/onboarding.d.ts +9 -0
- package/dist/esm/components-page/onboarding.d.ts.map +1 -0
- package/dist/esm/components-page/onboarding.js +138 -0
- package/dist/esm/components-page/onboarding.js.map +1 -0
- package/dist/esm/components-page/password-reset.d.ts +17 -0
- package/dist/esm/components-page/password-reset.d.ts.map +1 -0
- package/dist/esm/components-page/password-reset.js +157 -0
- package/dist/esm/components-page/password-reset.js.map +1 -0
- package/dist/esm/components-page/section.d.ts +1 -0
- package/dist/esm/components-page/section.js +4 -0
- package/dist/esm/components-page/sign-in.d.ts +23 -0
- package/dist/esm/components-page/sign-in.d.ts.map +1 -0
- package/dist/esm/components-page/sign-in.js +18 -0
- package/dist/esm/components-page/sign-in.js.map +1 -0
- package/dist/esm/components-page/sign-out.d.ts +9 -0
- package/dist/esm/components-page/sign-out.d.ts.map +1 -0
- package/dist/esm/components-page/sign-out.js +24 -0
- package/dist/esm/components-page/sign-out.js.map +1 -0
- package/dist/esm/components-page/sign-up.d.ts +13 -0
- package/dist/esm/components-page/sign-up.d.ts.map +1 -0
- package/dist/esm/components-page/sign-up.js +20 -0
- package/dist/esm/components-page/sign-up.js.map +1 -0
- package/dist/esm/components-page/stack-handler-client.d.ts +49 -0
- package/dist/esm/components-page/stack-handler-client.d.ts.map +1 -0
- package/dist/esm/components-page/stack-handler-client.js +233 -0
- package/dist/esm/components-page/stack-handler-client.js.map +1 -0
- package/dist/esm/components-page/stack-handler.d.ts +33 -0
- package/dist/esm/components-page/stack-handler.d.ts.map +1 -0
- package/dist/esm/components-page/stack-handler.js +11 -0
- package/dist/esm/components-page/stack-handler.js.map +1 -0
- package/dist/esm/components-page/team-creation.d.ts +9 -0
- package/dist/esm/components-page/team-creation.d.ts.map +1 -0
- package/dist/esm/components-page/team-creation.js +78 -0
- package/dist/esm/components-page/team-creation.js.map +1 -0
- package/dist/esm/components-page/team-invitation.d.ts +13 -0
- package/dist/esm/components-page/team-invitation.d.ts.map +1 -0
- package/dist/esm/components-page/team-invitation.js +106 -0
- package/dist/esm/components-page/team-invitation.js.map +1 -0
- package/dist/esm/dev-tool/dev-tool-core.d.ts +7 -0
- package/dist/esm/dev-tool/dev-tool-core.d.ts.map +1 -0
- package/dist/esm/dev-tool/dev-tool-core.js +2105 -0
- package/dist/esm/dev-tool/dev-tool-core.js.map +1 -0
- package/dist/esm/dev-tool/dev-tool-styles.d.ts +5 -0
- package/dist/esm/dev-tool/dev-tool-styles.d.ts.map +1 -0
- package/dist/esm/dev-tool/dev-tool-styles.js +2755 -0
- package/dist/esm/dev-tool/dev-tool-styles.js.map +1 -0
- package/dist/esm/dev-tool/dev-tool-trigger-position.d.ts +36 -0
- package/dist/esm/dev-tool/dev-tool-trigger-position.d.ts.map +1 -0
- package/dist/esm/dev-tool/dev-tool-trigger-position.js +65 -0
- package/dist/esm/dev-tool/dev-tool-trigger-position.js.map +1 -0
- package/dist/esm/dev-tool/dev-tool-trigger-position.test.d.ts +1 -0
- package/dist/esm/dev-tool/dev-tool-trigger-position.test.js +155 -0
- package/dist/esm/dev-tool/dev-tool-trigger-position.test.js.map +1 -0
- package/dist/esm/dev-tool/index.d.ts +19 -0
- package/dist/esm/dev-tool/index.d.ts.map +1 -0
- package/dist/esm/dev-tool/index.js +117 -0
- package/dist/esm/dev-tool/index.js.map +1 -0
- package/dist/esm/generated/global-css.d.ts +5 -0
- package/dist/esm/generated/global-css.d.ts.map +1 -0
- package/dist/esm/generated/global-css.js +6 -0
- package/dist/esm/generated/global-css.js.map +1 -0
- package/dist/esm/generated/quetzal-translations.d.ts +6 -0
- package/dist/esm/generated/quetzal-translations.d.ts.map +1 -0
- package/dist/esm/generated/quetzal-translations.js +4307 -0
- package/dist/esm/generated/quetzal-translations.js.map +1 -0
- package/dist/esm/global.d.ts +1 -0
- package/dist/esm/index.d.ts +27 -0
- package/dist/esm/index.js +28 -0
- package/dist/esm/integrations/convex/component/convex.config.d.ts +7 -0
- package/dist/esm/integrations/convex/component/convex.config.d.ts.map +1 -0
- package/dist/esm/integrations/convex/component/convex.config.js +8 -0
- package/dist/esm/integrations/convex/component/convex.config.js.map +1 -0
- package/dist/esm/integrations/convex.d.ts +13 -0
- package/dist/esm/integrations/convex.d.ts.map +1 -0
- package/dist/esm/integrations/convex.js +23 -0
- package/dist/esm/integrations/convex.js.map +1 -0
- package/dist/esm/lib/auth.d.ts +29 -0
- package/dist/esm/lib/auth.d.ts.map +1 -0
- package/dist/esm/lib/auth.js +108 -0
- package/dist/esm/lib/auth.js.map +1 -0
- package/dist/esm/lib/auth.test.d.ts +1 -0
- package/dist/esm/lib/auth.test.js +60 -0
- package/dist/esm/lib/auth.test.js.map +1 -0
- package/dist/esm/lib/cookie.d.ts +50 -0
- package/dist/esm/lib/cookie.d.ts.map +1 -0
- package/dist/esm/lib/cookie.js +347 -0
- package/dist/esm/lib/cookie.js.map +1 -0
- package/dist/esm/lib/env.d.ts +37 -0
- package/dist/esm/lib/env.d.ts.map +1 -0
- package/dist/esm/lib/env.js +88 -0
- package/dist/esm/lib/env.js.map +1 -0
- package/dist/esm/lib/hooks.d.ts +33 -0
- package/dist/esm/lib/hooks.d.ts.map +1 -0
- package/dist/esm/lib/hooks.js +27 -0
- package/dist/esm/lib/hooks.js.map +1 -0
- package/dist/esm/lib/stack-app/api-keys/index.d.ts +53 -0
- package/dist/esm/lib/stack-app/api-keys/index.d.ts.map +1 -0
- package/dist/esm/lib/stack-app/api-keys/index.js +22 -0
- package/dist/esm/lib/stack-app/api-keys/index.js.map +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.d.ts +423 -0
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.d.ts.map +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js +1039 -0
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.d.ts +562 -0
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.d.ts.map +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js +2631 -0
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.oauth-prefetch.test.d.ts +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.oauth-prefetch.test.js +32 -0
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.oauth-prefetch.test.js.map +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/common.d.ts +66 -0
- package/dist/esm/lib/stack-app/apps/implementations/common.d.ts.map +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/common.js +167 -0
- package/dist/esm/lib/stack-app/apps/implementations/common.js.map +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/event-tracker.d.ts +42 -0
- package/dist/esm/lib/stack-app/apps/implementations/event-tracker.d.ts.map +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/event-tracker.js +211 -0
- package/dist/esm/lib/stack-app/apps/implementations/event-tracker.js.map +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/event-tracker.test.d.ts +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/event-tracker.test.js +87 -0
- package/dist/esm/lib/stack-app/apps/implementations/event-tracker.test.js.map +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/index.d.ts +9 -0
- package/dist/esm/lib/stack-app/apps/implementations/index.d.ts.map +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/index.js +27 -0
- package/dist/esm/lib/stack-app/apps/implementations/index.js.map +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/redirect-page-urls.d.ts +35 -0
- package/dist/esm/lib/stack-app/apps/implementations/redirect-page-urls.d.ts.map +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/redirect-page-urls.js +187 -0
- package/dist/esm/lib/stack-app/apps/implementations/redirect-page-urls.js.map +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.d.ts +260 -0
- package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.d.ts.map +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js +1383 -0
- package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/session-refresh-subscription.d.ts +28 -0
- package/dist/esm/lib/stack-app/apps/implementations/session-refresh-subscription.d.ts.map +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/session-refresh-subscription.js +31 -0
- package/dist/esm/lib/stack-app/apps/implementations/session-refresh-subscription.js.map +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/session-refresh-subscription.test.d.ts +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/session-refresh-subscription.test.js +82 -0
- package/dist/esm/lib/stack-app/apps/implementations/session-refresh-subscription.test.js.map +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/session-replay.d.ts +108 -0
- package/dist/esm/lib/stack-app/apps/implementations/session-replay.d.ts.map +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/session-replay.js +234 -0
- package/dist/esm/lib/stack-app/apps/implementations/session-replay.js.map +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/session-replay.test.d.ts +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/session-replay.test.js +29 -0
- package/dist/esm/lib/stack-app/apps/implementations/session-replay.test.js.map +1 -0
- package/dist/esm/lib/stack-app/apps/index.d.ts +4 -0
- package/dist/esm/lib/stack-app/apps/index.js +5 -0
- package/dist/esm/lib/stack-app/apps/interfaces/admin-app.d.ts +252 -0
- package/dist/esm/lib/stack-app/apps/interfaces/admin-app.d.ts.map +1 -0
- package/dist/esm/lib/stack-app/apps/interfaces/admin-app.js +8 -0
- package/dist/esm/lib/stack-app/apps/interfaces/admin-app.js.map +1 -0
- package/dist/esm/lib/stack-app/apps/interfaces/client-app.d.ts +220 -0
- package/dist/esm/lib/stack-app/apps/interfaces/client-app.d.ts.map +1 -0
- package/dist/esm/lib/stack-app/apps/interfaces/client-app.js +8 -0
- package/dist/esm/lib/stack-app/apps/interfaces/client-app.js.map +1 -0
- package/dist/esm/lib/stack-app/apps/interfaces/server-app.d.ts +153 -0
- package/dist/esm/lib/stack-app/apps/interfaces/server-app.d.ts.map +1 -0
- package/dist/esm/lib/stack-app/apps/interfaces/server-app.js +8 -0
- package/dist/esm/lib/stack-app/apps/interfaces/server-app.js.map +1 -0
- package/dist/esm/lib/stack-app/common.d.ts +183 -0
- package/dist/esm/lib/stack-app/common.d.ts.map +1 -0
- package/dist/esm/lib/stack-app/common.js +7 -0
- package/dist/esm/lib/stack-app/common.js.map +1 -0
- package/dist/esm/lib/stack-app/connected-accounts/index.d.ts +57 -0
- package/dist/esm/lib/stack-app/connected-accounts/index.d.ts.map +1 -0
- package/dist/esm/lib/stack-app/connected-accounts/index.js +1 -0
- package/dist/esm/lib/stack-app/contact-channels/index.d.ts +43 -0
- package/dist/esm/lib/stack-app/contact-channels/index.d.ts.map +1 -0
- package/dist/esm/lib/stack-app/contact-channels/index.js +39 -0
- package/dist/esm/lib/stack-app/contact-channels/index.js.map +1 -0
- package/dist/esm/lib/stack-app/customers/index.d.ts +129 -0
- package/dist/esm/lib/stack-app/customers/index.d.ts.map +1 -0
- package/dist/esm/lib/stack-app/customers/index.js +1 -0
- package/dist/esm/lib/stack-app/data-vault/index.d.ts +14 -0
- package/dist/esm/lib/stack-app/data-vault/index.d.ts.map +1 -0
- package/dist/esm/lib/stack-app/data-vault/index.js +1 -0
- package/dist/esm/lib/stack-app/email/index.d.ts +204 -0
- package/dist/esm/lib/stack-app/email/index.d.ts.map +1 -0
- package/dist/esm/lib/stack-app/email/index.js +1 -0
- package/dist/esm/lib/stack-app/email-templates/index.d.ts +17 -0
- package/dist/esm/lib/stack-app/email-templates/index.d.ts.map +1 -0
- package/dist/esm/lib/stack-app/email-templates/index.js +11 -0
- package/dist/esm/lib/stack-app/email-templates/index.js.map +1 -0
- package/dist/esm/lib/stack-app/index.d.ts +14 -0
- package/dist/esm/lib/stack-app/index.js +5 -0
- package/dist/esm/lib/stack-app/internal-api-keys/index.d.ts +42 -0
- package/dist/esm/lib/stack-app/internal-api-keys/index.d.ts.map +1 -0
- package/dist/esm/lib/stack-app/internal-api-keys/index.js +14 -0
- package/dist/esm/lib/stack-app/internal-api-keys/index.js.map +1 -0
- package/dist/esm/lib/stack-app/notification-categories/index.d.ts +11 -0
- package/dist/esm/lib/stack-app/notification-categories/index.d.ts.map +1 -0
- package/dist/esm/lib/stack-app/notification-categories/index.js +1 -0
- package/dist/esm/lib/stack-app/permissions/index.d.ts +43 -0
- package/dist/esm/lib/stack-app/permissions/index.d.ts.map +1 -0
- package/dist/esm/lib/stack-app/permissions/index.js +31 -0
- package/dist/esm/lib/stack-app/permissions/index.js.map +1 -0
- package/dist/esm/lib/stack-app/project-configs/index.d.ts +99 -0
- package/dist/esm/lib/stack-app/project-configs/index.d.ts.map +1 -0
- package/dist/esm/lib/stack-app/project-configs/index.js +1 -0
- package/dist/esm/lib/stack-app/projects/index.d.ts +146 -0
- package/dist/esm/lib/stack-app/projects/index.d.ts.map +1 -0
- package/dist/esm/lib/stack-app/projects/index.js +66 -0
- package/dist/esm/lib/stack-app/projects/index.js.map +1 -0
- package/dist/esm/lib/stack-app/session-replays/index.d.ts +66 -0
- package/dist/esm/lib/stack-app/session-replays/index.d.ts.map +1 -0
- package/dist/esm/lib/stack-app/session-replays/index.js +1 -0
- package/dist/esm/lib/stack-app/teams/index.d.ts +163 -0
- package/dist/esm/lib/stack-app/teams/index.d.ts.map +1 -0
- package/dist/esm/lib/stack-app/teams/index.js +35 -0
- package/dist/esm/lib/stack-app/teams/index.js.map +1 -0
- package/dist/esm/lib/stack-app/url-targets.d.ts +40 -0
- package/dist/esm/lib/stack-app/url-targets.d.ts.map +1 -0
- package/dist/esm/lib/stack-app/url-targets.js +280 -0
- package/dist/esm/lib/stack-app/url-targets.js.map +1 -0
- package/dist/esm/lib/stack-app/url-targets.test.d.ts +1 -0
- package/dist/esm/lib/stack-app/url-targets.test.js +169 -0
- package/dist/esm/lib/stack-app/url-targets.test.js.map +1 -0
- package/dist/esm/lib/stack-app/users/index.d.ts +400 -0
- package/dist/esm/lib/stack-app/users/index.d.ts.map +1 -0
- package/dist/esm/lib/stack-app/users/index.js +71 -0
- package/dist/esm/lib/stack-app/users/index.js.map +1 -0
- package/dist/esm/lib/translations.d.ts +7 -0
- package/dist/esm/lib/translations.d.ts.map +1 -0
- package/dist/esm/lib/translations.js +18 -0
- package/dist/esm/lib/translations.js.map +1 -0
- package/dist/esm/providers/stack-context.d.ts +10 -0
- package/dist/esm/providers/stack-context.d.ts.map +1 -0
- package/dist/esm/providers/stack-context.js +10 -0
- package/dist/esm/providers/stack-context.js.map +1 -0
- package/dist/esm/providers/stack-provider-client.d.ts +17 -0
- package/dist/esm/providers/stack-provider-client.d.ts.map +1 -0
- package/dist/esm/providers/stack-provider-client.js +30 -0
- package/dist/esm/providers/stack-provider-client.js.map +1 -0
- package/dist/esm/providers/stack-provider.d.ts +26 -0
- package/dist/esm/providers/stack-provider.d.ts.map +1 -0
- package/dist/esm/providers/stack-provider.js +24 -0
- package/dist/esm/providers/stack-provider.js.map +1 -0
- package/dist/esm/providers/theme-provider.d.ts +46 -0
- package/dist/esm/providers/theme-provider.d.ts.map +1 -0
- package/dist/esm/providers/theme-provider.js +68 -0
- package/dist/esm/providers/theme-provider.js.map +1 -0
- package/dist/esm/providers/translation-provider-client.d.ts +16 -0
- package/dist/esm/providers/translation-provider-client.d.ts.map +1 -0
- package/dist/esm/providers/translation-provider-client.js +20 -0
- package/dist/esm/providers/translation-provider-client.js.map +1 -0
- package/dist/esm/providers/translation-provider.d.ts +16 -0
- package/dist/esm/providers/translation-provider.d.ts.map +1 -0
- package/dist/esm/providers/translation-provider.js +23 -0
- package/dist/esm/providers/translation-provider.js.map +1 -0
- package/dist/esm/tanstack-start-server-context.combined.d.ts +12 -0
- package/dist/esm/tanstack-start-server-context.combined.d.ts.map +1 -0
- package/dist/esm/tanstack-start-server-context.combined.js +1 -0
- package/dist/esm/tanstack-start-server-context.default.d.ts +9 -0
- package/dist/esm/tanstack-start-server-context.default.d.ts.map +1 -0
- package/dist/esm/tanstack-start-server-context.default.js +10 -0
- package/dist/esm/tanstack-start-server-context.default.js.map +1 -0
- package/dist/esm/tanstack-start-server-context.server.d.ts +2 -0
- package/dist/esm/tanstack-start-server-context.server.js +3 -0
- package/dist/esm/utils/browser-script.d.ts +9 -0
- package/dist/esm/utils/browser-script.d.ts.map +1 -0
- package/dist/esm/utils/browser-script.js +105 -0
- package/dist/esm/utils/browser-script.js.map +1 -0
- package/dist/esm/utils/constants.d.ts +81 -0
- package/dist/esm/utils/constants.d.ts.map +1 -0
- package/dist/esm/utils/constants.js +82 -0
- package/dist/esm/utils/constants.js.map +1 -0
- package/dist/esm/utils/url.d.ts +5 -0
- package/dist/esm/utils/url.d.ts.map +1 -0
- package/dist/esm/utils/url.js +16 -0
- package/dist/esm/utils/url.js.map +1 -0
- package/dist/generated/global-css.d.ts +5 -0
- package/dist/generated/global-css.d.ts.map +1 -0
- package/dist/generated/global-css.js +8 -0
- package/dist/generated/global-css.js.map +1 -0
- package/dist/generated/quetzal-translations.d.ts +6 -0
- package/dist/generated/quetzal-translations.d.ts.map +1 -0
- package/dist/generated/quetzal-translations.js +4310 -0
- package/dist/generated/quetzal-translations.js.map +1 -0
- package/dist/global.d.d.ts +0 -0
- package/dist/global.d.ts +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +192 -0
- package/dist/integrations/convex/component/convex.config.d.ts +61 -0
- package/dist/integrations/convex/component/convex.config.d.ts.map +1 -0
- package/dist/integrations/convex/component/convex.config.js +9 -0
- package/dist/integrations/convex/component/convex.config.js.map +1 -0
- package/dist/integrations/convex.d.ts +13 -0
- package/dist/integrations/convex.d.ts.map +1 -0
- package/dist/integrations/convex.js +25 -0
- package/dist/integrations/convex.js.map +1 -0
- package/dist/lib/auth.d.ts +29 -0
- package/dist/lib/auth.d.ts.map +1 -0
- package/dist/lib/auth.js +111 -0
- package/dist/lib/auth.js.map +1 -0
- package/dist/lib/auth.test.d.ts +1 -0
- package/dist/lib/auth.test.js +60 -0
- package/dist/lib/auth.test.js.map +1 -0
- package/dist/lib/cookie.d.ts +50 -0
- package/dist/lib/cookie.d.ts.map +1 -0
- package/dist/lib/cookie.js +366 -0
- package/dist/lib/cookie.js.map +1 -0
- package/dist/lib/env.d.ts +37 -0
- package/dist/lib/env.d.ts.map +1 -0
- package/dist/lib/env.js +90 -0
- package/dist/lib/env.js.map +1 -0
- package/dist/lib/hooks.d.ts +35 -0
- package/dist/lib/hooks.d.ts.map +1 -0
- package/dist/lib/hooks.js +30 -0
- package/dist/lib/hooks.js.map +1 -0
- package/dist/lib/stack-app/api-keys/index.d.ts +53 -0
- package/dist/lib/stack-app/api-keys/index.d.ts.map +1 -0
- package/dist/lib/stack-app/api-keys/index.js +25 -0
- package/dist/lib/stack-app/api-keys/index.js.map +1 -0
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.d.ts +421 -0
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.d.ts.map +1 -0
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js +1041 -0
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -0
- package/dist/lib/stack-app/apps/implementations/client-app-impl.d.ts +561 -0
- package/dist/lib/stack-app/apps/implementations/client-app-impl.d.ts.map +1 -0
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js +2637 -0
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -0
- package/dist/lib/stack-app/apps/implementations/client-app-impl.oauth-prefetch.test.d.ts +1 -0
- package/dist/lib/stack-app/apps/implementations/client-app-impl.oauth-prefetch.test.js +32 -0
- package/dist/lib/stack-app/apps/implementations/client-app-impl.oauth-prefetch.test.js.map +1 -0
- package/dist/lib/stack-app/apps/implementations/common.d.ts +66 -0
- package/dist/lib/stack-app/apps/implementations/common.d.ts.map +1 -0
- package/dist/lib/stack-app/apps/implementations/common.js +186 -0
- package/dist/lib/stack-app/apps/implementations/common.js.map +1 -0
- package/dist/lib/stack-app/apps/implementations/event-tracker.d.ts +42 -0
- package/dist/lib/stack-app/apps/implementations/event-tracker.d.ts.map +1 -0
- package/dist/lib/stack-app/apps/implementations/event-tracker.js +213 -0
- package/dist/lib/stack-app/apps/implementations/event-tracker.js.map +1 -0
- package/dist/lib/stack-app/apps/implementations/event-tracker.test.d.ts +1 -0
- package/dist/lib/stack-app/apps/implementations/event-tracker.test.js +87 -0
- package/dist/lib/stack-app/apps/implementations/event-tracker.test.js.map +1 -0
- package/dist/lib/stack-app/apps/implementations/index.d.ts +9 -0
- package/dist/lib/stack-app/apps/implementations/index.d.ts.map +1 -0
- package/dist/lib/stack-app/apps/implementations/index.js +31 -0
- package/dist/lib/stack-app/apps/implementations/index.js.map +1 -0
- package/dist/lib/stack-app/apps/implementations/redirect-page-urls.d.ts +35 -0
- package/dist/lib/stack-app/apps/implementations/redirect-page-urls.d.ts.map +1 -0
- package/dist/lib/stack-app/apps/implementations/redirect-page-urls.js +191 -0
- package/dist/lib/stack-app/apps/implementations/redirect-page-urls.js.map +1 -0
- package/dist/lib/stack-app/apps/implementations/server-app-impl.d.ts +260 -0
- package/dist/lib/stack-app/apps/implementations/server-app-impl.d.ts.map +1 -0
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js +1385 -0
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -0
- package/dist/lib/stack-app/apps/implementations/session-refresh-subscription.d.ts +28 -0
- package/dist/lib/stack-app/apps/implementations/session-refresh-subscription.d.ts.map +1 -0
- package/dist/lib/stack-app/apps/implementations/session-refresh-subscription.js +33 -0
- package/dist/lib/stack-app/apps/implementations/session-refresh-subscription.js.map +1 -0
- package/dist/lib/stack-app/apps/implementations/session-refresh-subscription.test.d.ts +1 -0
- package/dist/lib/stack-app/apps/implementations/session-refresh-subscription.test.js +82 -0
- package/dist/lib/stack-app/apps/implementations/session-refresh-subscription.test.js.map +1 -0
- package/dist/lib/stack-app/apps/implementations/session-replay.d.ts +108 -0
- package/dist/lib/stack-app/apps/implementations/session-replay.d.ts.map +1 -0
- package/dist/lib/stack-app/apps/implementations/session-replay.js +242 -0
- package/dist/lib/stack-app/apps/implementations/session-replay.js.map +1 -0
- package/dist/lib/stack-app/apps/implementations/session-replay.test.d.ts +1 -0
- package/dist/lib/stack-app/apps/implementations/session-replay.test.js +29 -0
- package/dist/lib/stack-app/apps/implementations/session-replay.test.js.map +1 -0
- package/dist/lib/stack-app/apps/index.d.ts +4 -0
- package/dist/lib/stack-app/apps/index.js +24 -0
- package/dist/lib/stack-app/apps/interfaces/admin-app.d.ts +252 -0
- package/dist/lib/stack-app/apps/interfaces/admin-app.d.ts.map +1 -0
- package/dist/lib/stack-app/apps/interfaces/admin-app.js +10 -0
- package/dist/lib/stack-app/apps/interfaces/admin-app.js.map +1 -0
- package/dist/lib/stack-app/apps/interfaces/client-app.d.ts +220 -0
- package/dist/lib/stack-app/apps/interfaces/client-app.d.ts.map +1 -0
- package/dist/lib/stack-app/apps/interfaces/client-app.js +10 -0
- package/dist/lib/stack-app/apps/interfaces/client-app.js.map +1 -0
- package/dist/lib/stack-app/apps/interfaces/server-app.d.ts +153 -0
- package/dist/lib/stack-app/apps/interfaces/server-app.d.ts.map +1 -0
- package/dist/lib/stack-app/apps/interfaces/server-app.js +10 -0
- package/dist/lib/stack-app/apps/interfaces/server-app.js.map +1 -0
- package/dist/lib/stack-app/common.d.ts +183 -0
- package/dist/lib/stack-app/common.d.ts.map +1 -0
- package/dist/lib/stack-app/common.js +9 -0
- package/dist/lib/stack-app/common.js.map +1 -0
- package/dist/lib/stack-app/connected-accounts/index.d.ts +57 -0
- package/dist/lib/stack-app/connected-accounts/index.d.ts.map +1 -0
- package/dist/lib/stack-app/connected-accounts/index.js +0 -0
- package/dist/lib/stack-app/contact-channels/index.d.ts +43 -0
- package/dist/lib/stack-app/contact-channels/index.d.ts.map +1 -0
- package/dist/lib/stack-app/contact-channels/index.js +44 -0
- package/dist/lib/stack-app/contact-channels/index.js.map +1 -0
- package/dist/lib/stack-app/customers/index.d.ts +129 -0
- package/dist/lib/stack-app/customers/index.d.ts.map +1 -0
- package/dist/lib/stack-app/customers/index.js +0 -0
- package/dist/lib/stack-app/data-vault/index.d.ts +14 -0
- package/dist/lib/stack-app/data-vault/index.d.ts.map +1 -0
- package/dist/lib/stack-app/data-vault/index.js +0 -0
- package/dist/lib/stack-app/email/index.d.ts +204 -0
- package/dist/lib/stack-app/email/index.d.ts.map +1 -0
- package/dist/lib/stack-app/email/index.js +0 -0
- package/dist/lib/stack-app/email-templates/index.d.ts +17 -0
- package/dist/lib/stack-app/email-templates/index.d.ts.map +1 -0
- package/dist/lib/stack-app/email-templates/index.js +13 -0
- package/dist/lib/stack-app/email-templates/index.js.map +1 -0
- package/dist/lib/stack-app/index.d.ts +15 -0
- package/dist/lib/stack-app/index.js +36 -0
- package/dist/lib/stack-app/internal-api-keys/index.d.ts +42 -0
- package/dist/lib/stack-app/internal-api-keys/index.d.ts.map +1 -0
- package/dist/lib/stack-app/internal-api-keys/index.js +16 -0
- package/dist/lib/stack-app/internal-api-keys/index.js.map +1 -0
- package/dist/lib/stack-app/notification-categories/index.d.ts +11 -0
- package/dist/lib/stack-app/notification-categories/index.d.ts.map +1 -0
- package/dist/lib/stack-app/notification-categories/index.js +0 -0
- package/dist/lib/stack-app/permissions/index.d.ts +43 -0
- package/dist/lib/stack-app/permissions/index.d.ts.map +1 -0
- package/dist/lib/stack-app/permissions/index.js +36 -0
- package/dist/lib/stack-app/permissions/index.js.map +1 -0
- package/dist/lib/stack-app/project-configs/index.d.ts +99 -0
- package/dist/lib/stack-app/project-configs/index.d.ts.map +1 -0
- package/dist/lib/stack-app/project-configs/index.js +0 -0
- package/dist/lib/stack-app/projects/index.d.ts +146 -0
- package/dist/lib/stack-app/projects/index.d.ts.map +1 -0
- package/dist/lib/stack-app/projects/index.js +69 -0
- package/dist/lib/stack-app/projects/index.js.map +1 -0
- package/dist/lib/stack-app/session-replays/index.d.ts +66 -0
- package/dist/lib/stack-app/session-replays/index.d.ts.map +1 -0
- package/dist/lib/stack-app/session-replays/index.js +0 -0
- package/dist/lib/stack-app/teams/index.d.ts +163 -0
- package/dist/lib/stack-app/teams/index.d.ts.map +1 -0
- package/dist/lib/stack-app/teams/index.js +40 -0
- package/dist/lib/stack-app/teams/index.js.map +1 -0
- package/dist/lib/stack-app/url-targets.d.ts +40 -0
- package/dist/lib/stack-app/url-targets.d.ts.map +1 -0
- package/dist/lib/stack-app/url-targets.js +289 -0
- package/dist/lib/stack-app/url-targets.js.map +1 -0
- package/dist/lib/stack-app/url-targets.test.d.ts +1 -0
- package/dist/lib/stack-app/url-targets.test.js +169 -0
- package/dist/lib/stack-app/url-targets.test.js.map +1 -0
- package/dist/lib/stack-app/users/index.d.ts +400 -0
- package/dist/lib/stack-app/users/index.d.ts.map +1 -0
- package/dist/lib/stack-app/users/index.js +76 -0
- package/dist/lib/stack-app/users/index.js.map +1 -0
- package/dist/lib/translations.d.ts +7 -0
- package/dist/lib/translations.d.ts.map +1 -0
- package/dist/lib/translations.js +21 -0
- package/dist/lib/translations.js.map +1 -0
- package/dist/providers/stack-context.d.ts +10 -0
- package/dist/providers/stack-context.d.ts.map +1 -0
- package/dist/providers/stack-context.js +13 -0
- package/dist/providers/stack-context.js.map +1 -0
- package/dist/providers/stack-provider-client.d.ts +17 -0
- package/dist/providers/stack-provider-client.d.ts.map +1 -0
- package/dist/providers/stack-provider-client.js +34 -0
- package/dist/providers/stack-provider-client.js.map +1 -0
- package/dist/providers/stack-provider.d.ts +25 -0
- package/dist/providers/stack-provider.d.ts.map +1 -0
- package/dist/providers/stack-provider.js +26 -0
- package/dist/providers/stack-provider.js.map +1 -0
- package/dist/providers/theme-provider.d.ts +46 -0
- package/dist/providers/theme-provider.d.ts.map +1 -0
- package/dist/providers/theme-provider.js +72 -0
- package/dist/providers/theme-provider.js.map +1 -0
- package/dist/providers/translation-provider-client.d.ts +16 -0
- package/dist/providers/translation-provider-client.d.ts.map +1 -0
- package/dist/providers/translation-provider-client.js +23 -0
- package/dist/providers/translation-provider-client.js.map +1 -0
- package/dist/providers/translation-provider.d.ts +16 -0
- package/dist/providers/translation-provider.d.ts.map +1 -0
- package/dist/providers/translation-provider.js +25 -0
- package/dist/providers/translation-provider.js.map +1 -0
- package/dist/storage-CKzvsBxG.d.ts +1912 -0
- package/dist/storage-CKzvsBxG.d.ts.map +1 -0
- package/dist/tanstack-start-server-context.combined.d.ts +12 -0
- package/dist/tanstack-start-server-context.combined.d.ts.map +1 -0
- package/dist/tanstack-start-server-context.combined.js +0 -0
- package/dist/tanstack-start-server-context.default.d.ts +9 -0
- package/dist/tanstack-start-server-context.default.d.ts.map +1 -0
- package/dist/tanstack-start-server-context.default.js +16 -0
- package/dist/tanstack-start-server-context.default.js.map +1 -0
- package/dist/tanstack-start-server-context.server.d.ts +2 -0
- package/dist/tanstack-start-server-context.server.js +34 -0
- package/dist/utils/browser-script.d.ts +9 -0
- package/dist/utils/browser-script.d.ts.map +1 -0
- package/dist/utils/browser-script.js +107 -0
- package/dist/utils/browser-script.js.map +1 -0
- package/dist/utils/constants.d.ts +81 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +92 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/url.d.ts +5 -0
- package/dist/utils/url.d.ts.map +1 -0
- package/dist/utils/url.js +18 -0
- package/dist/utils/url.js.map +1 -0
- package/package.json +129 -6
|
@@ -0,0 +1,2631 @@
|
|
|
1
|
+
import { StackAssertionError, captureError, throwErr } from "@stackframe/stack-shared/dist/utils/errors";
|
|
2
|
+
import { neverResolve, runAsynchronously, wait } from "@stackframe/stack-shared/dist/utils/promises";
|
|
3
|
+
import React, { useCallback, useMemo } from "react";
|
|
4
|
+
import { KnownErrors, StackClientInterface } from "@stackframe/stack-shared";
|
|
5
|
+
import { suspend, suspendIfSsr, use } from "@stackframe/stack-shared/dist/utils/react";
|
|
6
|
+
import { deepPlainEquals, omit } from "@stackframe/stack-shared/dist/utils/objects";
|
|
7
|
+
import { isRelative } from "@stackframe/stack-shared/dist/utils/urls";
|
|
8
|
+
import { Result } from "@stackframe/stack-shared/dist/utils/results";
|
|
9
|
+
import { deindent, mergeScopeStrings } from "@stackframe/stack-shared/dist/utils/strings";
|
|
10
|
+
import { isBrowserLike } from "@stackframe/stack-shared/dist/utils/env";
|
|
11
|
+
import * as tanstackStartServerContext from "@stackframe/tanstack-start/tanstack-start-server-context";
|
|
12
|
+
import { clientVersion, createCache, createCacheBySession, createEmptyTokenStore, getAnalyticsBaseUrl, getDefaultExtraRequestHeaders, getDefaultProjectId, getDefaultPublishableClientKey, getUrls, resolveApiUrls, resolveConstructorOptions, useAsyncCache } from "./common.js";
|
|
13
|
+
import { decodeBase32, decodeBase64, encodeBase32, encodeBase64 } from "@stackframe/stack-shared/dist/utils/bytes";
|
|
14
|
+
import { stackAppInternalsSymbol } from "../../common.js";
|
|
15
|
+
import { adminProjectCreateOptionsToCrud } from "../../projects/index.js";
|
|
16
|
+
import { WebAuthnError, startAuthentication, startRegistration } from "@simplewebauthn/browser";
|
|
17
|
+
import { InternalSession } from "@stackframe/stack-shared/dist/sessions";
|
|
18
|
+
import { parseJson } from "@stackframe/stack-shared/dist/utils/json";
|
|
19
|
+
import { DependenciesMap } from "@stackframe/stack-shared/dist/utils/maps";
|
|
20
|
+
import { Store, storeLock } from "@stackframe/stack-shared/dist/utils/stores";
|
|
21
|
+
import { BotChallengeExecutionFailedError, BotChallengeUserCancelledError, withBotChallengeFlow } from "@stackframe/stack-shared/dist/utils/turnstile-flow";
|
|
22
|
+
import { generateUuid } from "@stackframe/stack-shared/dist/utils/uuids";
|
|
23
|
+
import * as TanStackRouter from "@tanstack/react-router";
|
|
24
|
+
import * as cookie from "cookie";
|
|
25
|
+
import { constructRedirectUrl } from "../../../../utils/url.js";
|
|
26
|
+
import { callOAuthCallback, getNewOAuthProviderOrScopeUrl } from "../../../auth.js";
|
|
27
|
+
import { createBrowserCookieHelper, createCookieHelper, createPlaceholderCookieHelper, deleteCookie, deleteCookieClient, isSecure, saveVerifierAndState, setOrDeleteCookie, setOrDeleteCookieClient } from "../../../cookie.js";
|
|
28
|
+
import { envVars } from "../../../env.js";
|
|
29
|
+
import { apiKeyCreationOptionsToCrud } from "../../api-keys/index.js";
|
|
30
|
+
import { contactChannelCreateOptionsToCrud, contactChannelUpdateOptionsToCrud } from "../../contact-channels/index.js";
|
|
31
|
+
import { teamCreateOptionsToCrud, teamUpdateOptionsToCrud } from "../../teams/index.js";
|
|
32
|
+
import { buildCliAuthConfirmUrl, isHostedHandlerUrlForProject, resolveHandlerUrls } from "../../url-targets.js";
|
|
33
|
+
import { userUpdateOptionsToCrud, withUserDestructureGuard } from "../../users/index.js";
|
|
34
|
+
import { EventTracker } from "./event-tracker.js";
|
|
35
|
+
import { crossDomainAuthQueryParams, getCrossDomainHandoffParamsFromCurrentUrl, planRedirectToHandler } from "./redirect-page-urls.js";
|
|
36
|
+
import { subscribeSessionRefresh } from "./session-refresh-subscription.js";
|
|
37
|
+
import { SessionRecorder, analyticsOptionsFromJson, analyticsOptionsToJson } from "./session-replay.js";
|
|
38
|
+
import { mountDevTool } from "../../../../dev-tool/index.js";
|
|
39
|
+
|
|
40
|
+
//#region src/lib/stack-app/apps/implementations/client-app-impl.ts
|
|
41
|
+
const prefetchedCrossDomainHandoffTtlMs = 3300 * 1e3;
|
|
42
|
+
const allClientApps = /* @__PURE__ */ new Map();
|
|
43
|
+
const STACK_AUTHORIZATION_VALUE_PREFIX = "stackauth_";
|
|
44
|
+
function getAuthorizationHeaderValueFromAuthJson(authJson) {
|
|
45
|
+
if (authJson.accessToken == null && authJson.refreshToken == null) return null;
|
|
46
|
+
return `Bearer ${STACK_AUTHORIZATION_VALUE_PREFIX}${encodeBase64(new TextEncoder().encode(JSON.stringify(authJson)))}`;
|
|
47
|
+
}
|
|
48
|
+
function getAuthJsonFromAuthorizationHeaderValue(authorizationHeaderValue) {
|
|
49
|
+
const match = authorizationHeaderValue.match(/^Bearer\s+(.+)$/i);
|
|
50
|
+
if (match == null) return null;
|
|
51
|
+
const credential = match[1].trim();
|
|
52
|
+
if (!credential.startsWith(STACK_AUTHORIZATION_VALUE_PREFIX)) return null;
|
|
53
|
+
const encodedAuthJson = credential.slice(10);
|
|
54
|
+
if (encodedAuthJson.length === 0) throw new Error("Invalid Authorization header format. Expected `Bearer stackauth_<base64(getAuthJson())>`.");
|
|
55
|
+
let parsed;
|
|
56
|
+
try {
|
|
57
|
+
const decodedAuthJson = new TextDecoder().decode(decodeBase64(encodedAuthJson));
|
|
58
|
+
parsed = JSON.parse(decodedAuthJson);
|
|
59
|
+
} catch (e) {
|
|
60
|
+
throw new Error("Invalid stackauth authorization header.", { cause: e });
|
|
61
|
+
}
|
|
62
|
+
if (parsed == null || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error("Invalid stackauth authorization payload. Expected an object.");
|
|
63
|
+
const accessToken = Reflect.get(parsed, "accessToken");
|
|
64
|
+
const refreshToken = Reflect.get(parsed, "refreshToken");
|
|
65
|
+
if (accessToken != null && typeof accessToken !== "string") throw new Error("Invalid stackauth authorization payload. `accessToken` must be a string or null.");
|
|
66
|
+
if (refreshToken != null && typeof refreshToken !== "string") throw new Error("Invalid stackauth authorization payload. `refreshToken` must be a string or null.");
|
|
67
|
+
return {
|
|
68
|
+
accessToken: accessToken ?? null,
|
|
69
|
+
refreshToken: refreshToken ?? null
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function getHeaderValueFromRequestLikeHeaders(headers, name) {
|
|
73
|
+
if ("get" in headers && typeof headers.get === "function") return headers.get(name);
|
|
74
|
+
const lowerCaseName = name.toLowerCase();
|
|
75
|
+
for (const [headerName, headerValue] of Object.entries(headers)) if (headerName.toLowerCase() === lowerCaseName) return headerValue;
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
function getTanStackStartRequestHeader(name) {
|
|
79
|
+
const { getRequestHeader } = tanstackStartServerContext;
|
|
80
|
+
if (getRequestHeader == null) throw new StackAssertionError("TanStack Start request headers are only available during server rendering");
|
|
81
|
+
return getRequestHeader(name) ?? null;
|
|
82
|
+
}
|
|
83
|
+
async function getServerRequestHost() {
|
|
84
|
+
return getTanStackStartRequestHeader("host");
|
|
85
|
+
}
|
|
86
|
+
var _StackClientAppImplIncomplete = class _StackClientAppImplIncomplete {
|
|
87
|
+
static {
|
|
88
|
+
this.LazyStackAdminAppImpl = { value: void 0 };
|
|
89
|
+
}
|
|
90
|
+
async _createCookieHelper(overrideTokenStoreInit) {
|
|
91
|
+
const tokenStoreInit = overrideTokenStoreInit === void 0 ? this._tokenStoreInit : overrideTokenStoreInit;
|
|
92
|
+
if (tokenStoreInit === "nextjs-cookie" || tokenStoreInit === "cookie") return await createCookieHelper();
|
|
93
|
+
else return await createPlaceholderCookieHelper();
|
|
94
|
+
}
|
|
95
|
+
/** @deprecated Used by legacy getConnectedAccount(providerId) — combines user check + token check + redirect into one cache */
|
|
96
|
+
async _getUserOAuthConnectionCacheFn(options) {
|
|
97
|
+
const user = await options.getUser();
|
|
98
|
+
let hasConnection = true;
|
|
99
|
+
if (!user || !user.oauth_providers.find((p) => p.id === options.providerId)) hasConnection = false;
|
|
100
|
+
if (!await options.getOrWaitOAuthToken()) hasConnection = false;
|
|
101
|
+
if (!hasConnection && options.redirect) {
|
|
102
|
+
if (!options.session) throw new Error(deindent`
|
|
103
|
+
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.
|
|
104
|
+
|
|
105
|
+
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.
|
|
106
|
+
`);
|
|
107
|
+
const location = await getNewOAuthProviderOrScopeUrl(this._interface, {
|
|
108
|
+
provider: options.providerId,
|
|
109
|
+
redirectUrl: this.urls.oauthCallback,
|
|
110
|
+
errorRedirectUrl: this.urls.error,
|
|
111
|
+
providerScope: mergeScopeStrings(options.scope || "", (this._oauthScopesOnSignIn[options.providerId] ?? []).join(" "))
|
|
112
|
+
}, options.session);
|
|
113
|
+
await this._redirectTo({ url: location });
|
|
114
|
+
return await neverResolve();
|
|
115
|
+
} else if (!hasConnection) return null;
|
|
116
|
+
const providerAccountId = user.oauth_providers.find((p) => p.id === options.providerId)?.account_id ?? "";
|
|
117
|
+
return {
|
|
118
|
+
id: options.providerId,
|
|
119
|
+
provider: options.providerId,
|
|
120
|
+
providerAccountId,
|
|
121
|
+
async getAccessToken() {
|
|
122
|
+
const result = await options.getOrWaitOAuthToken();
|
|
123
|
+
if (!result) throw new StackAssertionError(`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\`.`);
|
|
124
|
+
return result;
|
|
125
|
+
},
|
|
126
|
+
useAccessToken() {
|
|
127
|
+
const result = options.useOAuthToken();
|
|
128
|
+
if (!result) throw new StackAssertionError(`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\`.`);
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
_createOAuthConnectionFromCrudItem(item, session) {
|
|
134
|
+
const app = this;
|
|
135
|
+
const providerId = item.provider;
|
|
136
|
+
const providerAccountId = item.provider_account_id;
|
|
137
|
+
return {
|
|
138
|
+
id: providerId,
|
|
139
|
+
provider: providerId,
|
|
140
|
+
providerAccountId,
|
|
141
|
+
async getAccessToken(options) {
|
|
142
|
+
const scopeString = options?.scopes?.join(" ") ?? "";
|
|
143
|
+
const result = Result.orThrow(await app._currentUserOAuthConnectionAccessTokensByAccountCache.getOrWait([
|
|
144
|
+
session,
|
|
145
|
+
providerId,
|
|
146
|
+
providerAccountId,
|
|
147
|
+
scopeString
|
|
148
|
+
], "write-only"));
|
|
149
|
+
if (!result) {
|
|
150
|
+
const scopeDetail = scopeString ? `The requested scopes [${scopeString}] are not available on the existing token.` : "The OAuth refresh token has likely been revoked or expired.";
|
|
151
|
+
return Result.error(new KnownErrors.OAuthAccessTokenNotAvailable(providerId, `${scopeDetail} The user needs to re-authorize by calling \`linkConnectedAccount\` or using \`getOrLinkConnectedAccount\`.`));
|
|
152
|
+
}
|
|
153
|
+
return Result.ok(result);
|
|
154
|
+
},
|
|
155
|
+
useAccessToken(options) {
|
|
156
|
+
const scopeString = options?.scopes?.join(" ") ?? "";
|
|
157
|
+
const result = useAsyncCache(app._currentUserOAuthConnectionAccessTokensByAccountCache, [
|
|
158
|
+
session,
|
|
159
|
+
providerId,
|
|
160
|
+
providerAccountId,
|
|
161
|
+
scopeString
|
|
162
|
+
], "connection.useAccessToken()");
|
|
163
|
+
if (!result) {
|
|
164
|
+
const scopeDetail = scopeString ? `The requested scopes [${scopeString}] are not available on the existing token.` : "The OAuth refresh token has likely been revoked or expired.";
|
|
165
|
+
return Result.error(new KnownErrors.OAuthAccessTokenNotAvailable(providerId, `${scopeDetail} The user needs to re-authorize by calling \`linkConnectedAccount\` or using \`getOrLinkConnectedAccount\`.`));
|
|
166
|
+
}
|
|
167
|
+
return Result.ok(result);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
constructor(options, extraOptions) {
|
|
172
|
+
this._uniqueIdentifier = void 0;
|
|
173
|
+
this._sessionRecorder = null;
|
|
174
|
+
this._eventTracker = null;
|
|
175
|
+
this.__DEMO_ENABLE_SLIGHT_FETCH_DELAY = false;
|
|
176
|
+
this._ownedAdminApps = new DependenciesMap();
|
|
177
|
+
this._currentUserCache = createCacheBySession(async (session) => {
|
|
178
|
+
if (this.__DEMO_ENABLE_SLIGHT_FETCH_DELAY) await wait(2e3);
|
|
179
|
+
if (session.isKnownToBeInvalid()) return null;
|
|
180
|
+
return await this._interface.getClientUserByToken(session);
|
|
181
|
+
});
|
|
182
|
+
this._currentProjectCache = createCache(async () => {
|
|
183
|
+
return Result.orThrow(await this._interface.getClientProject());
|
|
184
|
+
});
|
|
185
|
+
this._ownedProjectsCache = createCacheBySession(async (session) => {
|
|
186
|
+
return await this._interface.listProjects(session);
|
|
187
|
+
});
|
|
188
|
+
this._currentUserPermissionsCache = createCacheBySession(async (session, [teamId, recursive]) => {
|
|
189
|
+
return await this._interface.listCurrentUserTeamPermissions({
|
|
190
|
+
teamId,
|
|
191
|
+
recursive
|
|
192
|
+
}, session);
|
|
193
|
+
});
|
|
194
|
+
this._currentUserProjectPermissionsCache = createCacheBySession(async (session, [recursive]) => {
|
|
195
|
+
return await this._interface.listCurrentUserProjectPermissions({ recursive }, session);
|
|
196
|
+
});
|
|
197
|
+
this._currentUserTeamsCache = createCacheBySession(async (session) => {
|
|
198
|
+
return await this._interface.listCurrentUserTeams(session);
|
|
199
|
+
});
|
|
200
|
+
this._currentUserOAuthConnectionAccessTokensCache = createCacheBySession(async (session, [providerId, scope]) => {
|
|
201
|
+
try {
|
|
202
|
+
return { accessToken: (await this._interface.createProviderAccessToken(providerId, scope || "", session)).access_token };
|
|
203
|
+
} catch (err) {
|
|
204
|
+
if (!(KnownErrors.OAuthConnectionDoesNotHaveRequiredScope.isInstance(err) || KnownErrors.OAuthConnectionNotConnectedToUser.isInstance(err))) throw err;
|
|
205
|
+
}
|
|
206
|
+
return null;
|
|
207
|
+
});
|
|
208
|
+
this._currentUserOAuthConnectionCache = createCacheBySession(async (session, [providerId, scope, redirect]) => {
|
|
209
|
+
return await this._getUserOAuthConnectionCacheFn({
|
|
210
|
+
getUser: async () => Result.orThrow(await this._currentUserCache.getOrWait([session], "write-only")),
|
|
211
|
+
getOrWaitOAuthToken: async () => Result.orThrow(await this._currentUserOAuthConnectionAccessTokensCache.getOrWait([
|
|
212
|
+
session,
|
|
213
|
+
providerId,
|
|
214
|
+
scope || ""
|
|
215
|
+
], "write-only")),
|
|
216
|
+
useOAuthToken: () => useAsyncCache(this._currentUserOAuthConnectionAccessTokensCache, [
|
|
217
|
+
session,
|
|
218
|
+
providerId,
|
|
219
|
+
scope || ""
|
|
220
|
+
], "connection.useAccessToken()"),
|
|
221
|
+
providerId,
|
|
222
|
+
scope,
|
|
223
|
+
redirect,
|
|
224
|
+
session
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
this._currentUserConnectedAccountsCache = createCacheBySession(async (session) => {
|
|
228
|
+
return (await this._interface.listConnectedAccounts(session)).items.map((item) => this._createOAuthConnectionFromCrudItem(item, session));
|
|
229
|
+
});
|
|
230
|
+
this._currentUserOAuthConnectionAccessTokensByAccountCache = createCacheBySession(async (session, [providerId, providerAccountId, scope]) => {
|
|
231
|
+
try {
|
|
232
|
+
return { accessToken: (await this._interface.createProviderAccessTokenByAccount(providerId, providerAccountId, scope, session)).access_token };
|
|
233
|
+
} catch (err) {
|
|
234
|
+
if (KnownErrors.OAuthConnectionDoesNotHaveRequiredScope.isInstance(err) || KnownErrors.OAuthConnectionNotConnectedToUser.isInstance(err)) return null;
|
|
235
|
+
throw err;
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
this._currentUserValidConnectedAccountForProviderCache = createCacheBySession(async (session, [provider, scopeString]) => {
|
|
239
|
+
const matchingAccounts = Result.orThrow(await this._currentUserConnectedAccountsCache.getOrWait([session], "write-only")).filter((a) => a.provider === provider);
|
|
240
|
+
const scopes = scopeString ? scopeString.split(" ") : void 0;
|
|
241
|
+
for (const account of matchingAccounts) if ((await account.getAccessToken({ scopes })).status === "ok") return account;
|
|
242
|
+
const location = await getNewOAuthProviderOrScopeUrl(this._interface, {
|
|
243
|
+
provider,
|
|
244
|
+
redirectUrl: this.urls.oauthCallback,
|
|
245
|
+
errorRedirectUrl: this.urls.error,
|
|
246
|
+
providerScope: mergeScopeStrings(scopeString, (this._oauthScopesOnSignIn[provider] ?? []).join(" "))
|
|
247
|
+
}, session);
|
|
248
|
+
await this._redirectTo({ url: location });
|
|
249
|
+
return await neverResolve();
|
|
250
|
+
});
|
|
251
|
+
this._teamMemberProfilesCache = createCacheBySession(async (session, [teamId]) => {
|
|
252
|
+
return await this._interface.listTeamMemberProfiles({ teamId }, session);
|
|
253
|
+
});
|
|
254
|
+
this._teamInvitationsCache = createCacheBySession(async (session, [teamId]) => {
|
|
255
|
+
return await this._interface.listTeamInvitations({ teamId }, session);
|
|
256
|
+
});
|
|
257
|
+
this._currentUserTeamProfileCache = createCacheBySession(async (session, [teamId]) => {
|
|
258
|
+
return await this._interface.getTeamMemberProfile({
|
|
259
|
+
teamId,
|
|
260
|
+
userId: "me"
|
|
261
|
+
}, session);
|
|
262
|
+
});
|
|
263
|
+
this._currentUserTeamInvitationsCache = createCacheBySession(async (session) => {
|
|
264
|
+
return await this._interface.listCurrentUserTeamInvitations(session);
|
|
265
|
+
});
|
|
266
|
+
this._clientContactChannelsCache = createCacheBySession(async (session) => {
|
|
267
|
+
return await this._interface.listClientContactChannels(session);
|
|
268
|
+
});
|
|
269
|
+
this._userApiKeysCache = createCacheBySession(async (session) => {
|
|
270
|
+
return await this._interface.listProjectApiKeys({ user_id: "me" }, session, "client");
|
|
271
|
+
});
|
|
272
|
+
this._teamApiKeysCache = createCacheBySession(async (session, [teamId]) => {
|
|
273
|
+
return await this._interface.listProjectApiKeys({ team_id: teamId }, session, "client");
|
|
274
|
+
});
|
|
275
|
+
this._notificationCategoriesCache = createCacheBySession(async (session) => {
|
|
276
|
+
return await this._interface.listNotificationCategories(session);
|
|
277
|
+
});
|
|
278
|
+
this._currentUserOAuthProvidersCache = createCacheBySession(async (session) => {
|
|
279
|
+
return await this._interface.listOAuthProviders({ user_id: "me" }, session);
|
|
280
|
+
});
|
|
281
|
+
this._userItemCache = createCacheBySession(async (session, [userId, itemId]) => {
|
|
282
|
+
return await this._interface.getItem({
|
|
283
|
+
userId,
|
|
284
|
+
itemId
|
|
285
|
+
}, session);
|
|
286
|
+
});
|
|
287
|
+
this._teamItemCache = createCacheBySession(async (session, [teamId, itemId]) => {
|
|
288
|
+
return await this._interface.getItem({
|
|
289
|
+
teamId,
|
|
290
|
+
itemId
|
|
291
|
+
}, session);
|
|
292
|
+
});
|
|
293
|
+
this._customItemCache = createCacheBySession(async (session, [customCustomerId, itemId]) => {
|
|
294
|
+
return await this._interface.getItem({
|
|
295
|
+
customCustomerId,
|
|
296
|
+
itemId
|
|
297
|
+
}, session);
|
|
298
|
+
});
|
|
299
|
+
this._userProductsCache = createCacheBySession(async (session, [userId, cursor, limit]) => {
|
|
300
|
+
return await this._interface.listProducts({
|
|
301
|
+
customer_type: "user",
|
|
302
|
+
customer_id: userId,
|
|
303
|
+
cursor: cursor ?? void 0,
|
|
304
|
+
limit: limit ?? void 0
|
|
305
|
+
}, session);
|
|
306
|
+
});
|
|
307
|
+
this._teamProductsCache = createCacheBySession(async (session, [teamId, cursor, limit]) => {
|
|
308
|
+
return await this._interface.listProducts({
|
|
309
|
+
customer_type: "team",
|
|
310
|
+
customer_id: teamId,
|
|
311
|
+
cursor: cursor ?? void 0,
|
|
312
|
+
limit: limit ?? void 0
|
|
313
|
+
}, session);
|
|
314
|
+
});
|
|
315
|
+
this._customProductsCache = createCacheBySession(async (session, [customCustomerId, cursor, limit]) => {
|
|
316
|
+
return await this._interface.listProducts({
|
|
317
|
+
customer_type: "custom",
|
|
318
|
+
customer_id: customCustomerId,
|
|
319
|
+
cursor: cursor ?? void 0,
|
|
320
|
+
limit: limit ?? void 0
|
|
321
|
+
}, session);
|
|
322
|
+
});
|
|
323
|
+
this._userInvoicesCache = createCacheBySession(async (session, [userId, cursor, limit]) => {
|
|
324
|
+
return await this._interface.listInvoices({
|
|
325
|
+
customer_type: "user",
|
|
326
|
+
customer_id: userId,
|
|
327
|
+
cursor: cursor ?? void 0,
|
|
328
|
+
limit: limit ?? void 0
|
|
329
|
+
}, session);
|
|
330
|
+
});
|
|
331
|
+
this._teamInvoicesCache = createCacheBySession(async (session, [teamId, cursor, limit]) => {
|
|
332
|
+
return await this._interface.listInvoices({
|
|
333
|
+
customer_type: "team",
|
|
334
|
+
customer_id: teamId,
|
|
335
|
+
cursor: cursor ?? void 0,
|
|
336
|
+
limit: limit ?? void 0
|
|
337
|
+
}, session);
|
|
338
|
+
});
|
|
339
|
+
this._customerBillingCache = createCacheBySession(async (session, [customerType, customerId]) => {
|
|
340
|
+
return await this._interface.getCustomerBilling(customerType, customerId, session);
|
|
341
|
+
});
|
|
342
|
+
this._convexPartialUserCache = createCache(async ([ctx]) => await this._getPartialUserFromConvex(ctx));
|
|
343
|
+
this._trustedParentDomainCache = createCache(async ([domain]) => await this._getTrustedParentDomain(domain));
|
|
344
|
+
this._anonymousSignUpInProgress = null;
|
|
345
|
+
this._prefetchedCrossDomainHandoffParams = null;
|
|
346
|
+
this._prefetchedCrossDomainHandoffParamsFetchedAt = 0;
|
|
347
|
+
this._isPrefetchingCrossDomainHandoffParams = false;
|
|
348
|
+
this._memoryTokenStore = createEmptyTokenStore();
|
|
349
|
+
this._nextServerCookiesTokenStores = /* @__PURE__ */ new WeakMap();
|
|
350
|
+
this._requestTokenStores = /* @__PURE__ */ new WeakMap();
|
|
351
|
+
this._storedBrowserCookieTokenStore = null;
|
|
352
|
+
this._mostRecentQueuedCookieRefreshIndex = 0;
|
|
353
|
+
this._sessionsByTokenStoreAndSessionKey = /* @__PURE__ */ new WeakMap();
|
|
354
|
+
this._botChallengeSiteKeysWarned = false;
|
|
355
|
+
const resolvedOptions = resolveConstructorOptions(options);
|
|
356
|
+
if (!_StackClientAppImplIncomplete.LazyStackAdminAppImpl.value) throw new StackAssertionError("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).");
|
|
357
|
+
this._options = resolvedOptions;
|
|
358
|
+
this._extraOptions = extraOptions;
|
|
359
|
+
const projectId = resolvedOptions.projectId ?? getDefaultProjectId();
|
|
360
|
+
if (projectId !== "internal" && !projectId.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i)) throw new Error(`Invalid project ID: ${projectId}. Project IDs must be UUIDs. Please check your environment variables and/or your StackApp.`);
|
|
361
|
+
const publishableClientKey = resolvedOptions.publishableClientKey ?? getDefaultPublishableClientKey();
|
|
362
|
+
if (extraOptions && extraOptions.interface) this._interface = extraOptions.interface;
|
|
363
|
+
else {
|
|
364
|
+
const apiUrls = resolveApiUrls(resolvedOptions.baseUrl);
|
|
365
|
+
this._interface = new StackClientInterface({
|
|
366
|
+
getBaseUrl: () => apiUrls()[0],
|
|
367
|
+
getAnalyticsBaseUrl: () => getAnalyticsBaseUrl(apiUrls()[0]),
|
|
368
|
+
getApiUrls: apiUrls,
|
|
369
|
+
extraRequestHeaders: resolvedOptions.extraRequestHeaders ?? getDefaultExtraRequestHeaders(),
|
|
370
|
+
projectId,
|
|
371
|
+
clientVersion,
|
|
372
|
+
...publishableClientKey != null ? { publishableClientKey } : {},
|
|
373
|
+
prepareRequest: async () => {}
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
this._tokenStoreInit = resolvedOptions.tokenStore;
|
|
377
|
+
this._redirectMethod = resolvedOptions.redirectMethod || (isBrowserLike() ? "window" : "none");
|
|
378
|
+
this._redirectMethod = resolvedOptions.redirectMethod || "tanstack-start";
|
|
379
|
+
this._urlOptions = resolvedOptions.urls ?? {};
|
|
380
|
+
this._oauthScopesOnSignIn = resolvedOptions.oauthScopesOnSignIn ?? {};
|
|
381
|
+
if (isBrowserLike() && (resolvedOptions.tokenStore === "cookie" || resolvedOptions.tokenStore === "nextjs-cookie")) {
|
|
382
|
+
runAsynchronously(this._trustedParentDomainCache.getOrWait([window.location.hostname], "write-only"));
|
|
383
|
+
this._ensureCrossSubdomainCookieExists();
|
|
384
|
+
}
|
|
385
|
+
if (extraOptions && extraOptions.uniqueIdentifier) {
|
|
386
|
+
this._uniqueIdentifier = extraOptions.uniqueIdentifier;
|
|
387
|
+
this._initUniqueIdentifier();
|
|
388
|
+
}
|
|
389
|
+
this._analyticsOptions = resolvedOptions.analytics;
|
|
390
|
+
const getAnalyticsSession = async () => {
|
|
391
|
+
this._ensurePersistentTokenStore();
|
|
392
|
+
if (await this.getPartialUser({
|
|
393
|
+
from: "token",
|
|
394
|
+
or: "anonymous-if-exists"
|
|
395
|
+
})) return await this._getSession();
|
|
396
|
+
return (await this.getUser({ or: "anonymous" }))._internalSession;
|
|
397
|
+
};
|
|
398
|
+
const analyticsEnabled = this._analyticsOptions?.enabled !== false;
|
|
399
|
+
if (analyticsEnabled && isBrowserLike() && this._hasPersistentTokenStore() && this._analyticsOptions?.replays?.enabled === true) {
|
|
400
|
+
this._sessionRecorder = new SessionRecorder({
|
|
401
|
+
projectId: this.projectId,
|
|
402
|
+
sendBatch: async (body, opts) => {
|
|
403
|
+
return await this._interface.sendSessionReplayBatch(body, await getAnalyticsSession(), opts);
|
|
404
|
+
}
|
|
405
|
+
}, this._analyticsOptions.replays);
|
|
406
|
+
this._sessionRecorder.start();
|
|
407
|
+
}
|
|
408
|
+
if (analyticsEnabled && isBrowserLike() && this._hasPersistentTokenStore()) {
|
|
409
|
+
this._eventTracker = new EventTracker({
|
|
410
|
+
projectId: this.projectId,
|
|
411
|
+
sendBatch: async (body, opts) => {
|
|
412
|
+
return await this._interface.sendAnalyticsEventBatch(body, await getAnalyticsSession(), opts);
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
this._eventTracker.start();
|
|
416
|
+
}
|
|
417
|
+
if (isBrowserLike() && resolvedOptions.devTool !== false) mountDevTool(this);
|
|
418
|
+
}
|
|
419
|
+
_initUniqueIdentifier() {
|
|
420
|
+
if (!this._uniqueIdentifier) throw new StackAssertionError("Unique identifier not initialized");
|
|
421
|
+
if (allClientApps.has(this._uniqueIdentifier)) throw new StackAssertionError("A Stack client app with the same unique identifier already exists");
|
|
422
|
+
allClientApps.set(this._uniqueIdentifier, [this._extraOptions?.checkString ?? void 0, this]);
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Cloudflare workers does not allow use of randomness on the global scope (on which the Stack app is probably
|
|
426
|
+
* initialized). For that reason, we generate the unique identifier lazily when it is first needed instead of in the
|
|
427
|
+
* constructor.
|
|
428
|
+
*/
|
|
429
|
+
_getUniqueIdentifier() {
|
|
430
|
+
if (!this._uniqueIdentifier) {
|
|
431
|
+
this._uniqueIdentifier = generateUuid();
|
|
432
|
+
this._initUniqueIdentifier();
|
|
433
|
+
}
|
|
434
|
+
return this._uniqueIdentifier;
|
|
435
|
+
}
|
|
436
|
+
async _checkFeatureSupport(name, options) {
|
|
437
|
+
return await this._interface.checkFeatureSupport({
|
|
438
|
+
...options,
|
|
439
|
+
name
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
_useCheckFeatureSupport(name, options) {
|
|
443
|
+
runAsynchronously(this._checkFeatureSupport(name, options));
|
|
444
|
+
throw new StackAssertionError(`${name} is not currently supported. Please reach out to Stack support for more information.`);
|
|
445
|
+
}
|
|
446
|
+
get _legacyRefreshTokenCookieName() {
|
|
447
|
+
return `stack-refresh-${this.projectId}`;
|
|
448
|
+
}
|
|
449
|
+
get _refreshTokenCookieName() {
|
|
450
|
+
return `stack-refresh-${this.projectId}`;
|
|
451
|
+
}
|
|
452
|
+
_getRefreshTokenDefaultCookieNameForSecure(secure) {
|
|
453
|
+
return `${secure ? "__Host-" : ""}${this._refreshTokenCookieName}--default`;
|
|
454
|
+
}
|
|
455
|
+
_getCustomRefreshCookieName(domain) {
|
|
456
|
+
const encoded = encodeBase32(new TextEncoder().encode(domain.toLowerCase()));
|
|
457
|
+
return `${this._refreshTokenCookieName}--custom-${encoded}`;
|
|
458
|
+
}
|
|
459
|
+
_getDomainFromCustomRefreshCookieName(name) {
|
|
460
|
+
const prefix = `${this._refreshTokenCookieName}--custom-`;
|
|
461
|
+
if (!name.startsWith(prefix)) return null;
|
|
462
|
+
try {
|
|
463
|
+
return new TextDecoder().decode(decodeBase32(name.slice(prefix.length)));
|
|
464
|
+
} catch {
|
|
465
|
+
return null;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
_formatRefreshCookieValue(refreshToken, updatedAt) {
|
|
469
|
+
return JSON.stringify({
|
|
470
|
+
refresh_token: refreshToken,
|
|
471
|
+
updated_at_millis: updatedAt
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
_formatAccessCookieValue(refreshToken, accessToken) {
|
|
475
|
+
return refreshToken && accessToken ? JSON.stringify([refreshToken, accessToken]) : null;
|
|
476
|
+
}
|
|
477
|
+
_parseStructuredRefreshCookie(value) {
|
|
478
|
+
if (!value) return null;
|
|
479
|
+
const parsed = parseJson(value);
|
|
480
|
+
if (parsed.status !== "ok" || typeof parsed.data !== "object" || parsed.data === null) {
|
|
481
|
+
console.warn("Failed to parse structured refresh cookie");
|
|
482
|
+
return null;
|
|
483
|
+
}
|
|
484
|
+
const data = parsed.data;
|
|
485
|
+
const refreshToken = "refresh_token" in data && typeof data.refresh_token === "string" ? data.refresh_token : null;
|
|
486
|
+
const updatedAt = "updated_at_millis" in data && typeof data.updated_at_millis === "number" ? data.updated_at_millis : null;
|
|
487
|
+
if (!refreshToken) {
|
|
488
|
+
console.warn("Refresh token not found in structured refresh cookie");
|
|
489
|
+
return null;
|
|
490
|
+
}
|
|
491
|
+
return {
|
|
492
|
+
refreshToken,
|
|
493
|
+
updatedAt
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
_extractRefreshTokenFromCookieMap(cookies) {
|
|
497
|
+
const { legacyNames, structuredPrefixes } = this._getRefreshTokenCookieNamePatterns();
|
|
498
|
+
for (const name of legacyNames) {
|
|
499
|
+
const value = cookies[name];
|
|
500
|
+
if (value) return {
|
|
501
|
+
refreshToken: value,
|
|
502
|
+
updatedAt: null
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
let selected = null;
|
|
506
|
+
for (const [name, value] of Object.entries(cookies)) {
|
|
507
|
+
if (!structuredPrefixes.some((prefix) => name.startsWith(prefix))) continue;
|
|
508
|
+
const parsed = this._parseStructuredRefreshCookie(value);
|
|
509
|
+
if (!parsed) continue;
|
|
510
|
+
const candidateUpdatedAt = parsed.updatedAt ?? Number.NEGATIVE_INFINITY;
|
|
511
|
+
const selectedUpdatedAt = selected?.updatedAt ?? Number.NEGATIVE_INFINITY;
|
|
512
|
+
if (!selected || candidateUpdatedAt > selectedUpdatedAt) selected = parsed;
|
|
513
|
+
}
|
|
514
|
+
if (!selected) return {
|
|
515
|
+
refreshToken: null,
|
|
516
|
+
updatedAt: null
|
|
517
|
+
};
|
|
518
|
+
return {
|
|
519
|
+
refreshToken: selected.refreshToken,
|
|
520
|
+
updatedAt: selected.updatedAt ?? null
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
_getTokensFromCookies(cookies) {
|
|
524
|
+
const { refreshToken } = this._extractRefreshTokenFromCookieMap(cookies);
|
|
525
|
+
const accessTokenCookie = cookies[this._accessTokenCookieName] ?? null;
|
|
526
|
+
let accessToken = null;
|
|
527
|
+
if (accessTokenCookie && accessTokenCookie.startsWith("[\"")) {
|
|
528
|
+
const parsed = parseJson(accessTokenCookie);
|
|
529
|
+
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") {
|
|
530
|
+
if (parsed.data[0] === refreshToken) accessToken = parsed.data[1];
|
|
531
|
+
} else console.warn("Access token cookie has invalid format");
|
|
532
|
+
}
|
|
533
|
+
return {
|
|
534
|
+
refreshToken,
|
|
535
|
+
accessToken
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
get _accessTokenCookieName() {
|
|
539
|
+
return `stack-access`;
|
|
540
|
+
}
|
|
541
|
+
_getAllBrowserCookies() {
|
|
542
|
+
if (!isBrowserLike()) throw new StackAssertionError("Cannot get browser cookies on the server!");
|
|
543
|
+
return cookie.parseCookie(document.cookie || "");
|
|
544
|
+
}
|
|
545
|
+
_getRefreshTokenCookieNamePatterns() {
|
|
546
|
+
return {
|
|
547
|
+
legacyNames: [this._legacyRefreshTokenCookieName, "stack-refresh"],
|
|
548
|
+
structuredPrefixes: [`${this._refreshTokenCookieName}--`, `__Host-${this._refreshTokenCookieName}--`]
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
_collectRefreshTokenCookieNames(cookies) {
|
|
552
|
+
const { legacyNames, structuredPrefixes } = this._getRefreshTokenCookieNamePatterns();
|
|
553
|
+
const names = /* @__PURE__ */ new Set();
|
|
554
|
+
for (const name of legacyNames) if (cookies[name]) names.add(name);
|
|
555
|
+
for (const name of Object.keys(cookies)) if (structuredPrefixes.some((prefix) => name.startsWith(prefix))) names.add(name);
|
|
556
|
+
return names;
|
|
557
|
+
}
|
|
558
|
+
_prepareRefreshCookieUpdate(existingCookies, refreshToken, accessToken, defaultCookieName) {
|
|
559
|
+
const cookieNames = this._collectRefreshTokenCookieNames(existingCookies);
|
|
560
|
+
cookieNames.delete(defaultCookieName);
|
|
561
|
+
const updatedAt = refreshToken ? Date.now() : null;
|
|
562
|
+
return {
|
|
563
|
+
updatedAt,
|
|
564
|
+
refreshCookieValue: refreshToken && updatedAt !== null ? this._formatRefreshCookieValue(refreshToken, updatedAt) : null,
|
|
565
|
+
accessTokenPayload: this._formatAccessCookieValue(refreshToken, accessToken),
|
|
566
|
+
cookieNamesToDelete: [...cookieNames]
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
_ensureCrossSubdomainCookieExists() {
|
|
570
|
+
runAsynchronously(async () => {
|
|
571
|
+
const hostname = window.location.hostname;
|
|
572
|
+
const domain = await this._trustedParentDomainCache.getOrWait([hostname], "read-write");
|
|
573
|
+
if (domain.status === "error" || !domain.data) return;
|
|
574
|
+
const cookies = this._getAllBrowserCookies();
|
|
575
|
+
const customCookieName = this._getCustomRefreshCookieName(domain.data);
|
|
576
|
+
if (cookies[customCookieName]) return;
|
|
577
|
+
const { refreshToken, updatedAt } = this._extractRefreshTokenFromCookieMap(cookies);
|
|
578
|
+
if (refreshToken && updatedAt) setOrDeleteCookieClient(customCookieName, this._formatRefreshCookieValue(refreshToken, updatedAt), {
|
|
579
|
+
maxAge: 3600 * 24 * 365,
|
|
580
|
+
domain: domain.data
|
|
581
|
+
});
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
_queueCustomRefreshCookieUpdate(refreshToken, updatedAt, context) {
|
|
585
|
+
runAsynchronously(async () => {
|
|
586
|
+
this._mostRecentQueuedCookieRefreshIndex++;
|
|
587
|
+
const updateIndex = this._mostRecentQueuedCookieRefreshIndex;
|
|
588
|
+
let hostname;
|
|
589
|
+
if (isBrowserLike()) hostname = window.location.hostname;
|
|
590
|
+
else hostname = await getServerRequestHost();
|
|
591
|
+
if (!hostname) {
|
|
592
|
+
console.warn("No hostname found when queueing custom refresh cookie update");
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
const domain = await this._trustedParentDomainCache.getOrWait([hostname], "read-write");
|
|
596
|
+
const cookieOptions = {
|
|
597
|
+
maxAge: 3600 * 24 * 365,
|
|
598
|
+
noOpIfServerComponent: true
|
|
599
|
+
};
|
|
600
|
+
const setCookie = async (targetDomain, value) => {
|
|
601
|
+
const name = this._getCustomRefreshCookieName(targetDomain);
|
|
602
|
+
const options = {
|
|
603
|
+
...cookieOptions,
|
|
604
|
+
domain: targetDomain
|
|
605
|
+
};
|
|
606
|
+
if (context === "browser") setOrDeleteCookieClient(name, value, options);
|
|
607
|
+
else await setOrDeleteCookie(name, value, options);
|
|
608
|
+
};
|
|
609
|
+
if (domain.status === "error" || !domain.data || updateIndex !== this._mostRecentQueuedCookieRefreshIndex) return;
|
|
610
|
+
const value = refreshToken && updatedAt ? this._formatRefreshCookieValue(refreshToken, updatedAt) : null;
|
|
611
|
+
await setCookie(domain.data, value);
|
|
612
|
+
const isSecure$1 = await isSecure();
|
|
613
|
+
await setOrDeleteCookie(this._getRefreshTokenDefaultCookieNameForSecure(isSecure$1), null, cookieOptions);
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
async _getTrustedParentDomain(currentDomain) {
|
|
617
|
+
const domains = Result.orThrow(await this._interface.getClientProject()).config.domains.map((d) => d.domain.trim().replace(/^https?:\/\//, "").split("/")[0]?.toLowerCase());
|
|
618
|
+
const trustedWildcards = domains.filter((d) => d.startsWith("**."));
|
|
619
|
+
const parts = currentDomain.split(".");
|
|
620
|
+
for (let i = parts.length - 2; i >= 0; i--) {
|
|
621
|
+
const parentDomain = parts.slice(i).join(".");
|
|
622
|
+
if (domains.includes(parentDomain) && trustedWildcards.includes("**." + parentDomain)) return parentDomain;
|
|
623
|
+
}
|
|
624
|
+
return null;
|
|
625
|
+
}
|
|
626
|
+
_getBrowserCookieTokenStore() {
|
|
627
|
+
if (!isBrowserLike()) throw new Error("Cannot use cookie token store on the server!");
|
|
628
|
+
if (this._storedBrowserCookieTokenStore === null) {
|
|
629
|
+
const getCurrentValue = (old) => {
|
|
630
|
+
const tokens = this._getTokensFromCookies(this._getAllBrowserCookies());
|
|
631
|
+
return {
|
|
632
|
+
refreshToken: tokens.refreshToken,
|
|
633
|
+
accessToken: tokens.accessToken ?? (old?.refreshToken === tokens.refreshToken ? old.accessToken : null)
|
|
634
|
+
};
|
|
635
|
+
};
|
|
636
|
+
this._storedBrowserCookieTokenStore = new Store(getCurrentValue(null));
|
|
637
|
+
let hasSucceededInWriting = true;
|
|
638
|
+
setInterval(() => {
|
|
639
|
+
if (hasSucceededInWriting) {
|
|
640
|
+
const oldValue = this._storedBrowserCookieTokenStore.get();
|
|
641
|
+
const currentValue = getCurrentValue(oldValue);
|
|
642
|
+
if (!deepPlainEquals(currentValue, oldValue)) this._storedBrowserCookieTokenStore.set(currentValue);
|
|
643
|
+
}
|
|
644
|
+
}, 100);
|
|
645
|
+
this._storedBrowserCookieTokenStore.onChange((value) => {
|
|
646
|
+
try {
|
|
647
|
+
const refreshToken = value.refreshToken;
|
|
648
|
+
const secure = window.location.protocol === "https:";
|
|
649
|
+
const defaultName = this._getRefreshTokenDefaultCookieNameForSecure(secure);
|
|
650
|
+
const { updatedAt, refreshCookieValue, accessTokenPayload, cookieNamesToDelete } = this._prepareRefreshCookieUpdate(this._getAllBrowserCookies(), refreshToken, value.accessToken ?? null, defaultName);
|
|
651
|
+
setOrDeleteCookieClient(defaultName, refreshCookieValue, {
|
|
652
|
+
maxAge: 3600 * 24 * 365,
|
|
653
|
+
secure
|
|
654
|
+
});
|
|
655
|
+
setOrDeleteCookieClient(this._accessTokenCookieName, accessTokenPayload, { maxAge: 3600 * 24 });
|
|
656
|
+
cookieNamesToDelete.forEach((name) => {
|
|
657
|
+
const domain = this._getDomainFromCustomRefreshCookieName(name);
|
|
658
|
+
deleteCookieClient(name, domain ? { domain } : {});
|
|
659
|
+
});
|
|
660
|
+
this._queueCustomRefreshCookieUpdate(refreshToken, updatedAt, "browser");
|
|
661
|
+
hasSucceededInWriting = true;
|
|
662
|
+
} catch (e) {
|
|
663
|
+
if (!isBrowserLike()) hasSucceededInWriting = false;
|
|
664
|
+
else throw e;
|
|
665
|
+
}
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
return this._storedBrowserCookieTokenStore;
|
|
669
|
+
}
|
|
670
|
+
_getOrCreateTokenStore(cookieHelper, overrideTokenStoreInit) {
|
|
671
|
+
const tokenStoreInit = overrideTokenStoreInit === void 0 ? this._tokenStoreInit : overrideTokenStoreInit;
|
|
672
|
+
switch (tokenStoreInit) {
|
|
673
|
+
case "cookie":
|
|
674
|
+
if (!isBrowserLike()) return this._getOrCreateTokenStore(cookieHelper, "nextjs-cookie");
|
|
675
|
+
return this._getBrowserCookieTokenStore();
|
|
676
|
+
case "nextjs-cookie": if (isBrowserLike()) return this._getBrowserCookieTokenStore();
|
|
677
|
+
else {
|
|
678
|
+
const store = new Store(this._getTokensFromCookies(cookieHelper.getAll()));
|
|
679
|
+
store.onChange((value) => {
|
|
680
|
+
runAsynchronously(async () => {
|
|
681
|
+
const refreshToken = value.refreshToken;
|
|
682
|
+
const secure = await isSecure();
|
|
683
|
+
const defaultName = this._getRefreshTokenDefaultCookieNameForSecure(secure);
|
|
684
|
+
const { updatedAt, refreshCookieValue, accessTokenPayload, cookieNamesToDelete } = this._prepareRefreshCookieUpdate(cookieHelper.getAll(), refreshToken, value.accessToken ?? null, defaultName);
|
|
685
|
+
await Promise.all([setOrDeleteCookie(defaultName, refreshCookieValue, {
|
|
686
|
+
maxAge: 3600 * 24 * 365,
|
|
687
|
+
noOpIfServerComponent: true
|
|
688
|
+
}), setOrDeleteCookie(this._accessTokenCookieName, accessTokenPayload, {
|
|
689
|
+
maxAge: 3600 * 24,
|
|
690
|
+
noOpIfServerComponent: true
|
|
691
|
+
})]);
|
|
692
|
+
if (cookieNamesToDelete.length > 0) await Promise.all(cookieNamesToDelete.map((name) => {
|
|
693
|
+
const domain = this._getDomainFromCustomRefreshCookieName(name);
|
|
694
|
+
return deleteCookie(name, {
|
|
695
|
+
noOpIfServerComponent: true,
|
|
696
|
+
...domain ? { domain } : {}
|
|
697
|
+
});
|
|
698
|
+
}));
|
|
699
|
+
this._queueCustomRefreshCookieUpdate(refreshToken, updatedAt, "server");
|
|
700
|
+
});
|
|
701
|
+
});
|
|
702
|
+
return store;
|
|
703
|
+
}
|
|
704
|
+
case "memory": return this._memoryTokenStore;
|
|
705
|
+
default:
|
|
706
|
+
if (tokenStoreInit === null) return createEmptyTokenStore();
|
|
707
|
+
else if (typeof tokenStoreInit === "object" && "headers" in tokenStoreInit) {
|
|
708
|
+
if (this._requestTokenStores.has(tokenStoreInit)) return this._requestTokenStores.get(tokenStoreInit);
|
|
709
|
+
const authorizationHeader = getHeaderValueFromRequestLikeHeaders(tokenStoreInit.headers, "authorization");
|
|
710
|
+
if (authorizationHeader) {
|
|
711
|
+
const authJson = getAuthJsonFromAuthorizationHeaderValue(authorizationHeader);
|
|
712
|
+
if (authJson != null) {
|
|
713
|
+
const tokenStore = new Store({
|
|
714
|
+
accessToken: authJson.accessToken,
|
|
715
|
+
refreshToken: authJson.refreshToken
|
|
716
|
+
});
|
|
717
|
+
this._requestTokenStores.set(tokenStoreInit, tokenStore);
|
|
718
|
+
return tokenStore;
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
const stackAuthHeader = getHeaderValueFromRequestLikeHeaders(tokenStoreInit.headers, "x-stack-auth");
|
|
722
|
+
if (stackAuthHeader) {
|
|
723
|
+
let parsed;
|
|
724
|
+
try {
|
|
725
|
+
parsed = JSON.parse(stackAuthHeader);
|
|
726
|
+
if (typeof parsed !== "object") throw new Error("x-stack-auth header must be a JSON object");
|
|
727
|
+
if (parsed === null) throw new Error("x-stack-auth header must not be null");
|
|
728
|
+
} catch (e) {
|
|
729
|
+
throw new Error("Invalid x-stack-auth header.", { cause: e });
|
|
730
|
+
}
|
|
731
|
+
return this._getOrCreateTokenStore(cookieHelper, {
|
|
732
|
+
accessToken: parsed.accessToken ?? null,
|
|
733
|
+
refreshToken: parsed.refreshToken ?? null
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
const cookieHeader = getHeaderValueFromRequestLikeHeaders(tokenStoreInit.headers, "cookie");
|
|
737
|
+
const parsed = cookie.parseCookie(cookieHeader || "");
|
|
738
|
+
const res = new Store(this._getTokensFromCookies(parsed));
|
|
739
|
+
this._requestTokenStores.set(tokenStoreInit, res);
|
|
740
|
+
return res;
|
|
741
|
+
} else if ("accessToken" in tokenStoreInit || "refreshToken" in tokenStoreInit) return new Store({
|
|
742
|
+
refreshToken: tokenStoreInit.refreshToken,
|
|
743
|
+
accessToken: tokenStoreInit.accessToken
|
|
744
|
+
});
|
|
745
|
+
throw new Error(`Invalid token store ${tokenStoreInit}`);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
_useTokenStore(overrideTokenStoreInit) {
|
|
749
|
+
if (!isBrowserLike()) return this._getOrCreateTokenStore(use(createCookieHelper()), overrideTokenStoreInit);
|
|
750
|
+
suspendIfSsr();
|
|
751
|
+
const cookieHelper = createBrowserCookieHelper();
|
|
752
|
+
return this._getOrCreateTokenStore(cookieHelper, overrideTokenStoreInit);
|
|
753
|
+
}
|
|
754
|
+
_getSessionFromTokenStore(tokenStore) {
|
|
755
|
+
const tokenObj = tokenStore.get();
|
|
756
|
+
const sessionKey = InternalSession.calculateSessionKey(tokenObj);
|
|
757
|
+
const existing = sessionKey ? this._sessionsByTokenStoreAndSessionKey.get(tokenStore)?.get(sessionKey) : null;
|
|
758
|
+
if (existing) return existing;
|
|
759
|
+
const session = this._interface.createSession({
|
|
760
|
+
refreshToken: tokenObj.refreshToken,
|
|
761
|
+
accessToken: tokenObj.accessToken
|
|
762
|
+
});
|
|
763
|
+
session.onAccessTokenChange((newAccessToken) => {
|
|
764
|
+
tokenStore.update((old) => ({
|
|
765
|
+
...old,
|
|
766
|
+
accessToken: newAccessToken?.token ?? null
|
|
767
|
+
}));
|
|
768
|
+
});
|
|
769
|
+
session.onInvalidate(() => {
|
|
770
|
+
tokenStore.update((old) => ({
|
|
771
|
+
...old,
|
|
772
|
+
accessToken: null,
|
|
773
|
+
refreshToken: null
|
|
774
|
+
}));
|
|
775
|
+
});
|
|
776
|
+
let sessionsBySessionKey = this._sessionsByTokenStoreAndSessionKey.get(tokenStore) ?? /* @__PURE__ */ new Map();
|
|
777
|
+
this._sessionsByTokenStoreAndSessionKey.set(tokenStore, sessionsBySessionKey);
|
|
778
|
+
sessionsBySessionKey.set(sessionKey, session);
|
|
779
|
+
return session;
|
|
780
|
+
}
|
|
781
|
+
async _getSession(overrideTokenStoreInit) {
|
|
782
|
+
const tokenStore = this._getOrCreateTokenStore(await this._createCookieHelper(overrideTokenStoreInit), overrideTokenStoreInit);
|
|
783
|
+
return this._getSessionFromTokenStore(tokenStore);
|
|
784
|
+
}
|
|
785
|
+
_useSession(overrideTokenStoreInit) {
|
|
786
|
+
const tokenStore = this._useTokenStore(overrideTokenStoreInit);
|
|
787
|
+
const subscribe = useCallback((cb) => {
|
|
788
|
+
return subscribeSessionRefresh({
|
|
789
|
+
tokenStore,
|
|
790
|
+
getSession: () => this._getSessionFromTokenStore(tokenStore),
|
|
791
|
+
onTokenStoreChange: cb
|
|
792
|
+
});
|
|
793
|
+
}, [tokenStore]);
|
|
794
|
+
const getSnapshot = useCallback(() => this._getSessionFromTokenStore(tokenStore), [tokenStore]);
|
|
795
|
+
return React.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
796
|
+
}
|
|
797
|
+
async _signInToAccountWithTokens(tokens) {
|
|
798
|
+
if (!("accessToken" in tokens) || !("refreshToken" in tokens)) throw new StackAssertionError("Invalid tokens object; can't sign in with this", { tokens });
|
|
799
|
+
const tokenStore = this._getOrCreateTokenStore(await this._createCookieHelper());
|
|
800
|
+
tokenStore.set(tokens);
|
|
801
|
+
const newSession = this._getSessionFromTokenStore(tokenStore);
|
|
802
|
+
this._currentUserCache.getOrWait([newSession], "write-only").catch(() => {});
|
|
803
|
+
}
|
|
804
|
+
_hasPersistentTokenStore(overrideTokenStoreInit) {
|
|
805
|
+
return (overrideTokenStoreInit !== void 0 ? overrideTokenStoreInit : this._tokenStoreInit) !== null;
|
|
806
|
+
}
|
|
807
|
+
_ensurePersistentTokenStore(overrideTokenStoreInit) {
|
|
808
|
+
if (!this._hasPersistentTokenStore(overrideTokenStoreInit)) throw new Error("Cannot call this function on a Stack app without a persistent token store. Make sure the tokenStore option on the constructor is set to a non-null value when initializing Stack.\n\nStack uses token stores to access access tokens of the current user. For example, on web frontends it is commonly the string value 'cookies' for cookie storage.");
|
|
809
|
+
}
|
|
810
|
+
_isInternalProject() {
|
|
811
|
+
return this.projectId === "internal";
|
|
812
|
+
}
|
|
813
|
+
_ensureInternalProject() {
|
|
814
|
+
if (!this._isInternalProject()) throw new Error("Cannot call this function on a Stack app with a project ID other than 'internal'.");
|
|
815
|
+
}
|
|
816
|
+
_clientProjectFromCrud(crud) {
|
|
817
|
+
return {
|
|
818
|
+
id: crud.id,
|
|
819
|
+
displayName: crud.display_name,
|
|
820
|
+
config: {
|
|
821
|
+
signUpEnabled: crud.config.sign_up_enabled,
|
|
822
|
+
credentialEnabled: crud.config.credential_enabled,
|
|
823
|
+
magicLinkEnabled: crud.config.magic_link_enabled,
|
|
824
|
+
passkeyEnabled: crud.config.passkey_enabled,
|
|
825
|
+
clientTeamCreationEnabled: crud.config.client_team_creation_enabled,
|
|
826
|
+
clientUserDeletionEnabled: crud.config.client_user_deletion_enabled,
|
|
827
|
+
allowTeamApiKeys: crud.config.allow_team_api_keys,
|
|
828
|
+
allowUserApiKeys: crud.config.allow_user_api_keys,
|
|
829
|
+
oauthProviders: crud.config.enabled_oauth_providers.map((p) => ({ id: p.id }))
|
|
830
|
+
}
|
|
831
|
+
};
|
|
832
|
+
}
|
|
833
|
+
_clientPermissionFromCrud(crud) {
|
|
834
|
+
return { id: crud.id };
|
|
835
|
+
}
|
|
836
|
+
_clientTeamUserFromCrud(crud) {
|
|
837
|
+
return {
|
|
838
|
+
id: crud.user_id,
|
|
839
|
+
teamProfile: {
|
|
840
|
+
displayName: crud.display_name,
|
|
841
|
+
profileImageUrl: crud.profile_image_url
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
_clientSentTeamInvitationFromCrud(session, crud) {
|
|
846
|
+
return {
|
|
847
|
+
id: crud.id,
|
|
848
|
+
recipientEmail: crud.recipient_email,
|
|
849
|
+
expiresAt: new Date(crud.expires_at_millis),
|
|
850
|
+
revoke: async () => {
|
|
851
|
+
await this._interface.revokeTeamInvitation(crud.id, crud.team_id, session);
|
|
852
|
+
await this._teamInvitationsCache.refresh([session, crud.team_id]);
|
|
853
|
+
}
|
|
854
|
+
};
|
|
855
|
+
}
|
|
856
|
+
_clientReceivedTeamInvitationFromCrud(session, crud) {
|
|
857
|
+
const app = this;
|
|
858
|
+
return {
|
|
859
|
+
id: crud.id,
|
|
860
|
+
teamId: crud.team_id,
|
|
861
|
+
teamDisplayName: crud.team_display_name,
|
|
862
|
+
recipientEmail: crud.recipient_email,
|
|
863
|
+
expiresAt: new Date(crud.expires_at_millis),
|
|
864
|
+
accept: async () => {
|
|
865
|
+
await app._interface.acceptTeamInvitationById(crud.id, session);
|
|
866
|
+
await Promise.all([
|
|
867
|
+
app._currentUserTeamInvitationsCache.refresh([session]),
|
|
868
|
+
app._currentUserTeamsCache.refresh([session]),
|
|
869
|
+
app._teamInvitationsCache.refresh([session, crud.team_id])
|
|
870
|
+
]);
|
|
871
|
+
}
|
|
872
|
+
};
|
|
873
|
+
}
|
|
874
|
+
_baseApiKeyFromCrud(crud) {
|
|
875
|
+
return {
|
|
876
|
+
id: crud.id,
|
|
877
|
+
description: crud.description,
|
|
878
|
+
expiresAt: crud.expires_at_millis ? new Date(crud.expires_at_millis) : void 0,
|
|
879
|
+
manuallyRevokedAt: crud.manually_revoked_at_millis ? new Date(crud.manually_revoked_at_millis) : null,
|
|
880
|
+
createdAt: new Date(crud.created_at_millis),
|
|
881
|
+
...crud.type === "team" ? {
|
|
882
|
+
type: "team",
|
|
883
|
+
teamId: crud.team_id
|
|
884
|
+
} : {
|
|
885
|
+
type: "user",
|
|
886
|
+
userId: crud.user_id
|
|
887
|
+
},
|
|
888
|
+
value: typeof crud.value === "string" ? crud.value : { lastFour: crud.value.last_four },
|
|
889
|
+
isValid: function() {
|
|
890
|
+
return this.whyInvalid() === null;
|
|
891
|
+
},
|
|
892
|
+
whyInvalid: function() {
|
|
893
|
+
if (this.manuallyRevokedAt) return "manually-revoked";
|
|
894
|
+
if (this.expiresAt && this.expiresAt < /* @__PURE__ */ new Date()) return "expired";
|
|
895
|
+
return null;
|
|
896
|
+
}
|
|
897
|
+
};
|
|
898
|
+
}
|
|
899
|
+
_clientApiKeyFromCrud(session, crud) {
|
|
900
|
+
return {
|
|
901
|
+
...this._baseApiKeyFromCrud(crud),
|
|
902
|
+
async revoke() {
|
|
903
|
+
await this.update({ revoked: true });
|
|
904
|
+
},
|
|
905
|
+
update: async (options) => {
|
|
906
|
+
await this._interface.updateProjectApiKey(crud.type === "team" ? { team_id: crud.team_id } : { user_id: crud.user_id }, crud.id, options, session, "client");
|
|
907
|
+
if (crud.type === "team") await this._teamApiKeysCache.refresh([session, crud.team_id]);
|
|
908
|
+
else await this._userApiKeysCache.refresh([session]);
|
|
909
|
+
}
|
|
910
|
+
};
|
|
911
|
+
}
|
|
912
|
+
_clientTeamFromCrud(crud, session) {
|
|
913
|
+
const app = this;
|
|
914
|
+
return {
|
|
915
|
+
id: crud.id,
|
|
916
|
+
displayName: crud.display_name,
|
|
917
|
+
profileImageUrl: crud.profile_image_url,
|
|
918
|
+
clientMetadata: crud.client_metadata,
|
|
919
|
+
clientReadOnlyMetadata: crud.client_read_only_metadata,
|
|
920
|
+
...this._createCustomer(crud.id, "team", session),
|
|
921
|
+
async inviteUser(options) {
|
|
922
|
+
await app._interface.sendTeamInvitation({
|
|
923
|
+
teamId: crud.id,
|
|
924
|
+
email: options.email,
|
|
925
|
+
session,
|
|
926
|
+
callbackUrl: options.callbackUrl ?? constructRedirectUrl(app.urls.teamInvitation, "callbackUrl")
|
|
927
|
+
});
|
|
928
|
+
await app._teamInvitationsCache.refresh([session, crud.id]);
|
|
929
|
+
},
|
|
930
|
+
async listUsers() {
|
|
931
|
+
return Result.orThrow(await app._teamMemberProfilesCache.getOrWait([session, crud.id], "write-only")).map((crud) => app._clientTeamUserFromCrud(crud));
|
|
932
|
+
},
|
|
933
|
+
useUsers() {
|
|
934
|
+
return useAsyncCache(app._teamMemberProfilesCache, [session, crud.id], "team.useUsers()").map((crud) => app._clientTeamUserFromCrud(crud));
|
|
935
|
+
},
|
|
936
|
+
async listInvitations() {
|
|
937
|
+
return Result.orThrow(await app._teamInvitationsCache.getOrWait([session, crud.id], "write-only")).map((crud) => app._clientSentTeamInvitationFromCrud(session, crud));
|
|
938
|
+
},
|
|
939
|
+
useInvitations() {
|
|
940
|
+
return useAsyncCache(app._teamInvitationsCache, [session, crud.id], "team.useInvitations()").map((crud) => app._clientSentTeamInvitationFromCrud(session, crud));
|
|
941
|
+
},
|
|
942
|
+
async update(data) {
|
|
943
|
+
await app._interface.updateTeam({
|
|
944
|
+
data: teamUpdateOptionsToCrud(data),
|
|
945
|
+
teamId: crud.id
|
|
946
|
+
}, session);
|
|
947
|
+
await app._currentUserTeamsCache.refresh([session]);
|
|
948
|
+
},
|
|
949
|
+
async delete() {
|
|
950
|
+
await app._interface.deleteTeam(crud.id, session);
|
|
951
|
+
await app._currentUserTeamsCache.refresh([session]);
|
|
952
|
+
},
|
|
953
|
+
useApiKeys() {
|
|
954
|
+
return useAsyncCache(app._teamApiKeysCache, [session, crud.id], "team.useApiKeys()").map((crud) => app._clientApiKeyFromCrud(session, crud));
|
|
955
|
+
},
|
|
956
|
+
async listApiKeys() {
|
|
957
|
+
return Result.orThrow(await app._teamApiKeysCache.getOrWait([session, crud.id], "write-only")).map((crud) => app._clientApiKeyFromCrud(session, crud));
|
|
958
|
+
},
|
|
959
|
+
async createApiKey(options) {
|
|
960
|
+
const result = await app._interface.createProjectApiKey(await apiKeyCreationOptionsToCrud("team", crud.id, options), session, "client");
|
|
961
|
+
await app._teamApiKeysCache.refresh([session, crud.id]);
|
|
962
|
+
return app._clientApiKeyFromCrud(session, result);
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
}
|
|
966
|
+
_clientContactChannelFromCrud(crud, session) {
|
|
967
|
+
const app = this;
|
|
968
|
+
return {
|
|
969
|
+
id: crud.id,
|
|
970
|
+
value: crud.value,
|
|
971
|
+
type: crud.type,
|
|
972
|
+
isVerified: crud.is_verified,
|
|
973
|
+
isPrimary: crud.is_primary,
|
|
974
|
+
usedForAuth: crud.used_for_auth,
|
|
975
|
+
async sendVerificationEmail(options) {
|
|
976
|
+
await app._interface.sendCurrentUserContactChannelVerificationEmail(crud.id, options?.callbackUrl || constructRedirectUrl(app.urls.emailVerification, "callbackUrl"), session);
|
|
977
|
+
},
|
|
978
|
+
async update(data) {
|
|
979
|
+
await app._interface.updateClientContactChannel(crud.id, contactChannelUpdateOptionsToCrud(data), session);
|
|
980
|
+
await app._clientContactChannelsCache.refresh([session]);
|
|
981
|
+
},
|
|
982
|
+
async delete() {
|
|
983
|
+
await app._interface.deleteClientContactChannel(crud.id, session);
|
|
984
|
+
await app._clientContactChannelsCache.refresh([session]);
|
|
985
|
+
}
|
|
986
|
+
};
|
|
987
|
+
}
|
|
988
|
+
_clientNotificationCategoryFromCrud(crud, session) {
|
|
989
|
+
const app = this;
|
|
990
|
+
return {
|
|
991
|
+
id: crud.notification_category_id,
|
|
992
|
+
name: crud.notification_category_name,
|
|
993
|
+
enabled: crud.enabled,
|
|
994
|
+
canDisable: crud.can_disable,
|
|
995
|
+
async setEnabled(enabled) {
|
|
996
|
+
await app._interface.setNotificationsEnabled(crud.notification_category_id, enabled, session);
|
|
997
|
+
await app._notificationCategoriesCache.refresh([session]);
|
|
998
|
+
}
|
|
999
|
+
};
|
|
1000
|
+
}
|
|
1001
|
+
_clientOAuthProviderFromCrud(crud, session) {
|
|
1002
|
+
const app = this;
|
|
1003
|
+
return {
|
|
1004
|
+
id: crud.id,
|
|
1005
|
+
type: crud.type,
|
|
1006
|
+
userId: crud.user_id,
|
|
1007
|
+
email: crud.email,
|
|
1008
|
+
allowSignIn: crud.allow_sign_in,
|
|
1009
|
+
allowConnectedAccounts: crud.allow_connected_accounts,
|
|
1010
|
+
async update(data) {
|
|
1011
|
+
try {
|
|
1012
|
+
await app._interface.updateOAuthProvider(crud.user_id, crud.id, {
|
|
1013
|
+
allow_sign_in: data.allowSignIn,
|
|
1014
|
+
allow_connected_accounts: data.allowConnectedAccounts
|
|
1015
|
+
}, session);
|
|
1016
|
+
await Promise.all([app._currentUserOAuthProvidersCache.refresh([session]), app._currentUserConnectedAccountsCache.refresh([session])]);
|
|
1017
|
+
return Result.ok(void 0);
|
|
1018
|
+
} catch (error) {
|
|
1019
|
+
if (KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn.isInstance(error)) return Result.error(error);
|
|
1020
|
+
throw error;
|
|
1021
|
+
}
|
|
1022
|
+
},
|
|
1023
|
+
async delete() {
|
|
1024
|
+
await app._interface.deleteOAuthProvider(crud.user_id, crud.id, session);
|
|
1025
|
+
await Promise.all([app._currentUserOAuthProvidersCache.refresh([session]), app._currentUserConnectedAccountsCache.refresh([session])]);
|
|
1026
|
+
}
|
|
1027
|
+
};
|
|
1028
|
+
}
|
|
1029
|
+
_clientItemFromCrud(crud) {
|
|
1030
|
+
return {
|
|
1031
|
+
displayName: crud.display_name,
|
|
1032
|
+
quantity: crud.quantity,
|
|
1033
|
+
nonNegativeQuantity: Math.max(0, crud.quantity)
|
|
1034
|
+
};
|
|
1035
|
+
}
|
|
1036
|
+
_customerProductsFromResponse(response) {
|
|
1037
|
+
const products = response.items.map((item) => ({
|
|
1038
|
+
id: item.id,
|
|
1039
|
+
quantity: item.quantity,
|
|
1040
|
+
displayName: item.product.display_name,
|
|
1041
|
+
customerType: item.product.customer_type,
|
|
1042
|
+
isServerOnly: item.product.server_only,
|
|
1043
|
+
stackable: item.product.stackable,
|
|
1044
|
+
type: item.type,
|
|
1045
|
+
subscription: item.subscription ? {
|
|
1046
|
+
subscriptionId: item.subscription.subscription_id,
|
|
1047
|
+
currentPeriodEnd: item.subscription.current_period_end ? new Date(item.subscription.current_period_end) : null,
|
|
1048
|
+
cancelAtPeriodEnd: item.subscription.cancel_at_period_end,
|
|
1049
|
+
isCancelable: item.subscription.is_cancelable
|
|
1050
|
+
} : null,
|
|
1051
|
+
switchOptions: item.switch_options?.map((option) => ({
|
|
1052
|
+
productId: option.product_id,
|
|
1053
|
+
displayName: option.product.display_name,
|
|
1054
|
+
prices: option.product.prices
|
|
1055
|
+
}))
|
|
1056
|
+
}));
|
|
1057
|
+
return Object.assign(products, { nextCursor: response.pagination.next_cursor ?? null });
|
|
1058
|
+
}
|
|
1059
|
+
_customerInvoicesFromResponse(response) {
|
|
1060
|
+
const invoices = response.items.map((item) => ({
|
|
1061
|
+
status: item.status,
|
|
1062
|
+
amountTotal: item.amount_total,
|
|
1063
|
+
hostedInvoiceUrl: item.hosted_invoice_url,
|
|
1064
|
+
createdAt: new Date(item.created_at_millis)
|
|
1065
|
+
}));
|
|
1066
|
+
return Object.assign(invoices, { nextCursor: response.pagination.next_cursor ?? null });
|
|
1067
|
+
}
|
|
1068
|
+
_customerBillingFromResponse(response) {
|
|
1069
|
+
return {
|
|
1070
|
+
hasCustomer: response.has_customer,
|
|
1071
|
+
defaultPaymentMethod: response.default_payment_method
|
|
1072
|
+
};
|
|
1073
|
+
}
|
|
1074
|
+
_createAuth(session) {
|
|
1075
|
+
const app = this;
|
|
1076
|
+
return {
|
|
1077
|
+
_internalSession: session,
|
|
1078
|
+
currentSession: {
|
|
1079
|
+
async getTokens() {
|
|
1080
|
+
const tokens = await session.getOrFetchLikelyValidTokens(2e4, 75e3);
|
|
1081
|
+
return {
|
|
1082
|
+
accessToken: tokens?.accessToken.token ?? null,
|
|
1083
|
+
refreshToken: tokens?.refreshToken?.token ?? null
|
|
1084
|
+
};
|
|
1085
|
+
},
|
|
1086
|
+
useTokens() {
|
|
1087
|
+
const subscribe = useCallback((cb) => {
|
|
1088
|
+
const { unsubscribe: unsubscribeInvalidate } = session.onInvalidate(cb);
|
|
1089
|
+
const { unsubscribe: unsubscribeAccessTokenChange } = session.onAccessTokenChange(cb);
|
|
1090
|
+
return () => {
|
|
1091
|
+
unsubscribeInvalidate();
|
|
1092
|
+
unsubscribeAccessTokenChange();
|
|
1093
|
+
};
|
|
1094
|
+
}, [session]);
|
|
1095
|
+
const getSnapshot = useCallback(() => {
|
|
1096
|
+
return session.isKnownToBeInvalid() ? null : session.getAccessTokenIfNotExpiredYet(2e4, 75e3)?.token ?? null;
|
|
1097
|
+
}, [session]);
|
|
1098
|
+
let accessToken = React.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
1099
|
+
if (accessToken === null && !session.isKnownToBeInvalid()) accessToken = use(session.getOrFetchLikelyValidTokens(2e4, 75e3))?.accessToken.token ?? null;
|
|
1100
|
+
return {
|
|
1101
|
+
accessToken,
|
|
1102
|
+
refreshToken: session.getRefreshToken()?.token ?? null
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1105
|
+
},
|
|
1106
|
+
async getAccessToken() {
|
|
1107
|
+
return (await this.currentSession.getTokens()).accessToken;
|
|
1108
|
+
},
|
|
1109
|
+
useAccessToken() {
|
|
1110
|
+
return this.currentSession.useTokens().accessToken;
|
|
1111
|
+
},
|
|
1112
|
+
async getRefreshToken() {
|
|
1113
|
+
return (await this.currentSession.getTokens()).refreshToken;
|
|
1114
|
+
},
|
|
1115
|
+
useRefreshToken() {
|
|
1116
|
+
return this.currentSession.useTokens().refreshToken;
|
|
1117
|
+
},
|
|
1118
|
+
async getAuthorizationHeader() {
|
|
1119
|
+
return getAuthorizationHeaderValueFromAuthJson(await this.getAuthJson());
|
|
1120
|
+
},
|
|
1121
|
+
useAuthorizationHeader() {
|
|
1122
|
+
return getAuthorizationHeaderValueFromAuthJson(this.useAuthJson());
|
|
1123
|
+
},
|
|
1124
|
+
async getAuthHeaders() {
|
|
1125
|
+
return { "x-stack-auth": JSON.stringify(await this.getAuthJson()) };
|
|
1126
|
+
},
|
|
1127
|
+
useAuthHeaders() {
|
|
1128
|
+
return { "x-stack-auth": JSON.stringify(this.useAuthJson()) };
|
|
1129
|
+
},
|
|
1130
|
+
async getAuthJson() {
|
|
1131
|
+
return await this.currentSession.getTokens();
|
|
1132
|
+
},
|
|
1133
|
+
useAuthJson() {
|
|
1134
|
+
return this.currentSession.useTokens();
|
|
1135
|
+
},
|
|
1136
|
+
signOut(options) {
|
|
1137
|
+
return app._signOut(session, options);
|
|
1138
|
+
}
|
|
1139
|
+
};
|
|
1140
|
+
}
|
|
1141
|
+
_editableTeamProfileFromCrud(crud, session) {
|
|
1142
|
+
const app = this;
|
|
1143
|
+
return {
|
|
1144
|
+
displayName: crud.display_name,
|
|
1145
|
+
profileImageUrl: crud.profile_image_url,
|
|
1146
|
+
async update(update) {
|
|
1147
|
+
await app._interface.updateTeamMemberProfile({
|
|
1148
|
+
teamId: crud.team_id,
|
|
1149
|
+
userId: crud.user_id,
|
|
1150
|
+
profile: {
|
|
1151
|
+
display_name: update.displayName,
|
|
1152
|
+
profile_image_url: update.profileImageUrl
|
|
1153
|
+
}
|
|
1154
|
+
}, session);
|
|
1155
|
+
await app._currentUserTeamProfileCache.refresh([session, crud.team_id]);
|
|
1156
|
+
}
|
|
1157
|
+
};
|
|
1158
|
+
}
|
|
1159
|
+
_createBaseUser(crud) {
|
|
1160
|
+
return {
|
|
1161
|
+
id: crud.id,
|
|
1162
|
+
displayName: crud.display_name,
|
|
1163
|
+
primaryEmail: crud.primary_email,
|
|
1164
|
+
primaryEmailVerified: crud.primary_email_verified,
|
|
1165
|
+
profileImageUrl: crud.profile_image_url,
|
|
1166
|
+
signedUpAt: new Date(crud.signed_up_at_millis),
|
|
1167
|
+
clientMetadata: crud.client_metadata,
|
|
1168
|
+
clientReadOnlyMetadata: crud.client_read_only_metadata,
|
|
1169
|
+
hasPassword: crud.has_password,
|
|
1170
|
+
emailAuthEnabled: crud.auth_with_email,
|
|
1171
|
+
otpAuthEnabled: crud.otp_auth_enabled,
|
|
1172
|
+
oauthProviders: crud.oauth_providers,
|
|
1173
|
+
passkeyAuthEnabled: crud.passkey_auth_enabled,
|
|
1174
|
+
isMultiFactorRequired: crud.requires_totp_mfa,
|
|
1175
|
+
isAnonymous: crud.is_anonymous,
|
|
1176
|
+
isRestricted: crud.is_restricted,
|
|
1177
|
+
restrictedReason: crud.restricted_reason,
|
|
1178
|
+
toClientJson() {
|
|
1179
|
+
return crud;
|
|
1180
|
+
}
|
|
1181
|
+
};
|
|
1182
|
+
}
|
|
1183
|
+
_createUserExtraFromCurrent(crud, session) {
|
|
1184
|
+
const app = this;
|
|
1185
|
+
async function getConnectedAccount(idOrAccount, options) {
|
|
1186
|
+
const scopeString = options?.scopes?.join(" ") ?? "";
|
|
1187
|
+
if (typeof idOrAccount === "object" && "provider" in idOrAccount && "providerAccountId" in idOrAccount) {
|
|
1188
|
+
const { provider, providerAccountId } = idOrAccount;
|
|
1189
|
+
const found = Result.orThrow(await app._currentUserConnectedAccountsCache.getOrWait([session], "write-only")).find((a) => a.provider === provider && a.providerAccountId === providerAccountId);
|
|
1190
|
+
if (!found) return null;
|
|
1191
|
+
return found;
|
|
1192
|
+
}
|
|
1193
|
+
return Result.orThrow(await app._currentUserOAuthConnectionCache.getOrWait([
|
|
1194
|
+
session,
|
|
1195
|
+
idOrAccount,
|
|
1196
|
+
scopeString,
|
|
1197
|
+
options?.or === "redirect"
|
|
1198
|
+
], "write-only"));
|
|
1199
|
+
}
|
|
1200
|
+
function useConnectedAccount(idOrAccount, options) {
|
|
1201
|
+
const scopeString = options?.scopes?.join(" ") ?? "";
|
|
1202
|
+
if (typeof idOrAccount === "object" && "provider" in idOrAccount && "providerAccountId" in idOrAccount) {
|
|
1203
|
+
const { provider, providerAccountId } = idOrAccount;
|
|
1204
|
+
return useAsyncCache(app._currentUserConnectedAccountsCache, [session], "user.useConnectedAccount()").find((a) => a.provider === provider && a.providerAccountId === providerAccountId) ?? null;
|
|
1205
|
+
}
|
|
1206
|
+
return useAsyncCache(app._currentUserOAuthConnectionCache, [
|
|
1207
|
+
session,
|
|
1208
|
+
idOrAccount,
|
|
1209
|
+
scopeString,
|
|
1210
|
+
options?.or === "redirect"
|
|
1211
|
+
], "user.useConnectedAccount()");
|
|
1212
|
+
}
|
|
1213
|
+
return {
|
|
1214
|
+
async getActiveSessions() {
|
|
1215
|
+
return (await app._interface.listSessions(session)).items.map((crud) => app._clientSessionFromCrud(crud));
|
|
1216
|
+
},
|
|
1217
|
+
async revokeSession(sessionId) {
|
|
1218
|
+
await app._interface.deleteSession(sessionId, session);
|
|
1219
|
+
},
|
|
1220
|
+
setDisplayName(displayName) {
|
|
1221
|
+
return this.update({ displayName });
|
|
1222
|
+
},
|
|
1223
|
+
setClientMetadata(metadata) {
|
|
1224
|
+
return this.update({ clientMetadata: metadata });
|
|
1225
|
+
},
|
|
1226
|
+
async setSelectedTeam(team) {
|
|
1227
|
+
await this.update({ selectedTeamId: typeof team === "string" ? team : team?.id ?? null });
|
|
1228
|
+
},
|
|
1229
|
+
getConnectedAccount,
|
|
1230
|
+
useConnectedAccount,
|
|
1231
|
+
async listConnectedAccounts() {
|
|
1232
|
+
return Result.orThrow(await app._currentUserConnectedAccountsCache.getOrWait([session], "write-only"));
|
|
1233
|
+
},
|
|
1234
|
+
useConnectedAccounts() {
|
|
1235
|
+
return useAsyncCache(app._currentUserConnectedAccountsCache, [session], "user.useConnectedAccounts()");
|
|
1236
|
+
},
|
|
1237
|
+
async linkConnectedAccount(provider, options) {
|
|
1238
|
+
const scopeString = options?.scopes?.join(" ") ?? "";
|
|
1239
|
+
const location = await getNewOAuthProviderOrScopeUrl(app._interface, {
|
|
1240
|
+
provider,
|
|
1241
|
+
redirectUrl: app.urls.oauthCallback,
|
|
1242
|
+
errorRedirectUrl: app.urls.error,
|
|
1243
|
+
providerScope: mergeScopeStrings(scopeString, (app._oauthScopesOnSignIn[provider] ?? []).join(" "))
|
|
1244
|
+
}, session);
|
|
1245
|
+
await app._redirectTo({ url: location });
|
|
1246
|
+
return await neverResolve();
|
|
1247
|
+
},
|
|
1248
|
+
async getOrLinkConnectedAccount(provider, options) {
|
|
1249
|
+
const matchingAccounts = Result.orThrow(await app._currentUserConnectedAccountsCache.getOrWait([session], "write-only")).filter((a) => a.provider === provider);
|
|
1250
|
+
for (const account of matchingAccounts) if ((await account.getAccessToken({ scopes: options?.scopes })).status === "ok") return account;
|
|
1251
|
+
await this.linkConnectedAccount(provider, options);
|
|
1252
|
+
return await neverResolve();
|
|
1253
|
+
},
|
|
1254
|
+
useOrLinkConnectedAccount(provider, options) {
|
|
1255
|
+
const scopeString = options?.scopes?.join(" ") ?? "";
|
|
1256
|
+
return useAsyncCache(app._currentUserValidConnectedAccountForProviderCache, [
|
|
1257
|
+
session,
|
|
1258
|
+
provider,
|
|
1259
|
+
scopeString
|
|
1260
|
+
], "user.useOrLinkConnectedAccount()");
|
|
1261
|
+
},
|
|
1262
|
+
async getTeam(teamId) {
|
|
1263
|
+
return (await this.listTeams()).find((t) => t.id === teamId) ?? null;
|
|
1264
|
+
},
|
|
1265
|
+
useTeam(teamId) {
|
|
1266
|
+
const teams = this.useTeams();
|
|
1267
|
+
return useMemo(() => {
|
|
1268
|
+
return teams.find((t) => t.id === teamId) ?? null;
|
|
1269
|
+
}, [teams, teamId]);
|
|
1270
|
+
},
|
|
1271
|
+
async listTeams() {
|
|
1272
|
+
return Result.orThrow(await app._currentUserTeamsCache.getOrWait([session], "write-only")).map((crud) => app._clientTeamFromCrud(crud, session));
|
|
1273
|
+
},
|
|
1274
|
+
useTeams() {
|
|
1275
|
+
const teams = useAsyncCache(app._currentUserTeamsCache, [session], "user.useTeams()");
|
|
1276
|
+
return useMemo(() => teams.map((crud) => app._clientTeamFromCrud(crud, session)), [teams]);
|
|
1277
|
+
},
|
|
1278
|
+
async createTeam(data) {
|
|
1279
|
+
const crud = await app._interface.createClientTeam(teamCreateOptionsToCrud(data, "me"), session);
|
|
1280
|
+
await app._currentUserTeamsCache.refresh([session]);
|
|
1281
|
+
await this.update({ selectedTeamId: crud.id });
|
|
1282
|
+
return app._clientTeamFromCrud(crud, session);
|
|
1283
|
+
},
|
|
1284
|
+
async leaveTeam(team) {
|
|
1285
|
+
await app._interface.leaveTeam(team.id, session);
|
|
1286
|
+
},
|
|
1287
|
+
async listTeamInvitations() {
|
|
1288
|
+
return Result.orThrow(await app._currentUserTeamInvitationsCache.getOrWait([session], "write-only")).map((crud) => app._clientReceivedTeamInvitationFromCrud(session, crud));
|
|
1289
|
+
},
|
|
1290
|
+
useTeamInvitations() {
|
|
1291
|
+
const invitations = useAsyncCache(app._currentUserTeamInvitationsCache, [session], "user.useTeamInvitations()");
|
|
1292
|
+
return useMemo(() => invitations.map((crud) => app._clientReceivedTeamInvitationFromCrud(session, crud)), [invitations]);
|
|
1293
|
+
},
|
|
1294
|
+
async listPermissions(scopeOrOptions, options) {
|
|
1295
|
+
if (scopeOrOptions && "id" in scopeOrOptions) {
|
|
1296
|
+
const scope = scopeOrOptions;
|
|
1297
|
+
const recursive = options?.recursive ?? true;
|
|
1298
|
+
return Result.orThrow(await app._currentUserPermissionsCache.getOrWait([
|
|
1299
|
+
session,
|
|
1300
|
+
scope.id,
|
|
1301
|
+
recursive
|
|
1302
|
+
], "write-only")).map((crud) => app._clientPermissionFromCrud(crud));
|
|
1303
|
+
} else {
|
|
1304
|
+
const recursive = scopeOrOptions?.recursive ?? true;
|
|
1305
|
+
return Result.orThrow(await app._currentUserProjectPermissionsCache.getOrWait([session, recursive], "write-only")).map((crud) => app._clientPermissionFromCrud(crud));
|
|
1306
|
+
}
|
|
1307
|
+
},
|
|
1308
|
+
usePermissions(scopeOrOptions, options) {
|
|
1309
|
+
if (scopeOrOptions && "id" in scopeOrOptions) {
|
|
1310
|
+
const scope = scopeOrOptions;
|
|
1311
|
+
const recursive = options?.recursive ?? true;
|
|
1312
|
+
const permissions = useAsyncCache(app._currentUserPermissionsCache, [
|
|
1313
|
+
session,
|
|
1314
|
+
scope.id,
|
|
1315
|
+
recursive
|
|
1316
|
+
], "user.usePermissions()");
|
|
1317
|
+
return useMemo(() => permissions.map((crud) => app._clientPermissionFromCrud(crud)), [permissions]);
|
|
1318
|
+
} else {
|
|
1319
|
+
const recursive = scopeOrOptions?.recursive ?? true;
|
|
1320
|
+
const permissions = useAsyncCache(app._currentUserProjectPermissionsCache, [session, recursive], "user.usePermissions()");
|
|
1321
|
+
return useMemo(() => permissions.map((crud) => app._clientPermissionFromCrud(crud)), [permissions]);
|
|
1322
|
+
}
|
|
1323
|
+
},
|
|
1324
|
+
usePermission(scopeOrPermissionId, permissionId) {
|
|
1325
|
+
if (scopeOrPermissionId && typeof scopeOrPermissionId !== "string") {
|
|
1326
|
+
const scope = scopeOrPermissionId;
|
|
1327
|
+
const permissions = this.usePermissions(scope);
|
|
1328
|
+
return useMemo(() => permissions.find((p) => p.id === permissionId) ?? null, [permissions, permissionId]);
|
|
1329
|
+
} else {
|
|
1330
|
+
const pid = scopeOrPermissionId;
|
|
1331
|
+
const permissions = this.usePermissions();
|
|
1332
|
+
return useMemo(() => permissions.find((p) => p.id === pid) ?? null, [permissions, pid]);
|
|
1333
|
+
}
|
|
1334
|
+
},
|
|
1335
|
+
async getPermission(scopeOrPermissionId, permissionId) {
|
|
1336
|
+
if (scopeOrPermissionId && typeof scopeOrPermissionId !== "string") {
|
|
1337
|
+
const scope = scopeOrPermissionId;
|
|
1338
|
+
return (await this.listPermissions(scope)).find((p) => p.id === permissionId) ?? null;
|
|
1339
|
+
} else {
|
|
1340
|
+
const pid = scopeOrPermissionId;
|
|
1341
|
+
return (await this.listPermissions()).find((p) => p.id === pid) ?? null;
|
|
1342
|
+
}
|
|
1343
|
+
},
|
|
1344
|
+
async hasPermission(scopeOrPermissionId, permissionId) {
|
|
1345
|
+
if (scopeOrPermissionId && typeof scopeOrPermissionId !== "string") {
|
|
1346
|
+
const scope = scopeOrPermissionId;
|
|
1347
|
+
return await this.getPermission(scope, permissionId) !== null;
|
|
1348
|
+
} else {
|
|
1349
|
+
const pid = scopeOrPermissionId;
|
|
1350
|
+
return await this.getPermission(pid) !== null;
|
|
1351
|
+
}
|
|
1352
|
+
},
|
|
1353
|
+
async update(update) {
|
|
1354
|
+
return await app._updateClientUser(update, session);
|
|
1355
|
+
},
|
|
1356
|
+
async sendVerificationEmail(options) {
|
|
1357
|
+
if (!crud.primary_email) throw new StackAssertionError("User does not have a primary email");
|
|
1358
|
+
return await app._interface.sendVerificationEmail(crud.primary_email, options?.callbackUrl ?? constructRedirectUrl(app.urls.emailVerification, "callbackUrl"), session);
|
|
1359
|
+
},
|
|
1360
|
+
async updatePassword(options) {
|
|
1361
|
+
const result = await app._interface.updatePassword(options, session);
|
|
1362
|
+
await app._currentUserCache.refresh([session]);
|
|
1363
|
+
return result;
|
|
1364
|
+
},
|
|
1365
|
+
async setPassword(options) {
|
|
1366
|
+
const result = await app._interface.setPassword(options, session);
|
|
1367
|
+
await app._currentUserCache.refresh([session]);
|
|
1368
|
+
return result;
|
|
1369
|
+
},
|
|
1370
|
+
selectedTeam: crud.selected_team && this._clientTeamFromCrud(crud.selected_team, session),
|
|
1371
|
+
async getTeamProfile(team) {
|
|
1372
|
+
const result = Result.orThrow(await app._currentUserTeamProfileCache.getOrWait([session, team.id], "write-only"));
|
|
1373
|
+
return app._editableTeamProfileFromCrud(result, session);
|
|
1374
|
+
},
|
|
1375
|
+
useTeamProfile(team) {
|
|
1376
|
+
const result = useAsyncCache(app._currentUserTeamProfileCache, [session, team.id], "user.useTeamProfile()");
|
|
1377
|
+
return app._editableTeamProfileFromCrud(result, session);
|
|
1378
|
+
},
|
|
1379
|
+
async delete() {
|
|
1380
|
+
await app._interface.deleteCurrentUser(session);
|
|
1381
|
+
session.markInvalid();
|
|
1382
|
+
},
|
|
1383
|
+
async listContactChannels() {
|
|
1384
|
+
return Result.orThrow(await app._clientContactChannelsCache.getOrWait([session], "write-only")).map((crud) => app._clientContactChannelFromCrud(crud, session));
|
|
1385
|
+
},
|
|
1386
|
+
useContactChannels() {
|
|
1387
|
+
return useAsyncCache(app._clientContactChannelsCache, [session], "user.useContactChannels()").map((crud) => app._clientContactChannelFromCrud(crud, session));
|
|
1388
|
+
},
|
|
1389
|
+
async createContactChannel(data) {
|
|
1390
|
+
const crud = await app._interface.createClientContactChannel(contactChannelCreateOptionsToCrud("me", data), session);
|
|
1391
|
+
await app._clientContactChannelsCache.refresh([session]);
|
|
1392
|
+
return app._clientContactChannelFromCrud(crud, session);
|
|
1393
|
+
},
|
|
1394
|
+
useNotificationCategories() {
|
|
1395
|
+
return useAsyncCache(app._notificationCategoriesCache, [session], "user.useNotificationCategories()").map((crud) => app._clientNotificationCategoryFromCrud(crud, session));
|
|
1396
|
+
},
|
|
1397
|
+
async listNotificationCategories() {
|
|
1398
|
+
return Result.orThrow(await app._notificationCategoriesCache.getOrWait([session], "write-only")).map((crud) => app._clientNotificationCategoryFromCrud(crud, session));
|
|
1399
|
+
},
|
|
1400
|
+
useApiKeys() {
|
|
1401
|
+
return useAsyncCache(app._userApiKeysCache, [session], "user.useApiKeys()").map((crud) => app._clientApiKeyFromCrud(session, crud));
|
|
1402
|
+
},
|
|
1403
|
+
async listApiKeys() {
|
|
1404
|
+
return (await app._interface.listProjectApiKeys({ user_id: "me" }, session, "client")).map((crud) => app._clientApiKeyFromCrud(session, crud));
|
|
1405
|
+
},
|
|
1406
|
+
async createApiKey(options) {
|
|
1407
|
+
const result = await app._interface.createProjectApiKey(await apiKeyCreationOptionsToCrud("user", "me", options), session, "client");
|
|
1408
|
+
await app._userApiKeysCache.refresh([session]);
|
|
1409
|
+
return app._clientApiKeyFromCrud(session, result);
|
|
1410
|
+
},
|
|
1411
|
+
useOAuthProviders() {
|
|
1412
|
+
return useAsyncCache(app._currentUserOAuthProvidersCache, [session], "user.useOAuthProviders()").map((crud) => app._clientOAuthProviderFromCrud(crud, session));
|
|
1413
|
+
},
|
|
1414
|
+
async listOAuthProviders() {
|
|
1415
|
+
return Result.orThrow(await app._currentUserOAuthProvidersCache.getOrWait([session], "write-only")).map((crud) => app._clientOAuthProviderFromCrud(crud, session));
|
|
1416
|
+
},
|
|
1417
|
+
useOAuthProvider(id) {
|
|
1418
|
+
const providers = this.useOAuthProviders();
|
|
1419
|
+
return useMemo(() => providers.find((p) => p.id === id) ?? null, [providers, id]);
|
|
1420
|
+
},
|
|
1421
|
+
async getOAuthProvider(id) {
|
|
1422
|
+
return (await this.listOAuthProviders()).find((p) => p.id === id) ?? null;
|
|
1423
|
+
},
|
|
1424
|
+
async registerPasskey(options) {
|
|
1425
|
+
const hostname = (await app._getCurrentUrl())?.hostname;
|
|
1426
|
+
if (!hostname) throw new StackAssertionError("hostname must be provided if the Stack App does not have a redirect method");
|
|
1427
|
+
const initiationResult = await app._interface.initiatePasskeyRegistration({}, session);
|
|
1428
|
+
if (initiationResult.status !== "ok") return Result.error(new KnownErrors.PasskeyRegistrationFailed("Failed to get initiation options for passkey registration"));
|
|
1429
|
+
const { options_json, code } = initiationResult.data;
|
|
1430
|
+
if (options_json.rp.id !== "THIS_VALUE_WILL_BE_REPLACED.example.com") throw new StackAssertionError(`Expected returned RP ID from server to equal sentinel, but found ${options_json.rp.id}`);
|
|
1431
|
+
options_json.rp.id = hostname;
|
|
1432
|
+
let attResp;
|
|
1433
|
+
try {
|
|
1434
|
+
attResp = await startRegistration({ optionsJSON: options_json });
|
|
1435
|
+
} catch (error) {
|
|
1436
|
+
if (error instanceof WebAuthnError) return Result.error(new KnownErrors.PasskeyWebAuthnError(error.message, error.name));
|
|
1437
|
+
else {
|
|
1438
|
+
captureError("passkey-registration-failed", error);
|
|
1439
|
+
return Result.error(new KnownErrors.PasskeyRegistrationFailed("Failed to start passkey registration due to unknown error"));
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
const registrationResult = await app._interface.registerPasskey({
|
|
1443
|
+
credential: attResp,
|
|
1444
|
+
code
|
|
1445
|
+
}, session);
|
|
1446
|
+
await app._refreshUser(session);
|
|
1447
|
+
return registrationResult;
|
|
1448
|
+
}
|
|
1449
|
+
};
|
|
1450
|
+
}
|
|
1451
|
+
_createInternalUserExtra(session) {
|
|
1452
|
+
const app = this;
|
|
1453
|
+
this._ensureInternalProject();
|
|
1454
|
+
return {
|
|
1455
|
+
createProject(newProject) {
|
|
1456
|
+
return app._createProject(session, newProject);
|
|
1457
|
+
},
|
|
1458
|
+
async transferProject(projectIdToTransfer, newTeamId) {
|
|
1459
|
+
await app._interface.transferProject(session, projectIdToTransfer, newTeamId);
|
|
1460
|
+
await app._refreshProject();
|
|
1461
|
+
},
|
|
1462
|
+
listOwnedProjects() {
|
|
1463
|
+
return app._listOwnedProjects(session);
|
|
1464
|
+
},
|
|
1465
|
+
useOwnedProjects() {
|
|
1466
|
+
return app._useOwnedProjects(session);
|
|
1467
|
+
}
|
|
1468
|
+
};
|
|
1469
|
+
}
|
|
1470
|
+
_createCustomer(userIdOrTeamId, type, session) {
|
|
1471
|
+
const app = this;
|
|
1472
|
+
const effectiveSession = session ?? app._interface.createSession({ refreshToken: null });
|
|
1473
|
+
const customerOptions = type === "user" ? { userId: userIdOrTeamId } : { teamId: userIdOrTeamId };
|
|
1474
|
+
return {
|
|
1475
|
+
async getBilling() {
|
|
1476
|
+
const response = Result.orThrow(await app._customerBillingCache.getOrWait([
|
|
1477
|
+
effectiveSession,
|
|
1478
|
+
type,
|
|
1479
|
+
userIdOrTeamId
|
|
1480
|
+
], "write-only"));
|
|
1481
|
+
return app._customerBillingFromResponse(response);
|
|
1482
|
+
},
|
|
1483
|
+
useBilling() {
|
|
1484
|
+
const response = useAsyncCache(app._customerBillingCache, [
|
|
1485
|
+
effectiveSession,
|
|
1486
|
+
type,
|
|
1487
|
+
userIdOrTeamId
|
|
1488
|
+
], "customer.useBilling()");
|
|
1489
|
+
return app._customerBillingFromResponse(response);
|
|
1490
|
+
},
|
|
1491
|
+
async createPaymentMethodSetupIntent() {
|
|
1492
|
+
const body = await app._interface.createCustomerPaymentMethodSetupIntent(type, userIdOrTeamId, effectiveSession);
|
|
1493
|
+
return {
|
|
1494
|
+
clientSecret: body.client_secret,
|
|
1495
|
+
stripeAccountId: body.stripe_account_id
|
|
1496
|
+
};
|
|
1497
|
+
},
|
|
1498
|
+
async setDefaultPaymentMethodFromSetupIntent(setupIntentId) {
|
|
1499
|
+
const body = await app._interface.setDefaultCustomerPaymentMethodFromSetupIntent(type, userIdOrTeamId, setupIntentId, effectiveSession);
|
|
1500
|
+
await app._customerBillingCache.refresh([
|
|
1501
|
+
effectiveSession,
|
|
1502
|
+
type,
|
|
1503
|
+
userIdOrTeamId
|
|
1504
|
+
]);
|
|
1505
|
+
return body.default_payment_method;
|
|
1506
|
+
},
|
|
1507
|
+
async getItem(itemId) {
|
|
1508
|
+
return await app.getItem({
|
|
1509
|
+
itemId,
|
|
1510
|
+
...customerOptions
|
|
1511
|
+
});
|
|
1512
|
+
},
|
|
1513
|
+
useItem(itemId) {
|
|
1514
|
+
return app.useItem({
|
|
1515
|
+
itemId,
|
|
1516
|
+
...customerOptions
|
|
1517
|
+
});
|
|
1518
|
+
},
|
|
1519
|
+
async listProducts(options) {
|
|
1520
|
+
return await app.listProducts({
|
|
1521
|
+
...options,
|
|
1522
|
+
...customerOptions
|
|
1523
|
+
});
|
|
1524
|
+
},
|
|
1525
|
+
useProducts(options) {
|
|
1526
|
+
return app.useProducts({
|
|
1527
|
+
...options,
|
|
1528
|
+
...customerOptions
|
|
1529
|
+
});
|
|
1530
|
+
},
|
|
1531
|
+
async listInvoices(options) {
|
|
1532
|
+
return await app.listInvoices({
|
|
1533
|
+
...options,
|
|
1534
|
+
...customerOptions
|
|
1535
|
+
});
|
|
1536
|
+
},
|
|
1537
|
+
useInvoices(options) {
|
|
1538
|
+
return app.useInvoices({
|
|
1539
|
+
...options,
|
|
1540
|
+
...customerOptions
|
|
1541
|
+
});
|
|
1542
|
+
},
|
|
1543
|
+
async createCheckoutUrl(options) {
|
|
1544
|
+
return await app._interface.createCheckoutUrl(type, userIdOrTeamId, options.productId, effectiveSession, options.returnUrl, "client");
|
|
1545
|
+
},
|
|
1546
|
+
async switchSubscription(options) {
|
|
1547
|
+
await app._interface.switchSubscription({
|
|
1548
|
+
customer_type: type,
|
|
1549
|
+
customer_id: userIdOrTeamId,
|
|
1550
|
+
from_product_id: options.fromProductId,
|
|
1551
|
+
to_product_id: options.toProductId,
|
|
1552
|
+
price_id: options.priceId,
|
|
1553
|
+
quantity: options.quantity
|
|
1554
|
+
}, effectiveSession);
|
|
1555
|
+
await app._customerBillingCache.refresh([
|
|
1556
|
+
effectiveSession,
|
|
1557
|
+
type,
|
|
1558
|
+
userIdOrTeamId
|
|
1559
|
+
]);
|
|
1560
|
+
if (type === "user") await app._userProductsCache.invalidateWhere(([cachedSession, userId]) => cachedSession === effectiveSession && userId === userIdOrTeamId);
|
|
1561
|
+
else await app._teamProductsCache.invalidateWhere(([cachedSession, teamId]) => cachedSession === effectiveSession && teamId === userIdOrTeamId);
|
|
1562
|
+
}
|
|
1563
|
+
};
|
|
1564
|
+
}
|
|
1565
|
+
async getItem(options) {
|
|
1566
|
+
const session = await this._getSession();
|
|
1567
|
+
let crud;
|
|
1568
|
+
if ("userId" in options) crud = Result.orThrow(await this._userItemCache.getOrWait([
|
|
1569
|
+
session,
|
|
1570
|
+
options.userId,
|
|
1571
|
+
options.itemId
|
|
1572
|
+
], "write-only"));
|
|
1573
|
+
else if ("teamId" in options) crud = Result.orThrow(await this._teamItemCache.getOrWait([
|
|
1574
|
+
session,
|
|
1575
|
+
options.teamId,
|
|
1576
|
+
options.itemId
|
|
1577
|
+
], "write-only"));
|
|
1578
|
+
else crud = Result.orThrow(await this._customItemCache.getOrWait([
|
|
1579
|
+
session,
|
|
1580
|
+
options.customCustomerId,
|
|
1581
|
+
options.itemId
|
|
1582
|
+
], "write-only"));
|
|
1583
|
+
return this._clientItemFromCrud(crud);
|
|
1584
|
+
}
|
|
1585
|
+
useItem(options) {
|
|
1586
|
+
const session = this._useSession();
|
|
1587
|
+
const [cache, ownerId] = "userId" in options ? [this._userItemCache, options.userId] : "teamId" in options ? [this._teamItemCache, options.teamId] : [this._customItemCache, options.customCustomerId];
|
|
1588
|
+
const crud = useAsyncCache(cache, [
|
|
1589
|
+
session,
|
|
1590
|
+
ownerId,
|
|
1591
|
+
options.itemId
|
|
1592
|
+
], "app.useItem()");
|
|
1593
|
+
return this._clientItemFromCrud(crud);
|
|
1594
|
+
}
|
|
1595
|
+
async listProducts(options) {
|
|
1596
|
+
const session = (await this.getUser())?._internalSession ?? await this._getSession();
|
|
1597
|
+
if ("userId" in options) {
|
|
1598
|
+
const response = Result.orThrow(await this._userProductsCache.getOrWait([
|
|
1599
|
+
session,
|
|
1600
|
+
options.userId,
|
|
1601
|
+
options.cursor ?? null,
|
|
1602
|
+
options.limit ?? null
|
|
1603
|
+
], "write-only"));
|
|
1604
|
+
return this._customerProductsFromResponse(response);
|
|
1605
|
+
} else if ("teamId" in options) {
|
|
1606
|
+
const response = Result.orThrow(await this._teamProductsCache.getOrWait([
|
|
1607
|
+
session,
|
|
1608
|
+
options.teamId,
|
|
1609
|
+
options.cursor ?? null,
|
|
1610
|
+
options.limit ?? null
|
|
1611
|
+
], "write-only"));
|
|
1612
|
+
return this._customerProductsFromResponse(response);
|
|
1613
|
+
}
|
|
1614
|
+
const response = Result.orThrow(await this._customProductsCache.getOrWait([
|
|
1615
|
+
session,
|
|
1616
|
+
options.customCustomerId,
|
|
1617
|
+
options.cursor ?? null,
|
|
1618
|
+
options.limit ?? null
|
|
1619
|
+
], "write-only"));
|
|
1620
|
+
return this._customerProductsFromResponse(response);
|
|
1621
|
+
}
|
|
1622
|
+
async listInvoices(options) {
|
|
1623
|
+
const session = await this._getSession();
|
|
1624
|
+
if ("userId" in options) {
|
|
1625
|
+
const response = Result.orThrow(await this._userInvoicesCache.getOrWait([
|
|
1626
|
+
session,
|
|
1627
|
+
options.userId,
|
|
1628
|
+
options.cursor ?? null,
|
|
1629
|
+
options.limit ?? null
|
|
1630
|
+
], "write-only"));
|
|
1631
|
+
return this._customerInvoicesFromResponse(response);
|
|
1632
|
+
}
|
|
1633
|
+
const response = Result.orThrow(await this._teamInvoicesCache.getOrWait([
|
|
1634
|
+
session,
|
|
1635
|
+
options.teamId,
|
|
1636
|
+
options.cursor ?? null,
|
|
1637
|
+
options.limit ?? null
|
|
1638
|
+
], "write-only"));
|
|
1639
|
+
return this._customerInvoicesFromResponse(response);
|
|
1640
|
+
}
|
|
1641
|
+
async cancelSubscription(options) {
|
|
1642
|
+
const session = await this._getSession();
|
|
1643
|
+
const user = await this.getUser();
|
|
1644
|
+
if (!user) throw new KnownErrors.UserAuthenticationRequired();
|
|
1645
|
+
const customerType = "teamId" in options ? "team" : "user";
|
|
1646
|
+
const customerId = "teamId" in options ? options.teamId : user.id;
|
|
1647
|
+
await this._interface.cancelSubscription({
|
|
1648
|
+
customer_type: customerType,
|
|
1649
|
+
customer_id: customerId,
|
|
1650
|
+
product_id: options.productId,
|
|
1651
|
+
subscription_id: options.subscriptionId
|
|
1652
|
+
}, session);
|
|
1653
|
+
if (customerType === "user") await this._userProductsCache.invalidateWhere(([cachedSession, userId]) => cachedSession === session && userId === customerId);
|
|
1654
|
+
else await this._teamProductsCache.invalidateWhere(([cachedSession, teamId]) => cachedSession === session && teamId === customerId);
|
|
1655
|
+
}
|
|
1656
|
+
useProducts(options) {
|
|
1657
|
+
const session = this._useSession();
|
|
1658
|
+
const response = useAsyncCache("userId" in options ? this._userProductsCache : "teamId" in options ? this._teamProductsCache : this._customProductsCache, [
|
|
1659
|
+
session,
|
|
1660
|
+
"userId" in options ? options.userId : "teamId" in options ? options.teamId : options.customCustomerId,
|
|
1661
|
+
options.cursor ?? null,
|
|
1662
|
+
options.limit ?? null
|
|
1663
|
+
], "clientApp.useProducts()");
|
|
1664
|
+
return this._customerProductsFromResponse(response);
|
|
1665
|
+
}
|
|
1666
|
+
useInvoices(options) {
|
|
1667
|
+
const session = this._useSession();
|
|
1668
|
+
const response = useAsyncCache("userId" in options ? this._userInvoicesCache : this._teamInvoicesCache, [
|
|
1669
|
+
session,
|
|
1670
|
+
"userId" in options ? options.userId : options.teamId,
|
|
1671
|
+
options.cursor ?? null,
|
|
1672
|
+
options.limit ?? null
|
|
1673
|
+
], "clientApp.useInvoices()");
|
|
1674
|
+
return this._customerInvoicesFromResponse(response);
|
|
1675
|
+
}
|
|
1676
|
+
_currentUserFromCrud(crud, session) {
|
|
1677
|
+
return withUserDestructureGuard({
|
|
1678
|
+
...this._createBaseUser(crud),
|
|
1679
|
+
...this._createAuth(session),
|
|
1680
|
+
...this._createUserExtraFromCurrent(crud, session),
|
|
1681
|
+
...this._isInternalProject() ? this._createInternalUserExtra(session) : {},
|
|
1682
|
+
...this._createCustomer(crud.id, "user", session)
|
|
1683
|
+
});
|
|
1684
|
+
}
|
|
1685
|
+
_clientSessionFromCrud(crud) {
|
|
1686
|
+
return {
|
|
1687
|
+
id: crud.id,
|
|
1688
|
+
userId: crud.user_id,
|
|
1689
|
+
createdAt: new Date(crud.created_at),
|
|
1690
|
+
isImpersonation: crud.is_impersonation,
|
|
1691
|
+
lastUsedAt: crud.last_used_at ? new Date(crud.last_used_at) : void 0,
|
|
1692
|
+
isCurrentSession: crud.is_current_session ?? false,
|
|
1693
|
+
geoInfo: crud.last_used_at_end_user_ip_info
|
|
1694
|
+
};
|
|
1695
|
+
}
|
|
1696
|
+
_getOwnedAdminApp(forProjectId, session) {
|
|
1697
|
+
if (!this._ownedAdminApps.has([session, forProjectId])) this._ownedAdminApps.set([session, forProjectId], new _StackClientAppImplIncomplete.LazyStackAdminAppImpl.value({
|
|
1698
|
+
baseUrl: this._interface.options.getBaseUrl(),
|
|
1699
|
+
projectId: forProjectId,
|
|
1700
|
+
tokenStore: null,
|
|
1701
|
+
projectOwnerSession: session,
|
|
1702
|
+
noAutomaticPrefetch: true
|
|
1703
|
+
}));
|
|
1704
|
+
return this._ownedAdminApps.get([session, forProjectId]);
|
|
1705
|
+
}
|
|
1706
|
+
get projectId() {
|
|
1707
|
+
return this._interface.projectId;
|
|
1708
|
+
}
|
|
1709
|
+
get version() {
|
|
1710
|
+
return clientVersion;
|
|
1711
|
+
}
|
|
1712
|
+
_getBotChallengeSiteKeys() {
|
|
1713
|
+
if (!isBrowserLike()) return null;
|
|
1714
|
+
const visibleSiteKey = envVars.NEXT_PUBLIC_STACK_BOT_CHALLENGE_SITE_KEY;
|
|
1715
|
+
if (!visibleSiteKey) {
|
|
1716
|
+
if (!this._botChallengeSiteKeysWarned) {
|
|
1717
|
+
this._botChallengeSiteKeysWarned = true;
|
|
1718
|
+
console.warn("[stack-auth] NEXT_PUBLIC_STACK_BOT_CHALLENGE_SITE_KEY is not set — bot challenge fraud protection is disabled. Set the env variable to enable it.");
|
|
1719
|
+
}
|
|
1720
|
+
return null;
|
|
1721
|
+
}
|
|
1722
|
+
return {
|
|
1723
|
+
visibleSiteKey,
|
|
1724
|
+
invisibleSiteKey: envVars.NEXT_PUBLIC_STACK_BOT_CHALLENGE_INVISIBLE_SITE_KEY ?? visibleSiteKey
|
|
1725
|
+
};
|
|
1726
|
+
}
|
|
1727
|
+
_getBotChallengeFlowFailure(error) {
|
|
1728
|
+
if (error instanceof BotChallengeUserCancelledError) return {
|
|
1729
|
+
type: "cancelled",
|
|
1730
|
+
knownError: new KnownErrors.BotChallengeFailed("Bot challenge cancelled by user")
|
|
1731
|
+
};
|
|
1732
|
+
if (error instanceof BotChallengeExecutionFailedError) return {
|
|
1733
|
+
type: "failed",
|
|
1734
|
+
knownError: new KnownErrors.BotChallengeFailed(error.message)
|
|
1735
|
+
};
|
|
1736
|
+
return null;
|
|
1737
|
+
}
|
|
1738
|
+
_normalizeBotChallengeResult(result) {
|
|
1739
|
+
if (result.status === "ok") return result;
|
|
1740
|
+
if (KnownErrors.BotChallengeRequired.isInstance(result.error)) {
|
|
1741
|
+
captureError("bot-challenge-unexpected-after-flow", result.error);
|
|
1742
|
+
return Result.error(new KnownErrors.BotChallengeFailed("Unexpected bot challenge after flow completion"));
|
|
1743
|
+
}
|
|
1744
|
+
return Result.error(result.error);
|
|
1745
|
+
}
|
|
1746
|
+
_toInterfaceBotChallengeInput(challenge) {
|
|
1747
|
+
if (challenge.unavailable) return { phase: "visible" };
|
|
1748
|
+
return {
|
|
1749
|
+
token: challenge.token,
|
|
1750
|
+
phase: challenge.phase
|
|
1751
|
+
};
|
|
1752
|
+
}
|
|
1753
|
+
async _executeResultWithBotChallengeFlow(options) {
|
|
1754
|
+
const siteKeys = this._getBotChallengeSiteKeys();
|
|
1755
|
+
let result;
|
|
1756
|
+
try {
|
|
1757
|
+
if (siteKeys) result = await withBotChallengeFlow({
|
|
1758
|
+
...siteKeys,
|
|
1759
|
+
action: options.action,
|
|
1760
|
+
execute: options.execute,
|
|
1761
|
+
isChallengeRequired: (flowResult) => {
|
|
1762
|
+
return flowResult.status === "error" && KnownErrors.BotChallengeRequired.isInstance(flowResult.error);
|
|
1763
|
+
}
|
|
1764
|
+
});
|
|
1765
|
+
else result = await options.execute({});
|
|
1766
|
+
} catch (e) {
|
|
1767
|
+
const flowFailure = this._getBotChallengeFlowFailure(e);
|
|
1768
|
+
if (flowFailure) return Result.error(flowFailure.knownError);
|
|
1769
|
+
throw e;
|
|
1770
|
+
}
|
|
1771
|
+
return this._normalizeBotChallengeResult(result);
|
|
1772
|
+
}
|
|
1773
|
+
async _isTrusted(url) {
|
|
1774
|
+
if (isRelative(url)) return true;
|
|
1775
|
+
if (typeof window !== "undefined" && window.location.origin === new URL(url).origin) return true;
|
|
1776
|
+
return isHostedHandlerUrlForProject({
|
|
1777
|
+
url,
|
|
1778
|
+
projectId: this.projectId
|
|
1779
|
+
});
|
|
1780
|
+
}
|
|
1781
|
+
get urls() {
|
|
1782
|
+
return getUrls(this._urlOptions, { projectId: this.projectId });
|
|
1783
|
+
}
|
|
1784
|
+
_prefetchCrossDomainHandoffParamsIfNeeded() {
|
|
1785
|
+
const canWriteOauthVerifierCookie = this._tokenStoreInit === "cookie" || this._tokenStoreInit === "nextjs-cookie";
|
|
1786
|
+
if (!isBrowserLike() || !canWriteOauthVerifierCookie || this._isPrefetchingCrossDomainHandoffParams || this._getFreshPrefetchedCrossDomainHandoffParams() != null) return;
|
|
1787
|
+
this._isPrefetchingCrossDomainHandoffParams = true;
|
|
1788
|
+
runAsynchronously(async () => {
|
|
1789
|
+
try {
|
|
1790
|
+
if (!isBrowserLike()) return;
|
|
1791
|
+
const { state, codeChallenge } = await saveVerifierAndState();
|
|
1792
|
+
this._prefetchedCrossDomainHandoffParams = {
|
|
1793
|
+
state,
|
|
1794
|
+
codeChallenge
|
|
1795
|
+
};
|
|
1796
|
+
this._prefetchedCrossDomainHandoffParamsFetchedAt = performance.now();
|
|
1797
|
+
} finally {
|
|
1798
|
+
this._isPrefetchingCrossDomainHandoffParams = false;
|
|
1799
|
+
}
|
|
1800
|
+
});
|
|
1801
|
+
}
|
|
1802
|
+
_getCrossDomainHandoffParamsForUrlsGetter(currentUrl) {
|
|
1803
|
+
const fromQuery = getCrossDomainHandoffParamsFromCurrentUrl(currentUrl);
|
|
1804
|
+
if (fromQuery != null) return fromQuery;
|
|
1805
|
+
const prefetched = this._getFreshPrefetchedCrossDomainHandoffParams();
|
|
1806
|
+
if (prefetched != null) return prefetched;
|
|
1807
|
+
this._prefetchCrossDomainHandoffParamsIfNeeded();
|
|
1808
|
+
return null;
|
|
1809
|
+
}
|
|
1810
|
+
async _getCrossDomainHandoffParamsForRedirect(currentUrl) {
|
|
1811
|
+
const fromQuery = getCrossDomainHandoffParamsFromCurrentUrl(currentUrl);
|
|
1812
|
+
if (fromQuery != null) return fromQuery;
|
|
1813
|
+
const prefetched = this._getFreshPrefetchedCrossDomainHandoffParams();
|
|
1814
|
+
if (prefetched != null) return prefetched;
|
|
1815
|
+
const { state, codeChallenge } = await saveVerifierAndState();
|
|
1816
|
+
this._prefetchedCrossDomainHandoffParams = {
|
|
1817
|
+
state,
|
|
1818
|
+
codeChallenge
|
|
1819
|
+
};
|
|
1820
|
+
this._prefetchedCrossDomainHandoffParamsFetchedAt = performance.now();
|
|
1821
|
+
return {
|
|
1822
|
+
state,
|
|
1823
|
+
codeChallenge
|
|
1824
|
+
};
|
|
1825
|
+
}
|
|
1826
|
+
_getLocalOAuthCallbackHandlerUrl() {
|
|
1827
|
+
return resolveHandlerUrls({
|
|
1828
|
+
urls: {
|
|
1829
|
+
...this._urlOptions,
|
|
1830
|
+
default: { type: "handler-component" },
|
|
1831
|
+
oauthCallback: { type: "handler-component" }
|
|
1832
|
+
},
|
|
1833
|
+
projectId: this.projectId
|
|
1834
|
+
}).oauthCallback;
|
|
1835
|
+
}
|
|
1836
|
+
async _createCrossDomainAuthRedirectUrl(options) {
|
|
1837
|
+
const session = await this._getSession();
|
|
1838
|
+
const response = await this._interface.sendClientRequest("/auth/oauth/cross-domain/authorize", {
|
|
1839
|
+
method: "POST",
|
|
1840
|
+
headers: { "Content-Type": "application/json" },
|
|
1841
|
+
body: JSON.stringify({
|
|
1842
|
+
redirect_uri: options.redirectUri,
|
|
1843
|
+
state: options.state,
|
|
1844
|
+
code_challenge: options.codeChallenge,
|
|
1845
|
+
code_challenge_method: "S256",
|
|
1846
|
+
after_callback_redirect_url: options.afterCallbackRedirectUrl
|
|
1847
|
+
})
|
|
1848
|
+
}, session);
|
|
1849
|
+
if (!response.ok) throw new StackAssertionError(`Cross-domain authorization endpoint failed: ${response.status} ${await response.text()}`);
|
|
1850
|
+
const result = await response.json();
|
|
1851
|
+
if (!("redirect_url" in result) || typeof result.redirect_url !== "string") throw new StackAssertionError("Cross-domain authorization endpoint returned an invalid payload", { result });
|
|
1852
|
+
return result.redirect_url;
|
|
1853
|
+
}
|
|
1854
|
+
_getFreshPrefetchedCrossDomainHandoffParams() {
|
|
1855
|
+
if (this._prefetchedCrossDomainHandoffParams == null) return null;
|
|
1856
|
+
if (performance.now() - this._prefetchedCrossDomainHandoffParamsFetchedAt > prefetchedCrossDomainHandoffTtlMs) {
|
|
1857
|
+
this._prefetchedCrossDomainHandoffParams = null;
|
|
1858
|
+
this._prefetchedCrossDomainHandoffParamsFetchedAt = 0;
|
|
1859
|
+
return null;
|
|
1860
|
+
}
|
|
1861
|
+
return this._prefetchedCrossDomainHandoffParams;
|
|
1862
|
+
}
|
|
1863
|
+
async _getCurrentUrl() {
|
|
1864
|
+
if (this._redirectMethod === "none") return null;
|
|
1865
|
+
return new URL(window.location.href);
|
|
1866
|
+
}
|
|
1867
|
+
async _redirectTo(options) {
|
|
1868
|
+
if (this._redirectMethod === "none") return;
|
|
1869
|
+
else if (this._redirectMethod === "tanstack-start" && !isBrowserLike()) throw TanStackRouter.redirect({
|
|
1870
|
+
href: options.url.toString(),
|
|
1871
|
+
replace: options.replace
|
|
1872
|
+
});
|
|
1873
|
+
else if (typeof this._redirectMethod === "object" && this._redirectMethod.navigate) this._redirectMethod.navigate(options.url.toString());
|
|
1874
|
+
else if (options.replace) window.location.replace(options.url);
|
|
1875
|
+
else window.location.assign(options.url);
|
|
1876
|
+
await wait(2e3);
|
|
1877
|
+
}
|
|
1878
|
+
useNavigate() {
|
|
1879
|
+
if (typeof this._redirectMethod === "object") return this._redirectMethod.useNavigate();
|
|
1880
|
+
else if (this._redirectMethod === "window") return (to) => window.location.assign(to);
|
|
1881
|
+
else if (this._redirectMethod === "tanstack-start") return (to) => window.location.assign(to);
|
|
1882
|
+
else return (to) => {};
|
|
1883
|
+
}
|
|
1884
|
+
async _redirectIfTrusted(url, options) {
|
|
1885
|
+
if (!await this._isTrusted(url)) throw new Error(`Redirect URL ${url} is not trusted; should be relative.`);
|
|
1886
|
+
return await this._redirectTo({
|
|
1887
|
+
url,
|
|
1888
|
+
...options
|
|
1889
|
+
});
|
|
1890
|
+
}
|
|
1891
|
+
async _redirectToHandler(handlerName, options) {
|
|
1892
|
+
const rawHandlerUrl = getUrls(this._urlOptions, { projectId: this.projectId })[handlerName];
|
|
1893
|
+
if (!rawHandlerUrl) throw new Error(`No URL for handler name ${handlerName}`);
|
|
1894
|
+
const currentUrl = typeof window === "undefined" ? null : new URL(window.location.href);
|
|
1895
|
+
const plan = await planRedirectToHandler({
|
|
1896
|
+
handlerName,
|
|
1897
|
+
rawHandlerUrl,
|
|
1898
|
+
noRedirectBack: options?.noRedirectBack === true,
|
|
1899
|
+
currentUrl,
|
|
1900
|
+
localOAuthCallbackUrl: this._getLocalOAuthCallbackHandlerUrl(),
|
|
1901
|
+
getCrossDomainHandoffParams: async (href) => await this._getCrossDomainHandoffParamsForRedirect(href)
|
|
1902
|
+
});
|
|
1903
|
+
if (plan.type === "cross-domain-authorize") {
|
|
1904
|
+
const crossDomainRedirectUrl = await this._createCrossDomainAuthRedirectUrl({
|
|
1905
|
+
redirectUri: plan.redirectUri,
|
|
1906
|
+
state: plan.state,
|
|
1907
|
+
codeChallenge: plan.codeChallenge,
|
|
1908
|
+
afterCallbackRedirectUrl: plan.afterCallbackRedirectUrl
|
|
1909
|
+
});
|
|
1910
|
+
await this._redirectTo({
|
|
1911
|
+
url: crossDomainRedirectUrl,
|
|
1912
|
+
...options
|
|
1913
|
+
});
|
|
1914
|
+
return;
|
|
1915
|
+
}
|
|
1916
|
+
await this._redirectIfTrusted(plan.url, options);
|
|
1917
|
+
}
|
|
1918
|
+
_redirectToHandlerDuringRender(handlerName, options) {
|
|
1919
|
+
if (this._redirectMethod === "tanstack-start" && !isBrowserLike()) {
|
|
1920
|
+
const rawHandlerUrl = getUrls(this._urlOptions, { projectId: this.projectId })[handlerName];
|
|
1921
|
+
if (!rawHandlerUrl) throw new Error(`No URL for handler name ${handlerName}`);
|
|
1922
|
+
throw TanStackRouter.redirect({
|
|
1923
|
+
href: rawHandlerUrl,
|
|
1924
|
+
replace: options?.replace
|
|
1925
|
+
});
|
|
1926
|
+
}
|
|
1927
|
+
return false;
|
|
1928
|
+
}
|
|
1929
|
+
async redirectToSignIn(options) {
|
|
1930
|
+
return await this._redirectToHandler("signIn", options);
|
|
1931
|
+
}
|
|
1932
|
+
async redirectToSignUp(options) {
|
|
1933
|
+
return await this._redirectToHandler("signUp", options);
|
|
1934
|
+
}
|
|
1935
|
+
async redirectToSignOut(options) {
|
|
1936
|
+
return await this._redirectToHandler("signOut", options);
|
|
1937
|
+
}
|
|
1938
|
+
async redirectToEmailVerification(options) {
|
|
1939
|
+
return await this._redirectToHandler("emailVerification", options);
|
|
1940
|
+
}
|
|
1941
|
+
async redirectToPasswordReset(options) {
|
|
1942
|
+
return await this._redirectToHandler("passwordReset", options);
|
|
1943
|
+
}
|
|
1944
|
+
async redirectToForgotPassword(options) {
|
|
1945
|
+
return await this._redirectToHandler("forgotPassword", options);
|
|
1946
|
+
}
|
|
1947
|
+
async redirectToHome(options) {
|
|
1948
|
+
return await this._redirectToHandler("home", options);
|
|
1949
|
+
}
|
|
1950
|
+
async redirectToOAuthCallback(options) {
|
|
1951
|
+
return await this._redirectToHandler("oauthCallback", options);
|
|
1952
|
+
}
|
|
1953
|
+
async redirectToMagicLinkCallback(options) {
|
|
1954
|
+
return await this._redirectToHandler("magicLinkCallback", options);
|
|
1955
|
+
}
|
|
1956
|
+
async redirectToAfterSignIn(options) {
|
|
1957
|
+
return await this._redirectToHandler("afterSignIn", options);
|
|
1958
|
+
}
|
|
1959
|
+
async redirectToAfterSignUp(options) {
|
|
1960
|
+
return await this._redirectToHandler("afterSignUp", options);
|
|
1961
|
+
}
|
|
1962
|
+
async redirectToOnboarding(options) {
|
|
1963
|
+
return await this._redirectToHandler("onboarding", options);
|
|
1964
|
+
}
|
|
1965
|
+
async redirectToAfterSignOut(options) {
|
|
1966
|
+
return await this._redirectToHandler("afterSignOut", options);
|
|
1967
|
+
}
|
|
1968
|
+
async redirectToAccountSettings(options) {
|
|
1969
|
+
return await this._redirectToHandler("accountSettings", options);
|
|
1970
|
+
}
|
|
1971
|
+
async redirectToError(options) {
|
|
1972
|
+
return await this._redirectToHandler("error", options);
|
|
1973
|
+
}
|
|
1974
|
+
async redirectToTeamInvitation(options) {
|
|
1975
|
+
return await this._redirectToHandler("teamInvitation", options);
|
|
1976
|
+
}
|
|
1977
|
+
async redirectToCliAuthConfirm(options) {
|
|
1978
|
+
return await this._redirectToHandler("cliAuthConfirm", options);
|
|
1979
|
+
}
|
|
1980
|
+
async redirectToMfa(options) {
|
|
1981
|
+
return await this._redirectToHandler("mfa", options);
|
|
1982
|
+
}
|
|
1983
|
+
async sendForgotPasswordEmail(email, options) {
|
|
1984
|
+
return await this._interface.sendForgotPasswordEmail(email, options?.callbackUrl ?? constructRedirectUrl(this.urls.passwordReset, "callbackUrl"));
|
|
1985
|
+
}
|
|
1986
|
+
async sendMagicLinkEmail(email, options) {
|
|
1987
|
+
const callbackUrl = options?.callbackUrl ?? constructRedirectUrl(this.urls.magicLinkCallback, "callbackUrl");
|
|
1988
|
+
return await this._executeResultWithBotChallengeFlow({
|
|
1989
|
+
action: "send_magic_link_email",
|
|
1990
|
+
execute: async (challenge) => {
|
|
1991
|
+
return await this._interface.sendMagicLinkEmail(email, callbackUrl, this._toInterfaceBotChallengeInput(challenge));
|
|
1992
|
+
}
|
|
1993
|
+
});
|
|
1994
|
+
}
|
|
1995
|
+
async resetPassword(options) {
|
|
1996
|
+
return await this._interface.resetPassword(options);
|
|
1997
|
+
}
|
|
1998
|
+
async verifyPasswordResetCode(code) {
|
|
1999
|
+
return await this._interface.verifyPasswordResetCode(code);
|
|
2000
|
+
}
|
|
2001
|
+
async verifyTeamInvitationCode(code) {
|
|
2002
|
+
return await this._interface.acceptTeamInvitation({
|
|
2003
|
+
type: "check",
|
|
2004
|
+
code,
|
|
2005
|
+
session: await this._getSession()
|
|
2006
|
+
});
|
|
2007
|
+
}
|
|
2008
|
+
async acceptTeamInvitation(code) {
|
|
2009
|
+
const result = await this._interface.acceptTeamInvitation({
|
|
2010
|
+
type: "use",
|
|
2011
|
+
code,
|
|
2012
|
+
session: await this._getSession()
|
|
2013
|
+
});
|
|
2014
|
+
if (result.status === "ok") return Result.ok(void 0);
|
|
2015
|
+
else return Result.error(result.error);
|
|
2016
|
+
}
|
|
2017
|
+
async getTeamInvitationDetails(code) {
|
|
2018
|
+
const result = await this._interface.acceptTeamInvitation({
|
|
2019
|
+
type: "details",
|
|
2020
|
+
code,
|
|
2021
|
+
session: await this._getSession()
|
|
2022
|
+
});
|
|
2023
|
+
if (result.status === "ok") return Result.ok({ teamDisplayName: result.data.team_display_name });
|
|
2024
|
+
else return Result.error(result.error);
|
|
2025
|
+
}
|
|
2026
|
+
async verifyEmail(code) {
|
|
2027
|
+
const result = await this._interface.verifyEmail(code);
|
|
2028
|
+
await this._currentUserCache.refresh([await this._getSession()]);
|
|
2029
|
+
await this._clientContactChannelsCache.refresh([await this._getSession()]);
|
|
2030
|
+
return result;
|
|
2031
|
+
}
|
|
2032
|
+
async getUser(options) {
|
|
2033
|
+
if (options?.or === "anonymous" && options.includeRestricted === false) throw new Error("Cannot use { or: 'anonymous' } with { includeRestricted: false }. Anonymous users implicitly include restricted users.");
|
|
2034
|
+
this._ensurePersistentTokenStore(options?.tokenStore);
|
|
2035
|
+
const session = await this._getSession(options?.tokenStore);
|
|
2036
|
+
let crud = Result.orThrow(await this._currentUserCache.getOrWait([session], "write-only"));
|
|
2037
|
+
const includeAnonymous = options?.or === "anonymous" || options?.or === "anonymous-if-exists[deprecated]";
|
|
2038
|
+
const includeRestricted = options?.includeRestricted === true || includeAnonymous;
|
|
2039
|
+
if (crud === null || crud.is_anonymous && !includeAnonymous || crud.is_restricted && !includeRestricted) switch (options?.or) {
|
|
2040
|
+
case "redirect":
|
|
2041
|
+
if (!crud?.is_anonymous && crud?.is_restricted) await this.redirectToOnboarding({ replace: true });
|
|
2042
|
+
else await this.redirectToSignIn({ replace: true });
|
|
2043
|
+
break;
|
|
2044
|
+
case "throw": throw new Error("User is not signed in but getUser was called with { or: 'throw' }");
|
|
2045
|
+
case "anonymous": {
|
|
2046
|
+
const tokens = await this._signUpAnonymously();
|
|
2047
|
+
return await this.getUser({
|
|
2048
|
+
tokenStore: tokens,
|
|
2049
|
+
or: "anonymous-if-exists[deprecated]",
|
|
2050
|
+
includeRestricted: true
|
|
2051
|
+
}) ?? throwErr("Something went wrong while signing up anonymously");
|
|
2052
|
+
}
|
|
2053
|
+
case void 0:
|
|
2054
|
+
case "anonymous-if-exists[deprecated]":
|
|
2055
|
+
case "return-null": return null;
|
|
2056
|
+
}
|
|
2057
|
+
return crud && this._currentUserFromCrud(crud, session);
|
|
2058
|
+
}
|
|
2059
|
+
useUser(options) {
|
|
2060
|
+
if (options?.or === "anonymous" && options.includeRestricted === false) throw new Error("Cannot use { or: 'anonymous' } with { includeRestricted: false }. Anonymous users implicitly include restricted users.");
|
|
2061
|
+
this._ensurePersistentTokenStore(options?.tokenStore);
|
|
2062
|
+
const session = this._useSession(options?.tokenStore);
|
|
2063
|
+
let crud = useAsyncCache(this._currentUserCache, [session], "clientApp.useUser()");
|
|
2064
|
+
const includeAnonymous = options?.or === "anonymous" || options?.or === "anonymous-if-exists[deprecated]";
|
|
2065
|
+
const includeRestricted = options?.includeRestricted === true || includeAnonymous;
|
|
2066
|
+
if (crud === null || crud.is_anonymous && !includeAnonymous || crud.is_restricted && !includeRestricted) switch (options?.or) {
|
|
2067
|
+
case "redirect":
|
|
2068
|
+
if (!crud?.is_anonymous && crud?.is_restricted) {
|
|
2069
|
+
if (!this._redirectToHandlerDuringRender("onboarding", { replace: true })) runAsynchronously(this.redirectToOnboarding({ replace: true }));
|
|
2070
|
+
} else if (!this._redirectToHandlerDuringRender("signIn", { replace: true })) runAsynchronously(this.redirectToSignIn({ replace: true }));
|
|
2071
|
+
suspend();
|
|
2072
|
+
throw new StackAssertionError("suspend should never return");
|
|
2073
|
+
case "throw": throw new Error("User is not signed in but useUser was called with { or: 'throw' }");
|
|
2074
|
+
case "anonymous":
|
|
2075
|
+
runAsynchronously(async () => {
|
|
2076
|
+
await this._signUpAnonymously();
|
|
2077
|
+
if (typeof window !== "undefined") window.location.reload();
|
|
2078
|
+
});
|
|
2079
|
+
suspend();
|
|
2080
|
+
throw new StackAssertionError("suspend should never return");
|
|
2081
|
+
case void 0:
|
|
2082
|
+
case "anonymous-if-exists[deprecated]":
|
|
2083
|
+
case "return-null":
|
|
2084
|
+
crud = null;
|
|
2085
|
+
break;
|
|
2086
|
+
}
|
|
2087
|
+
return useMemo(() => {
|
|
2088
|
+
return crud && this._currentUserFromCrud(crud, session);
|
|
2089
|
+
}, [
|
|
2090
|
+
crud,
|
|
2091
|
+
session,
|
|
2092
|
+
options?.or
|
|
2093
|
+
]);
|
|
2094
|
+
}
|
|
2095
|
+
_getTokenPartialUserFromSession(session, options) {
|
|
2096
|
+
const accessToken = session.getAccessTokenIfNotExpiredYet(0, null);
|
|
2097
|
+
if (!accessToken) return null;
|
|
2098
|
+
const isAnonymous = accessToken.payload.is_anonymous;
|
|
2099
|
+
if (isAnonymous && options.or !== "anonymous-if-exists") return null;
|
|
2100
|
+
return {
|
|
2101
|
+
id: accessToken.payload.sub,
|
|
2102
|
+
primaryEmail: accessToken.payload.email,
|
|
2103
|
+
displayName: accessToken.payload.name,
|
|
2104
|
+
primaryEmailVerified: accessToken.payload.email_verified,
|
|
2105
|
+
isAnonymous,
|
|
2106
|
+
isMultiFactorRequired: accessToken.payload.requires_totp_mfa,
|
|
2107
|
+
isRestricted: accessToken.payload.is_restricted,
|
|
2108
|
+
restrictedReason: accessToken.payload.restricted_reason
|
|
2109
|
+
};
|
|
2110
|
+
}
|
|
2111
|
+
async _getPartialUserFromConvex(ctx) {
|
|
2112
|
+
const auth = await ctx.auth.getUserIdentity();
|
|
2113
|
+
if (!auth) return null;
|
|
2114
|
+
return {
|
|
2115
|
+
id: auth.subject,
|
|
2116
|
+
displayName: auth.name ?? null,
|
|
2117
|
+
primaryEmail: auth.email ?? null,
|
|
2118
|
+
primaryEmailVerified: auth.email_verified,
|
|
2119
|
+
isAnonymous: auth.is_anonymous,
|
|
2120
|
+
isMultiFactorRequired: auth.requires_totp_mfa,
|
|
2121
|
+
isRestricted: auth.is_restricted,
|
|
2122
|
+
restrictedReason: auth.restricted_reason ?? null
|
|
2123
|
+
};
|
|
2124
|
+
}
|
|
2125
|
+
async getPartialUser(options) {
|
|
2126
|
+
switch (options.from) {
|
|
2127
|
+
case "token": {
|
|
2128
|
+
this._ensurePersistentTokenStore(options.tokenStore ?? this._tokenStoreInit);
|
|
2129
|
+
const session = await this._getSession(options.tokenStore);
|
|
2130
|
+
return this._getTokenPartialUserFromSession(session, options);
|
|
2131
|
+
}
|
|
2132
|
+
case "convex": return await this._getPartialUserFromConvex(options.ctx);
|
|
2133
|
+
default: throw new Error(`Invalid 'from' option: ${options.from}`);
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2136
|
+
usePartialUser(options) {
|
|
2137
|
+
switch (options.from) {
|
|
2138
|
+
case "token": {
|
|
2139
|
+
this._ensurePersistentTokenStore(options.tokenStore ?? this._tokenStoreInit);
|
|
2140
|
+
const session = this._useSession(options.tokenStore);
|
|
2141
|
+
return this._getTokenPartialUserFromSession(session, options);
|
|
2142
|
+
}
|
|
2143
|
+
case "convex": return useAsyncCache(this._convexPartialUserCache, [options.ctx], "clientApp.usePartialUser()");
|
|
2144
|
+
default: throw new Error(`Invalid 'from' option: ${options.from}`);
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
getConvexClientAuth(options) {
|
|
2148
|
+
return async (args) => {
|
|
2149
|
+
const session = await this._getSession(options.tokenStore ?? this._tokenStoreInit);
|
|
2150
|
+
if (!args.forceRefreshToken) return (await session.getOrFetchLikelyValidTokens(2e4, 75e3))?.accessToken.token ?? null;
|
|
2151
|
+
return (await session.fetchNewTokens())?.accessToken.token ?? null;
|
|
2152
|
+
};
|
|
2153
|
+
}
|
|
2154
|
+
async getConvexHttpClientAuth(options) {
|
|
2155
|
+
return (await (await this._getSession(options.tokenStore)).getOrFetchLikelyValidTokens(2e4, 75e3))?.accessToken.token ?? "";
|
|
2156
|
+
}
|
|
2157
|
+
async _updateClientUser(update, session) {
|
|
2158
|
+
const res = await this._interface.updateClientUser(userUpdateOptionsToCrud(update), session);
|
|
2159
|
+
await this._refreshUser(session);
|
|
2160
|
+
return res;
|
|
2161
|
+
}
|
|
2162
|
+
async signInWithOAuth(provider, options) {
|
|
2163
|
+
if (typeof window === "undefined") throw new Error("signInWithOAuth can currently only be called in a browser environment");
|
|
2164
|
+
this._ensurePersistentTokenStore();
|
|
2165
|
+
const session = await this._getSession();
|
|
2166
|
+
const currentUrl = new URL(window.location.href);
|
|
2167
|
+
const afterCallbackRedirectUrl = options?.returnTo != null ? constructRedirectUrl(options.returnTo, "returnTo") : currentUrl.searchParams.has("after_auth_return_to") ? currentUrl.toString() : void 0;
|
|
2168
|
+
const siteKeys = this._getBotChallengeSiteKeys();
|
|
2169
|
+
const { codeChallenge, state } = await saveVerifierAndState();
|
|
2170
|
+
const executeOAuth = async (challenge) => {
|
|
2171
|
+
return await this._interface.authorizeOAuth({
|
|
2172
|
+
provider,
|
|
2173
|
+
redirectUrl: constructRedirectUrl(this.urls.oauthCallback, "redirectUrl"),
|
|
2174
|
+
errorRedirectUrl: constructRedirectUrl(this.urls.error, "errorRedirectUrl"),
|
|
2175
|
+
afterCallbackRedirectUrl,
|
|
2176
|
+
type: "authenticate",
|
|
2177
|
+
providerScope: this._oauthScopesOnSignIn[provider]?.join(" "),
|
|
2178
|
+
codeChallenge,
|
|
2179
|
+
state,
|
|
2180
|
+
botChallenge: this._toInterfaceBotChallengeInput(challenge),
|
|
2181
|
+
session
|
|
2182
|
+
});
|
|
2183
|
+
};
|
|
2184
|
+
let authorizeResult;
|
|
2185
|
+
try {
|
|
2186
|
+
if (siteKeys) authorizeResult = await withBotChallengeFlow({
|
|
2187
|
+
...siteKeys,
|
|
2188
|
+
action: "oauth_authenticate",
|
|
2189
|
+
execute: executeOAuth,
|
|
2190
|
+
isChallengeRequired: (result) => {
|
|
2191
|
+
return result.status === "error" && KnownErrors.BotChallengeRequired.isInstance(result.error);
|
|
2192
|
+
}
|
|
2193
|
+
});
|
|
2194
|
+
else authorizeResult = await executeOAuth({});
|
|
2195
|
+
} catch (e) {
|
|
2196
|
+
const flowFailure = this._getBotChallengeFlowFailure(e);
|
|
2197
|
+
if (flowFailure?.type === "cancelled") return;
|
|
2198
|
+
if (flowFailure?.type === "failed") throw flowFailure.knownError;
|
|
2199
|
+
throw e;
|
|
2200
|
+
}
|
|
2201
|
+
const location = Result.orThrow(authorizeResult);
|
|
2202
|
+
await this._redirectTo({ url: location });
|
|
2203
|
+
await neverResolve();
|
|
2204
|
+
}
|
|
2205
|
+
/**
|
|
2206
|
+
* Handles MFA verification by redirecting to the OTP page
|
|
2207
|
+
*/
|
|
2208
|
+
async _experimentalMfa(error, session) {
|
|
2209
|
+
if (typeof window !== "undefined") window.sessionStorage.setItem("stack_mfa_attempt_code", error.details?.attempt_code ?? throwErr("attempt code missing"));
|
|
2210
|
+
await this.redirectToMfa();
|
|
2211
|
+
throw new StackAssertionError("we should have redirected in redirectToMfa()");
|
|
2212
|
+
}
|
|
2213
|
+
/**
|
|
2214
|
+
* @deprecated
|
|
2215
|
+
* TODO remove
|
|
2216
|
+
*/
|
|
2217
|
+
async _catchMfaRequiredError(callback) {
|
|
2218
|
+
try {
|
|
2219
|
+
return await callback();
|
|
2220
|
+
} catch (e) {
|
|
2221
|
+
if (KnownErrors.MultiFactorAuthenticationRequired.isInstance(e)) return Result.ok(await this._experimentalMfa(e, await this._getSession()));
|
|
2222
|
+
throw e;
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
async signInWithCredential(options) {
|
|
2226
|
+
this._ensurePersistentTokenStore();
|
|
2227
|
+
const session = await this._getSession();
|
|
2228
|
+
let result;
|
|
2229
|
+
try {
|
|
2230
|
+
result = await this._catchMfaRequiredError(async () => {
|
|
2231
|
+
return await this._interface.signInWithCredential(options.email, options.password, session);
|
|
2232
|
+
});
|
|
2233
|
+
} catch (e) {
|
|
2234
|
+
if (KnownErrors.InvalidTotpCode.isInstance(e)) return Result.error(e);
|
|
2235
|
+
throw e;
|
|
2236
|
+
}
|
|
2237
|
+
if (result.status === "ok") {
|
|
2238
|
+
await this._signInToAccountWithTokens(result.data);
|
|
2239
|
+
if (!options.noRedirect) await this.redirectToAfterSignIn({ replace: true });
|
|
2240
|
+
return Result.ok(void 0);
|
|
2241
|
+
} else return Result.error(result.error);
|
|
2242
|
+
}
|
|
2243
|
+
async signUpWithCredential(options) {
|
|
2244
|
+
if (options.noVerificationCallback && options.verificationCallbackUrl) throw new StackAssertionError("verificationCallbackUrl is not allowed when noVerificationCallback is true");
|
|
2245
|
+
this._ensurePersistentTokenStore();
|
|
2246
|
+
const session = await this._getSession();
|
|
2247
|
+
const emailVerificationRedirectUrl = options.noVerificationCallback ? void 0 : options.verificationCallbackUrl ?? constructRedirectUrl(this.urls.emailVerification, "verificationCallbackUrl");
|
|
2248
|
+
const executeSignUp = async (challenge) => {
|
|
2249
|
+
let result = await this._interface.signUpWithCredential(options.email, options.password, emailVerificationRedirectUrl, session, this._toInterfaceBotChallengeInput(challenge));
|
|
2250
|
+
if (result.status === "error" && result.error instanceof KnownErrors.RedirectUrlNotWhitelisted && emailVerificationRedirectUrl !== void 0) {
|
|
2251
|
+
if (!options.verificationCallbackUrl) {
|
|
2252
|
+
captureError("signup-verification-url-not-whitelisted", new StackAssertionError("The auto-constructed verification callback URL is not whitelisted; proceeding without email verification", { emailVerificationRedirectUrl }));
|
|
2253
|
+
result = await this._interface.signUpWithCredential(options.email, options.password, void 0, session, this._toInterfaceBotChallengeInput(challenge));
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
return result;
|
|
2257
|
+
};
|
|
2258
|
+
let result;
|
|
2259
|
+
result = await this._executeResultWithBotChallengeFlow({
|
|
2260
|
+
action: "sign_up_with_credential",
|
|
2261
|
+
execute: executeSignUp
|
|
2262
|
+
});
|
|
2263
|
+
if (result.status === "ok") {
|
|
2264
|
+
await this._signInToAccountWithTokens(result.data);
|
|
2265
|
+
if (!options.noRedirect) await this.redirectToAfterSignUp({ replace: true });
|
|
2266
|
+
return Result.ok(void 0);
|
|
2267
|
+
} else return Result.error(result.error);
|
|
2268
|
+
}
|
|
2269
|
+
async _signUpAnonymously() {
|
|
2270
|
+
this._ensurePersistentTokenStore();
|
|
2271
|
+
if (!this._anonymousSignUpInProgress) this._anonymousSignUpInProgress = (async () => {
|
|
2272
|
+
this._ensurePersistentTokenStore();
|
|
2273
|
+
const session = await this._getSession();
|
|
2274
|
+
const result = await this._interface.signUpAnonymously(session);
|
|
2275
|
+
if (result.status === "ok") await this._signInToAccountWithTokens(result.data);
|
|
2276
|
+
else throw new StackAssertionError("signUpAnonymously() should never return an error");
|
|
2277
|
+
this._anonymousSignUpInProgress = null;
|
|
2278
|
+
return result.data;
|
|
2279
|
+
})();
|
|
2280
|
+
return await this._anonymousSignUpInProgress;
|
|
2281
|
+
}
|
|
2282
|
+
async signInWithMagicLink(code, options) {
|
|
2283
|
+
this._ensurePersistentTokenStore();
|
|
2284
|
+
const session = await this._getSession();
|
|
2285
|
+
let result;
|
|
2286
|
+
try {
|
|
2287
|
+
result = await this._catchMfaRequiredError(async () => {
|
|
2288
|
+
return await this._interface.signInWithMagicLink(code, session);
|
|
2289
|
+
});
|
|
2290
|
+
} catch (e) {
|
|
2291
|
+
if (KnownErrors.InvalidTotpCode.isInstance(e)) return Result.error(e);
|
|
2292
|
+
throw e;
|
|
2293
|
+
}
|
|
2294
|
+
if (result.status === "ok") {
|
|
2295
|
+
await this._signInToAccountWithTokens(result.data);
|
|
2296
|
+
if (!options?.noRedirect) if (result.data.newUser) await this.redirectToAfterSignUp({ replace: true });
|
|
2297
|
+
else await this.redirectToAfterSignIn({ replace: true });
|
|
2298
|
+
return Result.ok(void 0);
|
|
2299
|
+
} else return Result.error(result.error);
|
|
2300
|
+
}
|
|
2301
|
+
/**
|
|
2302
|
+
* Initiates a CLI authentication process that allows a command line application
|
|
2303
|
+
* to get a refresh token for a user's account.
|
|
2304
|
+
*
|
|
2305
|
+
* This process works as follows:
|
|
2306
|
+
* 1. The CLI app calls this method, which initiates the auth process with the server
|
|
2307
|
+
* 2. The server returns a polling code and a login code
|
|
2308
|
+
* 3. The CLI app opens a browser window to the appUrl with the login code as a parameter
|
|
2309
|
+
* 4. The user logs in through the browser and confirms the authorization
|
|
2310
|
+
* 5. The CLI app polls for the refresh token using the polling code
|
|
2311
|
+
*
|
|
2312
|
+
* @param options Options for the CLI login
|
|
2313
|
+
* @param options.appUrl The URL of the app that will handle the CLI auth confirmation
|
|
2314
|
+
* @param options.expiresInMillis Optional duration in milliseconds before the auth attempt expires (default: 2 hours)
|
|
2315
|
+
* @param options.maxAttempts Optional maximum number of polling attempts (default: Infinity)
|
|
2316
|
+
* @param options.waitTimeMillis Optional time to wait between polling attempts (default: 2 seconds)
|
|
2317
|
+
* @param options.promptLink Optional function to call with the login URL and code to prompt the user to open the browser
|
|
2318
|
+
* @param options.anonRefreshToken Optional anonymous refresh token from the CLI's token store to associate with this login attempt
|
|
2319
|
+
* @returns Result containing either the refresh token or an error
|
|
2320
|
+
*/
|
|
2321
|
+
async promptCliLogin(options) {
|
|
2322
|
+
const response = await this._interface.sendClientRequest("/auth/cli", {
|
|
2323
|
+
method: "POST",
|
|
2324
|
+
headers: { "Content-Type": "application/json" },
|
|
2325
|
+
body: JSON.stringify({
|
|
2326
|
+
expires_in_millis: options.expiresInMillis,
|
|
2327
|
+
...options.anonRefreshToken != null ? { anon_refresh_token: options.anonRefreshToken } : {}
|
|
2328
|
+
})
|
|
2329
|
+
}, null);
|
|
2330
|
+
if (!response.ok) return Result.error(new KnownErrors.CliAuthError(`Failed to initiate CLI auth: ${response.status} ${await response.text()}`));
|
|
2331
|
+
const initResult = await response.json();
|
|
2332
|
+
const pollingCode = initResult.polling_code;
|
|
2333
|
+
const loginCode = initResult.login_code;
|
|
2334
|
+
const url = buildCliAuthConfirmUrl({
|
|
2335
|
+
cliAuthConfirmUrl: this.urls.cliAuthConfirm,
|
|
2336
|
+
appUrl: options.appUrl,
|
|
2337
|
+
loginCode
|
|
2338
|
+
});
|
|
2339
|
+
if (options.promptLink) options.promptLink(url, loginCode);
|
|
2340
|
+
else {
|
|
2341
|
+
console.log(`Your verification code: ${loginCode}`);
|
|
2342
|
+
console.log(`Please visit the following URL to authenticate:\n${url}`);
|
|
2343
|
+
}
|
|
2344
|
+
let attempts = 0;
|
|
2345
|
+
while (attempts < (options.maxAttempts ?? Infinity)) {
|
|
2346
|
+
attempts++;
|
|
2347
|
+
const pollResponse = await this._interface.sendClientRequest("/auth/cli/poll", {
|
|
2348
|
+
method: "POST",
|
|
2349
|
+
headers: { "Content-Type": "application/json" },
|
|
2350
|
+
body: JSON.stringify({ polling_code: pollingCode })
|
|
2351
|
+
}, null);
|
|
2352
|
+
if (!pollResponse.ok) return Result.error(new KnownErrors.CliAuthError(`Failed to initiate CLI auth: ${pollResponse.status} ${await pollResponse.text()}`));
|
|
2353
|
+
const pollResult = await pollResponse.json();
|
|
2354
|
+
if (pollResponse.status === 201 && pollResult.status === "success") return Result.ok(pollResult.refresh_token);
|
|
2355
|
+
if (pollResult.status === "waiting") {
|
|
2356
|
+
await wait(options.waitTimeMillis ?? 2e3);
|
|
2357
|
+
continue;
|
|
2358
|
+
}
|
|
2359
|
+
if (pollResult.status === "expired") return Result.error(new KnownErrors.CliAuthExpiredError("CLI authentication request expired. Please try again."));
|
|
2360
|
+
if (pollResult.status === "used") return Result.error(new KnownErrors.CliAuthUsedError("This authentication token has already been used."));
|
|
2361
|
+
return Result.error(new KnownErrors.CliAuthError(`Unexpected status from CLI auth polling: ${pollResult.status}`));
|
|
2362
|
+
}
|
|
2363
|
+
return Result.error(new KnownErrors.CliAuthError("Timed out waiting for CLI authentication."));
|
|
2364
|
+
}
|
|
2365
|
+
async signInWithMfa(totp, code, options) {
|
|
2366
|
+
this._ensurePersistentTokenStore();
|
|
2367
|
+
const session = await this._getSession();
|
|
2368
|
+
let result;
|
|
2369
|
+
try {
|
|
2370
|
+
result = await this._catchMfaRequiredError(async () => {
|
|
2371
|
+
return await this._interface.signInWithMfa(totp, code, session);
|
|
2372
|
+
});
|
|
2373
|
+
} catch (e) {
|
|
2374
|
+
if (e instanceof KnownErrors.InvalidTotpCode) return Result.error(e);
|
|
2375
|
+
throw e;
|
|
2376
|
+
}
|
|
2377
|
+
if (result.status === "ok") {
|
|
2378
|
+
await this._signInToAccountWithTokens(result.data);
|
|
2379
|
+
if (!options?.noRedirect) if (result.data.newUser) await this.redirectToAfterSignUp({ replace: true });
|
|
2380
|
+
else await this.redirectToAfterSignIn({ replace: true });
|
|
2381
|
+
return Result.ok(void 0);
|
|
2382
|
+
}
|
|
2383
|
+
return Result.error(result.error);
|
|
2384
|
+
}
|
|
2385
|
+
async signInWithPasskey() {
|
|
2386
|
+
this._ensurePersistentTokenStore();
|
|
2387
|
+
const session = await this._getSession();
|
|
2388
|
+
let result;
|
|
2389
|
+
try {
|
|
2390
|
+
result = await this._catchMfaRequiredError(async () => {
|
|
2391
|
+
const initiationResult = await this._interface.initiatePasskeyAuthentication({}, session);
|
|
2392
|
+
if (initiationResult.status !== "ok") return Result.error(new KnownErrors.PasskeyAuthenticationFailed("Failed to get initiation options for passkey authentication"));
|
|
2393
|
+
const { options_json, code } = initiationResult.data;
|
|
2394
|
+
if (options_json.rpId !== "THIS_VALUE_WILL_BE_REPLACED.example.com") throw new StackAssertionError(`Expected returned RP ID from server to equal sentinel, but found ${options_json.rpId}`);
|
|
2395
|
+
options_json.rpId = window.location.hostname;
|
|
2396
|
+
const authentication_response = await startAuthentication({ optionsJSON: options_json });
|
|
2397
|
+
return await this._interface.signInWithPasskey({
|
|
2398
|
+
authentication_response,
|
|
2399
|
+
code
|
|
2400
|
+
}, session);
|
|
2401
|
+
});
|
|
2402
|
+
} catch (error) {
|
|
2403
|
+
if (error instanceof WebAuthnError) return Result.error(new KnownErrors.PasskeyWebAuthnError(error.message, error.name));
|
|
2404
|
+
else return Result.error(new KnownErrors.PasskeyAuthenticationFailed("Failed to sign in with passkey"));
|
|
2405
|
+
}
|
|
2406
|
+
if (result.status === "ok") {
|
|
2407
|
+
await this._signInToAccountWithTokens(result.data);
|
|
2408
|
+
await this.redirectToAfterSignIn({ replace: true });
|
|
2409
|
+
return Result.ok(void 0);
|
|
2410
|
+
} else return Result.error(result.error);
|
|
2411
|
+
}
|
|
2412
|
+
async callOAuthCallback() {
|
|
2413
|
+
if (typeof window === "undefined") throw new Error("callOAuthCallback can currently only be called in a browser environment");
|
|
2414
|
+
this._ensurePersistentTokenStore();
|
|
2415
|
+
let oauthCallbackRedirectUri = this.urls.oauthCallback;
|
|
2416
|
+
const currentUrl = new URL(window.location.href);
|
|
2417
|
+
if (currentUrl.searchParams.get(crossDomainAuthQueryParams.marker) === "1") {
|
|
2418
|
+
currentUrl.searchParams.delete("code");
|
|
2419
|
+
currentUrl.searchParams.delete("state");
|
|
2420
|
+
oauthCallbackRedirectUri = currentUrl.toString();
|
|
2421
|
+
}
|
|
2422
|
+
let result;
|
|
2423
|
+
try {
|
|
2424
|
+
result = await this._catchMfaRequiredError(async () => {
|
|
2425
|
+
return await callOAuthCallback(this._interface, oauthCallbackRedirectUri);
|
|
2426
|
+
});
|
|
2427
|
+
} catch (e) {
|
|
2428
|
+
if (KnownErrors.InvalidTotpCode.isInstance(e)) {
|
|
2429
|
+
alert("Invalid TOTP code. Please try signing in again.");
|
|
2430
|
+
return false;
|
|
2431
|
+
} else throw e;
|
|
2432
|
+
}
|
|
2433
|
+
if (result.status === "ok" && result.data) {
|
|
2434
|
+
await this._signInToAccountWithTokens(result.data);
|
|
2435
|
+
if ("afterCallbackRedirectUrl" in result.data && result.data.afterCallbackRedirectUrl) {
|
|
2436
|
+
await this._redirectTo({
|
|
2437
|
+
url: result.data.afterCallbackRedirectUrl,
|
|
2438
|
+
replace: true
|
|
2439
|
+
});
|
|
2440
|
+
return true;
|
|
2441
|
+
} else if (result.data.newUser) {
|
|
2442
|
+
await this.redirectToAfterSignUp({ replace: true });
|
|
2443
|
+
return true;
|
|
2444
|
+
} else {
|
|
2445
|
+
await this.redirectToAfterSignIn({ replace: true });
|
|
2446
|
+
return true;
|
|
2447
|
+
}
|
|
2448
|
+
}
|
|
2449
|
+
return false;
|
|
2450
|
+
}
|
|
2451
|
+
async _signOut(session, options) {
|
|
2452
|
+
this._eventTracker?.clearBuffer();
|
|
2453
|
+
this._sessionRecorder?.clearBuffer();
|
|
2454
|
+
await storeLock.withWriteLock(async () => {
|
|
2455
|
+
await this._interface.signOut(session);
|
|
2456
|
+
if (options?.redirectUrl) await this._redirectTo({
|
|
2457
|
+
url: options.redirectUrl,
|
|
2458
|
+
replace: true
|
|
2459
|
+
});
|
|
2460
|
+
else await this.redirectToAfterSignOut();
|
|
2461
|
+
});
|
|
2462
|
+
}
|
|
2463
|
+
async signOut(options) {
|
|
2464
|
+
const user = await this.getUser({ tokenStore: options?.tokenStore ?? void 0 });
|
|
2465
|
+
if (user) await user.signOut({ redirectUrl: options?.redirectUrl });
|
|
2466
|
+
}
|
|
2467
|
+
async getAccessToken(options) {
|
|
2468
|
+
const user = await this.getUser({ tokenStore: options?.tokenStore ?? void 0 });
|
|
2469
|
+
if (user) return await user.getAccessToken();
|
|
2470
|
+
return null;
|
|
2471
|
+
}
|
|
2472
|
+
useAccessToken(options) {
|
|
2473
|
+
const user = this.useUser({ tokenStore: options?.tokenStore ?? void 0 });
|
|
2474
|
+
if (user) return user.useAccessToken();
|
|
2475
|
+
return null;
|
|
2476
|
+
}
|
|
2477
|
+
async getRefreshToken(options) {
|
|
2478
|
+
const user = await this.getUser({ tokenStore: options?.tokenStore ?? void 0 });
|
|
2479
|
+
if (user) return await user.getRefreshToken();
|
|
2480
|
+
return null;
|
|
2481
|
+
}
|
|
2482
|
+
useRefreshToken(options) {
|
|
2483
|
+
const user = this.useUser({ tokenStore: options?.tokenStore ?? void 0 });
|
|
2484
|
+
if (user) return user.useRefreshToken();
|
|
2485
|
+
return null;
|
|
2486
|
+
}
|
|
2487
|
+
async getAuthorizationHeader(options) {
|
|
2488
|
+
return getAuthorizationHeaderValueFromAuthJson(await this.getAuthJson(options));
|
|
2489
|
+
}
|
|
2490
|
+
useAuthorizationHeader(options) {
|
|
2491
|
+
return getAuthorizationHeaderValueFromAuthJson(this.useAuthJson(options));
|
|
2492
|
+
}
|
|
2493
|
+
async getAuthHeaders(options) {
|
|
2494
|
+
return { "x-stack-auth": JSON.stringify(await this.getAuthJson(options)) };
|
|
2495
|
+
}
|
|
2496
|
+
useAuthHeaders(options) {
|
|
2497
|
+
return { "x-stack-auth": JSON.stringify(this.useAuthJson(options)) };
|
|
2498
|
+
}
|
|
2499
|
+
async getAuthJson(options) {
|
|
2500
|
+
const user = await this.getUser({ tokenStore: options?.tokenStore ?? void 0 });
|
|
2501
|
+
if (user) return await user.getAuthJson();
|
|
2502
|
+
return {
|
|
2503
|
+
accessToken: null,
|
|
2504
|
+
refreshToken: null
|
|
2505
|
+
};
|
|
2506
|
+
}
|
|
2507
|
+
useAuthJson(options) {
|
|
2508
|
+
const user = this.useUser({ tokenStore: options?.tokenStore ?? void 0 });
|
|
2509
|
+
if (user) return user.useAuthJson();
|
|
2510
|
+
return {
|
|
2511
|
+
accessToken: null,
|
|
2512
|
+
refreshToken: null
|
|
2513
|
+
};
|
|
2514
|
+
}
|
|
2515
|
+
async getProject() {
|
|
2516
|
+
const crud = Result.orThrow(await this._currentProjectCache.getOrWait([], "write-only"));
|
|
2517
|
+
return this._clientProjectFromCrud(crud);
|
|
2518
|
+
}
|
|
2519
|
+
useProject() {
|
|
2520
|
+
const crud = useAsyncCache(this._currentProjectCache, [], "clientApp.useProject()");
|
|
2521
|
+
return useMemo(() => this._clientProjectFromCrud(crud), [crud]);
|
|
2522
|
+
}
|
|
2523
|
+
async _listOwnedProjects(session) {
|
|
2524
|
+
this._ensureInternalProject();
|
|
2525
|
+
return Result.orThrow(await this._ownedProjectsCache.getOrWait([session], "write-only")).map((j) => this._getOwnedAdminApp(j.id, session)._adminOwnedProjectFromCrud(j, () => this._refreshOwnedProjects(session)));
|
|
2526
|
+
}
|
|
2527
|
+
_useOwnedProjects(session) {
|
|
2528
|
+
this._ensureInternalProject();
|
|
2529
|
+
const projects = useAsyncCache(this._ownedProjectsCache, [session], "clientApp.useOwnedProjects()");
|
|
2530
|
+
return useMemo(() => projects.map((j) => this._getOwnedAdminApp(j.id, session)._adminOwnedProjectFromCrud(j, () => this._refreshOwnedProjects(session))), [projects]);
|
|
2531
|
+
}
|
|
2532
|
+
async _createProject(session, newProject) {
|
|
2533
|
+
this._ensureInternalProject();
|
|
2534
|
+
const crud = await this._interface.createProject(adminProjectCreateOptionsToCrud(newProject), session);
|
|
2535
|
+
const res = this._getOwnedAdminApp(crud.id, session)._adminOwnedProjectFromCrud(crud, () => this._refreshOwnedProjects(session));
|
|
2536
|
+
await this._refreshOwnedProjects(session);
|
|
2537
|
+
return res;
|
|
2538
|
+
}
|
|
2539
|
+
async _refreshUser(session) {
|
|
2540
|
+
await this._refreshSession(session);
|
|
2541
|
+
}
|
|
2542
|
+
async _refreshSession(session) {
|
|
2543
|
+
await Promise.all([this._currentUserCache.refresh([session]), this._currentUserConnectedAccountsCache.refresh([session])]);
|
|
2544
|
+
session.suggestAccessTokenExpired();
|
|
2545
|
+
}
|
|
2546
|
+
async _refreshUsers() {}
|
|
2547
|
+
async _refreshProject() {
|
|
2548
|
+
await this._currentProjectCache.refresh([]);
|
|
2549
|
+
}
|
|
2550
|
+
async _refreshOwnedProjects(session) {
|
|
2551
|
+
await this._ownedProjectsCache.refresh([session]);
|
|
2552
|
+
}
|
|
2553
|
+
static get [stackAppInternalsSymbol]() {
|
|
2554
|
+
return { fromClientJson: (json) => {
|
|
2555
|
+
const providedCheckString = JSON.stringify(omit(json, []));
|
|
2556
|
+
const existing = allClientApps.get(json.uniqueIdentifier);
|
|
2557
|
+
if (existing) {
|
|
2558
|
+
const [existingCheckString, clientApp] = existing;
|
|
2559
|
+
if (existingCheckString !== void 0 && existingCheckString !== providedCheckString) throw new StackAssertionError("The provided app JSON does not match the configuration of the existing client app with the same unique identifier", {
|
|
2560
|
+
providedObj: json,
|
|
2561
|
+
existingString: existingCheckString
|
|
2562
|
+
});
|
|
2563
|
+
return clientApp;
|
|
2564
|
+
}
|
|
2565
|
+
const { analytics, ...restJson } = omit(json, ["uniqueIdentifier"]);
|
|
2566
|
+
return new _StackClientAppImplIncomplete({
|
|
2567
|
+
...restJson,
|
|
2568
|
+
analytics: analyticsOptionsFromJson(analytics)
|
|
2569
|
+
}, {
|
|
2570
|
+
uniqueIdentifier: json.uniqueIdentifier,
|
|
2571
|
+
checkString: providedCheckString
|
|
2572
|
+
});
|
|
2573
|
+
} };
|
|
2574
|
+
}
|
|
2575
|
+
get [stackAppInternalsSymbol]() {
|
|
2576
|
+
return {
|
|
2577
|
+
toClientJson: () => {
|
|
2578
|
+
if (typeof this._redirectMethod !== "string") throw new StackAssertionError("Cannot serialize to JSON from an application with a non-string redirect method");
|
|
2579
|
+
const publishableClientKey = "publishableClientKey" in this._interface.options ? this._interface.options.publishableClientKey : void 0;
|
|
2580
|
+
return {
|
|
2581
|
+
baseUrl: this._options.baseUrl,
|
|
2582
|
+
projectId: this.projectId,
|
|
2583
|
+
...publishableClientKey != null ? { publishableClientKey } : {},
|
|
2584
|
+
tokenStore: this._tokenStoreInit,
|
|
2585
|
+
urls: this._urlOptions,
|
|
2586
|
+
oauthScopesOnSignIn: this._oauthScopesOnSignIn,
|
|
2587
|
+
uniqueIdentifier: this._getUniqueIdentifier(),
|
|
2588
|
+
redirectMethod: this._redirectMethod,
|
|
2589
|
+
extraRequestHeaders: this._options.extraRequestHeaders,
|
|
2590
|
+
devTool: this._options.devTool,
|
|
2591
|
+
analytics: analyticsOptionsToJson(this._analyticsOptions)
|
|
2592
|
+
};
|
|
2593
|
+
},
|
|
2594
|
+
setCurrentUser: (userJsonPromise) => {
|
|
2595
|
+
runAsynchronously(async () => {
|
|
2596
|
+
await this._currentUserCache.forceSetCachedValueAsync([await this._getSession()], Result.fromPromise(userJsonPromise));
|
|
2597
|
+
});
|
|
2598
|
+
},
|
|
2599
|
+
getConstructorOptions: () => this._options,
|
|
2600
|
+
sendSessionReplayBatch: async (body, options) => {
|
|
2601
|
+
return await this._interface.sendSessionReplayBatch(body, await this._getSession(), options);
|
|
2602
|
+
},
|
|
2603
|
+
sendAnalyticsEventBatch: async (body, options) => {
|
|
2604
|
+
return await this._interface.sendAnalyticsEventBatch(body, await this._getSession(), options);
|
|
2605
|
+
},
|
|
2606
|
+
addRequestListener: (listener) => {
|
|
2607
|
+
return this._interface.addRequestListener(listener);
|
|
2608
|
+
},
|
|
2609
|
+
sendRequest: async (path, requestOptions, requestType = "client") => {
|
|
2610
|
+
return await this._interface.sendClientRequest(path, requestOptions, await this._getSession(), requestType);
|
|
2611
|
+
},
|
|
2612
|
+
getRedirectMethod: () => this._redirectMethod ?? throwErr("Redirect method should have been initialized in the Stack client app constructor"),
|
|
2613
|
+
redirectToUrl: async (url, options) => {
|
|
2614
|
+
await this._redirectTo({
|
|
2615
|
+
url,
|
|
2616
|
+
...options
|
|
2617
|
+
});
|
|
2618
|
+
},
|
|
2619
|
+
refreshOwnedProjects: async () => {
|
|
2620
|
+
await this._refreshOwnedProjects(await this._getSession());
|
|
2621
|
+
},
|
|
2622
|
+
signInWithTokens: async (tokens) => {
|
|
2623
|
+
await this._signInToAccountWithTokens(tokens);
|
|
2624
|
+
}
|
|
2625
|
+
};
|
|
2626
|
+
}
|
|
2627
|
+
};
|
|
2628
|
+
|
|
2629
|
+
//#endregion
|
|
2630
|
+
export { _StackClientAppImplIncomplete };
|
|
2631
|
+
//# sourceMappingURL=client-app-impl.js.map
|