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