@stackframe/stack 2.8.35 → 2.8.39

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 (44) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/components/user-button.js +2 -2
  3. package/dist/components/user-button.js.map +1 -1
  4. package/dist/esm/components/user-button.js +2 -2
  5. package/dist/esm/components/user-button.js.map +1 -1
  6. package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js +59 -6
  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 +58 -2
  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 +107 -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/data-vault/index.js +1 -0
  18. package/dist/esm/lib/stack-app/data-vault/index.js.map +1 -0
  19. package/dist/esm/lib/stack-app/index.js.map +1 -1
  20. package/dist/esm/lib/stack-app/users/index.js.map +1 -1
  21. package/dist/esm/providers/theme-provider.js +2 -1
  22. package/dist/esm/providers/theme-provider.js.map +1 -1
  23. package/dist/index.d.mts +115 -26
  24. package/dist/index.d.ts +115 -26
  25. package/dist/lib/stack-app/apps/implementations/admin-app-impl.js +58 -5
  26. package/dist/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
  27. package/dist/lib/stack-app/apps/implementations/client-app-impl.js +58 -2
  28. package/dist/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
  29. package/dist/lib/stack-app/apps/implementations/common.js +7 -7
  30. package/dist/lib/stack-app/apps/implementations/common.js.map +1 -1
  31. package/dist/lib/stack-app/apps/implementations/server-app-impl.js +106 -3
  32. package/dist/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
  33. package/dist/lib/stack-app/apps/interfaces/admin-app.js.map +1 -1
  34. package/dist/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
  35. package/dist/lib/stack-app/apps/interfaces/server-app.js.map +1 -1
  36. package/dist/lib/stack-app/data-vault/index.js +19 -0
  37. package/dist/lib/stack-app/data-vault/index.js.map +1 -0
  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/dist/providers/theme-provider.js +2 -1
  43. package/dist/providers/theme-provider.js.map +1 -1
  44. package/package.json +4 -4
@@ -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 useContactChannels(): ContactChannel[], // THIS_LINE_PLATFORM react-like\n listContactChannels(): Promise<ContactChannel[]>,\n createContactChannel(data: ContactChannelCreateOptions): Promise<ContactChannel>,\n\n useNotificationCategories(): NotificationCategory[], // THIS_LINE_PLATFORM react-like\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 useConnectedAccount(id: ProviderType, options: { or: 'redirect', scopes?: string[] }): OAuthConnection,\n useConnectedAccount(id: ProviderType, options?: { or?: 'redirect' | 'throw' | 'return-null', scopes?: string[] }): OAuthConnection | null,\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 usePermissions(scope: Team, options?: { recursive?: boolean }): TeamPermission[],\n usePermissions(options?: { recursive?: boolean }): TeamPermission[],\n\n usePermission(scope: Team, permissionId: string): TeamPermission | null,\n usePermission(permissionId: string): TeamPermission | null,\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 useTeamProfile(team: Team): EditableTeamMemberProfile, // THIS_LINE_PLATFORM react-like\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 useContactChannels(): ServerContactChannel[], // THIS_LINE_PLATFORM react-like\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 usePermissions(scope: Team, options?: { recursive?: boolean }): TeamPermission[],\n usePermissions(options?: { recursive?: boolean }): TeamPermission[],\n\n usePermission(scope: Team, permissionId: string): TeamPermission | null,\n usePermission(permissionId: string): TeamPermission | 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\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;AAgQtB,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;AAwEO,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 useContactChannels(): ContactChannel[], // THIS_LINE_PLATFORM react-like\n listContactChannels(): Promise<ContactChannel[]>,\n createContactChannel(data: ContactChannelCreateOptions): Promise<ContactChannel>,\n\n useNotificationCategories(): NotificationCategory[], // THIS_LINE_PLATFORM react-like\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 useConnectedAccount(id: ProviderType, options: { or: 'redirect', scopes?: string[] }): OAuthConnection,\n useConnectedAccount(id: ProviderType, options?: { or?: 'redirect' | 'throw' | 'return-null', scopes?: string[] }): OAuthConnection | null,\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 usePermissions(scope: Team, options?: { recursive?: boolean }): TeamPermission[],\n usePermissions(options?: { recursive?: boolean }): TeamPermission[],\n\n usePermission(scope: Team, permissionId: string): TeamPermission | null,\n usePermission(permissionId: string): TeamPermission | null,\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 useTeamProfile(team: Team): EditableTeamMemberProfile, // THIS_LINE_PLATFORM react-like\n\n createApiKey(options: ApiKeyCreationOptions<\"user\">): Promise<UserApiKeyFirstView>,\n\n useOAuthProviders(): OAuthProvider[], // THIS_LINE_PLATFORM react-like\n listOAuthProviders(): Promise<OAuthProvider[]>,\n\n useOAuthProvider(id: string): OAuthProvider | null, // THIS_LINE_PLATFORM react-like\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\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 useContactChannels(): ServerContactChannel[], // THIS_LINE_PLATFORM react-like\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 usePermissions(scope: Team, options?: { recursive?: boolean }): TeamPermission[],\n usePermissions(options?: { recursive?: boolean }): TeamPermission[],\n\n usePermission(scope: Team, permissionId: string): TeamPermission | null,\n usePermission(permissionId: string): TeamPermission | null,\n\n useOAuthProviders(): ServerOAuthProvider[], // THIS_LINE_PLATFORM react-like\n listOAuthProviders(): Promise<ServerOAuthProvider[]>,\n\n useOAuthProvider(id: string): ServerOAuthProvider | null, // THIS_LINE_PLATFORM react-like\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\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;AAkStB,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;AA8EO,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":[]}
@@ -3,6 +3,7 @@
3
3
 
4
4
  // src/providers/theme-provider.tsx
5
5
  import { deindent } from "@stackframe/stack-shared/dist/utils/strings";
6
+ import { TooltipProvider } from "@stackframe/stack-ui";
6
7
  import Color from "color";
7
8
  import { globalCSS } from "../generated/global-css.js";
8
9
  import { BrowserScript } from "../utils/browser-script.js";
@@ -63,7 +64,7 @@ function StackTheme({
63
64
  }
64
65
  }
65
66
  ),
66
- children
67
+ /* @__PURE__ */ jsx(TooltipProvider, { children })
67
68
  ] });
68
69
  }
69
70
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/providers/theme-provider.tsx"],"sourcesContent":["'use client';\n\n\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\n\nimport { deindent } from \"@stackframe/stack-shared/dist/utils/strings\";\nimport Color from \"color\";\nimport React from \"react\";\nimport { globalCSS } from \"../generated/global-css\";\nimport { BrowserScript } from \"../utils/browser-script\";\nimport { DEFAULT_THEME } from \"../utils/constants\";\n\ntype Colors = {\n background: string,\n foreground: string,\n card: string,\n cardForeground: string,\n popover: string,\n popoverForeground: string,\n primary: string,\n primaryForeground: string,\n secondary: string,\n secondaryForeground: string,\n muted: string,\n mutedForeground: string,\n accent: string,\n accentForeground: string,\n destructive: string,\n destructiveForeground: string,\n border: string,\n input: string,\n ring: string,\n}\n\nexport type Theme = {\n light: Colors,\n dark: Colors,\n radius: string,\n};\n\ntype ThemeConfig = {\n light?: Partial<Colors>,\n dark?: Partial<Colors>,\n} & Partial<Omit<Theme, 'light' | 'dark'>>;\n\nfunction convertColorToCSSVars(obj: Record<string, string>) {\n return Object.fromEntries(Object.entries(obj).map(([key, value]) => {\n const color = Color(value).hsl().array();\n return [\n // Convert camelCase key to dash-case\n key.replace(/[A-Z]/g, m => `-${m.toLowerCase()}`),\n // Convert color to CSS HSL string\n `${color[0]} ${color[1]}% ${color[2]}%`\n ];\n }));\n}\n\nfunction convertColorsToCSS(theme: Theme) {\n const { dark, light, ...rest } = theme;\n const colors = {\n light: { ...convertColorToCSSVars(light), ...rest },\n dark: convertColorToCSSVars(dark),\n };\n\n function colorsToCSSVars(colors: Record<string, string>) {\n return Object.entries(colors).map((params) => {\n return `--${params[0]}: ${params[1]};\\n`;\n }).join('');\n }\n\n return deindent`\n .stack-scope {\n ${colorsToCSSVars(colors.light)}\n }\n html:has(head > [data-stack-theme=\"dark\"]) .stack-scope { \n ${colorsToCSSVars(colors.dark)}\n }\n `;\n}\n\n\nexport function StackTheme({\n theme,\n children,\n nonce,\n} : {\n theme?: ThemeConfig,\n children?: React.ReactNode,\n nonce?: string,\n}) {\n const themeValue: Theme = {\n ...DEFAULT_THEME,\n ...theme,\n dark: { ...DEFAULT_THEME.dark, ...theme?.dark },\n light: { ...DEFAULT_THEME.light, ...theme?.light },\n };\n\n return (\n <>\n <BrowserScript nonce={nonce} />\n <style\n suppressHydrationWarning // we need this since the nonce can differ between client and server\n nonce={nonce}\n dangerouslySetInnerHTML={{\n __html: globalCSS + \"\\n\" + convertColorsToCSS(themeValue),\n }}\n />\n {children}\n </>\n );\n}\n"],"mappings":";;;AAOA,SAAS,gBAAgB;AACzB,OAAO,WAAW;AAElB,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAwF1B,mBACE,KADF;AArDJ,SAAS,sBAAsB,KAA6B;AAC1D,SAAO,OAAO,YAAY,OAAO,QAAQ,GAAG,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM;AAClE,UAAM,QAAQ,MAAM,KAAK,EAAE,IAAI,EAAE,MAAM;AACvC,WAAO;AAAA;AAAA,MAEL,IAAI,QAAQ,UAAU,OAAK,IAAI,EAAE,YAAY,CAAC,EAAE;AAAA;AAAA,MAEhD,GAAG,MAAM,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC;AAAA,IACtC;AAAA,EACF,CAAC,CAAC;AACJ;AAEA,SAAS,mBAAmB,OAAc;AACxC,QAAM,EAAE,MAAM,OAAO,GAAG,KAAK,IAAI;AACjC,QAAM,SAAS;AAAA,IACb,OAAO,EAAE,GAAG,sBAAsB,KAAK,GAAG,GAAG,KAAK;AAAA,IAClD,MAAM,sBAAsB,IAAI;AAAA,EAClC;AAEA,WAAS,gBAAgBA,SAAgC;AACvD,WAAO,OAAO,QAAQA,OAAM,EAAE,IAAI,CAAC,WAAW;AAC5C,aAAO,KAAK,OAAO,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC;AAAA;AAAA,IACrC,CAAC,EAAE,KAAK,EAAE;AAAA,EACZ;AAEA,SAAO;AAAA;AAAA,QAED,gBAAgB,OAAO,KAAK,CAAC;AAAA;AAAA;AAAA,QAG7B,gBAAgB,OAAO,IAAI,CAAC;AAAA;AAAA;AAGpC;AAGO,SAAS,WAAW;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,QAAM,aAAoB;AAAA,IACxB,GAAG;AAAA,IACH,GAAG;AAAA,IACH,MAAM,EAAE,GAAG,cAAc,MAAM,GAAG,OAAO,KAAK;AAAA,IAC9C,OAAO,EAAE,GAAG,cAAc,OAAO,GAAG,OAAO,MAAM;AAAA,EACnD;AAEA,SACE,iCACE;AAAA,wBAAC,iBAAc,OAAc;AAAA,IAC7B;AAAA,MAAC;AAAA;AAAA,QACC,0BAAwB;AAAA,QACxB;AAAA,QACA,yBAAyB;AAAA,UACvB,QAAQ,YAAY,OAAO,mBAAmB,UAAU;AAAA,QAC1D;AAAA;AAAA,IACF;AAAA,IACC;AAAA,KACH;AAEJ;","names":["colors"]}
1
+ {"version":3,"sources":["../../../src/providers/theme-provider.tsx"],"sourcesContent":["'use client';\n\n\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\n\nimport { deindent } from \"@stackframe/stack-shared/dist/utils/strings\";\nimport { TooltipProvider } from \"@stackframe/stack-ui\";\nimport Color from \"color\";\nimport React from \"react\";\nimport { globalCSS } from \"../generated/global-css\";\nimport { BrowserScript } from \"../utils/browser-script\";\nimport { DEFAULT_THEME } from \"../utils/constants\";\n\ntype Colors = {\n background: string,\n foreground: string,\n card: string,\n cardForeground: string,\n popover: string,\n popoverForeground: string,\n primary: string,\n primaryForeground: string,\n secondary: string,\n secondaryForeground: string,\n muted: string,\n mutedForeground: string,\n accent: string,\n accentForeground: string,\n destructive: string,\n destructiveForeground: string,\n border: string,\n input: string,\n ring: string,\n}\n\nexport type Theme = {\n light: Colors,\n dark: Colors,\n radius: string,\n};\n\ntype ThemeConfig = {\n light?: Partial<Colors>,\n dark?: Partial<Colors>,\n} & Partial<Omit<Theme, 'light' | 'dark'>>;\n\nfunction convertColorToCSSVars(obj: Record<string, string>) {\n return Object.fromEntries(Object.entries(obj).map(([key, value]) => {\n const color = Color(value).hsl().array();\n return [\n // Convert camelCase key to dash-case\n key.replace(/[A-Z]/g, m => `-${m.toLowerCase()}`),\n // Convert color to CSS HSL string\n `${color[0]} ${color[1]}% ${color[2]}%`\n ];\n }));\n}\n\nfunction convertColorsToCSS(theme: Theme) {\n const { dark, light, ...rest } = theme;\n const colors = {\n light: { ...convertColorToCSSVars(light), ...rest },\n dark: convertColorToCSSVars(dark),\n };\n\n function colorsToCSSVars(colors: Record<string, string>) {\n return Object.entries(colors).map((params) => {\n return `--${params[0]}: ${params[1]};\\n`;\n }).join('');\n }\n\n return deindent`\n .stack-scope {\n ${colorsToCSSVars(colors.light)}\n }\n html:has(head > [data-stack-theme=\"dark\"]) .stack-scope { \n ${colorsToCSSVars(colors.dark)}\n }\n `;\n}\n\n\nexport function StackTheme({\n theme,\n children,\n nonce,\n} : {\n theme?: ThemeConfig,\n children?: React.ReactNode,\n nonce?: string,\n}) {\n const themeValue: Theme = {\n ...DEFAULT_THEME,\n ...theme,\n dark: { ...DEFAULT_THEME.dark, ...theme?.dark },\n light: { ...DEFAULT_THEME.light, ...theme?.light },\n };\n\n return (\n <>\n <BrowserScript nonce={nonce} />\n <style\n suppressHydrationWarning // we need this since the nonce can differ between client and server\n nonce={nonce}\n dangerouslySetInnerHTML={{\n __html: globalCSS + \"\\n\" + convertColorsToCSS(themeValue),\n }}\n />\n <TooltipProvider>\n {children}\n </TooltipProvider>\n </>\n );\n}\n"],"mappings":";;;AAOA,SAAS,gBAAgB;AACzB,SAAS,uBAAuB;AAChC,OAAO,WAAW;AAElB,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAwF1B,mBACE,KADF;AArDJ,SAAS,sBAAsB,KAA6B;AAC1D,SAAO,OAAO,YAAY,OAAO,QAAQ,GAAG,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM;AAClE,UAAM,QAAQ,MAAM,KAAK,EAAE,IAAI,EAAE,MAAM;AACvC,WAAO;AAAA;AAAA,MAEL,IAAI,QAAQ,UAAU,OAAK,IAAI,EAAE,YAAY,CAAC,EAAE;AAAA;AAAA,MAEhD,GAAG,MAAM,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC;AAAA,IACtC;AAAA,EACF,CAAC,CAAC;AACJ;AAEA,SAAS,mBAAmB,OAAc;AACxC,QAAM,EAAE,MAAM,OAAO,GAAG,KAAK,IAAI;AACjC,QAAM,SAAS;AAAA,IACb,OAAO,EAAE,GAAG,sBAAsB,KAAK,GAAG,GAAG,KAAK;AAAA,IAClD,MAAM,sBAAsB,IAAI;AAAA,EAClC;AAEA,WAAS,gBAAgBA,SAAgC;AACvD,WAAO,OAAO,QAAQA,OAAM,EAAE,IAAI,CAAC,WAAW;AAC5C,aAAO,KAAK,OAAO,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC;AAAA;AAAA,IACrC,CAAC,EAAE,KAAK,EAAE;AAAA,EACZ;AAEA,SAAO;AAAA;AAAA,QAED,gBAAgB,OAAO,KAAK,CAAC;AAAA;AAAA;AAAA,QAG7B,gBAAgB,OAAO,IAAI,CAAC;AAAA;AAAA;AAGpC;AAGO,SAAS,WAAW;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,QAAM,aAAoB;AAAA,IACxB,GAAG;AAAA,IACH,GAAG;AAAA,IACH,MAAM,EAAE,GAAG,cAAc,MAAM,GAAG,OAAO,KAAK;AAAA,IAC9C,OAAO,EAAE,GAAG,cAAc,OAAO,GAAG,OAAO,MAAM;AAAA,EACnD;AAEA,SACE,iCACE;AAAA,wBAAC,iBAAc,OAAc;AAAA,IAC7B;AAAA,MAAC;AAAA;AAAA,QACC,0BAAwB;AAAA,QACxB;AAAA,QACA,yBAAyB;AAAA,UACvB,QAAQ,YAAY,OAAO,mBAAmB,UAAU;AAAA,QAC1D;AAAA;AAAA,IACF;AAAA,IACA,oBAAC,mBACE,UACH;AAAA,KACF;AAEJ;","names":["colors"]}
package/dist/index.d.mts CHANGED
@@ -7,10 +7,11 @@ import * as yup from 'yup';
7
7
  import { ProductionModeError } from '@stackframe/stack-shared/dist/helpers/production-mode';
8
8
  import { CompleteConfig, EnvironmentConfigOverrideOverride } from '@stackframe/stack-shared/dist/config/schema';
9
9
  import { ChatContent } from '@stackframe/stack-shared/dist/interface/admin-interface';
10
+ import { AdminTransaction } from '@stackframe/stack-shared/dist/interface/crud/transactions';
10
11
  import { InternalSession } from '@stackframe/stack-shared/dist/sessions';
12
+ import { XOR, PrettifyType, IfAndOnlyIf } from '@stackframe/stack-shared/dist/utils/types';
11
13
  import { InternalApiKeysCrud } from '@stackframe/stack-shared/dist/interface/crud/internal-api-keys';
12
14
  import { ReadonlyJson } from '@stackframe/stack-shared/dist/utils/json';
13
- import { PrettifyType, IfAndOnlyIf } from '@stackframe/stack-shared/dist/utils/types';
14
15
  import { GeoInfo } from '@stackframe/stack-shared/dist/utils/geo';
15
16
  import * as react_jsx_runtime from 'react/jsx-runtime';
16
17
  import * as lucide_react from 'lucide-react';
@@ -123,17 +124,30 @@ type AdminSentEmail = {
123
124
  sentAt: Date;
124
125
  error?: unknown;
125
126
  };
126
- type SendEmailOptions = {
127
- userIds: string[];
127
+ type SendEmailOptionsBase = {
128
128
  themeId?: string | null | false;
129
129
  subject?: string;
130
130
  notificationCategoryName?: string;
131
- } & ({
132
- html: string;
133
- } | {
134
- templateId: string;
135
- variables?: Record<string, any>;
136
- });
131
+ };
132
+ type SendEmailOptions = SendEmailOptionsBase & XOR<[
133
+ {
134
+ userIds: string[];
135
+ },
136
+ {
137
+ allUsers: true;
138
+ }
139
+ ]> & XOR<[
140
+ {
141
+ html: string;
142
+ },
143
+ {
144
+ templateId: string;
145
+ variables?: Record<string, any>;
146
+ },
147
+ {
148
+ draftId: string;
149
+ }
150
+ ]>;
137
151
 
138
152
  type InternalApiKeyBase = {
139
153
  id: string;
@@ -203,6 +217,15 @@ type AdminProjectPermissionDefinitionCreateOptions = {
203
217
  };
204
218
  type AdminProjectPermissionDefinitionUpdateOptions = Pick<Partial<AdminProjectPermissionDefinitionCreateOptions>, "description" | "containedPermissionIds">;
205
219
 
220
+ type DataVaultStore = {
221
+ id: string;
222
+ setValue: (key: string, value: string, options: {
223
+ secret: string;
224
+ }) => Promise<void>;
225
+ } & AsyncStoreProperty<"value", [key: string, options: {
226
+ secret: string;
227
+ }], string | null, false>;
228
+
206
229
  type ApiKeyType = "user" | "team";
207
230
  type ApiKey<Type extends ApiKeyType = ApiKeyType, IsFirstView extends boolean = false> = {
208
231
  id: string;
@@ -297,6 +320,36 @@ type NotificationCategory = {
297
320
  setEnabled(enabled: boolean): Promise<void>;
298
321
  };
299
322
 
323
+ type OAuthProvider = {
324
+ readonly id: string;
325
+ readonly type: string;
326
+ readonly userId: string;
327
+ readonly accountId?: string;
328
+ readonly email?: string;
329
+ readonly allowSignIn: boolean;
330
+ readonly allowConnectedAccounts: boolean;
331
+ update(data: {
332
+ allowSignIn?: boolean;
333
+ allowConnectedAccounts?: boolean;
334
+ }): Promise<Result<void, InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>>>;
335
+ delete(): Promise<void>;
336
+ };
337
+ type ServerOAuthProvider = {
338
+ readonly id: string;
339
+ readonly type: string;
340
+ readonly userId: string;
341
+ readonly accountId: string;
342
+ readonly email?: string;
343
+ readonly allowSignIn: boolean;
344
+ readonly allowConnectedAccounts: boolean;
345
+ update(data: {
346
+ accountId?: string;
347
+ email?: string;
348
+ allowSignIn?: boolean;
349
+ allowConnectedAccounts?: boolean;
350
+ }): Promise<Result<void, InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>>>;
351
+ delete(): Promise<void>;
352
+ };
300
353
  type Session = {
301
354
  getTokens(): Promise<{
302
355
  accessToken: string | null;
@@ -508,6 +561,10 @@ type UserExtra = {
508
561
  getTeamProfile(team: Team): Promise<EditableTeamMemberProfile>;
509
562
  useTeamProfile(team: Team): EditableTeamMemberProfile;
510
563
  createApiKey(options: ApiKeyCreationOptions<"user">): Promise<UserApiKeyFirstView>;
564
+ useOAuthProviders(): OAuthProvider[];
565
+ listOAuthProviders(): Promise<OAuthProvider[]>;
566
+ useOAuthProvider(id: string): OAuthProvider | null;
567
+ getOAuthProvider(id: string): Promise<OAuthProvider | null>;
511
568
  } & AsyncStoreProperty<"apiKeys", [], UserApiKey[], true> & AsyncStoreProperty<"team", [id: string], Team | null, false> & AsyncStoreProperty<"teams", [], Team[], true> & AsyncStoreProperty<"permission", [scope: Team, permissionId: string, options?: {
512
569
  recursive?: boolean;
513
570
  }], TeamPermission | null, false> & AsyncStoreProperty<"permissions", [scope: Team, options?: {
@@ -573,6 +630,10 @@ type ServerBaseUser = {
573
630
  }): TeamPermission[];
574
631
  usePermission(scope: Team, permissionId: string): TeamPermission | null;
575
632
  usePermission(permissionId: string): TeamPermission | null;
633
+ useOAuthProviders(): ServerOAuthProvider[];
634
+ listOAuthProviders(): Promise<ServerOAuthProvider[]>;
635
+ useOAuthProvider(id: string): ServerOAuthProvider | null;
636
+ getOAuthProvider(id: string): Promise<ServerOAuthProvider | null>;
576
637
  /**
577
638
  * Creates a new session object with a refresh token for this user. Can be used to impersonate them.
578
639
  */
@@ -751,8 +812,16 @@ type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends s
751
812
  listUsers(options?: ServerListUsersOptions): Promise<ServerUser[] & {
752
813
  nextCursor: string | null;
753
814
  }>;
754
- sendEmail(options: SendEmailOptions): Promise<Result<void, KnownErrors["RequiresCustomEmailServer"] | KnownErrors["SchemaError"] | KnownErrors["UserIdDoesNotExist"]>>;
755
- } & AsyncStoreProperty<"user", [id: string], ServerUser | null, false> & Omit<AsyncStoreProperty<"users", [], ServerUser[], true>, "listUsers" | "useUsers"> & AsyncStoreProperty<"teams", [], ServerTeam[], true> & AsyncStoreProperty<"item", [
815
+ createOAuthProvider(options: {
816
+ userId: string;
817
+ accountId: string;
818
+ providerConfigId: string;
819
+ email: string;
820
+ allowSignIn: boolean;
821
+ allowConnectedAccounts: boolean;
822
+ }): Promise<Result<ServerOAuthProvider, InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>>>;
823
+ sendEmail(options: SendEmailOptions): Promise<void>;
824
+ } & 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", [
756
825
  {
757
826
  itemId: string;
758
827
  userId: string;
@@ -788,22 +857,28 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
788
857
  displayName: string;
789
858
  themeId?: string;
790
859
  tsxSource: string;
860
+ }[], true> & AsyncStoreProperty<"emailDrafts", [], {
861
+ id: string;
862
+ displayName: string;
863
+ themeId: string | undefined | false;
864
+ tsxSource: string;
865
+ sentAt: Date | null;
791
866
  }[], true> & AsyncStoreProperty<"stripeAccountInfo", [], {
792
867
  account_id: string;
793
868
  charges_enabled: boolean;
794
869
  details_submitted: boolean;
795
870
  payouts_enabled: boolean;
796
- } | null, false> & {
797
- useEmailTemplates(): {
798
- id: string;
799
- displayName: string;
800
- tsxSource: string;
801
- }[];
802
- listEmailTemplates(): Promise<{
803
- id: string;
804
- displayName: string;
805
- tsxSource: string;
806
- }[]>;
871
+ } | null, false> & AsyncStoreProperty<"transactions", [
872
+ {
873
+ cursor?: string;
874
+ limit?: number;
875
+ type?: 'subscription' | 'one_time' | 'item_quantity_change';
876
+ customerType?: 'user' | 'team' | 'custom';
877
+ }
878
+ ], {
879
+ transactions: AdminTransaction[];
880
+ nextCursor: string | null;
881
+ }, true> & {
807
882
  createInternalApiKey(options: InternalApiKeyCreateOptions): Promise<InternalApiKeyFirstView>;
808
883
  createTeamPermissionDefinition(data: AdminTeamPermissionDefinitionCreateOptions): Promise<AdminTeamPermission>;
809
884
  updateTeamPermissionDefinition(permissionId: string, data: AdminTeamPermissionDefinitionUpdateOptions): Promise<void>;
@@ -828,7 +903,7 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
828
903
  id: string;
829
904
  }>;
830
905
  updateEmailTheme(id: string, tsxSource: string): Promise<void>;
831
- sendChatMessage(threadId: string, contextType: "email-theme" | "email-template", messages: Array<{
906
+ sendChatMessage(threadId: string, contextType: "email-theme" | "email-template" | "email-draft", messages: Array<{
832
907
  role: string;
833
908
  content: any;
834
909
  }>, abortSignal?: AbortSignal): Promise<{
@@ -850,6 +925,18 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
850
925
  createStripeWidgetAccountSession(): Promise<{
851
926
  client_secret: string;
852
927
  }>;
928
+ createEmailDraft(options: {
929
+ displayName: string;
930
+ themeId?: string | undefined | false;
931
+ tsxSource?: string;
932
+ }): Promise<{
933
+ id: string;
934
+ }>;
935
+ updateEmailDraft(id: string, data: {
936
+ displayName?: string;
937
+ themeId?: string | undefined | false;
938
+ tsxSource?: string;
939
+ }): Promise<void>;
853
940
  createItemQuantityChange(options: ({
854
941
  userId: string;
855
942
  itemId: string;
@@ -912,7 +999,7 @@ type AdminProjectConfig = {
912
999
  readonly allowTeamApiKeys: boolean;
913
1000
  };
914
1001
  type AdminEmailConfig = ({
915
- type: "standard";
1002
+ type: "standard" | "resend";
916
1003
  senderName: string;
917
1004
  senderEmail: string;
918
1005
  host: string;
@@ -1039,7 +1126,9 @@ type StackClientAppConstructor = {
1039
1126
  type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = ({
1040
1127
  readonly projectId: ProjectId;
1041
1128
  readonly urls: Readonly<HandlerUrls>;
1042
- signInWithOAuth(provider: string): Promise<void>;
1129
+ signInWithOAuth(provider: string, options?: {
1130
+ returnTo?: string;
1131
+ }): Promise<void>;
1043
1132
  signInWithCredential(options: {
1044
1133
  email: string;
1045
1134
  password: string;
@@ -1498,4 +1587,4 @@ type UserButtonProps = {
1498
1587
  };
1499
1588
  declare function UserButton(props: UserButtonProps): react_jsx_runtime.JSX.Element;
1500
1589
 
1501
- export { AccountSettings, 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, AuthPage, CliAuthConfirmation, type Connection, type ContactChannel, CredentialSignIn, CredentialSignUp, type CurrentInternalServerUser, type CurrentInternalUser, type CurrentServerUser, type CurrentUser, type EditableTeamMemberProfile, EmailVerification, ForgotPassword, type GetUserOptions$1 as GetUserOptions, type HandlerUrls, type InternalApiKey, type InternalApiKeyBase, type InternalApiKeyBaseCrudRead, type InternalApiKeyCreateOptions, type InternalApiKeyFirstView, MagicLinkSignIn, MessageCard, OAuthButton, OAuthButtonGroup, type OAuthConnection, type OAuthProviderConfig, type OAuthScopesOnSignIn, PasswordReset, type Project, type ProjectConfig, SelectedTeamSwitcher, type ServerContactChannel, type ServerListUsersOptions, type ServerTeam, type ServerTeamCreateOptions, type ServerTeamMemberProfile, type ServerTeamUpdateOptions, type ServerTeamUser, type ServerUser, type Session, SignIn, SignUp, StackAdminApp, type StackAdminAppConstructor, type StackAdminAppConstructorOptions, StackClientApp, type StackClientAppConstructor, type StackClientAppConstructorOptions, type StackClientAppJson, NextStackHandler as StackHandler, NextStackProvider as StackProvider, StackServerApp, type StackServerAppConstructor, type StackServerAppConstructorOptions, StackTheme, type Team, type TeamCreateOptions, type TeamInvitation$1 as TeamInvitation, type TeamMemberProfile, TeamSwitcher, type TeamUpdateOptions, type TeamUser, type User, UserAvatar, UserButton, stackAppInternalsSymbol, useStackApp, useUser };
1590
+ export { AccountSettings, 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, AuthPage, CliAuthConfirmation, type Connection, type ContactChannel, CredentialSignIn, CredentialSignUp, type CurrentInternalServerUser, type CurrentInternalUser, type CurrentServerUser, type CurrentUser, type EditableTeamMemberProfile, EmailVerification, ForgotPassword, type GetUserOptions$1 as GetUserOptions, type HandlerUrls, type InternalApiKey, type InternalApiKeyBase, type InternalApiKeyBaseCrudRead, type InternalApiKeyCreateOptions, type InternalApiKeyFirstView, MagicLinkSignIn, MessageCard, OAuthButton, OAuthButtonGroup, type OAuthConnection, type OAuthProvider, type OAuthProviderConfig, type OAuthScopesOnSignIn, PasswordReset, type Project, type ProjectConfig, SelectedTeamSwitcher, type ServerContactChannel, type ServerListUsersOptions, type ServerOAuthProvider, type ServerTeam, type ServerTeamCreateOptions, type ServerTeamMemberProfile, type ServerTeamUpdateOptions, type ServerTeamUser, type ServerUser, type Session, SignIn, SignUp, StackAdminApp, type StackAdminAppConstructor, type StackAdminAppConstructorOptions, StackClientApp, type StackClientAppConstructor, type StackClientAppConstructorOptions, type StackClientAppJson, NextStackHandler as StackHandler, NextStackProvider as StackProvider, StackServerApp, type StackServerAppConstructor, type StackServerAppConstructorOptions, StackTheme, type Team, type TeamCreateOptions, type TeamInvitation$1 as TeamInvitation, type TeamMemberProfile, TeamSwitcher, type TeamUpdateOptions, type TeamUser, type User, UserAvatar, UserButton, stackAppInternalsSymbol, useStackApp, useUser };
package/dist/index.d.ts CHANGED
@@ -7,10 +7,11 @@ import * as yup from 'yup';
7
7
  import { ProductionModeError } from '@stackframe/stack-shared/dist/helpers/production-mode';
8
8
  import { CompleteConfig, EnvironmentConfigOverrideOverride } from '@stackframe/stack-shared/dist/config/schema';
9
9
  import { ChatContent } from '@stackframe/stack-shared/dist/interface/admin-interface';
10
+ import { AdminTransaction } from '@stackframe/stack-shared/dist/interface/crud/transactions';
10
11
  import { InternalSession } from '@stackframe/stack-shared/dist/sessions';
12
+ import { XOR, PrettifyType, IfAndOnlyIf } from '@stackframe/stack-shared/dist/utils/types';
11
13
  import { InternalApiKeysCrud } from '@stackframe/stack-shared/dist/interface/crud/internal-api-keys';
12
14
  import { ReadonlyJson } from '@stackframe/stack-shared/dist/utils/json';
13
- import { PrettifyType, IfAndOnlyIf } from '@stackframe/stack-shared/dist/utils/types';
14
15
  import { GeoInfo } from '@stackframe/stack-shared/dist/utils/geo';
15
16
  import * as react_jsx_runtime from 'react/jsx-runtime';
16
17
  import * as lucide_react from 'lucide-react';
@@ -123,17 +124,30 @@ type AdminSentEmail = {
123
124
  sentAt: Date;
124
125
  error?: unknown;
125
126
  };
126
- type SendEmailOptions = {
127
- userIds: string[];
127
+ type SendEmailOptionsBase = {
128
128
  themeId?: string | null | false;
129
129
  subject?: string;
130
130
  notificationCategoryName?: string;
131
- } & ({
132
- html: string;
133
- } | {
134
- templateId: string;
135
- variables?: Record<string, any>;
136
- });
131
+ };
132
+ type SendEmailOptions = SendEmailOptionsBase & XOR<[
133
+ {
134
+ userIds: string[];
135
+ },
136
+ {
137
+ allUsers: true;
138
+ }
139
+ ]> & XOR<[
140
+ {
141
+ html: string;
142
+ },
143
+ {
144
+ templateId: string;
145
+ variables?: Record<string, any>;
146
+ },
147
+ {
148
+ draftId: string;
149
+ }
150
+ ]>;
137
151
 
138
152
  type InternalApiKeyBase = {
139
153
  id: string;
@@ -203,6 +217,15 @@ type AdminProjectPermissionDefinitionCreateOptions = {
203
217
  };
204
218
  type AdminProjectPermissionDefinitionUpdateOptions = Pick<Partial<AdminProjectPermissionDefinitionCreateOptions>, "description" | "containedPermissionIds">;
205
219
 
220
+ type DataVaultStore = {
221
+ id: string;
222
+ setValue: (key: string, value: string, options: {
223
+ secret: string;
224
+ }) => Promise<void>;
225
+ } & AsyncStoreProperty<"value", [key: string, options: {
226
+ secret: string;
227
+ }], string | null, false>;
228
+
206
229
  type ApiKeyType = "user" | "team";
207
230
  type ApiKey<Type extends ApiKeyType = ApiKeyType, IsFirstView extends boolean = false> = {
208
231
  id: string;
@@ -297,6 +320,36 @@ type NotificationCategory = {
297
320
  setEnabled(enabled: boolean): Promise<void>;
298
321
  };
299
322
 
323
+ type OAuthProvider = {
324
+ readonly id: string;
325
+ readonly type: string;
326
+ readonly userId: string;
327
+ readonly accountId?: string;
328
+ readonly email?: string;
329
+ readonly allowSignIn: boolean;
330
+ readonly allowConnectedAccounts: boolean;
331
+ update(data: {
332
+ allowSignIn?: boolean;
333
+ allowConnectedAccounts?: boolean;
334
+ }): Promise<Result<void, InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>>>;
335
+ delete(): Promise<void>;
336
+ };
337
+ type ServerOAuthProvider = {
338
+ readonly id: string;
339
+ readonly type: string;
340
+ readonly userId: string;
341
+ readonly accountId: string;
342
+ readonly email?: string;
343
+ readonly allowSignIn: boolean;
344
+ readonly allowConnectedAccounts: boolean;
345
+ update(data: {
346
+ accountId?: string;
347
+ email?: string;
348
+ allowSignIn?: boolean;
349
+ allowConnectedAccounts?: boolean;
350
+ }): Promise<Result<void, InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>>>;
351
+ delete(): Promise<void>;
352
+ };
300
353
  type Session = {
301
354
  getTokens(): Promise<{
302
355
  accessToken: string | null;
@@ -508,6 +561,10 @@ type UserExtra = {
508
561
  getTeamProfile(team: Team): Promise<EditableTeamMemberProfile>;
509
562
  useTeamProfile(team: Team): EditableTeamMemberProfile;
510
563
  createApiKey(options: ApiKeyCreationOptions<"user">): Promise<UserApiKeyFirstView>;
564
+ useOAuthProviders(): OAuthProvider[];
565
+ listOAuthProviders(): Promise<OAuthProvider[]>;
566
+ useOAuthProvider(id: string): OAuthProvider | null;
567
+ getOAuthProvider(id: string): Promise<OAuthProvider | null>;
511
568
  } & AsyncStoreProperty<"apiKeys", [], UserApiKey[], true> & AsyncStoreProperty<"team", [id: string], Team | null, false> & AsyncStoreProperty<"teams", [], Team[], true> & AsyncStoreProperty<"permission", [scope: Team, permissionId: string, options?: {
512
569
  recursive?: boolean;
513
570
  }], TeamPermission | null, false> & AsyncStoreProperty<"permissions", [scope: Team, options?: {
@@ -573,6 +630,10 @@ type ServerBaseUser = {
573
630
  }): TeamPermission[];
574
631
  usePermission(scope: Team, permissionId: string): TeamPermission | null;
575
632
  usePermission(permissionId: string): TeamPermission | null;
633
+ useOAuthProviders(): ServerOAuthProvider[];
634
+ listOAuthProviders(): Promise<ServerOAuthProvider[]>;
635
+ useOAuthProvider(id: string): ServerOAuthProvider | null;
636
+ getOAuthProvider(id: string): Promise<ServerOAuthProvider | null>;
576
637
  /**
577
638
  * Creates a new session object with a refresh token for this user. Can be used to impersonate them.
578
639
  */
@@ -751,8 +812,16 @@ type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends s
751
812
  listUsers(options?: ServerListUsersOptions): Promise<ServerUser[] & {
752
813
  nextCursor: string | null;
753
814
  }>;
754
- sendEmail(options: SendEmailOptions): Promise<Result<void, KnownErrors["RequiresCustomEmailServer"] | KnownErrors["SchemaError"] | KnownErrors["UserIdDoesNotExist"]>>;
755
- } & AsyncStoreProperty<"user", [id: string], ServerUser | null, false> & Omit<AsyncStoreProperty<"users", [], ServerUser[], true>, "listUsers" | "useUsers"> & AsyncStoreProperty<"teams", [], ServerTeam[], true> & AsyncStoreProperty<"item", [
815
+ createOAuthProvider(options: {
816
+ userId: string;
817
+ accountId: string;
818
+ providerConfigId: string;
819
+ email: string;
820
+ allowSignIn: boolean;
821
+ allowConnectedAccounts: boolean;
822
+ }): Promise<Result<ServerOAuthProvider, InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>>>;
823
+ sendEmail(options: SendEmailOptions): Promise<void>;
824
+ } & 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", [
756
825
  {
757
826
  itemId: string;
758
827
  userId: string;
@@ -788,22 +857,28 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
788
857
  displayName: string;
789
858
  themeId?: string;
790
859
  tsxSource: string;
860
+ }[], true> & AsyncStoreProperty<"emailDrafts", [], {
861
+ id: string;
862
+ displayName: string;
863
+ themeId: string | undefined | false;
864
+ tsxSource: string;
865
+ sentAt: Date | null;
791
866
  }[], true> & AsyncStoreProperty<"stripeAccountInfo", [], {
792
867
  account_id: string;
793
868
  charges_enabled: boolean;
794
869
  details_submitted: boolean;
795
870
  payouts_enabled: boolean;
796
- } | null, false> & {
797
- useEmailTemplates(): {
798
- id: string;
799
- displayName: string;
800
- tsxSource: string;
801
- }[];
802
- listEmailTemplates(): Promise<{
803
- id: string;
804
- displayName: string;
805
- tsxSource: string;
806
- }[]>;
871
+ } | null, false> & AsyncStoreProperty<"transactions", [
872
+ {
873
+ cursor?: string;
874
+ limit?: number;
875
+ type?: 'subscription' | 'one_time' | 'item_quantity_change';
876
+ customerType?: 'user' | 'team' | 'custom';
877
+ }
878
+ ], {
879
+ transactions: AdminTransaction[];
880
+ nextCursor: string | null;
881
+ }, true> & {
807
882
  createInternalApiKey(options: InternalApiKeyCreateOptions): Promise<InternalApiKeyFirstView>;
808
883
  createTeamPermissionDefinition(data: AdminTeamPermissionDefinitionCreateOptions): Promise<AdminTeamPermission>;
809
884
  updateTeamPermissionDefinition(permissionId: string, data: AdminTeamPermissionDefinitionUpdateOptions): Promise<void>;
@@ -828,7 +903,7 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
828
903
  id: string;
829
904
  }>;
830
905
  updateEmailTheme(id: string, tsxSource: string): Promise<void>;
831
- sendChatMessage(threadId: string, contextType: "email-theme" | "email-template", messages: Array<{
906
+ sendChatMessage(threadId: string, contextType: "email-theme" | "email-template" | "email-draft", messages: Array<{
832
907
  role: string;
833
908
  content: any;
834
909
  }>, abortSignal?: AbortSignal): Promise<{
@@ -850,6 +925,18 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
850
925
  createStripeWidgetAccountSession(): Promise<{
851
926
  client_secret: string;
852
927
  }>;
928
+ createEmailDraft(options: {
929
+ displayName: string;
930
+ themeId?: string | undefined | false;
931
+ tsxSource?: string;
932
+ }): Promise<{
933
+ id: string;
934
+ }>;
935
+ updateEmailDraft(id: string, data: {
936
+ displayName?: string;
937
+ themeId?: string | undefined | false;
938
+ tsxSource?: string;
939
+ }): Promise<void>;
853
940
  createItemQuantityChange(options: ({
854
941
  userId: string;
855
942
  itemId: string;
@@ -912,7 +999,7 @@ type AdminProjectConfig = {
912
999
  readonly allowTeamApiKeys: boolean;
913
1000
  };
914
1001
  type AdminEmailConfig = ({
915
- type: "standard";
1002
+ type: "standard" | "resend";
916
1003
  senderName: string;
917
1004
  senderEmail: string;
918
1005
  host: string;
@@ -1039,7 +1126,9 @@ type StackClientAppConstructor = {
1039
1126
  type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = ({
1040
1127
  readonly projectId: ProjectId;
1041
1128
  readonly urls: Readonly<HandlerUrls>;
1042
- signInWithOAuth(provider: string): Promise<void>;
1129
+ signInWithOAuth(provider: string, options?: {
1130
+ returnTo?: string;
1131
+ }): Promise<void>;
1043
1132
  signInWithCredential(options: {
1044
1133
  email: string;
1045
1134
  password: string;
@@ -1498,4 +1587,4 @@ type UserButtonProps = {
1498
1587
  };
1499
1588
  declare function UserButton(props: UserButtonProps): react_jsx_runtime.JSX.Element;
1500
1589
 
1501
- export { AccountSettings, 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, AuthPage, CliAuthConfirmation, type Connection, type ContactChannel, CredentialSignIn, CredentialSignUp, type CurrentInternalServerUser, type CurrentInternalUser, type CurrentServerUser, type CurrentUser, type EditableTeamMemberProfile, EmailVerification, ForgotPassword, type GetUserOptions$1 as GetUserOptions, type HandlerUrls, type InternalApiKey, type InternalApiKeyBase, type InternalApiKeyBaseCrudRead, type InternalApiKeyCreateOptions, type InternalApiKeyFirstView, MagicLinkSignIn, MessageCard, OAuthButton, OAuthButtonGroup, type OAuthConnection, type OAuthProviderConfig, type OAuthScopesOnSignIn, PasswordReset, type Project, type ProjectConfig, SelectedTeamSwitcher, type ServerContactChannel, type ServerListUsersOptions, type ServerTeam, type ServerTeamCreateOptions, type ServerTeamMemberProfile, type ServerTeamUpdateOptions, type ServerTeamUser, type ServerUser, type Session, SignIn, SignUp, StackAdminApp, type StackAdminAppConstructor, type StackAdminAppConstructorOptions, StackClientApp, type StackClientAppConstructor, type StackClientAppConstructorOptions, type StackClientAppJson, NextStackHandler as StackHandler, NextStackProvider as StackProvider, StackServerApp, type StackServerAppConstructor, type StackServerAppConstructorOptions, StackTheme, type Team, type TeamCreateOptions, type TeamInvitation$1 as TeamInvitation, type TeamMemberProfile, TeamSwitcher, type TeamUpdateOptions, type TeamUser, type User, UserAvatar, UserButton, stackAppInternalsSymbol, useStackApp, useUser };
1590
+ export { AccountSettings, 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, AuthPage, CliAuthConfirmation, type Connection, type ContactChannel, CredentialSignIn, CredentialSignUp, type CurrentInternalServerUser, type CurrentInternalUser, type CurrentServerUser, type CurrentUser, type EditableTeamMemberProfile, EmailVerification, ForgotPassword, type GetUserOptions$1 as GetUserOptions, type HandlerUrls, type InternalApiKey, type InternalApiKeyBase, type InternalApiKeyBaseCrudRead, type InternalApiKeyCreateOptions, type InternalApiKeyFirstView, MagicLinkSignIn, MessageCard, OAuthButton, OAuthButtonGroup, type OAuthConnection, type OAuthProvider, type OAuthProviderConfig, type OAuthScopesOnSignIn, PasswordReset, type Project, type ProjectConfig, SelectedTeamSwitcher, type ServerContactChannel, type ServerListUsersOptions, type ServerOAuthProvider, type ServerTeam, type ServerTeamCreateOptions, type ServerTeamMemberProfile, type ServerTeamUpdateOptions, type ServerTeamUser, type ServerUser, type Session, SignIn, SignUp, StackAdminApp, type StackAdminAppConstructor, type StackAdminAppConstructorOptions, StackClientApp, type StackClientAppConstructor, type StackClientAppConstructorOptions, type StackClientAppJson, NextStackHandler as StackHandler, NextStackProvider as StackProvider, StackServerApp, type StackServerAppConstructor, type StackServerAppConstructorOptions, StackTheme, type Team, type TeamCreateOptions, type TeamInvitation$1 as TeamInvitation, type TeamMemberProfile, TeamSwitcher, type TeamUpdateOptions, type TeamUser, type User, UserAvatar, UserButton, stackAppInternalsSymbol, useStackApp, useUser };