@stackframe/js 2.8.36 → 2.8.40

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/esm/index.js +4 -0
  3. package/dist/esm/index.js.map +1 -1
  4. package/dist/esm/integrations/convex.js +18 -0
  5. package/dist/esm/integrations/convex.js.map +1 -0
  6. package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js +41 -4
  7. package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
  8. package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js +116 -3
  9. package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
  10. package/dist/esm/lib/stack-app/apps/implementations/common.js +7 -7
  11. package/dist/esm/lib/stack-app/apps/implementations/common.js.map +1 -1
  12. package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js +90 -4
  13. package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
  14. package/dist/esm/lib/stack-app/apps/interfaces/admin-app.js.map +1 -1
  15. package/dist/esm/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
  16. package/dist/esm/lib/stack-app/apps/interfaces/server-app.js.map +1 -1
  17. package/dist/esm/lib/stack-app/common.js.map +1 -1
  18. package/dist/esm/lib/stack-app/index.js.map +1 -1
  19. package/dist/esm/lib/stack-app/users/index.js.map +1 -1
  20. package/dist/index.d.mts +167 -29
  21. package/dist/index.d.ts +167 -29
  22. package/dist/index.js +9 -0
  23. package/dist/index.js.map +1 -1
  24. package/dist/integrations/convex.js +43 -0
  25. package/dist/integrations/convex.js.map +1 -0
  26. package/dist/lib/stack-app/apps/implementations/admin-app-impl.js +40 -3
  27. package/dist/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
  28. package/dist/lib/stack-app/apps/implementations/client-app-impl.js +116 -3
  29. package/dist/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
  30. package/dist/lib/stack-app/apps/implementations/common.js +7 -7
  31. package/dist/lib/stack-app/apps/implementations/common.js.map +1 -1
  32. package/dist/lib/stack-app/apps/implementations/server-app-impl.js +89 -3
  33. package/dist/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
  34. package/dist/lib/stack-app/apps/interfaces/admin-app.js.map +1 -1
  35. package/dist/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
  36. package/dist/lib/stack-app/apps/interfaces/server-app.js.map +1 -1
  37. package/dist/lib/stack-app/common.js.map +1 -1
  38. package/dist/lib/stack-app/email/index.js.map +1 -1
  39. package/dist/lib/stack-app/index.js.map +1 -1
  40. package/dist/lib/stack-app/project-configs/index.js.map +1 -1
  41. package/dist/lib/stack-app/users/index.js.map +1 -1
  42. package/package.json +4 -3
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/lib/stack-app/apps/interfaces/admin-app.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { ChatContent } from \"@stackframe/stack-shared/dist/interface/admin-interface\";\nimport { InternalSession } from \"@stackframe/stack-shared/dist/sessions\";\nimport { Result } from \"@stackframe/stack-shared/dist/utils/results\";\nimport { AsyncStoreProperty, EmailConfig } from \"../../common\";\nimport { AdminSentEmail } from \"../../email\";\nimport { InternalApiKey, InternalApiKeyCreateOptions, InternalApiKeyFirstView } from \"../../internal-api-keys\";\nimport { AdminProjectPermission, AdminProjectPermissionDefinition, AdminProjectPermissionDefinitionCreateOptions, AdminProjectPermissionDefinitionUpdateOptions, AdminTeamPermission, AdminTeamPermissionDefinition, AdminTeamPermissionDefinitionCreateOptions, AdminTeamPermissionDefinitionUpdateOptions } from \"../../permissions\";\nimport { AdminProject } from \"../../projects\";\nimport { _StackAdminAppImpl } from \"../implementations\";\nimport { StackServerApp, StackServerAppConstructorOptions } from \"./server-app\";\n\n\nexport type StackAdminAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = (\n | (\n & StackServerAppConstructorOptions<HasTokenStore, ProjectId>\n & {\n superSecretAdminKey?: string,\n }\n )\n | (\n & Omit<StackServerAppConstructorOptions<HasTokenStore, ProjectId>, \"publishableClientKey\" | \"secretServerKey\">\n & {\n projectOwnerSession: InternalSession,\n }\n )\n);\n\n\nexport type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = (\n & AsyncStoreProperty<\"project\", [], AdminProject, false>\n & AsyncStoreProperty<\"internalApiKeys\", [], InternalApiKey[], true>\n & AsyncStoreProperty<\"teamPermissionDefinitions\", [], AdminTeamPermissionDefinition[], true>\n & AsyncStoreProperty<\"projectPermissionDefinitions\", [], AdminProjectPermissionDefinition[], true>\n & AsyncStoreProperty<\"emailThemes\", [], { id: string, displayName: string }[], true>\n & AsyncStoreProperty<\"emailPreview\", [{ themeId?: string | null | false, themeTsxSource?: string, templateId?: string, templateTsxSource?: string }], string, false>\n & AsyncStoreProperty<\"emailTemplates\", [], { id: string, displayName: string, themeId?: string, tsxSource: string }[], true>\n & AsyncStoreProperty<\"stripeAccountInfo\", [], { account_id: string, charges_enabled: boolean, details_submitted: boolean, payouts_enabled: boolean } | null, false>\n & {\n listEmailTemplates(): Promise<{ id: string, displayName: string, tsxSource: string }[]>,\n\n createInternalApiKey(options: InternalApiKeyCreateOptions): Promise<InternalApiKeyFirstView>,\n\n createTeamPermissionDefinition(data: AdminTeamPermissionDefinitionCreateOptions): Promise<AdminTeamPermission>,\n updateTeamPermissionDefinition(permissionId: string, data: AdminTeamPermissionDefinitionUpdateOptions): Promise<void>,\n deleteTeamPermissionDefinition(permissionId: string): Promise<void>,\n\n createProjectPermissionDefinition(data: AdminProjectPermissionDefinitionCreateOptions): Promise<AdminProjectPermission>,\n updateProjectPermissionDefinition(permissionId: string, data: AdminProjectPermissionDefinitionUpdateOptions): Promise<void>,\n deleteProjectPermissionDefinition(permissionId: string): Promise<void>,\n\n\n sendTestEmail(options: {\n recipientEmail: string,\n emailConfig: EmailConfig,\n }): Promise<Result<undefined, { errorMessage: string }>>,\n\n sendSignInInvitationEmail(email: string, callbackUrl: string): Promise<void>,\n\n listSentEmails(): Promise<AdminSentEmail[]>,\n\n createEmailTheme(displayName: string): Promise<{ id: string }>,\n updateEmailTheme(id: string, tsxSource: string): Promise<void>,\n\n sendChatMessage(\n threadId: string,\n contextType: \"email-theme\" | \"email-template\",\n messages: Array<{ role: string, content: any }>,\n abortSignal?: AbortSignal,\n ): Promise<{ content: ChatContent }>,\n saveChatMessage(threadId: string, message: any): Promise<void>,\n listChatMessages(threadId: string): Promise<{ messages: Array<any> }>,\n updateEmailTemplate(id: string, tsxSource: string, themeId: string | null | false): Promise<{ renderedHtml: string }>,\n createEmailTemplate(displayName: string): Promise<{ id: string }>,\n\n setupPayments(): Promise<{ url: string }>,\n createStripeWidgetAccountSession(): Promise<{ client_secret: string }>,\n createItemQuantityChange(options: (\n { userId: string, itemId: string, quantity: number, expiresAt?: string, description?: string } |\n { teamId: string, itemId: string, quantity: number, expiresAt?: string, description?: string } |\n { customCustomerId: string, itemId: string, quantity: number, expiresAt?: string, description?: string }\n )): Promise<void>,\n testModePurchase(options: { priceId: string, fullCode: string, quantity?: number }): Promise<void>,\n }\n & StackServerApp<HasTokenStore, ProjectId>\n);\nexport type StackAdminAppConstructor = {\n new <\n HasTokenStore extends boolean,\n ProjectId extends string\n >(options: StackAdminAppConstructorOptions<HasTokenStore, ProjectId>): StackAdminApp<HasTokenStore, ProjectId>,\n new (options: StackAdminAppConstructorOptions<boolean, string>): StackAdminApp<boolean, string>,\n};\nexport const StackAdminApp: StackAdminAppConstructor = _StackAdminAppImpl;\n"],"mappings":";AAYA,SAAS,0BAA0B;AAoF5B,IAAM,gBAA0C;","names":[]}
1
+ {"version":3,"sources":["../../../../../../src/lib/stack-app/apps/interfaces/admin-app.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { ChatContent } from \"@stackframe/stack-shared/dist/interface/admin-interface\";\nimport type { AdminTransaction } from \"@stackframe/stack-shared/dist/interface/crud/transactions\";\nimport { InternalSession } from \"@stackframe/stack-shared/dist/sessions\";\nimport { Result } from \"@stackframe/stack-shared/dist/utils/results\";\nimport { AsyncStoreProperty, EmailConfig } from \"../../common\";\nimport { AdminSentEmail } from \"../../email\";\nimport { InternalApiKey, InternalApiKeyCreateOptions, InternalApiKeyFirstView } from \"../../internal-api-keys\";\nimport { AdminProjectPermission, AdminProjectPermissionDefinition, AdminProjectPermissionDefinitionCreateOptions, AdminProjectPermissionDefinitionUpdateOptions, AdminTeamPermission, AdminTeamPermissionDefinition, AdminTeamPermissionDefinitionCreateOptions, AdminTeamPermissionDefinitionUpdateOptions } from \"../../permissions\";\nimport { AdminProject } from \"../../projects\";\nimport { _StackAdminAppImpl } from \"../implementations\";\nimport { StackServerApp, StackServerAppConstructorOptions } from \"./server-app\";\n\n\nexport type StackAdminAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = (\n | (\n & StackServerAppConstructorOptions<HasTokenStore, ProjectId>\n & {\n superSecretAdminKey?: string,\n }\n )\n | (\n & Omit<StackServerAppConstructorOptions<HasTokenStore, ProjectId>, \"publishableClientKey\" | \"secretServerKey\">\n & {\n projectOwnerSession: InternalSession,\n }\n )\n);\n\n\nexport type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = (\n & AsyncStoreProperty<\"project\", [], AdminProject, false>\n & AsyncStoreProperty<\"internalApiKeys\", [], InternalApiKey[], true>\n & AsyncStoreProperty<\"teamPermissionDefinitions\", [], AdminTeamPermissionDefinition[], true>\n & AsyncStoreProperty<\"projectPermissionDefinitions\", [], AdminProjectPermissionDefinition[], true>\n & AsyncStoreProperty<\"emailThemes\", [], { id: string, displayName: string }[], true>\n & AsyncStoreProperty<\"emailPreview\", [{ themeId?: string | null | false, themeTsxSource?: string, templateId?: string, templateTsxSource?: string }], string, false>\n & AsyncStoreProperty<\"emailTemplates\", [], { id: string, displayName: string, themeId?: string, tsxSource: string }[], true>\n & AsyncStoreProperty<\"emailDrafts\", [], { id: string, displayName: string, themeId: string | undefined | false, tsxSource: string, sentAt: Date | null }[], true>\n & AsyncStoreProperty<\"stripeAccountInfo\", [], { account_id: string, charges_enabled: boolean, details_submitted: boolean, payouts_enabled: boolean } | null, false>\n & AsyncStoreProperty<\n \"transactions\",\n [\n { cursor?: string, limit?: number, type?: 'subscription' | 'one_time' | 'item_quantity_change', customerType?: 'user' | 'team' | 'custom' }\n ],\n { transactions: AdminTransaction[], nextCursor: string | null },\n true\n >\n & {\n createInternalApiKey(options: InternalApiKeyCreateOptions): Promise<InternalApiKeyFirstView>,\n\n createTeamPermissionDefinition(data: AdminTeamPermissionDefinitionCreateOptions): Promise<AdminTeamPermission>,\n updateTeamPermissionDefinition(permissionId: string, data: AdminTeamPermissionDefinitionUpdateOptions): Promise<void>,\n deleteTeamPermissionDefinition(permissionId: string): Promise<void>,\n\n createProjectPermissionDefinition(data: AdminProjectPermissionDefinitionCreateOptions): Promise<AdminProjectPermission>,\n updateProjectPermissionDefinition(permissionId: string, data: AdminProjectPermissionDefinitionUpdateOptions): Promise<void>,\n deleteProjectPermissionDefinition(permissionId: string): Promise<void>,\n\n\n sendTestEmail(options: {\n recipientEmail: string,\n emailConfig: EmailConfig,\n }): Promise<Result<undefined, { errorMessage: string }>>,\n\n sendSignInInvitationEmail(email: string, callbackUrl: string): Promise<void>,\n\n listSentEmails(): Promise<AdminSentEmail[]>,\n\n createEmailTheme(displayName: string): Promise<{ id: string }>,\n updateEmailTheme(id: string, tsxSource: string): Promise<void>,\n\n sendChatMessage(\n threadId: string,\n contextType: \"email-theme\" | \"email-template\" | \"email-draft\",\n messages: Array<{ role: string, content: any }>,\n abortSignal?: AbortSignal,\n ): Promise<{ content: ChatContent }>,\n saveChatMessage(threadId: string, message: any): Promise<void>,\n listChatMessages(threadId: string): Promise<{ messages: Array<any> }>,\n updateEmailTemplate(id: string, tsxSource: string, themeId: string | null | false): Promise<{ renderedHtml: string }>,\n createEmailTemplate(displayName: string): Promise<{ id: string }>,\n\n setupPayments(): Promise<{ url: string }>,\n createStripeWidgetAccountSession(): Promise<{ client_secret: string }>,\n createEmailDraft(options: { displayName: string, themeId?: string | undefined | false, tsxSource?: string }): Promise<{ id: string }>,\n updateEmailDraft(id: string, data: { displayName?: string, themeId?: string | undefined | false, tsxSource?: string }): Promise<void>,\n createItemQuantityChange(options: (\n { userId: string, itemId: string, quantity: number, expiresAt?: string, description?: string } |\n { teamId: string, itemId: string, quantity: number, expiresAt?: string, description?: string } |\n { customCustomerId: string, itemId: string, quantity: number, expiresAt?: string, description?: string }\n )): Promise<void>,\n testModePurchase(options: { priceId: string, fullCode: string, quantity?: number }): Promise<void>,\n }\n & StackServerApp<HasTokenStore, ProjectId>\n);\nexport type StackAdminAppConstructor = {\n new <\n HasTokenStore extends boolean,\n ProjectId extends string\n >(options: StackAdminAppConstructorOptions<HasTokenStore, ProjectId>): StackAdminApp<HasTokenStore, ProjectId>,\n new (options: StackAdminAppConstructorOptions<boolean, string>): StackAdminApp<boolean, string>,\n};\nexport const StackAdminApp: StackAdminAppConstructor = _StackAdminAppImpl;\n"],"mappings":";AAaA,SAAS,0BAA0B;AA6F5B,IAAM,gBAA0C;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/lib/stack-app/apps/interfaces/client-app.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { KnownErrors } from \"@stackframe/stack-shared\";\nimport { CurrentUserCrud } from \"@stackframe/stack-shared/dist/interface/crud/current-user\";\nimport { Result } from \"@stackframe/stack-shared/dist/utils/results\";\nimport { AsyncStoreProperty, GetUserOptions, HandlerUrls, OAuthScopesOnSignIn, RedirectMethod, RedirectToOptions, TokenStoreInit, stackAppInternalsSymbol } from \"../../common\";\nimport { Item } from \"../../customers\";\nimport { Project } from \"../../projects\";\nimport { ProjectCurrentUser } from \"../../users\";\nimport { _StackClientAppImpl } from \"../implementations\";\n\n\nexport type StackClientAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = {\n baseUrl?: string | { browser: string, server: string },\n extraRequestHeaders?: Record<string, string>,\n projectId?: ProjectId,\n publishableClientKey?: string,\n urls?: Partial<HandlerUrls>,\n oauthScopesOnSignIn?: Partial<OAuthScopesOnSignIn>,\n tokenStore: TokenStoreInit<HasTokenStore>,\n redirectMethod?: RedirectMethod,\n\n /**\n * By default, the Stack app will automatically prefetch some data from Stack's server when this app is first\n * constructed. This improves the performance of your app, but will create network requests that are unnecessary if\n * the app is never used or disposed of immediately. To disable this behavior, set this option to true.\n */\n noAutomaticPrefetch?: boolean,\n};\n\n\nexport type StackClientAppJson<HasTokenStore extends boolean, ProjectId extends string> = StackClientAppConstructorOptions<HasTokenStore, ProjectId> & {\n uniqueIdentifier: string,\n // note: if you add more fields here, make sure to ensure the checkString in the constructor has/doesn't have them\n};\n\nexport type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = (\n & {\n readonly projectId: ProjectId,\n\n readonly urls: Readonly<HandlerUrls>,\n\n signInWithOAuth(provider: string): Promise<void>,\n signInWithCredential(options: { email: string, password: string, noRedirect?: boolean }): Promise<Result<undefined, KnownErrors[\"EmailPasswordMismatch\"] | KnownErrors[\"InvalidTotpCode\"]>>,\n signUpWithCredential(options: { email: string, password: string, noRedirect?: boolean, verificationCallbackUrl?: string }): Promise<Result<undefined, KnownErrors[\"UserWithEmailAlreadyExists\"] | KnownErrors[\"PasswordRequirementsNotMet\"]>>,\n signInWithPasskey(): Promise<Result<undefined, KnownErrors[\"PasskeyAuthenticationFailed\"]| KnownErrors[\"InvalidTotpCode\"] | KnownErrors[\"PasskeyWebAuthnError\"]>>,\n callOAuthCallback(): Promise<boolean>,\n promptCliLogin(options: { appUrl: string, expiresInMillis?: number }): Promise<Result<string, KnownErrors[\"CliAuthError\"] | KnownErrors[\"CliAuthExpiredError\"] | KnownErrors[\"CliAuthUsedError\"]>>,\n sendForgotPasswordEmail(email: string, options?: { callbackUrl?: string }): Promise<Result<undefined, KnownErrors[\"UserNotFound\"]>>,\n sendMagicLinkEmail(email: string, options?: { callbackUrl?: string }): Promise<Result<{ nonce: string }, KnownErrors[\"RedirectUrlNotWhitelisted\"]>>,\n resetPassword(options: { code: string, password: string }): Promise<Result<undefined, KnownErrors[\"VerificationCodeError\"]>>,\n verifyPasswordResetCode(code: string): Promise<Result<undefined, KnownErrors[\"VerificationCodeError\"]>>,\n verifyTeamInvitationCode(code: string): Promise<Result<undefined, KnownErrors[\"VerificationCodeError\"]>>,\n acceptTeamInvitation(code: string): Promise<Result<undefined, KnownErrors[\"VerificationCodeError\"]>>,\n getTeamInvitationDetails(code: string): Promise<Result<{ teamDisplayName: string }, KnownErrors[\"VerificationCodeError\"]>>,\n verifyEmail(code: string): Promise<Result<undefined, KnownErrors[\"VerificationCodeError\"]>>,\n signInWithMagicLink(code: string, options?: { noRedirect?: boolean }): Promise<Result<undefined, KnownErrors[\"VerificationCodeError\"] | KnownErrors[\"InvalidTotpCode\"]>>,\n signInWithMfa(otp: string, code: string, options?: { noRedirect?: boolean }): Promise<Result<undefined, KnownErrors[\"VerificationCodeError\"] | KnownErrors[\"InvalidTotpCode\"]>>,\n\n redirectToOAuthCallback(): Promise<void>,\n\n\n getUser(options: GetUserOptions<HasTokenStore> & { or: 'redirect' }): Promise<ProjectCurrentUser<ProjectId>>,\n getUser(options: GetUserOptions<HasTokenStore> & { or: 'throw' }): Promise<ProjectCurrentUser<ProjectId>>,\n getUser(options: GetUserOptions<HasTokenStore> & { or: 'anonymous' }): Promise<ProjectCurrentUser<ProjectId>>,\n getUser(options?: GetUserOptions<HasTokenStore>): Promise<ProjectCurrentUser<ProjectId> | null>,\n\n\n [stackAppInternalsSymbol]: {\n toClientJson(): StackClientAppJson<HasTokenStore, ProjectId>,\n setCurrentUser(userJsonPromise: Promise<CurrentUserCrud['Client']['Read'] | null>): void,\n },\n }\n & AsyncStoreProperty<\"project\", [], Project, false>\n & AsyncStoreProperty<\n \"item\",\n [{ itemId: string, userId: string } | { itemId: string, teamId: string } | { itemId: string, customCustomerId: string }],\n Item,\n false\n >\n & { [K in `redirectTo${Capitalize<keyof Omit<HandlerUrls, 'handler' | 'oauthCallback'>>}`]: (options?: RedirectToOptions) => Promise<void> }\n);\nexport type StackClientAppConstructor = {\n new <\n TokenStoreType extends string,\n HasTokenStore extends (TokenStoreType extends {} ? true : boolean),\n ProjectId extends string\n >(options: StackClientAppConstructorOptions<HasTokenStore, ProjectId>): StackClientApp<HasTokenStore, ProjectId>,\n new (options: StackClientAppConstructorOptions<boolean, string>): StackClientApp<boolean, string>,\n\n [stackAppInternalsSymbol]: {\n fromClientJson<HasTokenStore extends boolean, ProjectId extends string>(\n json: StackClientAppJson<HasTokenStore, ProjectId>\n ): StackClientApp<HasTokenStore, ProjectId>,\n },\n};\nexport const StackClientApp: StackClientAppConstructor = _StackClientAppImpl;\n"],"mappings":";AAWA,SAAS,2BAA2B;AAuF7B,IAAM,iBAA4C;","names":[]}
1
+ {"version":3,"sources":["../../../../../../src/lib/stack-app/apps/interfaces/client-app.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { KnownErrors } from \"@stackframe/stack-shared\";\nimport { CurrentUserCrud } from \"@stackframe/stack-shared/dist/interface/crud/current-user\";\nimport { Result } from \"@stackframe/stack-shared/dist/utils/results\";\nimport { AsyncStoreProperty, GetCurrentPartialUserOptions, GetCurrentUserOptions, HandlerUrls, OAuthScopesOnSignIn, RedirectMethod, RedirectToOptions, TokenStoreInit, stackAppInternalsSymbol } from \"../../common\";\nimport { Item } from \"../../customers\";\nimport { Project } from \"../../projects\";\nimport { ProjectCurrentUser, SyncedPartialUser, TokenPartialUser } from \"../../users\";\nimport { _StackClientAppImpl } from \"../implementations\";\n\nexport type StackClientAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = {\n baseUrl?: string | { browser: string, server: string },\n extraRequestHeaders?: Record<string, string>,\n projectId?: ProjectId,\n publishableClientKey?: string,\n urls?: Partial<HandlerUrls>,\n oauthScopesOnSignIn?: Partial<OAuthScopesOnSignIn>,\n tokenStore: TokenStoreInit<HasTokenStore>,\n redirectMethod?: RedirectMethod,\n\n /**\n * By default, the Stack app will automatically prefetch some data from Stack's server when this app is first\n * constructed. This improves the performance of your app, but will create network requests that are unnecessary if\n * the app is never used or disposed of immediately. To disable this behavior, set this option to true.\n */\n noAutomaticPrefetch?: boolean,\n};\n\n\nexport type StackClientAppJson<HasTokenStore extends boolean, ProjectId extends string> = StackClientAppConstructorOptions<HasTokenStore, ProjectId> & {\n uniqueIdentifier: string,\n // note: if you add more fields here, make sure to ensure the checkString in the constructor has/doesn't have them\n};\n\nexport type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = (\n & {\n readonly projectId: ProjectId,\n\n readonly urls: Readonly<HandlerUrls>,\n\n signInWithOAuth(provider: string, options?: { returnTo?: string }): Promise<void>,\n signInWithCredential(options: { email: string, password: string, noRedirect?: boolean }): Promise<Result<undefined, KnownErrors[\"EmailPasswordMismatch\"] | KnownErrors[\"InvalidTotpCode\"]>>,\n signUpWithCredential(options: { email: string, password: string, noRedirect?: boolean, verificationCallbackUrl?: string }): Promise<Result<undefined, KnownErrors[\"UserWithEmailAlreadyExists\"] | KnownErrors[\"PasswordRequirementsNotMet\"]>>,\n signInWithPasskey(): Promise<Result<undefined, KnownErrors[\"PasskeyAuthenticationFailed\"] | KnownErrors[\"InvalidTotpCode\"] | KnownErrors[\"PasskeyWebAuthnError\"]>>,\n callOAuthCallback(): Promise<boolean>,\n promptCliLogin(options: { appUrl: string, expiresInMillis?: number }): Promise<Result<string, KnownErrors[\"CliAuthError\"] | KnownErrors[\"CliAuthExpiredError\"] | KnownErrors[\"CliAuthUsedError\"]>>,\n sendForgotPasswordEmail(email: string, options?: { callbackUrl?: string }): Promise<Result<undefined, KnownErrors[\"UserNotFound\"]>>,\n sendMagicLinkEmail(email: string, options?: { callbackUrl?: string }): Promise<Result<{ nonce: string }, KnownErrors[\"RedirectUrlNotWhitelisted\"]>>,\n resetPassword(options: { code: string, password: string }): Promise<Result<undefined, KnownErrors[\"VerificationCodeError\"]>>,\n verifyPasswordResetCode(code: string): Promise<Result<undefined, KnownErrors[\"VerificationCodeError\"]>>,\n verifyTeamInvitationCode(code: string): Promise<Result<undefined, KnownErrors[\"VerificationCodeError\"]>>,\n acceptTeamInvitation(code: string): Promise<Result<undefined, KnownErrors[\"VerificationCodeError\"]>>,\n getTeamInvitationDetails(code: string): Promise<Result<{ teamDisplayName: string }, KnownErrors[\"VerificationCodeError\"]>>,\n verifyEmail(code: string): Promise<Result<undefined, KnownErrors[\"VerificationCodeError\"]>>,\n signInWithMagicLink(code: string, options?: { noRedirect?: boolean }): Promise<Result<undefined, KnownErrors[\"VerificationCodeError\"] | KnownErrors[\"InvalidTotpCode\"]>>,\n signInWithMfa(otp: string, code: string, options?: { noRedirect?: boolean }): Promise<Result<undefined, KnownErrors[\"VerificationCodeError\"] | KnownErrors[\"InvalidTotpCode\"]>>,\n\n redirectToOAuthCallback(): Promise<void>,\n\n getConvexClientAuth(options: { tokenStore: TokenStoreInit }): (args: { forceRefreshToken: boolean }) => Promise<string | null>,\n getConvexHttpClientAuth(options: { tokenStore: TokenStoreInit }): Promise<string>,\n\n\n getUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'redirect' }): Promise<ProjectCurrentUser<ProjectId>>,\n getUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'throw' }): Promise<ProjectCurrentUser<ProjectId>>,\n getUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'anonymous' }): Promise<ProjectCurrentUser<ProjectId>>,\n getUser(options?: GetCurrentUserOptions<HasTokenStore>): Promise<ProjectCurrentUser<ProjectId> | null>,\n\n // note: we don't special-case 'anonymous' here to return non-null, see GetPartialUserOptions for more details\n getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & { from: 'token' }): Promise<TokenPartialUser | null>,\n getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & { from: 'convex' }): Promise<TokenPartialUser | null>,\n getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore>): Promise<SyncedPartialUser | TokenPartialUser | null>,\n\n [stackAppInternalsSymbol]: {\n toClientJson(): StackClientAppJson<HasTokenStore, ProjectId>,\n setCurrentUser(userJsonPromise: Promise<CurrentUserCrud['Client']['Read'] | null>): void,\n },\n }\n & AsyncStoreProperty<\"project\", [], Project, false>\n & AsyncStoreProperty<\n \"item\",\n [{ itemId: string, userId: string } | { itemId: string, teamId: string } | { itemId: string, customCustomerId: string }],\n Item,\n false\n >\n & { [K in `redirectTo${Capitalize<keyof Omit<HandlerUrls, 'handler' | 'oauthCallback'>>}`]: (options?: RedirectToOptions) => Promise<void> }\n);\nexport type StackClientAppConstructor = {\n new <\n TokenStoreType extends string,\n HasTokenStore extends (TokenStoreType extends {} ? true : boolean),\n ProjectId extends string\n >(options: StackClientAppConstructorOptions<HasTokenStore, ProjectId>): StackClientApp<HasTokenStore, ProjectId>,\n new(options: StackClientAppConstructorOptions<boolean, string>): StackClientApp<boolean, string>,\n\n [stackAppInternalsSymbol]: {\n fromClientJson<HasTokenStore extends boolean, ProjectId extends string>(\n json: StackClientAppJson<HasTokenStore, ProjectId>\n ): StackClientApp<HasTokenStore, ProjectId>,\n },\n};\nexport const StackClientApp: StackClientAppConstructor = _StackClientAppImpl;\n"],"mappings":";AAWA,SAAS,2BAA2B;AA6F7B,IAAM,iBAA4C;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/lib/stack-app/apps/interfaces/server-app.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { KnownErrors } from \"@stackframe/stack-shared\";\nimport { Result } from \"@stackframe/stack-shared/dist/utils/results\";\nimport { AsyncStoreProperty, GetUserOptions } from \"../../common\";\nimport { ServerItem } from \"../../customers\";\nimport { DataVaultStore } from \"../../data-vault\";\nimport { SendEmailOptions } from \"../../email\";\nimport { ServerListUsersOptions, ServerTeam, ServerTeamCreateOptions } from \"../../teams\";\nimport { ProjectCurrentServerUser, ServerUser, ServerUserCreateOptions } from \"../../users\";\nimport { _StackServerAppImpl } from \"../implementations\";\nimport { StackClientApp, StackClientAppConstructorOptions } from \"./client-app\";\n\n\nexport type StackServerAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = StackClientAppConstructorOptions<HasTokenStore, ProjectId> & {\n secretServerKey?: string,\n};\n\nexport type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = (\n & {\n createTeam(data: ServerTeamCreateOptions): Promise<ServerTeam>,\n /**\n * @deprecated use `getUser()` instead\n */\n getServerUser(): Promise<ProjectCurrentServerUser<ProjectId> | null>,\n\n createUser(options: ServerUserCreateOptions): Promise<ServerUser>,\n\n\n getUser(options: GetUserOptions<HasTokenStore> & { or: 'redirect' }): Promise<ProjectCurrentServerUser<ProjectId>>,\n getUser(options: GetUserOptions<HasTokenStore> & { or: 'throw' }): Promise<ProjectCurrentServerUser<ProjectId>>,\n getUser(options: GetUserOptions<HasTokenStore> & { or: 'anonymous' }): Promise<ProjectCurrentServerUser<ProjectId>>,\n getUser(options?: GetUserOptions<HasTokenStore>): Promise<ProjectCurrentServerUser<ProjectId> | null>,\n getUser(id: string): Promise<ServerUser | null>,\n getUser(options: { apiKey: string }): Promise<ServerUser | null>,\n\n\n getTeam(id: string): Promise<ServerTeam | null>,\n getTeam(options: { apiKey: string }): Promise<ServerTeam | null>,\n\n\n listUsers(options?: ServerListUsersOptions): Promise<ServerUser[] & { nextCursor: string | null }>,\n sendEmail(options: SendEmailOptions): Promise<Result<void, KnownErrors[\"RequiresCustomEmailServer\"] | KnownErrors[\"SchemaError\"] | KnownErrors[\"UserIdDoesNotExist\"]>>,\n }\n & AsyncStoreProperty<\"user\", [id: string], ServerUser | null, false>\n & Omit<AsyncStoreProperty<\"users\", [], ServerUser[], true>, \"listUsers\" | \"useUsers\">\n & AsyncStoreProperty<\"teams\", [], ServerTeam[], true>\n & AsyncStoreProperty<\"dataVaultStore\", [id: string], DataVaultStore, false>\n & AsyncStoreProperty<\n \"item\",\n [{ itemId: string, userId: string } | { itemId: string, teamId: string } | { itemId: string, customCustomerId: string }],\n ServerItem,\n false\n >\n & StackClientApp<HasTokenStore, ProjectId>\n);\nexport type StackServerAppConstructor = {\n new <\n TokenStoreType extends string,\n HasTokenStore extends (TokenStoreType extends {} ? true : boolean),\n ProjectId extends string\n >(options: StackServerAppConstructorOptions<HasTokenStore, ProjectId>): StackServerApp<HasTokenStore, ProjectId>,\n new (options: StackServerAppConstructorOptions<boolean, string>): StackServerApp<boolean, string>,\n};\nexport const StackServerApp: StackServerAppConstructor = _StackServerAppImpl;\n"],"mappings":";AAYA,SAAS,2BAA2B;AAsD7B,IAAM,iBAA4C;","names":[]}
1
+ {"version":3,"sources":["../../../../../../src/lib/stack-app/apps/interfaces/server-app.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { KnownErrors } from \"@stackframe/stack-shared\";\nimport { Result } from \"@stackframe/stack-shared/dist/utils/results\";\nimport type { GenericQueryCtx } from \"convex/server\";\nimport { AsyncStoreProperty, GetCurrentPartialUserOptions, GetCurrentUserOptions } from \"../../common\";\nimport { ServerItem } from \"../../customers\";\nimport { DataVaultStore } from \"../../data-vault\";\nimport { SendEmailOptions } from \"../../email\";\nimport { ServerListUsersOptions, ServerTeam, ServerTeamCreateOptions } from \"../../teams\";\nimport { ProjectCurrentServerUser, ServerOAuthProvider, ServerUser, ServerUserCreateOptions, SyncedPartialServerUser, TokenPartialUser } from \"../../users\";\nimport { _StackServerAppImpl } from \"../implementations\";\nimport { StackClientApp, StackClientAppConstructorOptions } from \"./client-app\";\n\n\nexport type StackServerAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = StackClientAppConstructorOptions<HasTokenStore, ProjectId> & {\n secretServerKey?: string,\n};\n\nexport type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = (\n & {\n createTeam(data: ServerTeamCreateOptions): Promise<ServerTeam>,\n /**\n * @deprecated use `getUser()` instead\n */\n getServerUser(): Promise<ProjectCurrentServerUser<ProjectId> | null>,\n\n createUser(options: ServerUserCreateOptions): Promise<ServerUser>,\n\n\n getUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'redirect' }): Promise<ProjectCurrentServerUser<ProjectId>>,\n getUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'throw' }): Promise<ProjectCurrentServerUser<ProjectId>>,\n getUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'anonymous' }): Promise<ProjectCurrentServerUser<ProjectId>>,\n getUser(options?: GetCurrentUserOptions<HasTokenStore>): Promise<ProjectCurrentServerUser<ProjectId> | null>,\n getUser(id: string): Promise<ServerUser | null>,\n getUser(options: { apiKey: string, or?: \"return-null\" | \"anonymous\" }): Promise<ServerUser | null>,\n getUser(options: { from: \"convex\", ctx: GenericQueryCtx<any>, or?: \"return-null\" | \"anonymous\" }): Promise<ServerUser | null>,\n\n // note: we don't special-case 'anonymous' here to return non-null, see GetPartialUserOptions for more details\n getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & { from: 'token' }): Promise<TokenPartialUser | null>,\n getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & { from: 'convex' }): Promise<TokenPartialUser | null>,\n getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore>): Promise<SyncedPartialServerUser | TokenPartialUser | null>,\n getTeam(id: string): Promise<ServerTeam | null>,\n getTeam(options: { apiKey: string }): Promise<ServerTeam | null>,\n\n\n listUsers(options?: ServerListUsersOptions): Promise<ServerUser[] & { nextCursor: string | null }>,\n\n createOAuthProvider(options: {\n userId: string,\n accountId: string,\n providerConfigId: string,\n email: string,\n allowSignIn: boolean,\n allowConnectedAccounts: boolean,\n }): Promise<Result<ServerOAuthProvider, InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>>>,\n\n sendEmail(options: SendEmailOptions): Promise<void>,\n }\n & AsyncStoreProperty<\"user\", [id: string], ServerUser | null, false>\n & Omit<AsyncStoreProperty<\"users\", [], ServerUser[], true>, \"listUsers\" | \"useUsers\">\n & AsyncStoreProperty<\"teams\", [], ServerTeam[], true>\n & AsyncStoreProperty<\"dataVaultStore\", [id: string], DataVaultStore, false>\n & AsyncStoreProperty<\n \"item\",\n [{ itemId: string, userId: string } | { itemId: string, teamId: string } | { itemId: string, customCustomerId: string }],\n ServerItem,\n false\n >\n & StackClientApp<HasTokenStore, ProjectId>\n);\nexport type StackServerAppConstructor = {\n new <\n TokenStoreType extends string,\n HasTokenStore extends (TokenStoreType extends {} ? true : boolean),\n ProjectId extends string\n >(options: StackServerAppConstructorOptions<HasTokenStore, ProjectId>): StackServerApp<HasTokenStore, ProjectId>,\n new (options: StackServerAppConstructorOptions<boolean, string>): StackServerApp<boolean, string>,\n};\nexport const StackServerApp: StackServerAppConstructor = _StackServerAppImpl;\n"],"mappings":";AAaA,SAAS,2BAA2B;AAoE7B,IAAM,iBAA4C;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/stack-app/common.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { ProviderType } from \"@stackframe/stack-shared/dist/utils/oauth\";\n\nexport type RedirectToOptions = {\n replace?: boolean,\n noRedirectBack?: boolean,\n};\n\nexport type AsyncStoreProperty<Name extends string, Args extends any[], Value, IsMultiple extends boolean> =\n & { [key in `${IsMultiple extends true ? \"list\" : \"get\"}${Capitalize<Name>}`]: (...args: Args) => Promise<Value> }\n\nexport type EmailConfig = {\n host: string,\n port: number,\n username: string,\n password: string,\n senderEmail: string,\n senderName: string,\n}\n\nexport type RedirectMethod = \"window\"\n | \"none\"\n | {\n useNavigate: () => (to: string) => void,\n navigate?: (to: string) => void,\n }\n\n\nexport type GetUserOptions<HasTokenStore> =\n & {\n or?: 'redirect' | 'throw' | 'return-null' | 'anonymous' | /** @deprecated */ 'anonymous-if-exists[deprecated]',\n tokenStore?: TokenStoreInit,\n }\n & (HasTokenStore extends false ? {\n tokenStore: TokenStoreInit,\n } : {});\n\nexport type RequestLike = {\n headers: {\n get: (name: string) => string | null,\n },\n};\n\nexport type TokenStoreInit<HasTokenStore extends boolean = boolean> =\n HasTokenStore extends true ? (\n | \"cookie\"\n | \"nextjs-cookie\"\n | \"memory\"\n | RequestLike\n | { accessToken: string, refreshToken: string }\n )\n : HasTokenStore extends false ? null\n : TokenStoreInit<true> | TokenStoreInit<false>;\n\nexport type HandlerUrls = {\n handler: string,\n signIn: string,\n signUp: string,\n afterSignIn: string,\n afterSignUp: string,\n signOut: string,\n afterSignOut: string,\n emailVerification: string,\n passwordReset: string,\n forgotPassword: string,\n home: string,\n oauthCallback: string,\n magicLinkCallback: string,\n accountSettings: string,\n teamInvitation: string,\n mfa: string,\n error: string,\n}\n\nexport type OAuthScopesOnSignIn = {\n [key in ProviderType]: string[];\n};\n\n/** @internal */\nexport const stackAppInternalsSymbol = Symbol.for(\"StackAuth--DO-NOT-USE-OR-YOU-WILL-BE-FIRED--StackAppInternals\");\n"],"mappings":";AAkFO,IAAM,0BAA0B,OAAO,IAAI,+DAA+D;","names":[]}
1
+ {"version":3,"sources":["../../../../src/lib/stack-app/common.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { ProviderType } from \"@stackframe/stack-shared/dist/utils/oauth\";\nimport type { GenericQueryCtx, UserIdentity } from \"convex/server\";\n\nexport type RedirectToOptions = {\n replace?: boolean,\n noRedirectBack?: boolean,\n};\n\nexport type AsyncStoreProperty<Name extends string, Args extends any[], Value, IsMultiple extends boolean> =\n & { [key in `${IsMultiple extends true ? \"list\" : \"get\"}${Capitalize<Name>}`]: (...args: Args) => Promise<Value> }\n\nexport type EmailConfig = {\n host: string,\n port: number,\n username: string,\n password: string,\n senderEmail: string,\n senderName: string,\n}\n\nexport type RedirectMethod = \"window\"\n | \"none\"\n | {\n useNavigate: () => (to: string) => void,\n navigate?: (to: string) => void,\n }\n\n\nexport type GetCurrentUserOptions<HasTokenStore> =\n & {\n or?: 'redirect' | 'throw' | 'return-null' | 'anonymous' | /** @deprecated */ 'anonymous-if-exists[deprecated]',\n tokenStore?: TokenStoreInit,\n }\n & (HasTokenStore extends false ? {\n tokenStore: TokenStoreInit,\n } : {});\n\nexport type ConvexCtx =\n| GenericQueryCtx<any>\n| { auth: { getUserIdentity: () => Promise<UserIdentity | null> } };\n\nexport type GetCurrentPartialUserOptions<HasTokenStore> =\n & {\n or?: 'return-null' | 'anonymous', // note: unlike normal getUser, 'anonymous' still returns null sometimes (eg. if no token is present)\n tokenStore?: TokenStoreInit,\n }\n & (\n | {\n from: 'token',\n }\n | {\n from: 'convex',\n ctx: ConvexCtx,\n }\n )\n & (HasTokenStore extends false ? {\n tokenStore: TokenStoreInit,\n } : {});\n\nexport type RequestLike = {\n headers: {\n get: (name: string) => string | null,\n },\n};\n\nexport type TokenStoreInit<HasTokenStore extends boolean = boolean> =\n HasTokenStore extends true ? (\n | \"cookie\"\n | \"nextjs-cookie\"\n | \"memory\"\n | RequestLike\n | { accessToken: string, refreshToken: string }\n )\n : HasTokenStore extends false ? null\n : TokenStoreInit<true> | TokenStoreInit<false>;\n\nexport type HandlerUrls = {\n handler: string,\n signIn: string,\n signUp: string,\n afterSignIn: string,\n afterSignUp: string,\n signOut: string,\n afterSignOut: string,\n emailVerification: string,\n passwordReset: string,\n forgotPassword: string,\n home: string,\n oauthCallback: string,\n magicLinkCallback: string,\n accountSettings: string,\n teamInvitation: string,\n mfa: string,\n error: string,\n}\n\nexport type OAuthScopesOnSignIn = {\n [key in ProviderType]: string[];\n};\n\n/** @internal */\nexport const stackAppInternalsSymbol = Symbol.for(\"StackAuth--DO-NOT-USE-OR-YOU-WILL-BE-FIRED--StackAppInternals\");\n"],"mappings":";AAyGO,IAAM,0BAA0B,OAAO,IAAI,+DAA+D;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/stack-app/index.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nexport {\n StackAdminApp, StackClientApp,\n StackServerApp\n} from \"./apps\";\nexport type {\n StackAdminAppConstructor,\n StackAdminAppConstructorOptions,\n StackClientAppConstructor,\n StackClientAppConstructorOptions,\n StackClientAppJson,\n StackServerAppConstructor,\n StackServerAppConstructorOptions\n} from \"./apps\";\n\nexport type {\n ProjectConfig\n} from \"./project-configs\";\n\nexport type {\n InternalApiKey,\n InternalApiKeyBase,\n InternalApiKeyBaseCrudRead,\n InternalApiKeyCreateOptions,\n InternalApiKeyFirstView\n} from \"./internal-api-keys\";\n\nexport {\n stackAppInternalsSymbol\n} from \"./common\";\nexport type {\n GetUserOptions,\n HandlerUrls,\n OAuthScopesOnSignIn\n} from \"./common\";\n\nexport type {\n Connection,\n OAuthConnection\n} from \"./connected-accounts\";\n\nexport type {\n ContactChannel,\n ServerContactChannel\n} from \"./contact-channels\";\n\nexport type {\n AdminSentEmail\n} from \"./email\";\n\nexport type {\n AdminTeamPermission,\n AdminTeamPermissionDefinition,\n AdminTeamPermissionDefinitionCreateOptions,\n AdminTeamPermissionDefinitionUpdateOptions,\n AdminProjectPermission,\n AdminProjectPermissionDefinition,\n AdminProjectPermissionDefinitionCreateOptions,\n AdminProjectPermissionDefinitionUpdateOptions,\n} from \"./permissions\";\n\nexport type {\n AdminDomainConfig,\n AdminEmailConfig,\n AdminOAuthProviderConfig,\n AdminProjectConfig,\n AdminProjectConfigUpdateOptions,\n OAuthProviderConfig\n} from \"./project-configs\";\n\nexport type {\n AdminOwnedProject,\n AdminProject,\n AdminProjectCreateOptions,\n AdminProjectUpdateOptions,\n Project\n} from \"./projects\";\n\nexport type {\n EditableTeamMemberProfile,\n ServerListUsersOptions,\n ServerTeam,\n ServerTeamCreateOptions,\n ServerTeamMemberProfile,\n ServerTeamUpdateOptions,\n ServerTeamUser,\n Team,\n TeamCreateOptions,\n TeamInvitation,\n TeamMemberProfile,\n TeamUpdateOptions,\n TeamUser\n} from \"./teams\";\n\nexport type {\n Auth,\n CurrentInternalServerUser,\n CurrentInternalUser,\n CurrentServerUser,\n CurrentUser,\n ServerUser,\n Session,\n User\n} from \"./users\";\n\n"],"mappings":";AAIA;AAAA,EACE;AAAA,EAAe;AAAA,EACf;AAAA,OACK;AAuBP;AAAA,EACE;AAAA,OACK;","names":[]}
1
+ {"version":3,"sources":["../../../../src/lib/stack-app/index.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nexport {\n StackAdminApp, StackClientApp,\n StackServerApp\n} from \"./apps\";\nexport type {\n StackAdminAppConstructor,\n StackAdminAppConstructorOptions,\n StackClientAppConstructor,\n StackClientAppConstructorOptions,\n StackClientAppJson,\n StackServerAppConstructor,\n StackServerAppConstructorOptions\n} from \"./apps\";\n\nexport type {\n ProjectConfig\n} from \"./project-configs\";\n\nexport type {\n InternalApiKey,\n InternalApiKeyBase,\n InternalApiKeyBaseCrudRead,\n InternalApiKeyCreateOptions,\n InternalApiKeyFirstView\n} from \"./internal-api-keys\";\n\nexport {\n stackAppInternalsSymbol\n} from \"./common\";\nexport type {\n GetCurrentUserOptions,\n /** @deprecated Use GetCurrentUserOptions instead */\n GetCurrentUserOptions as GetUserOptions,\n HandlerUrls,\n OAuthScopesOnSignIn\n} from \"./common\";\n\nexport type {\n Connection,\n OAuthConnection\n} from \"./connected-accounts\";\n\nexport type {\n ContactChannel,\n ServerContactChannel\n} from \"./contact-channels\";\n\nexport type {\n AdminSentEmail\n} from \"./email\";\n\nexport type {\n AdminProjectPermission,\n AdminProjectPermissionDefinition,\n AdminProjectPermissionDefinitionCreateOptions,\n AdminProjectPermissionDefinitionUpdateOptions, AdminTeamPermission,\n AdminTeamPermissionDefinition,\n AdminTeamPermissionDefinitionCreateOptions,\n AdminTeamPermissionDefinitionUpdateOptions\n} from \"./permissions\";\n\nexport type {\n AdminDomainConfig,\n AdminEmailConfig,\n AdminOAuthProviderConfig,\n AdminProjectConfig,\n AdminProjectConfigUpdateOptions,\n OAuthProviderConfig\n} from \"./project-configs\";\n\nexport type {\n AdminOwnedProject,\n AdminProject,\n AdminProjectCreateOptions,\n AdminProjectUpdateOptions,\n Project\n} from \"./projects\";\n\nexport type {\n EditableTeamMemberProfile,\n ServerListUsersOptions,\n ServerTeam,\n ServerTeamCreateOptions,\n ServerTeamMemberProfile,\n ServerTeamUpdateOptions,\n ServerTeamUser,\n Team,\n TeamCreateOptions,\n TeamInvitation,\n TeamMemberProfile,\n TeamUpdateOptions,\n TeamUser\n} from \"./teams\";\n\nexport type {\n Auth,\n CurrentInternalServerUser,\n CurrentInternalUser,\n CurrentServerUser,\n CurrentUser,\n OAuthProvider,\n ServerOAuthProvider,\n ServerUser,\n Session,\n User\n} from \"./users\";\n\n"],"mappings":";AAIA;AAAA,EACE;AAAA,EAAe;AAAA,EACf;AAAA,OACK;AAuBP;AAAA,EACE;AAAA,OACK;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/lib/stack-app/users/index.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { KnownErrors } from \"@stackframe/stack-shared\";\nimport { CurrentUserCrud } from \"@stackframe/stack-shared/dist/interface/crud/current-user\";\nimport { UsersCrud } from \"@stackframe/stack-shared/dist/interface/crud/users\";\nimport { InternalSession } from \"@stackframe/stack-shared/dist/sessions\";\nimport { encodeBase64 } from \"@stackframe/stack-shared/dist/utils/bytes\";\nimport { GeoInfo } from \"@stackframe/stack-shared/dist/utils/geo\";\nimport { ReadonlyJson } from \"@stackframe/stack-shared/dist/utils/json\";\nimport { ProviderType } from \"@stackframe/stack-shared/dist/utils/oauth\";\nimport { Result } from \"@stackframe/stack-shared/dist/utils/results\";\nimport { ApiKeyCreationOptions, UserApiKey, UserApiKeyFirstView } from \"../api-keys\";\nimport { AsyncStoreProperty } from \"../common\";\nimport { OAuthConnection } from \"../connected-accounts\";\nimport { ContactChannel, ContactChannelCreateOptions, ServerContactChannel, ServerContactChannelCreateOptions } from \"../contact-channels\";\nimport { AdminTeamPermission, TeamPermission } from \"../permissions\";\nimport { AdminOwnedProject, AdminProjectCreateOptions, AdminProjectUpdateOptions } from \"../projects\";\nimport { EditableTeamMemberProfile, ServerTeam, ServerTeamCreateOptions, Team, TeamCreateOptions } from \"../teams\";\nimport { NotificationCategory } from \"../notification-categories\";\nimport { Customer } from \"../customers\";\n\n\nexport type Session = {\n getTokens(): Promise<{ accessToken: string | null, refreshToken: string | null }>,\n};\n\n/**\n * Contains everything related to the current user session.\n */\nexport type Auth = {\n readonly _internalSession: InternalSession,\n readonly currentSession: Session,\n signOut(options?: { redirectUrl?: URL | string }): Promise<void>,\n\n /**\n * Returns headers for sending authenticated HTTP requests to external servers. Most commonly used in cross-origin\n * requests. Similar to `getAuthJson`, but specifically for HTTP requests.\n *\n * If you are using `tokenStore: \"cookie\"`, you don't need this for same-origin requests. However, most\n * browsers now disable third-party cookies by default, so we must pass authentication tokens by header instead\n * if the client and server are on different origins.\n *\n * This function returns a header object that can be used with `fetch` or other HTTP request libraries to send\n * authenticated requests.\n *\n * On the server, you can then pass in the `Request` object to the `tokenStore` option\n * of your Stack app. Please note that CORS does not allow most headers by default, so you\n * must include `x-stack-auth` in the [`Access-Control-Allow-Headers` header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers)\n * of the CORS preflight response.\n *\n * If you are not using HTTP (and hence cannot set headers), you will need to use the `getAuthJson()` function\n * instead.\n *\n * Example:\n *\n * ```ts\n * // client\n * const res = await fetch(\"https://api.example.com\", {\n * headers: {\n * ...await stackApp.getAuthHeaders()\n * // you can also add your own headers here\n * },\n * });\n *\n * // server\n * function handleRequest(req: Request) {\n * const user = await stackServerApp.getUser({ tokenStore: req });\n * return new Response(\"Welcome, \" + user.displayName);\n * }\n * ```\n */\n getAuthHeaders(): Promise<{ \"x-stack-auth\": string }>,\n\n /**\n * Creates a JSON-serializable object containing the information to authenticate a user on an external server.\n * Similar to `getAuthHeaders`, but returns an object that can be sent over any protocol instead of just\n * HTTP headers.\n *\n * While `getAuthHeaders` is the recommended way to send authentication tokens over HTTP, your app may use\n * a different protocol, for example WebSockets or gRPC. This function returns a token object that can be JSON-serialized and sent to the server in any way you like.\n *\n * On the server, you can pass in this token object into the `tokenStore` option to fetch user details.\n *\n * Example:\n *\n * ```ts\n * // client\n * const res = await rpcCall(rpcEndpoint, {\n * data: {\n * auth: await stackApp.getAuthJson(),\n * },\n * });\n *\n * // server\n * function handleRequest(data) {\n * const user = await stackServerApp.getUser({ tokenStore: data.auth });\n * return new Response(\"Welcome, \" + user.displayName);\n * }\n * ```\n */\n getAuthJson(): Promise<{ accessToken: string | null, refreshToken: string | null }>,\n registerPasskey(options?: { hostname?: string }): Promise<Result<undefined, KnownErrors[\"PasskeyRegistrationFailed\"] | KnownErrors[\"PasskeyWebAuthnError\"]>>,\n};\n\n/**\n * ```\n * +----------+-------------+-------------------+\n * | \\ | !Server | Server |\n * +----------+-------------+-------------------+\n * | !Session | User | ServerUser |\n * | Session | CurrentUser | CurrentServerUser |\n * +----------+-------------+-------------------+\n * ```\n *\n * The fields on each of these types are available iff:\n * BaseUser: true\n * Auth: Session\n * ServerBaseUser: Server\n * UserExtra: Session OR Server\n *\n * The types are defined as follows (in the typescript manner):\n * User = BaseUser\n * CurrentUser = BaseUser & Auth & UserExtra\n * ServerUser = BaseUser & ServerBaseUser & UserExtra\n * CurrentServerUser = BaseUser & ServerBaseUser & Auth & UserExtra\n **/\n\nexport type BaseUser = {\n readonly id: string,\n\n readonly displayName: string | null,\n\n /**\n * The user's email address.\n *\n * Note: This might NOT be unique across multiple users, so always use `id` for unique identification.\n */\n readonly primaryEmail: string | null,\n readonly primaryEmailVerified: boolean,\n readonly profileImageUrl: string | null,\n\n readonly signedUpAt: Date,\n\n readonly clientMetadata: any,\n readonly clientReadOnlyMetadata: any,\n\n /**\n * Whether the user has a password set.\n */\n readonly hasPassword: boolean,\n readonly otpAuthEnabled: boolean,\n readonly passkeyAuthEnabled: boolean,\n\n readonly isMultiFactorRequired: boolean,\n readonly isAnonymous: boolean,\n toClientJson(): CurrentUserCrud[\"Client\"][\"Read\"],\n\n /**\n * @deprecated, use contact channel's usedForAuth instead\n */\n readonly emailAuthEnabled: boolean,\n /**\n * @deprecated\n */\n readonly oauthProviders: readonly { id: string }[],\n}\n\nexport type UserExtra = {\n setDisplayName(displayName: string): Promise<void>,\n /** @deprecated Use contact channel's sendVerificationEmail instead */\n sendVerificationEmail(): Promise<KnownErrors[\"EmailAlreadyVerified\"] | void>,\n setClientMetadata(metadata: any): Promise<void>,\n updatePassword(options: { oldPassword: string, newPassword: string}): Promise<KnownErrors[\"PasswordConfirmationMismatch\"] | KnownErrors[\"PasswordRequirementsNotMet\"] | void>,\n setPassword(options: { password: string }): Promise<KnownErrors[\"PasswordRequirementsNotMet\"] | void>,\n\n /**\n * A shorthand method to update multiple fields of the user at once.\n */\n update(update: UserUpdateOptions): Promise<void>,\n\n listContactChannels(): Promise<ContactChannel[]>,\n createContactChannel(data: ContactChannelCreateOptions): Promise<ContactChannel>,\n\n listNotificationCategories(): Promise<NotificationCategory[]>,\n\n delete(): Promise<void>,\n\n getConnectedAccount(id: ProviderType, options: { or: 'redirect', scopes?: string[] }): Promise<OAuthConnection>,\n getConnectedAccount(id: ProviderType, options?: { or?: 'redirect' | 'throw' | 'return-null', scopes?: string[] }): Promise<OAuthConnection | null>,\n\n\n hasPermission(scope: Team, permissionId: string): Promise<boolean>,\n hasPermission(permissionId: string): Promise<boolean>,\n\n getPermission(scope: Team, permissionId: string): Promise<TeamPermission | null>,\n getPermission(permissionId: string): Promise<TeamPermission | null>,\n\n listPermissions(scope: Team, options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n listPermissions(options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n\n\n readonly selectedTeam: Team | null,\n setSelectedTeam(team: Team | null): Promise<void>,\n createTeam(data: TeamCreateOptions): Promise<Team>,\n leaveTeam(team: Team): Promise<void>,\n\n getActiveSessions(): Promise<ActiveSession[]>,\n revokeSession(sessionId: string): Promise<void>,\n getTeamProfile(team: Team): Promise<EditableTeamMemberProfile>,\n\n createApiKey(options: ApiKeyCreationOptions<\"user\">): Promise<UserApiKeyFirstView>,\n}\n& AsyncStoreProperty<\"apiKeys\", [], UserApiKey[], true>\n& AsyncStoreProperty<\"team\", [id: string], Team | null, false>\n& AsyncStoreProperty<\"teams\", [], Team[], true>\n& AsyncStoreProperty<\"permission\", [scope: Team, permissionId: string, options?: { recursive?: boolean }], TeamPermission | null, false>\n& AsyncStoreProperty<\"permissions\", [scope: Team, options?: { recursive?: boolean }], TeamPermission[], true>;\n\nexport type InternalUserExtra =\n & {\n createProject(newProject: AdminProjectCreateOptions): Promise<AdminOwnedProject>,\n }\n & AsyncStoreProperty<\"ownedProjects\", [], AdminOwnedProject[], true>\n\nexport type User = BaseUser;\n\nexport type CurrentUser = BaseUser & Auth & UserExtra & Customer;\n\nexport type CurrentInternalUser = CurrentUser & InternalUserExtra;\n\nexport type ProjectCurrentUser<ProjectId> = ProjectId extends \"internal\" ? CurrentInternalUser : CurrentUser;\n\n\nexport type ActiveSession = {\n id: string,\n userId: string,\n createdAt: Date,\n isImpersonation: boolean,\n lastUsedAt: Date | undefined,\n isCurrentSession: boolean,\n geoInfo?: GeoInfo,\n};\n\nexport type UserUpdateOptions = {\n displayName?: string,\n clientMetadata?: ReadonlyJson,\n selectedTeamId?: string | null,\n totpMultiFactorSecret?: Uint8Array | null,\n profileImageUrl?: string | null,\n otpAuthEnabled?: boolean,\n passkeyAuthEnabled?:boolean,\n}\nexport function userUpdateOptionsToCrud(options: UserUpdateOptions): CurrentUserCrud[\"Client\"][\"Update\"] {\n return {\n display_name: options.displayName,\n client_metadata: options.clientMetadata,\n selected_team_id: options.selectedTeamId,\n totp_secret_base64: options.totpMultiFactorSecret != null ? encodeBase64(options.totpMultiFactorSecret) : options.totpMultiFactorSecret,\n profile_image_url: options.profileImageUrl,\n otp_auth_enabled: options.otpAuthEnabled,\n passkey_auth_enabled: options.passkeyAuthEnabled,\n };\n}\n\n\nexport type ServerBaseUser = {\n setPrimaryEmail(email: string | null, options?: { verified?: boolean | undefined }): Promise<void>,\n\n readonly lastActiveAt: Date,\n\n readonly serverMetadata: any,\n setServerMetadata(metadata: any): Promise<void>,\n setClientReadOnlyMetadata(metadata: any): Promise<void>,\n\n createTeam(data: Omit<ServerTeamCreateOptions, \"creatorUserId\">): Promise<ServerTeam>,\n\n listContactChannels(): Promise<ServerContactChannel[]>,\n createContactChannel(data: ServerContactChannelCreateOptions): Promise<ServerContactChannel>,\n\n update(user: ServerUserUpdateOptions): Promise<void>,\n\n grantPermission(scope: Team, permissionId: string): Promise<void>,\n grantPermission(permissionId: string): Promise<void>,\n\n revokePermission(scope: Team, permissionId: string): Promise<void>,\n revokePermission(permissionId: string): Promise<void>,\n\n getPermission(scope: Team, permissionId: string): Promise<TeamPermission | null>,\n getPermission(permissionId: string): Promise<TeamPermission | null>,\n\n hasPermission(scope: Team, permissionId: string): Promise<boolean>,\n hasPermission(permissionId: string): Promise<boolean>,\n\n listPermissions(scope: Team, options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n listPermissions(options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n\n\n /**\n * Creates a new session object with a refresh token for this user. Can be used to impersonate them.\n */\n createSession(options?: { expiresInMillis?: number, isImpersonation?: boolean }): Promise<Session>,\n}\n& AsyncStoreProperty<\"team\", [id: string], ServerTeam | null, false>\n& AsyncStoreProperty<\"teams\", [], ServerTeam[], true>\n& AsyncStoreProperty<\"permission\", [scope: Team, permissionId: string, options?: { direct?: boolean }], AdminTeamPermission | null, false>\n& AsyncStoreProperty<\"permissions\", [scope: Team, options?: { direct?: boolean }], AdminTeamPermission[], true>;\n\n/**\n * A user including sensitive fields that should only be used on the server, never sent to the client\n * (such as sensitive information and serverMetadata).\n */\nexport type ServerUser = ServerBaseUser & BaseUser & UserExtra & Customer<true>;\n\nexport type CurrentServerUser = Auth & ServerUser;\n\nexport type CurrentInternalServerUser = CurrentServerUser & InternalUserExtra;\n\nexport type ProjectCurrentServerUser<ProjectId> = ProjectId extends \"internal\" ? CurrentInternalServerUser : CurrentServerUser;\n\n\nexport type ServerUserUpdateOptions = {\n primaryEmail?: string | null,\n primaryEmailVerified?: boolean,\n primaryEmailAuthEnabled?: boolean,\n clientReadOnlyMetadata?: ReadonlyJson,\n serverMetadata?: ReadonlyJson,\n password?: string,\n} & UserUpdateOptions;\nexport function serverUserUpdateOptionsToCrud(options: ServerUserUpdateOptions): CurrentUserCrud[\"Server\"][\"Update\"] {\n return {\n display_name: options.displayName,\n primary_email: options.primaryEmail,\n client_metadata: options.clientMetadata,\n client_read_only_metadata: options.clientReadOnlyMetadata,\n server_metadata: options.serverMetadata,\n selected_team_id: options.selectedTeamId,\n primary_email_auth_enabled: options.primaryEmailAuthEnabled,\n primary_email_verified: options.primaryEmailVerified,\n password: options.password,\n profile_image_url: options.profileImageUrl,\n totp_secret_base64: options.totpMultiFactorSecret != null ? encodeBase64(options.totpMultiFactorSecret) : options.totpMultiFactorSecret,\n };\n}\n\n\nexport type ServerUserCreateOptions = {\n primaryEmail?: string | null,\n primaryEmailAuthEnabled?: boolean,\n password?: string,\n otpAuthEnabled?: boolean,\n displayName?: string,\n primaryEmailVerified?: boolean,\n clientMetadata?: any,\n clientReadOnlyMetadata?: any,\n serverMetadata?: any,\n}\nexport function serverUserCreateOptionsToCrud(options: ServerUserCreateOptions): UsersCrud[\"Server\"][\"Create\"] {\n return {\n primary_email: options.primaryEmail,\n password: options.password,\n otp_auth_enabled: options.otpAuthEnabled,\n primary_email_auth_enabled: options.primaryEmailAuthEnabled,\n display_name: options.displayName,\n primary_email_verified: options.primaryEmailVerified,\n client_metadata: options.clientMetadata,\n client_read_only_metadata: options.clientReadOnlyMetadata,\n server_metadata: options.serverMetadata,\n };\n}\n"],"mappings":";AAQA,SAAS,oBAAoB;AAsPtB,SAAS,wBAAwB,SAAiE;AACvG,SAAO;AAAA,IACL,cAAc,QAAQ;AAAA,IACtB,iBAAiB,QAAQ;AAAA,IACzB,kBAAkB,QAAQ;AAAA,IAC1B,oBAAoB,QAAQ,yBAAyB,OAAO,aAAa,QAAQ,qBAAqB,IAAI,QAAQ;AAAA,IAClH,mBAAmB,QAAQ;AAAA,IAC3B,kBAAkB,QAAQ;AAAA,IAC1B,sBAAsB,QAAQ;AAAA,EAChC;AACF;AAkEO,SAAS,8BAA8B,SAAuE;AACnH,SAAO;AAAA,IACL,cAAc,QAAQ;AAAA,IACtB,eAAe,QAAQ;AAAA,IACvB,iBAAiB,QAAQ;AAAA,IACzB,2BAA2B,QAAQ;AAAA,IACnC,iBAAiB,QAAQ;AAAA,IACzB,kBAAkB,QAAQ;AAAA,IAC1B,4BAA4B,QAAQ;AAAA,IACpC,wBAAwB,QAAQ;AAAA,IAChC,UAAU,QAAQ;AAAA,IAClB,mBAAmB,QAAQ;AAAA,IAC3B,oBAAoB,QAAQ,yBAAyB,OAAO,aAAa,QAAQ,qBAAqB,IAAI,QAAQ;AAAA,EACpH;AACF;AAcO,SAAS,8BAA8B,SAAiE;AAC7G,SAAO;AAAA,IACL,eAAe,QAAQ;AAAA,IACvB,UAAU,QAAQ;AAAA,IAClB,kBAAkB,QAAQ;AAAA,IAC1B,4BAA4B,QAAQ;AAAA,IACpC,cAAc,QAAQ;AAAA,IACtB,wBAAwB,QAAQ;AAAA,IAChC,iBAAiB,QAAQ;AAAA,IACzB,2BAA2B,QAAQ;AAAA,IACnC,iBAAiB,QAAQ;AAAA,EAC3B;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/lib/stack-app/users/index.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { KnownErrors } from \"@stackframe/stack-shared\";\nimport { CurrentUserCrud } from \"@stackframe/stack-shared/dist/interface/crud/current-user\";\nimport { UsersCrud } from \"@stackframe/stack-shared/dist/interface/crud/users\";\nimport { InternalSession } from \"@stackframe/stack-shared/dist/sessions\";\nimport { encodeBase64 } from \"@stackframe/stack-shared/dist/utils/bytes\";\nimport { GeoInfo } from \"@stackframe/stack-shared/dist/utils/geo\";\nimport { ReadonlyJson } from \"@stackframe/stack-shared/dist/utils/json\";\nimport { ProviderType } from \"@stackframe/stack-shared/dist/utils/oauth\";\nimport { Result } from \"@stackframe/stack-shared/dist/utils/results\";\nimport { ApiKeyCreationOptions, UserApiKey, UserApiKeyFirstView } from \"../api-keys\";\nimport { AsyncStoreProperty } from \"../common\";\nimport { OAuthConnection } from \"../connected-accounts\";\nimport { ContactChannel, ContactChannelCreateOptions, ServerContactChannel, ServerContactChannelCreateOptions } from \"../contact-channels\";\nimport { Customer } from \"../customers\";\nimport { NotificationCategory } from \"../notification-categories\";\nimport { AdminTeamPermission, TeamPermission } from \"../permissions\";\nimport { AdminOwnedProject, AdminProjectCreateOptions } from \"../projects\";\nimport { EditableTeamMemberProfile, ServerTeam, ServerTeamCreateOptions, Team, TeamCreateOptions } from \"../teams\";\n\nexport type OAuthProvider = {\n readonly id: string,\n readonly type: string,\n readonly userId: string,\n readonly accountId?: string,\n readonly email?: string,\n readonly allowSignIn: boolean,\n readonly allowConnectedAccounts: boolean,\n update(data: { allowSignIn?: boolean, allowConnectedAccounts?: boolean }): Promise<Result<void,\n InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>\n >>,\n delete(): Promise<void>,\n};\n\nexport type ServerOAuthProvider = {\n readonly id: string,\n readonly type: string,\n readonly userId: string,\n readonly accountId: string,\n readonly email?: string,\n readonly allowSignIn: boolean,\n readonly allowConnectedAccounts: boolean,\n update(data: { accountId?: string, email?: string, allowSignIn?: boolean, allowConnectedAccounts?: boolean }): Promise<Result<void,\n InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>\n >>,\n delete(): Promise<void>,\n};\n\n\nexport type Session = {\n getTokens(): Promise<{ accessToken: string | null, refreshToken: string | null }>,\n};\n\n/**\n * Contains everything related to the current user session.\n */\nexport type Auth = {\n readonly _internalSession: InternalSession,\n readonly currentSession: Session,\n signOut(options?: { redirectUrl?: URL | string }): Promise<void>,\n\n /**\n * Returns headers for sending authenticated HTTP requests to external servers. Most commonly used in cross-origin\n * requests. Similar to `getAuthJson`, but specifically for HTTP requests.\n *\n * If you are using `tokenStore: \"cookie\"`, you don't need this for same-origin requests. However, most\n * browsers now disable third-party cookies by default, so we must pass authentication tokens by header instead\n * if the client and server are on different origins.\n *\n * This function returns a header object that can be used with `fetch` or other HTTP request libraries to send\n * authenticated requests.\n *\n * On the server, you can then pass in the `Request` object to the `tokenStore` option\n * of your Stack app. Please note that CORS does not allow most headers by default, so you\n * must include `x-stack-auth` in the [`Access-Control-Allow-Headers` header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers)\n * of the CORS preflight response.\n *\n * If you are not using HTTP (and hence cannot set headers), you will need to use the `getAuthJson()` function\n * instead.\n *\n * Example:\n *\n * ```ts\n * // client\n * const res = await fetch(\"https://api.example.com\", {\n * headers: {\n * ...await stackApp.getAuthHeaders()\n * // you can also add your own headers here\n * },\n * });\n *\n * // server\n * function handleRequest(req: Request) {\n * const user = await stackServerApp.getUser({ tokenStore: req });\n * return new Response(\"Welcome, \" + user.displayName);\n * }\n * ```\n */\n getAuthHeaders(): Promise<{ \"x-stack-auth\": string }>,\n\n /**\n * Creates a JSON-serializable object containing the information to authenticate a user on an external server.\n * Similar to `getAuthHeaders`, but returns an object that can be sent over any protocol instead of just\n * HTTP headers.\n *\n * While `getAuthHeaders` is the recommended way to send authentication tokens over HTTP, your app may use\n * a different protocol, for example WebSockets or gRPC. This function returns a token object that can be JSON-serialized and sent to the server in any way you like.\n *\n * On the server, you can pass in this token object into the `tokenStore` option to fetch user details.\n *\n * Example:\n *\n * ```ts\n * // client\n * const res = await rpcCall(rpcEndpoint, {\n * data: {\n * auth: await stackApp.getAuthJson(),\n * },\n * });\n *\n * // server\n * function handleRequest(data) {\n * const user = await stackServerApp.getUser({ tokenStore: data.auth });\n * return new Response(\"Welcome, \" + user.displayName);\n * }\n * ```\n */\n getAuthJson(): Promise<{ accessToken: string | null, refreshToken: string | null }>,\n registerPasskey(options?: { hostname?: string }): Promise<Result<undefined, KnownErrors[\"PasskeyRegistrationFailed\"] | KnownErrors[\"PasskeyWebAuthnError\"]>>,\n};\n\n/**\n * ```\n * +----------+-------------+-------------------+\n * | \\ | !Server | Server |\n * +----------+-------------+-------------------+\n * | !Session | User | ServerUser |\n * | Session | CurrentUser | CurrentServerUser |\n * +----------+-------------+-------------------+\n * ```\n *\n * The fields on each of these types are available iff:\n * BaseUser: true\n * Auth: Session\n * ServerBaseUser: Server\n * UserExtra: Session OR Server\n *\n * The types are defined as follows (in the typescript manner):\n * User = BaseUser\n * CurrentUser = BaseUser & Auth & UserExtra\n * ServerUser = BaseUser & ServerBaseUser & UserExtra\n * CurrentServerUser = BaseUser & ServerBaseUser & Auth & UserExtra\n **/\n\nexport type BaseUser = {\n readonly id: string,\n\n readonly displayName: string | null,\n\n /**\n * The user's email address.\n *\n * Note: This might NOT be unique across multiple users, so always use `id` for unique identification.\n */\n readonly primaryEmail: string | null,\n readonly primaryEmailVerified: boolean,\n readonly profileImageUrl: string | null,\n\n readonly signedUpAt: Date,\n\n readonly clientMetadata: any,\n readonly clientReadOnlyMetadata: any,\n\n /**\n * Whether the user has a password set.\n */\n readonly hasPassword: boolean,\n readonly otpAuthEnabled: boolean,\n readonly passkeyAuthEnabled: boolean,\n\n readonly isMultiFactorRequired: boolean,\n readonly isAnonymous: boolean,\n toClientJson(): CurrentUserCrud[\"Client\"][\"Read\"],\n\n /**\n * @deprecated, use contact channel's usedForAuth instead\n */\n readonly emailAuthEnabled: boolean,\n /**\n * @deprecated\n */\n readonly oauthProviders: readonly { id: string }[],\n}\n\nexport type UserExtra = {\n setDisplayName(displayName: string): Promise<void>,\n /** @deprecated Use contact channel's sendVerificationEmail instead */\n sendVerificationEmail(): Promise<KnownErrors[\"EmailAlreadyVerified\"] | void>,\n setClientMetadata(metadata: any): Promise<void>,\n updatePassword(options: { oldPassword: string, newPassword: string}): Promise<KnownErrors[\"PasswordConfirmationMismatch\"] | KnownErrors[\"PasswordRequirementsNotMet\"] | void>,\n setPassword(options: { password: string }): Promise<KnownErrors[\"PasswordRequirementsNotMet\"] | void>,\n\n /**\n * A shorthand method to update multiple fields of the user at once.\n */\n update(update: UserUpdateOptions): Promise<void>,\n\n listContactChannels(): Promise<ContactChannel[]>,\n createContactChannel(data: ContactChannelCreateOptions): Promise<ContactChannel>,\n\n listNotificationCategories(): Promise<NotificationCategory[]>,\n\n delete(): Promise<void>,\n\n getConnectedAccount(id: ProviderType, options: { or: 'redirect', scopes?: string[] }): Promise<OAuthConnection>,\n getConnectedAccount(id: ProviderType, options?: { or?: 'redirect' | 'throw' | 'return-null', scopes?: string[] }): Promise<OAuthConnection | null>,\n\n\n hasPermission(scope: Team, permissionId: string): Promise<boolean>,\n hasPermission(permissionId: string): Promise<boolean>,\n\n getPermission(scope: Team, permissionId: string): Promise<TeamPermission | null>,\n getPermission(permissionId: string): Promise<TeamPermission | null>,\n\n listPermissions(scope: Team, options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n listPermissions(options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n\n\n readonly selectedTeam: Team | null,\n setSelectedTeam(team: Team | null): Promise<void>,\n createTeam(data: TeamCreateOptions): Promise<Team>,\n leaveTeam(team: Team): Promise<void>,\n\n getActiveSessions(): Promise<ActiveSession[]>,\n revokeSession(sessionId: string): Promise<void>,\n getTeamProfile(team: Team): Promise<EditableTeamMemberProfile>,\n\n createApiKey(options: ApiKeyCreationOptions<\"user\">): Promise<UserApiKeyFirstView>,\n\n listOAuthProviders(): Promise<OAuthProvider[]>,\n\n getOAuthProvider(id: string): Promise<OAuthProvider | null>,\n}\n& AsyncStoreProperty<\"apiKeys\", [], UserApiKey[], true>\n& AsyncStoreProperty<\"team\", [id: string], Team | null, false>\n& AsyncStoreProperty<\"teams\", [], Team[], true>\n& AsyncStoreProperty<\"permission\", [scope: Team, permissionId: string, options?: { recursive?: boolean }], TeamPermission | null, false>\n& AsyncStoreProperty<\"permissions\", [scope: Team, options?: { recursive?: boolean }], TeamPermission[], true>;\n\nexport type InternalUserExtra =\n & {\n createProject(newProject: AdminProjectCreateOptions): Promise<AdminOwnedProject>,\n }\n & AsyncStoreProperty<\"ownedProjects\", [], AdminOwnedProject[], true>\n\nexport type User = BaseUser;\n\nexport type CurrentUser = BaseUser & Auth & UserExtra & Customer;\n\nexport type CurrentInternalUser = CurrentUser & InternalUserExtra;\n\nexport type ProjectCurrentUser<ProjectId> = ProjectId extends \"internal\" ? CurrentInternalUser : CurrentUser;\n\nexport type TokenPartialUser = Pick<\n User,\n | \"id\"\n | \"displayName\"\n | \"primaryEmail\"\n | \"primaryEmailVerified\"\n | \"isAnonymous\"\n>\n\nexport type SyncedPartialUser = TokenPartialUser & Pick<\n User,\n | \"id\"\n | \"displayName\"\n | \"primaryEmail\"\n | \"primaryEmailVerified\"\n | \"profileImageUrl\"\n | \"signedUpAt\"\n | \"clientMetadata\"\n | \"clientReadOnlyMetadata\"\n | \"isAnonymous\"\n | \"hasPassword\"\n>;\n\n\nexport type ActiveSession = {\n id: string,\n userId: string,\n createdAt: Date,\n isImpersonation: boolean,\n lastUsedAt: Date | undefined,\n isCurrentSession: boolean,\n geoInfo?: GeoInfo,\n};\n\nexport type UserUpdateOptions = {\n displayName?: string,\n clientMetadata?: ReadonlyJson,\n selectedTeamId?: string | null,\n totpMultiFactorSecret?: Uint8Array | null,\n profileImageUrl?: string | null,\n otpAuthEnabled?: boolean,\n passkeyAuthEnabled?:boolean,\n}\nexport function userUpdateOptionsToCrud(options: UserUpdateOptions): CurrentUserCrud[\"Client\"][\"Update\"] {\n return {\n display_name: options.displayName,\n client_metadata: options.clientMetadata,\n selected_team_id: options.selectedTeamId,\n totp_secret_base64: options.totpMultiFactorSecret != null ? encodeBase64(options.totpMultiFactorSecret) : options.totpMultiFactorSecret,\n profile_image_url: options.profileImageUrl,\n otp_auth_enabled: options.otpAuthEnabled,\n passkey_auth_enabled: options.passkeyAuthEnabled,\n };\n}\n\n\nexport type ServerBaseUser = {\n setPrimaryEmail(email: string | null, options?: { verified?: boolean | undefined }): Promise<void>,\n\n readonly lastActiveAt: Date,\n\n readonly serverMetadata: any,\n setServerMetadata(metadata: any): Promise<void>,\n setClientReadOnlyMetadata(metadata: any): Promise<void>,\n\n createTeam(data: Omit<ServerTeamCreateOptions, \"creatorUserId\">): Promise<ServerTeam>,\n\n listContactChannels(): Promise<ServerContactChannel[]>,\n createContactChannel(data: ServerContactChannelCreateOptions): Promise<ServerContactChannel>,\n\n update(user: ServerUserUpdateOptions): Promise<void>,\n\n grantPermission(scope: Team, permissionId: string): Promise<void>,\n grantPermission(permissionId: string): Promise<void>,\n\n revokePermission(scope: Team, permissionId: string): Promise<void>,\n revokePermission(permissionId: string): Promise<void>,\n\n getPermission(scope: Team, permissionId: string): Promise<TeamPermission | null>,\n getPermission(permissionId: string): Promise<TeamPermission | null>,\n\n hasPermission(scope: Team, permissionId: string): Promise<boolean>,\n hasPermission(permissionId: string): Promise<boolean>,\n\n listPermissions(scope: Team, options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n listPermissions(options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n\n\n listOAuthProviders(): Promise<ServerOAuthProvider[]>,\n\n getOAuthProvider(id: string): Promise<ServerOAuthProvider | null>,\n\n /**\n * Creates a new session object with a refresh token for this user. Can be used to impersonate them.\n */\n createSession(options?: { expiresInMillis?: number, isImpersonation?: boolean }): Promise<Session>,\n}\n& AsyncStoreProperty<\"team\", [id: string], ServerTeam | null, false>\n& AsyncStoreProperty<\"teams\", [], ServerTeam[], true>\n& AsyncStoreProperty<\"permission\", [scope: Team, permissionId: string, options?: { direct?: boolean }], AdminTeamPermission | null, false>\n& AsyncStoreProperty<\"permissions\", [scope: Team, options?: { direct?: boolean }], AdminTeamPermission[], true>;\n\n/**\n * A user including sensitive fields that should only be used on the server, never sent to the client\n * (such as sensitive information and serverMetadata).\n */\nexport type ServerUser = ServerBaseUser & BaseUser & UserExtra & Customer<true>;\n\nexport type CurrentServerUser = Auth & ServerUser;\n\nexport type CurrentInternalServerUser = CurrentServerUser & InternalUserExtra;\n\nexport type ProjectCurrentServerUser<ProjectId> = ProjectId extends \"internal\" ? CurrentInternalServerUser : CurrentServerUser;\n\nexport type SyncedPartialServerUser = SyncedPartialUser & Pick<\n ServerUser,\n | \"serverMetadata\"\n>;\n\nexport type ServerUserUpdateOptions = {\n primaryEmail?: string | null,\n primaryEmailVerified?: boolean,\n primaryEmailAuthEnabled?: boolean,\n clientReadOnlyMetadata?: ReadonlyJson,\n serverMetadata?: ReadonlyJson,\n password?: string,\n} & UserUpdateOptions;\nexport function serverUserUpdateOptionsToCrud(options: ServerUserUpdateOptions): CurrentUserCrud[\"Server\"][\"Update\"] {\n return {\n display_name: options.displayName,\n primary_email: options.primaryEmail,\n client_metadata: options.clientMetadata,\n client_read_only_metadata: options.clientReadOnlyMetadata,\n server_metadata: options.serverMetadata,\n selected_team_id: options.selectedTeamId,\n primary_email_auth_enabled: options.primaryEmailAuthEnabled,\n primary_email_verified: options.primaryEmailVerified,\n password: options.password,\n profile_image_url: options.profileImageUrl,\n totp_secret_base64: options.totpMultiFactorSecret != null ? encodeBase64(options.totpMultiFactorSecret) : options.totpMultiFactorSecret,\n };\n}\n\n\nexport type ServerUserCreateOptions = {\n primaryEmail?: string | null,\n primaryEmailAuthEnabled?: boolean,\n password?: string,\n otpAuthEnabled?: boolean,\n displayName?: string,\n primaryEmailVerified?: boolean,\n clientMetadata?: any,\n clientReadOnlyMetadata?: any,\n serverMetadata?: any,\n}\nexport function serverUserCreateOptionsToCrud(options: ServerUserCreateOptions): UsersCrud[\"Server\"][\"Create\"] {\n return {\n primary_email: options.primaryEmail,\n password: options.password,\n otp_auth_enabled: options.otpAuthEnabled,\n primary_email_auth_enabled: options.primaryEmailAuthEnabled,\n display_name: options.displayName,\n primary_email_verified: options.primaryEmailVerified,\n client_metadata: options.clientMetadata,\n client_read_only_metadata: options.clientReadOnlyMetadata,\n server_metadata: options.serverMetadata,\n };\n}\n"],"mappings":";AAQA,SAAS,oBAAoB;AA6StB,SAAS,wBAAwB,SAAiE;AACvG,SAAO;AAAA,IACL,cAAc,QAAQ;AAAA,IACtB,iBAAiB,QAAQ;AAAA,IACzB,kBAAkB,QAAQ;AAAA,IAC1B,oBAAoB,QAAQ,yBAAyB,OAAO,aAAa,QAAQ,qBAAqB,IAAI,QAAQ;AAAA,IAClH,mBAAmB,QAAQ;AAAA,IAC3B,kBAAkB,QAAQ;AAAA,IAC1B,sBAAsB,QAAQ;AAAA,EAChC;AACF;AA0EO,SAAS,8BAA8B,SAAuE;AACnH,SAAO;AAAA,IACL,cAAc,QAAQ;AAAA,IACtB,eAAe,QAAQ;AAAA,IACvB,iBAAiB,QAAQ;AAAA,IACzB,2BAA2B,QAAQ;AAAA,IACnC,iBAAiB,QAAQ;AAAA,IACzB,kBAAkB,QAAQ;AAAA,IAC1B,4BAA4B,QAAQ;AAAA,IACpC,wBAAwB,QAAQ;AAAA,IAChC,UAAU,QAAQ;AAAA,IAClB,mBAAmB,QAAQ;AAAA,IAC3B,oBAAoB,QAAQ,yBAAyB,OAAO,aAAa,QAAQ,qBAAqB,IAAI,QAAQ;AAAA,EACpH;AACF;AAcO,SAAS,8BAA8B,SAAiE;AAC7G,SAAO;AAAA,IACL,eAAe,QAAQ;AAAA,IACvB,UAAU,QAAQ;AAAA,IAClB,kBAAkB,QAAQ;AAAA,IAC1B,4BAA4B,QAAQ;AAAA,IACpC,cAAc,QAAQ;AAAA,IACtB,wBAAwB,QAAQ;AAAA,IAChC,iBAAiB,QAAQ;AAAA,IACzB,2BAA2B,QAAQ;AAAA,IACnC,iBAAiB,QAAQ;AAAA,EAC3B;AACF;","names":[]}
package/dist/index.d.mts CHANGED
@@ -2,15 +2,17 @@ import { KnownErrors } from '@stackframe/stack-shared';
2
2
  import { CurrentUserCrud } from '@stackframe/stack-shared/dist/interface/crud/current-user';
3
3
  import { Result } from '@stackframe/stack-shared/dist/utils/results';
4
4
  import { ProviderType } from '@stackframe/stack-shared/dist/utils/oauth';
5
+ import { GenericQueryCtx, UserIdentity } from 'convex/server';
5
6
  import { inlineOfferSchema } from '@stackframe/stack-shared/dist/schema-fields';
6
7
  import * as yup from 'yup';
7
8
  import { ProductionModeError } from '@stackframe/stack-shared/dist/helpers/production-mode';
8
9
  import { CompleteConfig, EnvironmentConfigOverrideOverride } from '@stackframe/stack-shared/dist/config/schema';
9
10
  import { ChatContent } from '@stackframe/stack-shared/dist/interface/admin-interface';
11
+ import { AdminTransaction } from '@stackframe/stack-shared/dist/interface/crud/transactions';
10
12
  import { InternalSession } from '@stackframe/stack-shared/dist/sessions';
13
+ import { XOR, PrettifyType, IfAndOnlyIf } from '@stackframe/stack-shared/dist/utils/types';
11
14
  import { InternalApiKeysCrud } from '@stackframe/stack-shared/dist/interface/crud/internal-api-keys';
12
15
  import { ReadonlyJson } from '@stackframe/stack-shared/dist/utils/json';
13
- import { PrettifyType, IfAndOnlyIf } from '@stackframe/stack-shared/dist/utils/types';
14
16
  import { GeoInfo } from '@stackframe/stack-shared/dist/utils/geo';
15
17
 
16
18
  type RedirectToOptions = {
@@ -32,12 +34,28 @@ type RedirectMethod = "window" | "none" | {
32
34
  useNavigate: () => (to: string) => void;
33
35
  navigate?: (to: string) => void;
34
36
  };
35
- type GetUserOptions<HasTokenStore> = {
37
+ type GetCurrentUserOptions<HasTokenStore> = {
36
38
  or?: 'redirect' | 'throw' | 'return-null' | 'anonymous' | /** @deprecated */ 'anonymous-if-exists[deprecated]';
37
39
  tokenStore?: TokenStoreInit;
38
40
  } & (HasTokenStore extends false ? {
39
41
  tokenStore: TokenStoreInit;
40
42
  } : {});
43
+ type ConvexCtx = GenericQueryCtx<any> | {
44
+ auth: {
45
+ getUserIdentity: () => Promise<UserIdentity | null>;
46
+ };
47
+ };
48
+ type GetCurrentPartialUserOptions<HasTokenStore> = {
49
+ or?: 'return-null' | 'anonymous';
50
+ tokenStore?: TokenStoreInit;
51
+ } & ({
52
+ from: 'token';
53
+ } | {
54
+ from: 'convex';
55
+ ctx: ConvexCtx;
56
+ }) & (HasTokenStore extends false ? {
57
+ tokenStore: TokenStoreInit;
58
+ } : {});
41
59
  type RequestLike = {
42
60
  headers: {
43
61
  get: (name: string) => string | null;
@@ -118,17 +136,30 @@ type AdminSentEmail = {
118
136
  sentAt: Date;
119
137
  error?: unknown;
120
138
  };
121
- type SendEmailOptions = {
122
- userIds: string[];
139
+ type SendEmailOptionsBase = {
123
140
  themeId?: string | null | false;
124
141
  subject?: string;
125
142
  notificationCategoryName?: string;
126
- } & ({
127
- html: string;
128
- } | {
129
- templateId: string;
130
- variables?: Record<string, any>;
131
- });
143
+ };
144
+ type SendEmailOptions = SendEmailOptionsBase & XOR<[
145
+ {
146
+ userIds: string[];
147
+ },
148
+ {
149
+ allUsers: true;
150
+ }
151
+ ]> & XOR<[
152
+ {
153
+ html: string;
154
+ },
155
+ {
156
+ templateId: string;
157
+ variables?: Record<string, any>;
158
+ },
159
+ {
160
+ draftId: string;
161
+ }
162
+ ]>;
132
163
 
133
164
  type InternalApiKeyBase = {
134
165
  id: string;
@@ -298,6 +329,36 @@ type NotificationCategory = {
298
329
  setEnabled(enabled: boolean): Promise<void>;
299
330
  };
300
331
 
332
+ type OAuthProvider = {
333
+ readonly id: string;
334
+ readonly type: string;
335
+ readonly userId: string;
336
+ readonly accountId?: string;
337
+ readonly email?: string;
338
+ readonly allowSignIn: boolean;
339
+ readonly allowConnectedAccounts: boolean;
340
+ update(data: {
341
+ allowSignIn?: boolean;
342
+ allowConnectedAccounts?: boolean;
343
+ }): Promise<Result<void, InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>>>;
344
+ delete(): Promise<void>;
345
+ };
346
+ type ServerOAuthProvider = {
347
+ readonly id: string;
348
+ readonly type: string;
349
+ readonly userId: string;
350
+ readonly accountId: string;
351
+ readonly email?: string;
352
+ readonly allowSignIn: boolean;
353
+ readonly allowConnectedAccounts: boolean;
354
+ update(data: {
355
+ accountId?: string;
356
+ email?: string;
357
+ allowSignIn?: boolean;
358
+ allowConnectedAccounts?: boolean;
359
+ }): Promise<Result<void, InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>>>;
360
+ delete(): Promise<void>;
361
+ };
301
362
  type Session = {
302
363
  getTokens(): Promise<{
303
364
  accessToken: string | null;
@@ -490,6 +551,8 @@ type UserExtra = {
490
551
  revokeSession(sessionId: string): Promise<void>;
491
552
  getTeamProfile(team: Team): Promise<EditableTeamMemberProfile>;
492
553
  createApiKey(options: ApiKeyCreationOptions<"user">): Promise<UserApiKeyFirstView>;
554
+ listOAuthProviders(): Promise<OAuthProvider[]>;
555
+ getOAuthProvider(id: string): Promise<OAuthProvider | null>;
493
556
  } & AsyncStoreProperty<"apiKeys", [], UserApiKey[], true> & AsyncStoreProperty<"team", [id: string], Team | null, false> & AsyncStoreProperty<"teams", [], Team[], true> & AsyncStoreProperty<"permission", [scope: Team, permissionId: string, options?: {
494
557
  recursive?: boolean;
495
558
  }], TeamPermission | null, false> & AsyncStoreProperty<"permissions", [scope: Team, options?: {
@@ -502,6 +565,8 @@ type User = BaseUser;
502
565
  type CurrentUser = BaseUser & Auth & UserExtra & Customer;
503
566
  type CurrentInternalUser = CurrentUser & InternalUserExtra;
504
567
  type ProjectCurrentUser<ProjectId> = ProjectId extends "internal" ? CurrentInternalUser : CurrentUser;
568
+ type TokenPartialUser = Pick<User, "id" | "displayName" | "primaryEmail" | "primaryEmailVerified" | "isAnonymous">;
569
+ type SyncedPartialUser = TokenPartialUser & Pick<User, "id" | "displayName" | "primaryEmail" | "primaryEmailVerified" | "profileImageUrl" | "signedUpAt" | "clientMetadata" | "clientReadOnlyMetadata" | "isAnonymous" | "hasPassword">;
505
570
  type ActiveSession = {
506
571
  id: string;
507
572
  userId: string;
@@ -546,6 +611,8 @@ type ServerBaseUser = {
546
611
  listPermissions(options?: {
547
612
  recursive?: boolean;
548
613
  }): Promise<TeamPermission[]>;
614
+ listOAuthProviders(): Promise<ServerOAuthProvider[]>;
615
+ getOAuthProvider(id: string): Promise<ServerOAuthProvider | null>;
549
616
  /**
550
617
  * Creates a new session object with a refresh token for this user. Can be used to impersonate them.
551
618
  */
@@ -566,6 +633,7 @@ type ServerUser = ServerBaseUser & BaseUser & UserExtra & Customer<true>;
566
633
  type CurrentServerUser = Auth & ServerUser;
567
634
  type CurrentInternalServerUser = CurrentServerUser & InternalUserExtra;
568
635
  type ProjectCurrentServerUser<ProjectId> = ProjectId extends "internal" ? CurrentInternalServerUser : CurrentServerUser;
636
+ type SyncedPartialServerUser = SyncedPartialUser & Pick<ServerUser, "serverMetadata">;
569
637
  type ServerUserUpdateOptions = {
570
638
  primaryEmail?: string | null;
571
639
  primaryEmailVerified?: boolean;
@@ -679,20 +747,33 @@ type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends s
679
747
  */
680
748
  getServerUser(): Promise<ProjectCurrentServerUser<ProjectId> | null>;
681
749
  createUser(options: ServerUserCreateOptions): Promise<ServerUser>;
682
- getUser(options: GetUserOptions<HasTokenStore> & {
750
+ getUser(options: GetCurrentUserOptions<HasTokenStore> & {
683
751
  or: 'redirect';
684
752
  }): Promise<ProjectCurrentServerUser<ProjectId>>;
685
- getUser(options: GetUserOptions<HasTokenStore> & {
753
+ getUser(options: GetCurrentUserOptions<HasTokenStore> & {
686
754
  or: 'throw';
687
755
  }): Promise<ProjectCurrentServerUser<ProjectId>>;
688
- getUser(options: GetUserOptions<HasTokenStore> & {
756
+ getUser(options: GetCurrentUserOptions<HasTokenStore> & {
689
757
  or: 'anonymous';
690
758
  }): Promise<ProjectCurrentServerUser<ProjectId>>;
691
- getUser(options?: GetUserOptions<HasTokenStore>): Promise<ProjectCurrentServerUser<ProjectId> | null>;
759
+ getUser(options?: GetCurrentUserOptions<HasTokenStore>): Promise<ProjectCurrentServerUser<ProjectId> | null>;
692
760
  getUser(id: string): Promise<ServerUser | null>;
693
761
  getUser(options: {
694
762
  apiKey: string;
763
+ or?: "return-null" | "anonymous";
764
+ }): Promise<ServerUser | null>;
765
+ getUser(options: {
766
+ from: "convex";
767
+ ctx: GenericQueryCtx<any>;
768
+ or?: "return-null" | "anonymous";
695
769
  }): Promise<ServerUser | null>;
770
+ getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & {
771
+ from: 'token';
772
+ }): Promise<TokenPartialUser | null>;
773
+ getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & {
774
+ from: 'convex';
775
+ }): Promise<TokenPartialUser | null>;
776
+ getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore>): Promise<SyncedPartialServerUser | TokenPartialUser | null>;
696
777
  getTeam(id: string): Promise<ServerTeam | null>;
697
778
  getTeam(options: {
698
779
  apiKey: string;
@@ -700,7 +781,15 @@ type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends s
700
781
  listUsers(options?: ServerListUsersOptions): Promise<ServerUser[] & {
701
782
  nextCursor: string | null;
702
783
  }>;
703
- sendEmail(options: SendEmailOptions): Promise<Result<void, KnownErrors["RequiresCustomEmailServer"] | KnownErrors["SchemaError"] | KnownErrors["UserIdDoesNotExist"]>>;
784
+ createOAuthProvider(options: {
785
+ userId: string;
786
+ accountId: string;
787
+ providerConfigId: string;
788
+ email: string;
789
+ allowSignIn: boolean;
790
+ allowConnectedAccounts: boolean;
791
+ }): Promise<Result<ServerOAuthProvider, InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>>>;
792
+ sendEmail(options: SendEmailOptions): Promise<void>;
704
793
  } & AsyncStoreProperty<"user", [id: string], ServerUser | null, false> & Omit<AsyncStoreProperty<"users", [], ServerUser[], true>, "listUsers" | "useUsers"> & AsyncStoreProperty<"teams", [], ServerTeam[], true> & AsyncStoreProperty<"dataVaultStore", [id: string], DataVaultStore, false> & AsyncStoreProperty<"item", [
705
794
  {
706
795
  itemId: string;
@@ -737,17 +826,28 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
737
826
  displayName: string;
738
827
  themeId?: string;
739
828
  tsxSource: string;
829
+ }[], true> & AsyncStoreProperty<"emailDrafts", [], {
830
+ id: string;
831
+ displayName: string;
832
+ themeId: string | undefined | false;
833
+ tsxSource: string;
834
+ sentAt: Date | null;
740
835
  }[], true> & AsyncStoreProperty<"stripeAccountInfo", [], {
741
836
  account_id: string;
742
837
  charges_enabled: boolean;
743
838
  details_submitted: boolean;
744
839
  payouts_enabled: boolean;
745
- } | null, false> & {
746
- listEmailTemplates(): Promise<{
747
- id: string;
748
- displayName: string;
749
- tsxSource: string;
750
- }[]>;
840
+ } | null, false> & AsyncStoreProperty<"transactions", [
841
+ {
842
+ cursor?: string;
843
+ limit?: number;
844
+ type?: 'subscription' | 'one_time' | 'item_quantity_change';
845
+ customerType?: 'user' | 'team' | 'custom';
846
+ }
847
+ ], {
848
+ transactions: AdminTransaction[];
849
+ nextCursor: string | null;
850
+ }, true> & {
751
851
  createInternalApiKey(options: InternalApiKeyCreateOptions): Promise<InternalApiKeyFirstView>;
752
852
  createTeamPermissionDefinition(data: AdminTeamPermissionDefinitionCreateOptions): Promise<AdminTeamPermission>;
753
853
  updateTeamPermissionDefinition(permissionId: string, data: AdminTeamPermissionDefinitionUpdateOptions): Promise<void>;
@@ -767,7 +867,7 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
767
867
  id: string;
768
868
  }>;
769
869
  updateEmailTheme(id: string, tsxSource: string): Promise<void>;
770
- sendChatMessage(threadId: string, contextType: "email-theme" | "email-template", messages: Array<{
870
+ sendChatMessage(threadId: string, contextType: "email-theme" | "email-template" | "email-draft", messages: Array<{
771
871
  role: string;
772
872
  content: any;
773
873
  }>, abortSignal?: AbortSignal): Promise<{
@@ -789,6 +889,18 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
789
889
  createStripeWidgetAccountSession(): Promise<{
790
890
  client_secret: string;
791
891
  }>;
892
+ createEmailDraft(options: {
893
+ displayName: string;
894
+ themeId?: string | undefined | false;
895
+ tsxSource?: string;
896
+ }): Promise<{
897
+ id: string;
898
+ }>;
899
+ updateEmailDraft(id: string, data: {
900
+ displayName?: string;
901
+ themeId?: string | undefined | false;
902
+ tsxSource?: string;
903
+ }): Promise<void>;
792
904
  createItemQuantityChange(options: ({
793
905
  userId: string;
794
906
  itemId: string;
@@ -851,7 +963,7 @@ type AdminProjectConfig = {
851
963
  readonly allowTeamApiKeys: boolean;
852
964
  };
853
965
  type AdminEmailConfig = ({
854
- type: "standard";
966
+ type: "standard" | "resend";
855
967
  senderName: string;
856
968
  senderEmail: string;
857
969
  host: string;
@@ -976,7 +1088,9 @@ type StackClientAppConstructor = {
976
1088
  type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = ({
977
1089
  readonly projectId: ProjectId;
978
1090
  readonly urls: Readonly<HandlerUrls>;
979
- signInWithOAuth(provider: string): Promise<void>;
1091
+ signInWithOAuth(provider: string, options?: {
1092
+ returnTo?: string;
1093
+ }): Promise<void>;
980
1094
  signInWithCredential(options: {
981
1095
  email: string;
982
1096
  password: string;
@@ -1020,16 +1134,31 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
1020
1134
  noRedirect?: boolean;
1021
1135
  }): Promise<Result<undefined, KnownErrors["VerificationCodeError"] | KnownErrors["InvalidTotpCode"]>>;
1022
1136
  redirectToOAuthCallback(): Promise<void>;
1023
- getUser(options: GetUserOptions<HasTokenStore> & {
1137
+ getConvexClientAuth(options: {
1138
+ tokenStore: TokenStoreInit;
1139
+ }): (args: {
1140
+ forceRefreshToken: boolean;
1141
+ }) => Promise<string | null>;
1142
+ getConvexHttpClientAuth(options: {
1143
+ tokenStore: TokenStoreInit;
1144
+ }): Promise<string>;
1145
+ getUser(options: GetCurrentUserOptions<HasTokenStore> & {
1024
1146
  or: 'redirect';
1025
1147
  }): Promise<ProjectCurrentUser<ProjectId>>;
1026
- getUser(options: GetUserOptions<HasTokenStore> & {
1148
+ getUser(options: GetCurrentUserOptions<HasTokenStore> & {
1027
1149
  or: 'throw';
1028
1150
  }): Promise<ProjectCurrentUser<ProjectId>>;
1029
- getUser(options: GetUserOptions<HasTokenStore> & {
1151
+ getUser(options: GetCurrentUserOptions<HasTokenStore> & {
1030
1152
  or: 'anonymous';
1031
1153
  }): Promise<ProjectCurrentUser<ProjectId>>;
1032
- getUser(options?: GetUserOptions<HasTokenStore>): Promise<ProjectCurrentUser<ProjectId> | null>;
1154
+ getUser(options?: GetCurrentUserOptions<HasTokenStore>): Promise<ProjectCurrentUser<ProjectId> | null>;
1155
+ getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & {
1156
+ from: 'token';
1157
+ }): Promise<TokenPartialUser | null>;
1158
+ getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & {
1159
+ from: 'convex';
1160
+ }): Promise<TokenPartialUser | null>;
1161
+ getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore>): Promise<SyncedPartialUser | TokenPartialUser | null>;
1033
1162
  [stackAppInternalsSymbol]: {
1034
1163
  toClientJson(): StackClientAppJson<HasTokenStore, ProjectId>;
1035
1164
  setCurrentUser(userJsonPromise: Promise<CurrentUserCrud['Client']['Read'] | null>): void;
@@ -1050,4 +1179,13 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
1050
1179
  });
1051
1180
  declare const StackClientApp: StackClientAppConstructor;
1052
1181
 
1053
- export { type AdminDomainConfig, type AdminEmailConfig, type AdminOAuthProviderConfig, type AdminOwnedProject, type AdminProject, type AdminProjectConfig, type AdminProjectConfigUpdateOptions, type AdminProjectCreateOptions, type AdminProjectPermission, type AdminProjectPermissionDefinition, type AdminProjectPermissionDefinitionCreateOptions, type AdminProjectPermissionDefinitionUpdateOptions, type AdminProjectUpdateOptions, type AdminSentEmail, type AdminTeamPermission, type AdminTeamPermissionDefinition, type AdminTeamPermissionDefinitionCreateOptions, type AdminTeamPermissionDefinitionUpdateOptions, type Auth, type Connection, type ContactChannel, type CurrentInternalServerUser, type CurrentInternalUser, type CurrentServerUser, type CurrentUser, type EditableTeamMemberProfile, type GetUserOptions, type HandlerUrls, type InternalApiKey, type InternalApiKeyBase, type InternalApiKeyBaseCrudRead, type InternalApiKeyCreateOptions, type InternalApiKeyFirstView, type OAuthConnection, type OAuthProviderConfig, type OAuthScopesOnSignIn, type Project, type ProjectConfig, type ServerContactChannel, type ServerListUsersOptions, type ServerTeam, type ServerTeamCreateOptions, type ServerTeamMemberProfile, type ServerTeamUpdateOptions, type ServerTeamUser, type ServerUser, type Session, StackAdminApp, type StackAdminAppConstructor, type StackAdminAppConstructorOptions, StackClientApp, type StackClientAppConstructor, type StackClientAppConstructorOptions, type StackClientAppJson, StackServerApp, type StackServerAppConstructor, type StackServerAppConstructorOptions, type Team, type TeamCreateOptions, type TeamInvitation, type TeamMemberProfile, type TeamUpdateOptions, type TeamUser, type User, stackAppInternalsSymbol };
1182
+ declare function getConvexProvidersConfig(options: {
1183
+ projectId?: string;
1184
+ }): {
1185
+ type: string;
1186
+ issuer: string;
1187
+ jwks: string;
1188
+ algorithm: string;
1189
+ }[];
1190
+
1191
+ export { type AdminDomainConfig, type AdminEmailConfig, type AdminOAuthProviderConfig, type AdminOwnedProject, type AdminProject, type AdminProjectConfig, type AdminProjectConfigUpdateOptions, type AdminProjectCreateOptions, type AdminProjectPermission, type AdminProjectPermissionDefinition, type AdminProjectPermissionDefinitionCreateOptions, type AdminProjectPermissionDefinitionUpdateOptions, type AdminProjectUpdateOptions, type AdminSentEmail, type AdminTeamPermission, type AdminTeamPermissionDefinition, type AdminTeamPermissionDefinitionCreateOptions, type AdminTeamPermissionDefinitionUpdateOptions, type Auth, type Connection, type ContactChannel, type CurrentInternalServerUser, type CurrentInternalUser, type CurrentServerUser, type CurrentUser, type EditableTeamMemberProfile, type GetCurrentUserOptions, type GetCurrentUserOptions as GetUserOptions, type HandlerUrls, type InternalApiKey, type InternalApiKeyBase, type InternalApiKeyBaseCrudRead, type InternalApiKeyCreateOptions, type InternalApiKeyFirstView, type OAuthConnection, type OAuthProvider, type OAuthProviderConfig, type OAuthScopesOnSignIn, type Project, type ProjectConfig, type ServerContactChannel, type ServerListUsersOptions, type ServerOAuthProvider, type ServerTeam, type ServerTeamCreateOptions, type ServerTeamMemberProfile, type ServerTeamUpdateOptions, type ServerTeamUser, type ServerUser, type Session, StackAdminApp, type StackAdminAppConstructor, type StackAdminAppConstructorOptions, StackClientApp, type StackClientAppConstructor, type StackClientAppConstructorOptions, type StackClientAppJson, StackServerApp, type StackServerAppConstructor, type StackServerAppConstructorOptions, type Team, type TeamCreateOptions, type TeamInvitation, type TeamMemberProfile, type TeamUpdateOptions, type TeamUser, type User, getConvexProvidersConfig, stackAppInternalsSymbol };