@stackframe/stack 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.
- package/CHANGELOG.md +40 -0
- package/dist/components/user-button.js +2 -2
- package/dist/components/user-button.js.map +1 -1
- package/dist/esm/components/user-button.js +2 -2
- package/dist/esm/components/user-button.js.map +1 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/integrations/convex.js +18 -0
- package/dist/esm/integrations/convex.js.map +1 -0
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js +59 -6
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js +140 -3
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/common.js +7 -7
- package/dist/esm/lib/stack-app/apps/implementations/common.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js +112 -4
- package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/admin-app.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/interfaces/server-app.js.map +1 -1
- package/dist/esm/lib/stack-app/common.js.map +1 -1
- package/dist/esm/lib/stack-app/index.js.map +1 -1
- package/dist/esm/lib/stack-app/users/index.js.map +1 -1
- package/dist/esm/providers/stack-provider-client.js.map +1 -1
- package/dist/index.d.mts +200 -43
- package/dist/index.d.ts +200 -43
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/convex.js +43 -0
- package/dist/integrations/convex.js.map +1 -0
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js +58 -5
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js +140 -3
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/common.js +7 -7
- package/dist/lib/stack-app/apps/implementations/common.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js +111 -3
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/admin-app.js.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
- package/dist/lib/stack-app/apps/interfaces/server-app.js.map +1 -1
- package/dist/lib/stack-app/common.js.map +1 -1
- package/dist/lib/stack-app/email/index.js.map +1 -1
- package/dist/lib/stack-app/index.js.map +1 -1
- package/dist/lib/stack-app/project-configs/index.js.map +1 -1
- package/dist/lib/stack-app/users/index.js.map +1 -1
- package/dist/providers/stack-provider-client.js.map +1 -1
- package/package.json +6 -5
|
@@ -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\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 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\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;AAyTtB,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;AAkFO,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 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/providers/stack-provider-client.tsx"],"sourcesContent":["\"use client\";\n\n\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\n\nimport { CurrentUserCrud } from \"@stackframe/stack-shared/dist/interface/crud/current-user\";\nimport { globalVar } from \"@stackframe/stack-shared/dist/utils/globals\";\nimport React, { useEffect } from \"react\";\nimport { useStackApp } from \"..\";\nimport { StackClientApp, StackClientAppJson, stackAppInternalsSymbol } from \"../lib/stack-app\";\n\nexport const StackContext = React.createContext<null | {\n app: StackClientApp<true>,\n}>(null);\n\nexport function StackProviderClient(props: {\n app: StackClientAppJson<true, string> | StackClientApp<true>,\n serialized: boolean,\n children?: React.ReactNode,\n}) {\n const app = props.serialized\n ? StackClientApp[stackAppInternalsSymbol].fromClientJson(props.app as StackClientAppJson<true, string>)\n : props.app as StackClientApp<true>;\n
|
|
1
|
+
{"version":3,"sources":["../../../src/providers/stack-provider-client.tsx"],"sourcesContent":["\"use client\";\n\n\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\n\nimport { CurrentUserCrud } from \"@stackframe/stack-shared/dist/interface/crud/current-user\";\nimport { globalVar } from \"@stackframe/stack-shared/dist/utils/globals\";\nimport React, { useEffect } from \"react\";\nimport { useStackApp } from \"..\";\nimport { StackClientApp, StackClientAppJson, stackAppInternalsSymbol } from \"../lib/stack-app\";\n\nexport const StackContext = React.createContext<null | {\n app: StackClientApp<true>,\n}>(null);\n\nexport function StackProviderClient(props: {\n app: StackClientAppJson<true, string> | StackClientApp<true>,\n serialized: boolean,\n children?: React.ReactNode,\n}) {\n const app = props.serialized\n ? StackClientApp[stackAppInternalsSymbol].fromClientJson(props.app as StackClientAppJson<true, string>)\n : props.app as StackClientApp<true>;\n globalVar.__STACK_AUTH__ = { app };\n\n return (\n <StackContext.Provider value={{ app }}>\n {props.children}\n </StackContext.Provider>\n );\n}\n\nexport function UserSetter(props: { userJsonPromise: Promise<CurrentUserCrud['Client']['Read'] | null> }) {\n const app = useStackApp();\n useEffect(() => {\n const promise = (async () => await props.userJsonPromise)(); // there is a Next.js bug where Promises passed by server components return `undefined` as their `then` value, so wrap it in a normal promise\n app[stackAppInternalsSymbol].setCurrentUser(promise);\n }, []);\n return null;\n}\n"],"mappings":";;;AAQA,SAAS,iBAAiB;AAC1B,OAAO,SAAS,iBAAiB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,gBAAoC,+BAA+B;AAiBxE;AAfG,IAAM,eAAe,MAAM,cAE/B,IAAI;AAEA,SAAS,oBAAoB,OAIjC;AACD,QAAM,MAAM,MAAM,aACd,eAAe,uBAAuB,EAAE,eAAe,MAAM,GAAuC,IACpG,MAAM;AACV,YAAU,iBAAiB,EAAE,IAAI;AAEjC,SACE,oBAAC,aAAa,UAAb,EAAsB,OAAO,EAAE,IAAI,GACjC,gBAAM,UACT;AAEJ;AAEO,SAAS,WAAW,OAA+E;AACxG,QAAM,MAAM,YAAY;AACxB,YAAU,MAAM;AACd,UAAM,WAAW,YAAY,MAAM,MAAM,iBAAiB;AAC1D,QAAI,uBAAuB,EAAE,eAAe,OAAO;AAAA,EACrD,GAAG,CAAC,CAAC;AACL,SAAO;AACT;","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
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
16
18
|
import * as lucide_react from 'lucide-react';
|
|
@@ -37,12 +39,28 @@ type RedirectMethod = "window" | "nextjs" | "none" | {
|
|
|
37
39
|
useNavigate: () => (to: string) => void;
|
|
38
40
|
navigate?: (to: string) => void;
|
|
39
41
|
};
|
|
40
|
-
type
|
|
42
|
+
type GetCurrentUserOptions<HasTokenStore> = {
|
|
41
43
|
or?: 'redirect' | 'throw' | 'return-null' | 'anonymous' | /** @deprecated */ 'anonymous-if-exists[deprecated]';
|
|
42
44
|
tokenStore?: TokenStoreInit;
|
|
43
45
|
} & (HasTokenStore extends false ? {
|
|
44
46
|
tokenStore: TokenStoreInit;
|
|
45
47
|
} : {});
|
|
48
|
+
type ConvexCtx = GenericQueryCtx<any> | {
|
|
49
|
+
auth: {
|
|
50
|
+
getUserIdentity: () => Promise<UserIdentity | null>;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
type GetCurrentPartialUserOptions<HasTokenStore> = {
|
|
54
|
+
or?: 'return-null' | 'anonymous';
|
|
55
|
+
tokenStore?: TokenStoreInit;
|
|
56
|
+
} & ({
|
|
57
|
+
from: 'token';
|
|
58
|
+
} | {
|
|
59
|
+
from: 'convex';
|
|
60
|
+
ctx: ConvexCtx;
|
|
61
|
+
}) & (HasTokenStore extends false ? {
|
|
62
|
+
tokenStore: TokenStoreInit;
|
|
63
|
+
} : {});
|
|
46
64
|
type RequestLike = {
|
|
47
65
|
headers: {
|
|
48
66
|
get: (name: string) => string | null;
|
|
@@ -123,17 +141,30 @@ type AdminSentEmail = {
|
|
|
123
141
|
sentAt: Date;
|
|
124
142
|
error?: unknown;
|
|
125
143
|
};
|
|
126
|
-
type
|
|
127
|
-
userIds: string[];
|
|
144
|
+
type SendEmailOptionsBase = {
|
|
128
145
|
themeId?: string | null | false;
|
|
129
146
|
subject?: string;
|
|
130
147
|
notificationCategoryName?: string;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
148
|
+
};
|
|
149
|
+
type SendEmailOptions = SendEmailOptionsBase & XOR<[
|
|
150
|
+
{
|
|
151
|
+
userIds: string[];
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
allUsers: true;
|
|
155
|
+
}
|
|
156
|
+
]> & XOR<[
|
|
157
|
+
{
|
|
158
|
+
html: string;
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
templateId: string;
|
|
162
|
+
variables?: Record<string, any>;
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
draftId: string;
|
|
166
|
+
}
|
|
167
|
+
]>;
|
|
137
168
|
|
|
138
169
|
type InternalApiKeyBase = {
|
|
139
170
|
id: string;
|
|
@@ -306,6 +337,36 @@ type NotificationCategory = {
|
|
|
306
337
|
setEnabled(enabled: boolean): Promise<void>;
|
|
307
338
|
};
|
|
308
339
|
|
|
340
|
+
type OAuthProvider = {
|
|
341
|
+
readonly id: string;
|
|
342
|
+
readonly type: string;
|
|
343
|
+
readonly userId: string;
|
|
344
|
+
readonly accountId?: string;
|
|
345
|
+
readonly email?: string;
|
|
346
|
+
readonly allowSignIn: boolean;
|
|
347
|
+
readonly allowConnectedAccounts: boolean;
|
|
348
|
+
update(data: {
|
|
349
|
+
allowSignIn?: boolean;
|
|
350
|
+
allowConnectedAccounts?: boolean;
|
|
351
|
+
}): Promise<Result<void, InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>>>;
|
|
352
|
+
delete(): Promise<void>;
|
|
353
|
+
};
|
|
354
|
+
type ServerOAuthProvider = {
|
|
355
|
+
readonly id: string;
|
|
356
|
+
readonly type: string;
|
|
357
|
+
readonly userId: string;
|
|
358
|
+
readonly accountId: string;
|
|
359
|
+
readonly email?: string;
|
|
360
|
+
readonly allowSignIn: boolean;
|
|
361
|
+
readonly allowConnectedAccounts: boolean;
|
|
362
|
+
update(data: {
|
|
363
|
+
accountId?: string;
|
|
364
|
+
email?: string;
|
|
365
|
+
allowSignIn?: boolean;
|
|
366
|
+
allowConnectedAccounts?: boolean;
|
|
367
|
+
}): Promise<Result<void, InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>>>;
|
|
368
|
+
delete(): Promise<void>;
|
|
369
|
+
};
|
|
309
370
|
type Session = {
|
|
310
371
|
getTokens(): Promise<{
|
|
311
372
|
accessToken: string | null;
|
|
@@ -517,6 +578,10 @@ type UserExtra = {
|
|
|
517
578
|
getTeamProfile(team: Team): Promise<EditableTeamMemberProfile>;
|
|
518
579
|
useTeamProfile(team: Team): EditableTeamMemberProfile;
|
|
519
580
|
createApiKey(options: ApiKeyCreationOptions<"user">): Promise<UserApiKeyFirstView>;
|
|
581
|
+
useOAuthProviders(): OAuthProvider[];
|
|
582
|
+
listOAuthProviders(): Promise<OAuthProvider[]>;
|
|
583
|
+
useOAuthProvider(id: string): OAuthProvider | null;
|
|
584
|
+
getOAuthProvider(id: string): Promise<OAuthProvider | null>;
|
|
520
585
|
} & AsyncStoreProperty<"apiKeys", [], UserApiKey[], true> & AsyncStoreProperty<"team", [id: string], Team | null, false> & AsyncStoreProperty<"teams", [], Team[], true> & AsyncStoreProperty<"permission", [scope: Team, permissionId: string, options?: {
|
|
521
586
|
recursive?: boolean;
|
|
522
587
|
}], TeamPermission | null, false> & AsyncStoreProperty<"permissions", [scope: Team, options?: {
|
|
@@ -529,6 +594,8 @@ type User = BaseUser;
|
|
|
529
594
|
type CurrentUser = BaseUser & Auth & UserExtra & Customer;
|
|
530
595
|
type CurrentInternalUser = CurrentUser & InternalUserExtra;
|
|
531
596
|
type ProjectCurrentUser<ProjectId> = ProjectId extends "internal" ? CurrentInternalUser : CurrentUser;
|
|
597
|
+
type TokenPartialUser = Pick<User, "id" | "displayName" | "primaryEmail" | "primaryEmailVerified" | "isAnonymous">;
|
|
598
|
+
type SyncedPartialUser = TokenPartialUser & Pick<User, "id" | "displayName" | "primaryEmail" | "primaryEmailVerified" | "profileImageUrl" | "signedUpAt" | "clientMetadata" | "clientReadOnlyMetadata" | "isAnonymous" | "hasPassword">;
|
|
532
599
|
type ActiveSession = {
|
|
533
600
|
id: string;
|
|
534
601
|
userId: string;
|
|
@@ -582,6 +649,10 @@ type ServerBaseUser = {
|
|
|
582
649
|
}): TeamPermission[];
|
|
583
650
|
usePermission(scope: Team, permissionId: string): TeamPermission | null;
|
|
584
651
|
usePermission(permissionId: string): TeamPermission | null;
|
|
652
|
+
useOAuthProviders(): ServerOAuthProvider[];
|
|
653
|
+
listOAuthProviders(): Promise<ServerOAuthProvider[]>;
|
|
654
|
+
useOAuthProvider(id: string): ServerOAuthProvider | null;
|
|
655
|
+
getOAuthProvider(id: string): Promise<ServerOAuthProvider | null>;
|
|
585
656
|
/**
|
|
586
657
|
* Creates a new session object with a refresh token for this user. Can be used to impersonate them.
|
|
587
658
|
*/
|
|
@@ -602,6 +673,7 @@ type ServerUser = ServerBaseUser & BaseUser & UserExtra & Customer<true>;
|
|
|
602
673
|
type CurrentServerUser = Auth & ServerUser;
|
|
603
674
|
type CurrentInternalServerUser = CurrentServerUser & InternalUserExtra;
|
|
604
675
|
type ProjectCurrentServerUser<ProjectId> = ProjectId extends "internal" ? CurrentInternalServerUser : CurrentServerUser;
|
|
676
|
+
type SyncedPartialServerUser = SyncedPartialUser & Pick<ServerUser, "serverMetadata">;
|
|
605
677
|
type ServerUserUpdateOptions = {
|
|
606
678
|
primaryEmail?: string | null;
|
|
607
679
|
primaryEmailVerified?: boolean;
|
|
@@ -718,34 +790,60 @@ type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
718
790
|
*/
|
|
719
791
|
getServerUser(): Promise<ProjectCurrentServerUser<ProjectId> | null>;
|
|
720
792
|
createUser(options: ServerUserCreateOptions): Promise<ServerUser>;
|
|
721
|
-
useUser(options:
|
|
793
|
+
useUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
722
794
|
or: 'redirect';
|
|
723
795
|
}): ProjectCurrentServerUser<ProjectId>;
|
|
724
|
-
useUser(options:
|
|
796
|
+
useUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
725
797
|
or: 'throw';
|
|
726
798
|
}): ProjectCurrentServerUser<ProjectId>;
|
|
727
|
-
useUser(options:
|
|
799
|
+
useUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
728
800
|
or: 'anonymous';
|
|
729
801
|
}): ProjectCurrentServerUser<ProjectId>;
|
|
730
|
-
useUser(options?:
|
|
802
|
+
useUser(options?: GetCurrentUserOptions<HasTokenStore>): ProjectCurrentServerUser<ProjectId> | null;
|
|
731
803
|
useUser(id: string): ServerUser | null;
|
|
732
804
|
useUser(options: {
|
|
733
805
|
apiKey: string;
|
|
806
|
+
or?: "return-null" | "anonymous";
|
|
734
807
|
}): ServerUser | null;
|
|
735
|
-
|
|
808
|
+
useUser(options: {
|
|
809
|
+
from: "convex";
|
|
810
|
+
ctx: GenericQueryCtx<any>;
|
|
811
|
+
or?: "return-null" | "anonymous";
|
|
812
|
+
}): ServerUser | null;
|
|
813
|
+
getUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
736
814
|
or: 'redirect';
|
|
737
815
|
}): Promise<ProjectCurrentServerUser<ProjectId>>;
|
|
738
|
-
getUser(options:
|
|
816
|
+
getUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
739
817
|
or: 'throw';
|
|
740
818
|
}): Promise<ProjectCurrentServerUser<ProjectId>>;
|
|
741
|
-
getUser(options:
|
|
819
|
+
getUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
742
820
|
or: 'anonymous';
|
|
743
821
|
}): Promise<ProjectCurrentServerUser<ProjectId>>;
|
|
744
|
-
getUser(options?:
|
|
822
|
+
getUser(options?: GetCurrentUserOptions<HasTokenStore>): Promise<ProjectCurrentServerUser<ProjectId> | null>;
|
|
745
823
|
getUser(id: string): Promise<ServerUser | null>;
|
|
746
824
|
getUser(options: {
|
|
747
825
|
apiKey: string;
|
|
826
|
+
or?: "return-null" | "anonymous";
|
|
827
|
+
}): Promise<ServerUser | null>;
|
|
828
|
+
getUser(options: {
|
|
829
|
+
from: "convex";
|
|
830
|
+
ctx: GenericQueryCtx<any>;
|
|
831
|
+
or?: "return-null" | "anonymous";
|
|
748
832
|
}): Promise<ServerUser | null>;
|
|
833
|
+
getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & {
|
|
834
|
+
from: 'token';
|
|
835
|
+
}): Promise<TokenPartialUser | null>;
|
|
836
|
+
getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & {
|
|
837
|
+
from: 'convex';
|
|
838
|
+
}): Promise<TokenPartialUser | null>;
|
|
839
|
+
getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore>): Promise<SyncedPartialServerUser | TokenPartialUser | null>;
|
|
840
|
+
usePartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & {
|
|
841
|
+
from: 'token';
|
|
842
|
+
}): TokenPartialUser | null;
|
|
843
|
+
usePartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & {
|
|
844
|
+
from: 'convex';
|
|
845
|
+
}): TokenPartialUser | null;
|
|
846
|
+
usePartialUser(options: GetCurrentPartialUserOptions<HasTokenStore>): SyncedPartialServerUser | TokenPartialUser | null;
|
|
749
847
|
useTeam(id: string): ServerTeam | null;
|
|
750
848
|
useTeam(options: {
|
|
751
849
|
apiKey: string;
|
|
@@ -760,7 +858,15 @@ type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
760
858
|
listUsers(options?: ServerListUsersOptions): Promise<ServerUser[] & {
|
|
761
859
|
nextCursor: string | null;
|
|
762
860
|
}>;
|
|
763
|
-
|
|
861
|
+
createOAuthProvider(options: {
|
|
862
|
+
userId: string;
|
|
863
|
+
accountId: string;
|
|
864
|
+
providerConfigId: string;
|
|
865
|
+
email: string;
|
|
866
|
+
allowSignIn: boolean;
|
|
867
|
+
allowConnectedAccounts: boolean;
|
|
868
|
+
}): Promise<Result<ServerOAuthProvider, InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>>>;
|
|
869
|
+
sendEmail(options: SendEmailOptions): Promise<void>;
|
|
764
870
|
} & 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", [
|
|
765
871
|
{
|
|
766
872
|
itemId: string;
|
|
@@ -797,22 +903,28 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
|
|
|
797
903
|
displayName: string;
|
|
798
904
|
themeId?: string;
|
|
799
905
|
tsxSource: string;
|
|
906
|
+
}[], true> & AsyncStoreProperty<"emailDrafts", [], {
|
|
907
|
+
id: string;
|
|
908
|
+
displayName: string;
|
|
909
|
+
themeId: string | undefined | false;
|
|
910
|
+
tsxSource: string;
|
|
911
|
+
sentAt: Date | null;
|
|
800
912
|
}[], true> & AsyncStoreProperty<"stripeAccountInfo", [], {
|
|
801
913
|
account_id: string;
|
|
802
914
|
charges_enabled: boolean;
|
|
803
915
|
details_submitted: boolean;
|
|
804
916
|
payouts_enabled: boolean;
|
|
805
|
-
} | null, false> &
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
917
|
+
} | null, false> & AsyncStoreProperty<"transactions", [
|
|
918
|
+
{
|
|
919
|
+
cursor?: string;
|
|
920
|
+
limit?: number;
|
|
921
|
+
type?: 'subscription' | 'one_time' | 'item_quantity_change';
|
|
922
|
+
customerType?: 'user' | 'team' | 'custom';
|
|
923
|
+
}
|
|
924
|
+
], {
|
|
925
|
+
transactions: AdminTransaction[];
|
|
926
|
+
nextCursor: string | null;
|
|
927
|
+
}, true> & {
|
|
816
928
|
createInternalApiKey(options: InternalApiKeyCreateOptions): Promise<InternalApiKeyFirstView>;
|
|
817
929
|
createTeamPermissionDefinition(data: AdminTeamPermissionDefinitionCreateOptions): Promise<AdminTeamPermission>;
|
|
818
930
|
updateTeamPermissionDefinition(permissionId: string, data: AdminTeamPermissionDefinitionUpdateOptions): Promise<void>;
|
|
@@ -837,7 +949,7 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
|
|
|
837
949
|
id: string;
|
|
838
950
|
}>;
|
|
839
951
|
updateEmailTheme(id: string, tsxSource: string): Promise<void>;
|
|
840
|
-
sendChatMessage(threadId: string, contextType: "email-theme" | "email-template", messages: Array<{
|
|
952
|
+
sendChatMessage(threadId: string, contextType: "email-theme" | "email-template" | "email-draft", messages: Array<{
|
|
841
953
|
role: string;
|
|
842
954
|
content: any;
|
|
843
955
|
}>, abortSignal?: AbortSignal): Promise<{
|
|
@@ -859,6 +971,18 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
|
|
|
859
971
|
createStripeWidgetAccountSession(): Promise<{
|
|
860
972
|
client_secret: string;
|
|
861
973
|
}>;
|
|
974
|
+
createEmailDraft(options: {
|
|
975
|
+
displayName: string;
|
|
976
|
+
themeId?: string | undefined | false;
|
|
977
|
+
tsxSource?: string;
|
|
978
|
+
}): Promise<{
|
|
979
|
+
id: string;
|
|
980
|
+
}>;
|
|
981
|
+
updateEmailDraft(id: string, data: {
|
|
982
|
+
displayName?: string;
|
|
983
|
+
themeId?: string | undefined | false;
|
|
984
|
+
tsxSource?: string;
|
|
985
|
+
}): Promise<void>;
|
|
862
986
|
createItemQuantityChange(options: ({
|
|
863
987
|
userId: string;
|
|
864
988
|
itemId: string;
|
|
@@ -921,7 +1045,7 @@ type AdminProjectConfig = {
|
|
|
921
1045
|
readonly allowTeamApiKeys: boolean;
|
|
922
1046
|
};
|
|
923
1047
|
type AdminEmailConfig = ({
|
|
924
|
-
type: "standard";
|
|
1048
|
+
type: "standard" | "resend";
|
|
925
1049
|
senderName: string;
|
|
926
1050
|
senderEmail: string;
|
|
927
1051
|
host: string;
|
|
@@ -1048,7 +1172,9 @@ type StackClientAppConstructor = {
|
|
|
1048
1172
|
type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = ({
|
|
1049
1173
|
readonly projectId: ProjectId;
|
|
1050
1174
|
readonly urls: Readonly<HandlerUrls>;
|
|
1051
|
-
signInWithOAuth(provider: string
|
|
1175
|
+
signInWithOAuth(provider: string, options?: {
|
|
1176
|
+
returnTo?: string;
|
|
1177
|
+
}): Promise<void>;
|
|
1052
1178
|
signInWithCredential(options: {
|
|
1053
1179
|
email: string;
|
|
1054
1180
|
password: string;
|
|
@@ -1092,26 +1218,48 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
1092
1218
|
noRedirect?: boolean;
|
|
1093
1219
|
}): Promise<Result<undefined, KnownErrors["VerificationCodeError"] | KnownErrors["InvalidTotpCode"]>>;
|
|
1094
1220
|
redirectToOAuthCallback(): Promise<void>;
|
|
1095
|
-
|
|
1221
|
+
getConvexClientAuth(options: {
|
|
1222
|
+
tokenStore: TokenStoreInit;
|
|
1223
|
+
}): (args: {
|
|
1224
|
+
forceRefreshToken: boolean;
|
|
1225
|
+
}) => Promise<string | null>;
|
|
1226
|
+
getConvexHttpClientAuth(options: {
|
|
1227
|
+
tokenStore: TokenStoreInit;
|
|
1228
|
+
}): Promise<string>;
|
|
1229
|
+
useUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
1096
1230
|
or: 'redirect';
|
|
1097
1231
|
}): ProjectCurrentUser<ProjectId>;
|
|
1098
|
-
useUser(options:
|
|
1232
|
+
useUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
1099
1233
|
or: 'throw';
|
|
1100
1234
|
}): ProjectCurrentUser<ProjectId>;
|
|
1101
|
-
useUser(options:
|
|
1235
|
+
useUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
1102
1236
|
or: 'anonymous';
|
|
1103
1237
|
}): ProjectCurrentUser<ProjectId>;
|
|
1104
|
-
useUser(options?:
|
|
1105
|
-
getUser(options:
|
|
1238
|
+
useUser(options?: GetCurrentUserOptions<HasTokenStore>): ProjectCurrentUser<ProjectId> | null;
|
|
1239
|
+
getUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
1106
1240
|
or: 'redirect';
|
|
1107
1241
|
}): Promise<ProjectCurrentUser<ProjectId>>;
|
|
1108
|
-
getUser(options:
|
|
1242
|
+
getUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
1109
1243
|
or: 'throw';
|
|
1110
1244
|
}): Promise<ProjectCurrentUser<ProjectId>>;
|
|
1111
|
-
getUser(options:
|
|
1245
|
+
getUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
1112
1246
|
or: 'anonymous';
|
|
1113
1247
|
}): Promise<ProjectCurrentUser<ProjectId>>;
|
|
1114
|
-
getUser(options?:
|
|
1248
|
+
getUser(options?: GetCurrentUserOptions<HasTokenStore>): Promise<ProjectCurrentUser<ProjectId> | null>;
|
|
1249
|
+
getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & {
|
|
1250
|
+
from: 'token';
|
|
1251
|
+
}): Promise<TokenPartialUser | null>;
|
|
1252
|
+
getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & {
|
|
1253
|
+
from: 'convex';
|
|
1254
|
+
}): Promise<TokenPartialUser | null>;
|
|
1255
|
+
getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore>): Promise<SyncedPartialUser | TokenPartialUser | null>;
|
|
1256
|
+
usePartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & {
|
|
1257
|
+
from: 'token';
|
|
1258
|
+
}): TokenPartialUser | null;
|
|
1259
|
+
usePartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & {
|
|
1260
|
+
from: 'convex';
|
|
1261
|
+
}): TokenPartialUser | null;
|
|
1262
|
+
usePartialUser(options: GetCurrentPartialUserOptions<HasTokenStore>): SyncedPartialUser | TokenPartialUser | null;
|
|
1115
1263
|
useNavigate(): (to: string) => void;
|
|
1116
1264
|
[stackAppInternalsSymbol]: {
|
|
1117
1265
|
toClientJson(): StackClientAppJson<HasTokenStore, ProjectId>;
|
|
@@ -1133,6 +1281,15 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
1133
1281
|
});
|
|
1134
1282
|
declare const StackClientApp: StackClientAppConstructor;
|
|
1135
1283
|
|
|
1284
|
+
declare function getConvexProvidersConfig(options: {
|
|
1285
|
+
projectId?: string;
|
|
1286
|
+
}): {
|
|
1287
|
+
type: string;
|
|
1288
|
+
issuer: string;
|
|
1289
|
+
jwks: string;
|
|
1290
|
+
algorithm: string;
|
|
1291
|
+
}[];
|
|
1292
|
+
|
|
1136
1293
|
declare const iconMap: {
|
|
1137
1294
|
readonly Contact: React$1.ForwardRefExoticComponent<Omit<lucide_react.LucideProps, "ref"> & React$1.RefAttributes<SVGSVGElement>>;
|
|
1138
1295
|
readonly ShieldCheck: React$1.ForwardRefExoticComponent<Omit<lucide_react.LucideProps, "ref"> & React$1.RefAttributes<SVGSVGElement>>;
|
|
@@ -1265,7 +1422,7 @@ declare function NextStackHandler<HasTokenStore extends boolean>(props: BaseHand
|
|
|
1265
1422
|
routeProps: RouteProps | unknown;
|
|
1266
1423
|
})): Promise<any>;
|
|
1267
1424
|
|
|
1268
|
-
type GetUserOptions =
|
|
1425
|
+
type GetUserOptions = GetCurrentUserOptions<true> & {
|
|
1269
1426
|
projectIdMustMatch?: string;
|
|
1270
1427
|
};
|
|
1271
1428
|
/**
|
|
@@ -1507,4 +1664,4 @@ type UserButtonProps = {
|
|
|
1507
1664
|
};
|
|
1508
1665
|
declare function UserButton(props: UserButtonProps): react_jsx_runtime.JSX.Element;
|
|
1509
1666
|
|
|
1510
|
-
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
|
|
1667
|
+
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 GetCurrentUserOptions, type GetCurrentUserOptions 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, getConvexProvidersConfig, stackAppInternalsSymbol, useStackApp, useUser };
|