@stackframe/js 2.8.1 → 2.8.3
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 +20 -0
- package/dist/esm/lib/auth.js +6 -6
- package/dist/esm/lib/auth.js.map +1 -1
- package/dist/esm/lib/stack-app/api-keys/index.js +14 -6
- package/dist/esm/lib/stack-app/api-keys/index.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js +23 -20
- 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 +98 -19
- 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 +1 -1
- 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 +108 -11
- 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/server-app.js.map +1 -1
- package/dist/esm/lib/stack-app/index.js.map +1 -1
- package/dist/esm/lib/stack-app/internal-api-keys/index.js +14 -0
- package/dist/esm/lib/stack-app/internal-api-keys/index.js.map +1 -0
- package/dist/esm/lib/stack-app/projects/index.js +3 -1
- package/dist/esm/lib/stack-app/projects/index.js.map +1 -1
- package/dist/esm/lib/stack-app/teams/index.js.map +1 -1
- package/dist/esm/lib/stack-app/users/index.js.map +1 -1
- package/dist/esm/utils/url.js +2 -2
- package/dist/esm/utils/url.js.map +1 -1
- package/dist/index.d.mts +91 -34
- package/dist/index.d.ts +91 -34
- package/dist/lib/auth.js +6 -6
- package/dist/lib/auth.js.map +1 -1
- package/dist/lib/stack-app/api-keys/index.js +16 -7
- package/dist/lib/stack-app/api-keys/index.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js +22 -19
- 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 +98 -19
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/common.js +1 -1
- package/dist/lib/stack-app/apps/implementations/common.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js +108 -11
- 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/server-app.js.map +1 -1
- package/dist/lib/stack-app/index.js.map +1 -1
- package/dist/lib/stack-app/internal-api-keys/index.js +39 -0
- package/dist/lib/stack-app/internal-api-keys/index.js.map +1 -0
- package/dist/lib/stack-app/project-configs/index.js.map +1 -1
- package/dist/lib/stack-app/projects/index.js +3 -1
- package/dist/lib/stack-app/projects/index.js.map +1 -1
- package/dist/lib/stack-app/teams/index.js.map +1 -1
- package/dist/lib/stack-app/users/index.js.map +1 -1
- package/dist/utils/url.js +2 -2
- package/dist/utils/url.js.map +1 -1
- package/package.json +3 -2
|
@@ -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 { AsyncStoreProperty } from \"../common\";\nimport { OAuthConnection } from \"../connected-accounts\";\nimport { ContactChannel, ContactChannelCreateOptions, ServerContactChannel, ServerContactChannelCreateOptions } from \"../contact-channels\";\nimport { AdminTeamPermission, TeamPermission } from \"../permissions\";\nimport { AdminOwnedProject, AdminProjectUpdateOptions } from \"../projects\";\nimport { EditableTeamMemberProfile, ServerTeam, ServerTeamCreateOptions, Team, TeamCreateOptions } from \"../teams\";\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 toClientJson(): CurrentUserCrud[\"Client\"][\"Read\"],\n\n /**\n * @deprecated, use contact channel's usedForAuth instead\n */\n readonly emailAuthEnabled: boolean,\n /**\n * @deprecated\n */\n readonly oauthProviders: readonly { id: string }[],\n}\n\nexport type UserExtra = {\n setDisplayName(displayName: string): Promise<void>,\n /** @deprecated Use contact channel's sendVerificationEmail instead */\n sendVerificationEmail(): Promise<KnownErrors[\"EmailAlreadyVerified\"] | void>,\n setClientMetadata(metadata: any): Promise<void>,\n updatePassword(options: { oldPassword: string, newPassword: string}): Promise<KnownErrors[\"PasswordConfirmationMismatch\"] | KnownErrors[\"PasswordRequirementsNotMet\"] | void>,\n setPassword(options: { password: string }): Promise<KnownErrors[\"PasswordRequirementsNotMet\"] | void>,\n\n /**\n * A shorthand method to update multiple fields of the user at once.\n */\n update(update: UserUpdateOptions): Promise<void>,\n\n listContactChannels(): Promise<ContactChannel[]>,\n createContactChannel(data: ContactChannelCreateOptions): Promise<ContactChannel>,\n\n delete(): Promise<void>,\n\n getConnectedAccount(id: ProviderType, options: { or: 'redirect', scopes?: string[] }): Promise<OAuthConnection>,\n getConnectedAccount(id: ProviderType, options?: { or?: 'redirect' | 'throw' | 'return-null', scopes?: string[] }): Promise<OAuthConnection | null>,\n\n\n hasPermission(scope: Team, permissionId: string): Promise<boolean>,\n hasPermission(permissionId: string): Promise<boolean>,\n\n getPermission(scope: Team, permissionId: string): Promise<TeamPermission | null>,\n getPermission(permissionId: string): Promise<TeamPermission | null>,\n\n listPermissions(scope: Team, options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n listPermissions(options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n\n\n readonly selectedTeam: Team | null,\n setSelectedTeam(team: Team | null): Promise<void>,\n createTeam(data: TeamCreateOptions): Promise<Team>,\n leaveTeam(team: Team): Promise<void>,\n\n getActiveSessions(): Promise<ActiveSession[]>,\n revokeSession(sessionId: string): Promise<void>,\n getTeamProfile(team: Team): Promise<EditableTeamMemberProfile>,\n}\n& 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: AdminProjectUpdateOptions & { displayName: string }): Promise<AdminOwnedProject>,\n }\n & AsyncStoreProperty<\"ownedProjects\", [], AdminOwnedProject[], true>\n\nexport type User = BaseUser;\n\nexport type CurrentUser = BaseUser & Auth & UserExtra;\n\nexport type CurrentInternalUser = CurrentUser & InternalUserExtra;\n\nexport type ProjectCurrentUser<ProjectId> = ProjectId extends \"internal\" ? CurrentInternalUser : CurrentUser;\n\n\nexport type ActiveSession = {\n id: string,\n userId: string,\n createdAt: Date,\n isImpersonation: boolean,\n lastUsedAt: Date | undefined,\n isCurrentSession: boolean,\n geoInfo?: GeoInfo,\n};\n\nexport type UserUpdateOptions = {\n displayName?: string,\n clientMetadata?: ReadonlyJson,\n selectedTeamId?: string | null,\n totpMultiFactorSecret?: Uint8Array | null,\n profileImageUrl?: string | null,\n otpAuthEnabled?: boolean,\n passkeyAuthEnabled?:boolean,\n}\nexport function userUpdateOptionsToCrud(options: UserUpdateOptions): CurrentUserCrud[\"Client\"][\"Update\"] {\n return {\n display_name: options.displayName,\n client_metadata: options.clientMetadata,\n selected_team_id: options.selectedTeamId,\n totp_secret_base64: options.totpMultiFactorSecret != null ? encodeBase64(options.totpMultiFactorSecret) : options.totpMultiFactorSecret,\n profile_image_url: options.profileImageUrl,\n otp_auth_enabled: options.otpAuthEnabled,\n passkey_auth_enabled: options.passkeyAuthEnabled,\n };\n}\n\n\nexport type ServerBaseUser = {\n setPrimaryEmail(email: string | null, options?: { verified?: boolean | undefined }): Promise<void>,\n\n readonly lastActiveAt: Date,\n\n readonly serverMetadata: any,\n setServerMetadata(metadata: any): Promise<void>,\n setClientReadOnlyMetadata(metadata: any): Promise<void>,\n\n createTeam(data: Omit<ServerTeamCreateOptions, \"creatorUserId\">): Promise<ServerTeam>,\n\n listContactChannels(): Promise<ServerContactChannel[]>,\n createContactChannel(data: ServerContactChannelCreateOptions): Promise<ServerContactChannel>,\n\n update(user: ServerUserUpdateOptions): Promise<void>,\n\n grantPermission(scope: Team, permissionId: string): Promise<void>,\n revokePermission(scope: Team, permissionId: string): Promise<void>,\n\n getPermission(scope: Team, permissionId: string): Promise<TeamPermission | null>,\n getPermission(permissionId: string): Promise<TeamPermission | null>,\n\n hasPermission(scope: Team, permissionId: string): Promise<boolean>,\n hasPermission(permissionId: string): Promise<boolean>,\n\n listPermissions(scope: Team, options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n listPermissions(options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n\n\n /**\n * Creates a new session object with a refresh token for this user. Can be used to impersonate them.\n */\n createSession(options?: { expiresInMillis?: number, isImpersonation?: boolean }): Promise<Session>,\n}\n& AsyncStoreProperty<\"team\", [id: string], ServerTeam | null, false>\n& AsyncStoreProperty<\"teams\", [], ServerTeam[], true>\n& AsyncStoreProperty<\"permission\", [scope: Team, permissionId: string, options?: { direct?: boolean }], AdminTeamPermission | null, false>\n& AsyncStoreProperty<\"permissions\", [scope: Team, options?: { direct?: boolean }], AdminTeamPermission[], true>;\n\n/**\n * A user including sensitive fields that should only be used on the server, never sent to the client\n * (such as sensitive information and serverMetadata).\n */\nexport type ServerUser = ServerBaseUser & BaseUser & UserExtra;\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;AA6OtB,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;AA+DO,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 { AdminTeamPermission, TeamPermission } from \"../permissions\";\nimport { AdminOwnedProject, AdminProjectUpdateOptions } from \"../projects\";\nimport { EditableTeamMemberProfile, ServerTeam, ServerTeamCreateOptions, Team, TeamCreateOptions } from \"../teams\";\n\n\nexport type Session = {\n getTokens(): Promise<{ accessToken: string | null, refreshToken: string | null }>,\n};\n\n/**\n * Contains everything related to the current user session.\n */\nexport type Auth = {\n readonly _internalSession: InternalSession,\n readonly currentSession: Session,\n signOut(options?: { redirectUrl?: URL | string }): Promise<void>,\n\n /**\n * Returns headers for sending authenticated HTTP requests to external servers. Most commonly used in cross-origin\n * requests. Similar to `getAuthJson`, but specifically for HTTP requests.\n *\n * If you are using `tokenStore: \"cookie\"`, you don't need this for same-origin requests. However, most\n * browsers now disable third-party cookies by default, so we must pass authentication tokens by header instead\n * if the client and server are on different origins.\n *\n * This function returns a header object that can be used with `fetch` or other HTTP request libraries to send\n * authenticated requests.\n *\n * On the server, you can then pass in the `Request` object to the `tokenStore` option\n * of your Stack app. Please note that CORS does not allow most headers by default, so you\n * must include `x-stack-auth` in the [`Access-Control-Allow-Headers` header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers)\n * of the CORS preflight response.\n *\n * If you are not using HTTP (and hence cannot set headers), you will need to use the `getAuthJson()` function\n * instead.\n *\n * Example:\n *\n * ```ts\n * // client\n * const res = await fetch(\"https://api.example.com\", {\n * headers: {\n * ...await stackApp.getAuthHeaders()\n * // you can also add your own headers here\n * },\n * });\n *\n * // server\n * function handleRequest(req: Request) {\n * const user = await stackServerApp.getUser({ tokenStore: req });\n * return new Response(\"Welcome, \" + user.displayName);\n * }\n * ```\n */\n getAuthHeaders(): Promise<{ \"x-stack-auth\": string }>,\n\n /**\n * Creates a JSON-serializable object containing the information to authenticate a user on an external server.\n * Similar to `getAuthHeaders`, but returns an object that can be sent over any protocol instead of just\n * HTTP headers.\n *\n * While `getAuthHeaders` is the recommended way to send authentication tokens over HTTP, your app may use\n * a different protocol, for example WebSockets or gRPC. This function returns a token object that can be JSON-serialized and sent to the server in any way you like.\n *\n * On the server, you can pass in this token object into the `tokenStore` option to fetch user details.\n *\n * Example:\n *\n * ```ts\n * // client\n * const res = await rpcCall(rpcEndpoint, {\n * data: {\n * auth: await stackApp.getAuthJson(),\n * },\n * });\n *\n * // server\n * function handleRequest(data) {\n * const user = await stackServerApp.getUser({ tokenStore: data.auth });\n * return new Response(\"Welcome, \" + user.displayName);\n * }\n * ```\n */\n getAuthJson(): Promise<{ accessToken: string | null, refreshToken: string | null }>,\n registerPasskey(options?: { hostname?: string }): Promise<Result<undefined, KnownErrors[\"PasskeyRegistrationFailed\"] | KnownErrors[\"PasskeyWebAuthnError\"]>>,\n};\n\n/**\n * ```\n * +----------+-------------+-------------------+\n * | \\ | !Server | Server |\n * +----------+-------------+-------------------+\n * | !Session | User | ServerUser |\n * | Session | CurrentUser | CurrentServerUser |\n * +----------+-------------+-------------------+\n * ```\n *\n * The fields on each of these types are available iff:\n * BaseUser: true\n * Auth: Session\n * ServerBaseUser: Server\n * UserExtra: Session OR Server\n *\n * The types are defined as follows (in the typescript manner):\n * User = BaseUser\n * CurrentUser = BaseUser & Auth & UserExtra\n * ServerUser = BaseUser & ServerBaseUser & UserExtra\n * CurrentServerUser = BaseUser & ServerBaseUser & Auth & UserExtra\n **/\n\nexport type BaseUser = {\n readonly id: string,\n\n readonly displayName: string | null,\n\n /**\n * The user's email address.\n *\n * Note: This might NOT be unique across multiple users, so always use `id` for unique identification.\n */\n readonly primaryEmail: string | null,\n readonly primaryEmailVerified: boolean,\n readonly profileImageUrl: string | null,\n\n readonly signedUpAt: Date,\n\n readonly clientMetadata: any,\n readonly clientReadOnlyMetadata: any,\n\n /**\n * Whether the user has a password set.\n */\n readonly hasPassword: boolean,\n readonly otpAuthEnabled: boolean,\n readonly passkeyAuthEnabled: boolean,\n\n readonly isMultiFactorRequired: boolean,\n readonly isAnonymous: boolean,\n toClientJson(): CurrentUserCrud[\"Client\"][\"Read\"],\n\n /**\n * @deprecated, use contact channel's usedForAuth instead\n */\n readonly emailAuthEnabled: boolean,\n /**\n * @deprecated\n */\n readonly oauthProviders: readonly { id: string }[],\n}\n\nexport type UserExtra = {\n setDisplayName(displayName: string): Promise<void>,\n /** @deprecated Use contact channel's sendVerificationEmail instead */\n sendVerificationEmail(): Promise<KnownErrors[\"EmailAlreadyVerified\"] | void>,\n setClientMetadata(metadata: any): Promise<void>,\n updatePassword(options: { oldPassword: string, newPassword: string}): Promise<KnownErrors[\"PasswordConfirmationMismatch\"] | KnownErrors[\"PasswordRequirementsNotMet\"] | void>,\n setPassword(options: { password: string }): Promise<KnownErrors[\"PasswordRequirementsNotMet\"] | void>,\n\n /**\n * A shorthand method to update multiple fields of the user at once.\n */\n update(update: UserUpdateOptions): Promise<void>,\n\n listContactChannels(): Promise<ContactChannel[]>,\n createContactChannel(data: ContactChannelCreateOptions): Promise<ContactChannel>,\n\n delete(): Promise<void>,\n\n getConnectedAccount(id: ProviderType, options: { or: 'redirect', scopes?: string[] }): Promise<OAuthConnection>,\n getConnectedAccount(id: ProviderType, options?: { or?: 'redirect' | 'throw' | 'return-null', scopes?: string[] }): Promise<OAuthConnection | null>,\n\n\n hasPermission(scope: Team, permissionId: string): Promise<boolean>,\n hasPermission(permissionId: string): Promise<boolean>,\n\n getPermission(scope: Team, permissionId: string): Promise<TeamPermission | null>,\n getPermission(permissionId: string): Promise<TeamPermission | null>,\n\n listPermissions(scope: Team, options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n listPermissions(options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n\n\n readonly selectedTeam: Team | null,\n setSelectedTeam(team: Team | null): Promise<void>,\n createTeam(data: TeamCreateOptions): Promise<Team>,\n leaveTeam(team: Team): Promise<void>,\n\n getActiveSessions(): Promise<ActiveSession[]>,\n revokeSession(sessionId: string): Promise<void>,\n getTeamProfile(team: Team): Promise<EditableTeamMemberProfile>,\n\n createApiKey(options: ApiKeyCreationOptions<\"user\">): Promise<UserApiKeyFirstView>,\n}\n& AsyncStoreProperty<\"apiKeys\", [], UserApiKey[], true>\n& AsyncStoreProperty<\"team\", [id: string], Team | null, false>\n& AsyncStoreProperty<\"teams\", [], Team[], true>\n& AsyncStoreProperty<\"permission\", [scope: Team, permissionId: string, options?: { recursive?: boolean }], TeamPermission | null, false>\n& AsyncStoreProperty<\"permissions\", [scope: Team, options?: { recursive?: boolean }], TeamPermission[], true>;\n\nexport type InternalUserExtra =\n & {\n createProject(newProject: AdminProjectUpdateOptions & { displayName: string }): Promise<AdminOwnedProject>,\n }\n & AsyncStoreProperty<\"ownedProjects\", [], AdminOwnedProject[], true>\n\nexport type User = BaseUser;\n\nexport type CurrentUser = BaseUser & Auth & UserExtra;\n\nexport type CurrentInternalUser = CurrentUser & InternalUserExtra;\n\nexport type ProjectCurrentUser<ProjectId> = ProjectId extends \"internal\" ? CurrentInternalUser : CurrentUser;\n\n\nexport type ActiveSession = {\n id: string,\n userId: string,\n createdAt: Date,\n isImpersonation: boolean,\n lastUsedAt: Date | undefined,\n isCurrentSession: boolean,\n geoInfo?: GeoInfo,\n};\n\nexport type UserUpdateOptions = {\n displayName?: string,\n clientMetadata?: ReadonlyJson,\n selectedTeamId?: string | null,\n totpMultiFactorSecret?: Uint8Array | null,\n profileImageUrl?: string | null,\n otpAuthEnabled?: boolean,\n passkeyAuthEnabled?:boolean,\n}\nexport function userUpdateOptionsToCrud(options: UserUpdateOptions): CurrentUserCrud[\"Client\"][\"Update\"] {\n return {\n display_name: options.displayName,\n client_metadata: options.clientMetadata,\n selected_team_id: options.selectedTeamId,\n totp_secret_base64: options.totpMultiFactorSecret != null ? encodeBase64(options.totpMultiFactorSecret) : options.totpMultiFactorSecret,\n profile_image_url: options.profileImageUrl,\n otp_auth_enabled: options.otpAuthEnabled,\n passkey_auth_enabled: options.passkeyAuthEnabled,\n };\n}\n\n\nexport type ServerBaseUser = {\n setPrimaryEmail(email: string | null, options?: { verified?: boolean | undefined }): Promise<void>,\n\n readonly lastActiveAt: Date,\n\n readonly serverMetadata: any,\n setServerMetadata(metadata: any): Promise<void>,\n setClientReadOnlyMetadata(metadata: any): Promise<void>,\n\n createTeam(data: Omit<ServerTeamCreateOptions, \"creatorUserId\">): Promise<ServerTeam>,\n\n listContactChannels(): Promise<ServerContactChannel[]>,\n createContactChannel(data: ServerContactChannelCreateOptions): Promise<ServerContactChannel>,\n\n update(user: ServerUserUpdateOptions): Promise<void>,\n\n grantPermission(scope: Team, permissionId: string): Promise<void>,\n revokePermission(scope: Team, permissionId: string): Promise<void>,\n\n getPermission(scope: Team, permissionId: string): Promise<TeamPermission | null>,\n getPermission(permissionId: string): Promise<TeamPermission | null>,\n\n hasPermission(scope: Team, permissionId: string): Promise<boolean>,\n hasPermission(permissionId: string): Promise<boolean>,\n\n listPermissions(scope: Team, options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n listPermissions(options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n\n\n /**\n * Creates a new session object with a refresh token for this user. Can be used to impersonate them.\n */\n createSession(options?: { expiresInMillis?: number, isImpersonation?: boolean }): Promise<Session>,\n}\n& AsyncStoreProperty<\"team\", [id: string], ServerTeam | null, false>\n& AsyncStoreProperty<\"teams\", [], ServerTeam[], true>\n& AsyncStoreProperty<\"permission\", [scope: Team, permissionId: string, options?: { direct?: boolean }], AdminTeamPermission | null, false>\n& AsyncStoreProperty<\"permissions\", [scope: Team, options?: { direct?: boolean }], AdminTeamPermission[], true>;\n\n/**\n * A user including sensitive fields that should only be used on the server, never sent to the client\n * (such as sensitive information and serverMetadata).\n */\nexport type ServerUser = ServerBaseUser & BaseUser & UserExtra;\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;AAkPtB,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;AA+DO,SAAS,8BAA8B,SAAuE;AACnH,SAAO;AAAA,IACL,cAAc,QAAQ;AAAA,IACtB,eAAe,QAAQ;AAAA,IACvB,iBAAiB,QAAQ;AAAA,IACzB,2BAA2B,QAAQ;AAAA,IACnC,iBAAiB,QAAQ;AAAA,IACzB,kBAAkB,QAAQ;AAAA,IAC1B,4BAA4B,QAAQ;AAAA,IACpC,wBAAwB,QAAQ;AAAA,IAChC,UAAU,QAAQ;AAAA,IAClB,mBAAmB,QAAQ;AAAA,IAC3B,oBAAoB,QAAQ,yBAAyB,OAAO,aAAa,QAAQ,qBAAqB,IAAI,QAAQ;AAAA,EACpH;AACF;AAcO,SAAS,8BAA8B,SAAiE;AAC7G,SAAO;AAAA,IACL,eAAe,QAAQ;AAAA,IACvB,UAAU,QAAQ;AAAA,IAClB,kBAAkB,QAAQ;AAAA,IAC1B,4BAA4B,QAAQ;AAAA,IACpC,cAAc,QAAQ;AAAA,IACtB,wBAAwB,QAAQ;AAAA,IAChC,iBAAiB,QAAQ;AAAA,IACzB,2BAA2B,QAAQ;AAAA,IACnC,iBAAiB,QAAQ;AAAA,EAC3B;AACF;","names":[]}
|
package/dist/esm/utils/url.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/utils/url.ts
|
|
2
2
|
import { StackAssertionError } from "@stackframe/stack-shared/dist/utils/errors";
|
|
3
|
-
function constructRedirectUrl(redirectUrl) {
|
|
3
|
+
function constructRedirectUrl(redirectUrl, callbackUrlName) {
|
|
4
4
|
if (typeof window === "undefined" || !window.location) {
|
|
5
|
-
throw new StackAssertionError(
|
|
5
|
+
throw new StackAssertionError(`${callbackUrlName} option is required in a non-browser environment.`, { redirectUrl });
|
|
6
6
|
}
|
|
7
7
|
const retainedQueryParams = ["after_auth_return_to"];
|
|
8
8
|
const currentUrl = new URL(window.location.href);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/url.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { StackAssertionError } from \"@stackframe/stack-shared/dist/utils/errors\";\n\n\nexport function constructRedirectUrl(redirectUrl: URL | string | undefined) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (typeof window === 'undefined' || !window.location) {\n throw new StackAssertionError(
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/url.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { StackAssertionError } from \"@stackframe/stack-shared/dist/utils/errors\";\n\n\nexport function constructRedirectUrl(redirectUrl: URL | string | undefined, callbackUrlName: string) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (typeof window === 'undefined' || !window.location) {\n throw new StackAssertionError(`${callbackUrlName} option is required in a non-browser environment.`, { redirectUrl });\n }\n\n const retainedQueryParams = [\"after_auth_return_to\"];\n const currentUrl = new URL(window.location.href);\n const url = redirectUrl ? new URL(redirectUrl, window.location.href) : new URL(window.location.href);\n for (const param of retainedQueryParams) {\n if (currentUrl.searchParams.has(param)) {\n url.searchParams.set(param, currentUrl.searchParams.get(param)!);\n }\n }\n url.hash = \"\";\n return url.toString();\n}\n"],"mappings":";AAIA,SAAS,2BAA2B;AAG7B,SAAS,qBAAqB,aAAuC,iBAAyB;AAEnG,MAAI,OAAO,WAAW,eAAe,CAAC,OAAO,UAAU;AACrD,UAAM,IAAI,oBAAoB,GAAG,eAAe,qDAAqD,EAAE,YAAY,CAAC;AAAA,EACtH;AAEA,QAAM,sBAAsB,CAAC,sBAAsB;AACnD,QAAM,aAAa,IAAI,IAAI,OAAO,SAAS,IAAI;AAC/C,QAAM,MAAM,cAAc,IAAI,IAAI,aAAa,OAAO,SAAS,IAAI,IAAI,IAAI,IAAI,OAAO,SAAS,IAAI;AACnG,aAAW,SAAS,qBAAqB;AACvC,QAAI,WAAW,aAAa,IAAI,KAAK,GAAG;AACtC,UAAI,aAAa,IAAI,OAAO,WAAW,aAAa,IAAI,KAAK,CAAE;AAAA,IACjE;AAAA,EACF;AACA,MAAI,OAAO;AACX,SAAO,IAAI,SAAS;AACtB;","names":[]}
|
package/dist/index.d.mts
CHANGED
|
@@ -5,8 +5,9 @@ import { ProviderType } from '@stackframe/stack-shared/dist/utils/oauth';
|
|
|
5
5
|
import { ProductionModeError } from '@stackframe/stack-shared/dist/helpers/production-mode';
|
|
6
6
|
import { EmailTemplateType } from '@stackframe/stack-shared/dist/interface/crud/email-templates';
|
|
7
7
|
import { InternalSession } from '@stackframe/stack-shared/dist/sessions';
|
|
8
|
-
import {
|
|
8
|
+
import { InternalApiKeysCrud } from '@stackframe/stack-shared/dist/interface/crud/internal-api-keys';
|
|
9
9
|
import { ReadonlyJson } from '@stackframe/stack-shared/dist/utils/json';
|
|
10
|
+
import { PrettifyType, IfAndOnlyIf } from '@stackframe/stack-shared/dist/utils/types';
|
|
10
11
|
import { GeoInfo } from '@stackframe/stack-shared/dist/utils/geo';
|
|
11
12
|
|
|
12
13
|
type RedirectToOptions = {
|
|
@@ -67,7 +68,27 @@ type OAuthScopesOnSignIn = {
|
|
|
67
68
|
/** @internal */
|
|
68
69
|
declare const stackAppInternalsSymbol: unique symbol;
|
|
69
70
|
|
|
70
|
-
type
|
|
71
|
+
type AdminSentEmail = {
|
|
72
|
+
id: string;
|
|
73
|
+
to: string[];
|
|
74
|
+
subject: string;
|
|
75
|
+
recipient: string;
|
|
76
|
+
sentAt: Date;
|
|
77
|
+
error?: unknown;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
type AdminEmailTemplate = {
|
|
81
|
+
type: EmailTemplateType;
|
|
82
|
+
subject: string;
|
|
83
|
+
content: any;
|
|
84
|
+
isDefault: boolean;
|
|
85
|
+
};
|
|
86
|
+
type AdminEmailTemplateUpdateOptions = {
|
|
87
|
+
subject?: string;
|
|
88
|
+
content?: any;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
type InternalApiKeyBase = {
|
|
71
92
|
id: string;
|
|
72
93
|
description: string;
|
|
73
94
|
expiresAt: Date;
|
|
@@ -77,13 +98,13 @@ type ApiKeyBase = {
|
|
|
77
98
|
whyInvalid(): "expired" | "manually-revoked" | null;
|
|
78
99
|
revoke(): Promise<void>;
|
|
79
100
|
};
|
|
80
|
-
type
|
|
81
|
-
type
|
|
101
|
+
type InternalApiKeyBaseCrudRead = Pick<InternalApiKeysCrud["Admin"]["Read"], "id" | "created_at_millis" | "description" | "expires_at_millis" | "manually_revoked_at_millis">;
|
|
102
|
+
type InternalApiKeyFirstView = {
|
|
82
103
|
publishableClientKey?: string;
|
|
83
104
|
secretServerKey?: string;
|
|
84
105
|
superSecretAdminKey?: string;
|
|
85
|
-
} &
|
|
86
|
-
type
|
|
106
|
+
} & InternalApiKeyBase;
|
|
107
|
+
type InternalApiKey = {
|
|
87
108
|
publishableClientKey: null | {
|
|
88
109
|
lastFour: string;
|
|
89
110
|
};
|
|
@@ -93,8 +114,8 @@ type ApiKey = {
|
|
|
93
114
|
superSecretAdminKey: null | {
|
|
94
115
|
lastFour: string;
|
|
95
116
|
};
|
|
96
|
-
} &
|
|
97
|
-
type
|
|
117
|
+
} & InternalApiKeyBase;
|
|
118
|
+
type InternalApiKeyCreateOptions = {
|
|
98
119
|
description: string;
|
|
99
120
|
expiresAt: Date;
|
|
100
121
|
hasPublishableClientKey: boolean;
|
|
@@ -102,26 +123,6 @@ type ApiKeyCreateOptions = {
|
|
|
102
123
|
hasSuperSecretAdminKey: boolean;
|
|
103
124
|
};
|
|
104
125
|
|
|
105
|
-
type AdminSentEmail = {
|
|
106
|
-
id: string;
|
|
107
|
-
to: string[];
|
|
108
|
-
subject: string;
|
|
109
|
-
recipient: string;
|
|
110
|
-
sentAt: Date;
|
|
111
|
-
error?: unknown;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
type AdminEmailTemplate = {
|
|
115
|
-
type: EmailTemplateType;
|
|
116
|
-
subject: string;
|
|
117
|
-
content: any;
|
|
118
|
-
isDefault: boolean;
|
|
119
|
-
};
|
|
120
|
-
type AdminEmailTemplateUpdateOptions = {
|
|
121
|
-
subject?: string;
|
|
122
|
-
content?: any;
|
|
123
|
-
};
|
|
124
|
-
|
|
125
126
|
type TeamPermission = {
|
|
126
127
|
id: string;
|
|
127
128
|
};
|
|
@@ -155,6 +156,46 @@ type AdminProjectPermissionDefinitionCreateOptions = {
|
|
|
155
156
|
};
|
|
156
157
|
type AdminProjectPermissionDefinitionUpdateOptions = Partial<AdminProjectPermissionDefinitionCreateOptions>;
|
|
157
158
|
|
|
159
|
+
type ApiKeyType = "user" | "team";
|
|
160
|
+
type ApiKey<Type extends ApiKeyType = ApiKeyType, IsFirstView extends boolean = false> = {
|
|
161
|
+
id: string;
|
|
162
|
+
description: string;
|
|
163
|
+
expiresAt?: Date;
|
|
164
|
+
manuallyRevokedAt?: Date | null;
|
|
165
|
+
createdAt: Date;
|
|
166
|
+
value: IfAndOnlyIf<IsFirstView, true, string, {
|
|
167
|
+
lastFour: string;
|
|
168
|
+
}>;
|
|
169
|
+
update(options: ApiKeyUpdateOptions<Type>): Promise<void>;
|
|
170
|
+
revoke: () => Promise<void>;
|
|
171
|
+
isValid: () => boolean;
|
|
172
|
+
whyInvalid: () => "manually-revoked" | "expired" | null;
|
|
173
|
+
} & (("user" extends Type ? {
|
|
174
|
+
type: "user";
|
|
175
|
+
userId: string;
|
|
176
|
+
} : never) | ("team" extends Type ? {
|
|
177
|
+
type: "team";
|
|
178
|
+
teamId: string;
|
|
179
|
+
} : never));
|
|
180
|
+
type UserApiKeyFirstView = PrettifyType<ApiKey<"user", true>>;
|
|
181
|
+
type UserApiKey = PrettifyType<ApiKey<"user", false>>;
|
|
182
|
+
type TeamApiKeyFirstView = PrettifyType<ApiKey<"team", true>>;
|
|
183
|
+
type TeamApiKey = PrettifyType<ApiKey<"team", false>>;
|
|
184
|
+
type ApiKeyCreationOptions<Type extends ApiKeyType = ApiKeyType> = {
|
|
185
|
+
description: string;
|
|
186
|
+
expiresAt: Date | null;
|
|
187
|
+
/**
|
|
188
|
+
* Whether the API key should be considered public. A public API key will not be detected by the secret scanner, which
|
|
189
|
+
* automatically revokes API keys when it detects that they may have been exposed to the public.
|
|
190
|
+
*/
|
|
191
|
+
isPublic?: boolean;
|
|
192
|
+
};
|
|
193
|
+
type ApiKeyUpdateOptions<Type extends ApiKeyType = ApiKeyType> = {
|
|
194
|
+
description?: string;
|
|
195
|
+
expiresAt?: Date | null;
|
|
196
|
+
revoked?: boolean;
|
|
197
|
+
};
|
|
198
|
+
|
|
158
199
|
type Connection = {
|
|
159
200
|
id: string;
|
|
160
201
|
};
|
|
@@ -329,6 +370,7 @@ type BaseUser = {
|
|
|
329
370
|
readonly otpAuthEnabled: boolean;
|
|
330
371
|
readonly passkeyAuthEnabled: boolean;
|
|
331
372
|
readonly isMultiFactorRequired: boolean;
|
|
373
|
+
readonly isAnonymous: boolean;
|
|
332
374
|
toClientJson(): CurrentUserCrud["Client"]["Read"];
|
|
333
375
|
/**
|
|
334
376
|
* @deprecated, use contact channel's usedForAuth instead
|
|
@@ -385,7 +427,8 @@ type UserExtra = {
|
|
|
385
427
|
getActiveSessions(): Promise<ActiveSession[]>;
|
|
386
428
|
revokeSession(sessionId: string): Promise<void>;
|
|
387
429
|
getTeamProfile(team: Team): Promise<EditableTeamMemberProfile>;
|
|
388
|
-
|
|
430
|
+
createApiKey(options: ApiKeyCreationOptions<"user">): Promise<UserApiKeyFirstView>;
|
|
431
|
+
} & AsyncStoreProperty<"apiKeys", [], UserApiKey[], true> & AsyncStoreProperty<"team", [id: string], Team | null, false> & AsyncStoreProperty<"teams", [], Team[], true> & AsyncStoreProperty<"permission", [scope: Team, permissionId: string, options?: {
|
|
389
432
|
recursive?: boolean;
|
|
390
433
|
}], TeamPermission | null, false> & AsyncStoreProperty<"permissions", [scope: Team, options?: {
|
|
391
434
|
recursive?: boolean;
|
|
@@ -516,7 +559,8 @@ type Team = {
|
|
|
516
559
|
listInvitations(): Promise<TeamInvitation[]>;
|
|
517
560
|
update(update: TeamUpdateOptions): Promise<void>;
|
|
518
561
|
delete(): Promise<void>;
|
|
519
|
-
|
|
562
|
+
createApiKey(options: ApiKeyCreationOptions<"team">): Promise<TeamApiKeyFirstView>;
|
|
563
|
+
} & AsyncStoreProperty<"apiKeys", [], TeamApiKey[], true>;
|
|
520
564
|
type TeamUpdateOptions = {
|
|
521
565
|
displayName?: string;
|
|
522
566
|
profileImageUrl?: string | null;
|
|
@@ -583,10 +627,17 @@ type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
583
627
|
}): Promise<ProjectCurrentServerUser<ProjectId>>;
|
|
584
628
|
getUser(options?: GetUserOptions<HasTokenStore>): Promise<ProjectCurrentServerUser<ProjectId> | null>;
|
|
585
629
|
getUser(id: string): Promise<ServerUser | null>;
|
|
630
|
+
getUser(options: {
|
|
631
|
+
apiKey: string;
|
|
632
|
+
}): Promise<ServerUser | null>;
|
|
633
|
+
getTeam(id: string): Promise<ServerTeam | null>;
|
|
634
|
+
getTeam(options: {
|
|
635
|
+
apiKey: string;
|
|
636
|
+
}): Promise<ServerTeam | null>;
|
|
586
637
|
listUsers(options?: ServerListUsersOptions): Promise<ServerUser[] & {
|
|
587
638
|
nextCursor: string | null;
|
|
588
639
|
}>;
|
|
589
|
-
} & AsyncStoreProperty<"user", [id: string], ServerUser | null, false> & Omit<AsyncStoreProperty<"users", [], ServerUser[], true>, "listUsers" | "useUsers"> & AsyncStoreProperty<"
|
|
640
|
+
} & AsyncStoreProperty<"user", [id: string], ServerUser | null, false> & Omit<AsyncStoreProperty<"users", [], ServerUser[], true>, "listUsers" | "useUsers"> & AsyncStoreProperty<"teams", [], ServerTeam[], true> & StackClientApp<HasTokenStore, ProjectId>);
|
|
590
641
|
declare const StackServerApp: StackServerAppConstructor;
|
|
591
642
|
|
|
592
643
|
type StackAdminAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = ((StackServerAppConstructorOptions<HasTokenStore, ProjectId> & {
|
|
@@ -598,11 +649,11 @@ type StackAdminAppConstructor = {
|
|
|
598
649
|
new <HasTokenStore extends boolean, ProjectId extends string>(options: StackAdminAppConstructorOptions<HasTokenStore, ProjectId>): StackAdminApp<HasTokenStore, ProjectId>;
|
|
599
650
|
new (options: StackAdminAppConstructorOptions<boolean, string>): StackAdminApp<boolean, string>;
|
|
600
651
|
};
|
|
601
|
-
type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = (AsyncStoreProperty<"project", [], AdminProject, false> & AsyncStoreProperty<"
|
|
652
|
+
type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = (AsyncStoreProperty<"project", [], AdminProject, false> & AsyncStoreProperty<"internalApiKeys", [], InternalApiKey[], true> & AsyncStoreProperty<"teamPermissionDefinitions", [], AdminTeamPermissionDefinition[], true> & AsyncStoreProperty<"projectPermissionDefinitions", [], AdminProjectPermissionDefinition[], true> & {
|
|
602
653
|
listEmailTemplates(): Promise<AdminEmailTemplate[]>;
|
|
603
654
|
updateEmailTemplate(type: EmailTemplateType, data: AdminEmailTemplateUpdateOptions): Promise<void>;
|
|
604
655
|
resetEmailTemplate(type: EmailTemplateType): Promise<void>;
|
|
605
|
-
|
|
656
|
+
createInternalApiKey(options: InternalApiKeyCreateOptions): Promise<InternalApiKeyFirstView>;
|
|
606
657
|
createTeamPermissionDefinition(data: AdminTeamPermissionDefinitionCreateOptions): Promise<AdminTeamPermission>;
|
|
607
658
|
updateTeamPermissionDefinition(permissionId: string, data: AdminTeamPermissionDefinitionUpdateOptions): Promise<void>;
|
|
608
659
|
deleteTeamPermissionDefinition(permissionId: string): Promise<void>;
|
|
@@ -627,6 +678,8 @@ type ProjectConfig = {
|
|
|
627
678
|
readonly clientTeamCreationEnabled: boolean;
|
|
628
679
|
readonly clientUserDeletionEnabled: boolean;
|
|
629
680
|
readonly oauthProviders: OAuthProviderConfig[];
|
|
681
|
+
readonly allowUserApiKeys: boolean;
|
|
682
|
+
readonly allowTeamApiKeys: boolean;
|
|
630
683
|
};
|
|
631
684
|
type OAuthProviderConfig = {
|
|
632
685
|
readonly id: string;
|
|
@@ -648,6 +701,8 @@ type AdminProjectConfig = {
|
|
|
648
701
|
readonly teamMemberDefaultPermissions: AdminTeamPermission[];
|
|
649
702
|
readonly userDefaultPermissions: AdminTeamPermission[];
|
|
650
703
|
readonly oauthAccountMergeStrategy: 'link_method' | 'raise_error' | 'allow_duplicates';
|
|
704
|
+
readonly allowUserApiKeys: boolean;
|
|
705
|
+
readonly allowTeamApiKeys: boolean;
|
|
651
706
|
};
|
|
652
707
|
type AdminEmailConfig = ({
|
|
653
708
|
type: "standard";
|
|
@@ -701,6 +756,8 @@ type AdminProjectConfigUpdateOptions = {
|
|
|
701
756
|
id: string;
|
|
702
757
|
}[];
|
|
703
758
|
oauthAccountMergeStrategy?: 'link_method' | 'raise_error' | 'allow_duplicates';
|
|
759
|
+
allowUserApiKeys?: boolean;
|
|
760
|
+
allowTeamApiKeys?: boolean;
|
|
704
761
|
};
|
|
705
762
|
|
|
706
763
|
type Project = {
|
|
@@ -822,4 +879,4 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
822
879
|
});
|
|
823
880
|
declare const StackClientApp: StackClientAppConstructor;
|
|
824
881
|
|
|
825
|
-
export { type AdminDomainConfig, type AdminEmailConfig, type AdminOAuthProviderConfig, type AdminOwnedProject, type AdminProject, type AdminProjectConfig, type AdminProjectConfigUpdateOptions, type AdminProjectCreateOptions, type AdminProjectPermission, type AdminProjectPermissionDefinition, type AdminProjectPermissionDefinitionCreateOptions, type AdminProjectPermissionDefinitionUpdateOptions, type AdminProjectUpdateOptions, type AdminSentEmail, type AdminTeamPermission, type AdminTeamPermissionDefinition, type AdminTeamPermissionDefinitionCreateOptions, type AdminTeamPermissionDefinitionUpdateOptions, type
|
|
882
|
+
export { type AdminDomainConfig, type AdminEmailConfig, type AdminOAuthProviderConfig, type AdminOwnedProject, type AdminProject, type AdminProjectConfig, type AdminProjectConfigUpdateOptions, type AdminProjectCreateOptions, type AdminProjectPermission, type AdminProjectPermissionDefinition, type AdminProjectPermissionDefinitionCreateOptions, type AdminProjectPermissionDefinitionUpdateOptions, type AdminProjectUpdateOptions, type AdminSentEmail, type AdminTeamPermission, type AdminTeamPermissionDefinition, type AdminTeamPermissionDefinitionCreateOptions, type AdminTeamPermissionDefinitionUpdateOptions, type Auth, type Connection, type ContactChannel, type CurrentInternalServerUser, type CurrentInternalUser, type CurrentServerUser, type CurrentUser, type EditableTeamMemberProfile, type GetUserOptions, type HandlerUrls, type InternalApiKey, type InternalApiKeyBase, type InternalApiKeyBaseCrudRead, type InternalApiKeyCreateOptions, type InternalApiKeyFirstView, type OAuthConnection, type OAuthProviderConfig, type OAuthScopesOnSignIn, type Project, type ProjectConfig, type ServerContactChannel, type ServerListUsersOptions, type ServerTeam, type ServerTeamCreateOptions, type ServerTeamMemberProfile, type ServerTeamUpdateOptions, type ServerTeamUser, type ServerUser, type Session, StackAdminApp, type StackAdminAppConstructor, type StackAdminAppConstructorOptions, StackClientApp, type StackClientAppConstructor, type StackClientAppConstructorOptions, type StackClientAppJson, StackServerApp, type StackServerAppConstructor, type StackServerAppConstructorOptions, type Team, type TeamCreateOptions, type TeamInvitation, type TeamMemberProfile, type TeamUpdateOptions, type TeamUser, type User, stackAppInternalsSymbol };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,8 +5,9 @@ import { ProviderType } from '@stackframe/stack-shared/dist/utils/oauth';
|
|
|
5
5
|
import { ProductionModeError } from '@stackframe/stack-shared/dist/helpers/production-mode';
|
|
6
6
|
import { EmailTemplateType } from '@stackframe/stack-shared/dist/interface/crud/email-templates';
|
|
7
7
|
import { InternalSession } from '@stackframe/stack-shared/dist/sessions';
|
|
8
|
-
import {
|
|
8
|
+
import { InternalApiKeysCrud } from '@stackframe/stack-shared/dist/interface/crud/internal-api-keys';
|
|
9
9
|
import { ReadonlyJson } from '@stackframe/stack-shared/dist/utils/json';
|
|
10
|
+
import { PrettifyType, IfAndOnlyIf } from '@stackframe/stack-shared/dist/utils/types';
|
|
10
11
|
import { GeoInfo } from '@stackframe/stack-shared/dist/utils/geo';
|
|
11
12
|
|
|
12
13
|
type RedirectToOptions = {
|
|
@@ -67,7 +68,27 @@ type OAuthScopesOnSignIn = {
|
|
|
67
68
|
/** @internal */
|
|
68
69
|
declare const stackAppInternalsSymbol: unique symbol;
|
|
69
70
|
|
|
70
|
-
type
|
|
71
|
+
type AdminSentEmail = {
|
|
72
|
+
id: string;
|
|
73
|
+
to: string[];
|
|
74
|
+
subject: string;
|
|
75
|
+
recipient: string;
|
|
76
|
+
sentAt: Date;
|
|
77
|
+
error?: unknown;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
type AdminEmailTemplate = {
|
|
81
|
+
type: EmailTemplateType;
|
|
82
|
+
subject: string;
|
|
83
|
+
content: any;
|
|
84
|
+
isDefault: boolean;
|
|
85
|
+
};
|
|
86
|
+
type AdminEmailTemplateUpdateOptions = {
|
|
87
|
+
subject?: string;
|
|
88
|
+
content?: any;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
type InternalApiKeyBase = {
|
|
71
92
|
id: string;
|
|
72
93
|
description: string;
|
|
73
94
|
expiresAt: Date;
|
|
@@ -77,13 +98,13 @@ type ApiKeyBase = {
|
|
|
77
98
|
whyInvalid(): "expired" | "manually-revoked" | null;
|
|
78
99
|
revoke(): Promise<void>;
|
|
79
100
|
};
|
|
80
|
-
type
|
|
81
|
-
type
|
|
101
|
+
type InternalApiKeyBaseCrudRead = Pick<InternalApiKeysCrud["Admin"]["Read"], "id" | "created_at_millis" | "description" | "expires_at_millis" | "manually_revoked_at_millis">;
|
|
102
|
+
type InternalApiKeyFirstView = {
|
|
82
103
|
publishableClientKey?: string;
|
|
83
104
|
secretServerKey?: string;
|
|
84
105
|
superSecretAdminKey?: string;
|
|
85
|
-
} &
|
|
86
|
-
type
|
|
106
|
+
} & InternalApiKeyBase;
|
|
107
|
+
type InternalApiKey = {
|
|
87
108
|
publishableClientKey: null | {
|
|
88
109
|
lastFour: string;
|
|
89
110
|
};
|
|
@@ -93,8 +114,8 @@ type ApiKey = {
|
|
|
93
114
|
superSecretAdminKey: null | {
|
|
94
115
|
lastFour: string;
|
|
95
116
|
};
|
|
96
|
-
} &
|
|
97
|
-
type
|
|
117
|
+
} & InternalApiKeyBase;
|
|
118
|
+
type InternalApiKeyCreateOptions = {
|
|
98
119
|
description: string;
|
|
99
120
|
expiresAt: Date;
|
|
100
121
|
hasPublishableClientKey: boolean;
|
|
@@ -102,26 +123,6 @@ type ApiKeyCreateOptions = {
|
|
|
102
123
|
hasSuperSecretAdminKey: boolean;
|
|
103
124
|
};
|
|
104
125
|
|
|
105
|
-
type AdminSentEmail = {
|
|
106
|
-
id: string;
|
|
107
|
-
to: string[];
|
|
108
|
-
subject: string;
|
|
109
|
-
recipient: string;
|
|
110
|
-
sentAt: Date;
|
|
111
|
-
error?: unknown;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
type AdminEmailTemplate = {
|
|
115
|
-
type: EmailTemplateType;
|
|
116
|
-
subject: string;
|
|
117
|
-
content: any;
|
|
118
|
-
isDefault: boolean;
|
|
119
|
-
};
|
|
120
|
-
type AdminEmailTemplateUpdateOptions = {
|
|
121
|
-
subject?: string;
|
|
122
|
-
content?: any;
|
|
123
|
-
};
|
|
124
|
-
|
|
125
126
|
type TeamPermission = {
|
|
126
127
|
id: string;
|
|
127
128
|
};
|
|
@@ -155,6 +156,46 @@ type AdminProjectPermissionDefinitionCreateOptions = {
|
|
|
155
156
|
};
|
|
156
157
|
type AdminProjectPermissionDefinitionUpdateOptions = Partial<AdminProjectPermissionDefinitionCreateOptions>;
|
|
157
158
|
|
|
159
|
+
type ApiKeyType = "user" | "team";
|
|
160
|
+
type ApiKey<Type extends ApiKeyType = ApiKeyType, IsFirstView extends boolean = false> = {
|
|
161
|
+
id: string;
|
|
162
|
+
description: string;
|
|
163
|
+
expiresAt?: Date;
|
|
164
|
+
manuallyRevokedAt?: Date | null;
|
|
165
|
+
createdAt: Date;
|
|
166
|
+
value: IfAndOnlyIf<IsFirstView, true, string, {
|
|
167
|
+
lastFour: string;
|
|
168
|
+
}>;
|
|
169
|
+
update(options: ApiKeyUpdateOptions<Type>): Promise<void>;
|
|
170
|
+
revoke: () => Promise<void>;
|
|
171
|
+
isValid: () => boolean;
|
|
172
|
+
whyInvalid: () => "manually-revoked" | "expired" | null;
|
|
173
|
+
} & (("user" extends Type ? {
|
|
174
|
+
type: "user";
|
|
175
|
+
userId: string;
|
|
176
|
+
} : never) | ("team" extends Type ? {
|
|
177
|
+
type: "team";
|
|
178
|
+
teamId: string;
|
|
179
|
+
} : never));
|
|
180
|
+
type UserApiKeyFirstView = PrettifyType<ApiKey<"user", true>>;
|
|
181
|
+
type UserApiKey = PrettifyType<ApiKey<"user", false>>;
|
|
182
|
+
type TeamApiKeyFirstView = PrettifyType<ApiKey<"team", true>>;
|
|
183
|
+
type TeamApiKey = PrettifyType<ApiKey<"team", false>>;
|
|
184
|
+
type ApiKeyCreationOptions<Type extends ApiKeyType = ApiKeyType> = {
|
|
185
|
+
description: string;
|
|
186
|
+
expiresAt: Date | null;
|
|
187
|
+
/**
|
|
188
|
+
* Whether the API key should be considered public. A public API key will not be detected by the secret scanner, which
|
|
189
|
+
* automatically revokes API keys when it detects that they may have been exposed to the public.
|
|
190
|
+
*/
|
|
191
|
+
isPublic?: boolean;
|
|
192
|
+
};
|
|
193
|
+
type ApiKeyUpdateOptions<Type extends ApiKeyType = ApiKeyType> = {
|
|
194
|
+
description?: string;
|
|
195
|
+
expiresAt?: Date | null;
|
|
196
|
+
revoked?: boolean;
|
|
197
|
+
};
|
|
198
|
+
|
|
158
199
|
type Connection = {
|
|
159
200
|
id: string;
|
|
160
201
|
};
|
|
@@ -329,6 +370,7 @@ type BaseUser = {
|
|
|
329
370
|
readonly otpAuthEnabled: boolean;
|
|
330
371
|
readonly passkeyAuthEnabled: boolean;
|
|
331
372
|
readonly isMultiFactorRequired: boolean;
|
|
373
|
+
readonly isAnonymous: boolean;
|
|
332
374
|
toClientJson(): CurrentUserCrud["Client"]["Read"];
|
|
333
375
|
/**
|
|
334
376
|
* @deprecated, use contact channel's usedForAuth instead
|
|
@@ -385,7 +427,8 @@ type UserExtra = {
|
|
|
385
427
|
getActiveSessions(): Promise<ActiveSession[]>;
|
|
386
428
|
revokeSession(sessionId: string): Promise<void>;
|
|
387
429
|
getTeamProfile(team: Team): Promise<EditableTeamMemberProfile>;
|
|
388
|
-
|
|
430
|
+
createApiKey(options: ApiKeyCreationOptions<"user">): Promise<UserApiKeyFirstView>;
|
|
431
|
+
} & AsyncStoreProperty<"apiKeys", [], UserApiKey[], true> & AsyncStoreProperty<"team", [id: string], Team | null, false> & AsyncStoreProperty<"teams", [], Team[], true> & AsyncStoreProperty<"permission", [scope: Team, permissionId: string, options?: {
|
|
389
432
|
recursive?: boolean;
|
|
390
433
|
}], TeamPermission | null, false> & AsyncStoreProperty<"permissions", [scope: Team, options?: {
|
|
391
434
|
recursive?: boolean;
|
|
@@ -516,7 +559,8 @@ type Team = {
|
|
|
516
559
|
listInvitations(): Promise<TeamInvitation[]>;
|
|
517
560
|
update(update: TeamUpdateOptions): Promise<void>;
|
|
518
561
|
delete(): Promise<void>;
|
|
519
|
-
|
|
562
|
+
createApiKey(options: ApiKeyCreationOptions<"team">): Promise<TeamApiKeyFirstView>;
|
|
563
|
+
} & AsyncStoreProperty<"apiKeys", [], TeamApiKey[], true>;
|
|
520
564
|
type TeamUpdateOptions = {
|
|
521
565
|
displayName?: string;
|
|
522
566
|
profileImageUrl?: string | null;
|
|
@@ -583,10 +627,17 @@ type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
583
627
|
}): Promise<ProjectCurrentServerUser<ProjectId>>;
|
|
584
628
|
getUser(options?: GetUserOptions<HasTokenStore>): Promise<ProjectCurrentServerUser<ProjectId> | null>;
|
|
585
629
|
getUser(id: string): Promise<ServerUser | null>;
|
|
630
|
+
getUser(options: {
|
|
631
|
+
apiKey: string;
|
|
632
|
+
}): Promise<ServerUser | null>;
|
|
633
|
+
getTeam(id: string): Promise<ServerTeam | null>;
|
|
634
|
+
getTeam(options: {
|
|
635
|
+
apiKey: string;
|
|
636
|
+
}): Promise<ServerTeam | null>;
|
|
586
637
|
listUsers(options?: ServerListUsersOptions): Promise<ServerUser[] & {
|
|
587
638
|
nextCursor: string | null;
|
|
588
639
|
}>;
|
|
589
|
-
} & AsyncStoreProperty<"user", [id: string], ServerUser | null, false> & Omit<AsyncStoreProperty<"users", [], ServerUser[], true>, "listUsers" | "useUsers"> & AsyncStoreProperty<"
|
|
640
|
+
} & AsyncStoreProperty<"user", [id: string], ServerUser | null, false> & Omit<AsyncStoreProperty<"users", [], ServerUser[], true>, "listUsers" | "useUsers"> & AsyncStoreProperty<"teams", [], ServerTeam[], true> & StackClientApp<HasTokenStore, ProjectId>);
|
|
590
641
|
declare const StackServerApp: StackServerAppConstructor;
|
|
591
642
|
|
|
592
643
|
type StackAdminAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = ((StackServerAppConstructorOptions<HasTokenStore, ProjectId> & {
|
|
@@ -598,11 +649,11 @@ type StackAdminAppConstructor = {
|
|
|
598
649
|
new <HasTokenStore extends boolean, ProjectId extends string>(options: StackAdminAppConstructorOptions<HasTokenStore, ProjectId>): StackAdminApp<HasTokenStore, ProjectId>;
|
|
599
650
|
new (options: StackAdminAppConstructorOptions<boolean, string>): StackAdminApp<boolean, string>;
|
|
600
651
|
};
|
|
601
|
-
type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = (AsyncStoreProperty<"project", [], AdminProject, false> & AsyncStoreProperty<"
|
|
652
|
+
type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = (AsyncStoreProperty<"project", [], AdminProject, false> & AsyncStoreProperty<"internalApiKeys", [], InternalApiKey[], true> & AsyncStoreProperty<"teamPermissionDefinitions", [], AdminTeamPermissionDefinition[], true> & AsyncStoreProperty<"projectPermissionDefinitions", [], AdminProjectPermissionDefinition[], true> & {
|
|
602
653
|
listEmailTemplates(): Promise<AdminEmailTemplate[]>;
|
|
603
654
|
updateEmailTemplate(type: EmailTemplateType, data: AdminEmailTemplateUpdateOptions): Promise<void>;
|
|
604
655
|
resetEmailTemplate(type: EmailTemplateType): Promise<void>;
|
|
605
|
-
|
|
656
|
+
createInternalApiKey(options: InternalApiKeyCreateOptions): Promise<InternalApiKeyFirstView>;
|
|
606
657
|
createTeamPermissionDefinition(data: AdminTeamPermissionDefinitionCreateOptions): Promise<AdminTeamPermission>;
|
|
607
658
|
updateTeamPermissionDefinition(permissionId: string, data: AdminTeamPermissionDefinitionUpdateOptions): Promise<void>;
|
|
608
659
|
deleteTeamPermissionDefinition(permissionId: string): Promise<void>;
|
|
@@ -627,6 +678,8 @@ type ProjectConfig = {
|
|
|
627
678
|
readonly clientTeamCreationEnabled: boolean;
|
|
628
679
|
readonly clientUserDeletionEnabled: boolean;
|
|
629
680
|
readonly oauthProviders: OAuthProviderConfig[];
|
|
681
|
+
readonly allowUserApiKeys: boolean;
|
|
682
|
+
readonly allowTeamApiKeys: boolean;
|
|
630
683
|
};
|
|
631
684
|
type OAuthProviderConfig = {
|
|
632
685
|
readonly id: string;
|
|
@@ -648,6 +701,8 @@ type AdminProjectConfig = {
|
|
|
648
701
|
readonly teamMemberDefaultPermissions: AdminTeamPermission[];
|
|
649
702
|
readonly userDefaultPermissions: AdminTeamPermission[];
|
|
650
703
|
readonly oauthAccountMergeStrategy: 'link_method' | 'raise_error' | 'allow_duplicates';
|
|
704
|
+
readonly allowUserApiKeys: boolean;
|
|
705
|
+
readonly allowTeamApiKeys: boolean;
|
|
651
706
|
};
|
|
652
707
|
type AdminEmailConfig = ({
|
|
653
708
|
type: "standard";
|
|
@@ -701,6 +756,8 @@ type AdminProjectConfigUpdateOptions = {
|
|
|
701
756
|
id: string;
|
|
702
757
|
}[];
|
|
703
758
|
oauthAccountMergeStrategy?: 'link_method' | 'raise_error' | 'allow_duplicates';
|
|
759
|
+
allowUserApiKeys?: boolean;
|
|
760
|
+
allowTeamApiKeys?: boolean;
|
|
704
761
|
};
|
|
705
762
|
|
|
706
763
|
type Project = {
|
|
@@ -822,4 +879,4 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
822
879
|
});
|
|
823
880
|
declare const StackClientApp: StackClientAppConstructor;
|
|
824
881
|
|
|
825
|
-
export { type AdminDomainConfig, type AdminEmailConfig, type AdminOAuthProviderConfig, type AdminOwnedProject, type AdminProject, type AdminProjectConfig, type AdminProjectConfigUpdateOptions, type AdminProjectCreateOptions, type AdminProjectPermission, type AdminProjectPermissionDefinition, type AdminProjectPermissionDefinitionCreateOptions, type AdminProjectPermissionDefinitionUpdateOptions, type AdminProjectUpdateOptions, type AdminSentEmail, type AdminTeamPermission, type AdminTeamPermissionDefinition, type AdminTeamPermissionDefinitionCreateOptions, type AdminTeamPermissionDefinitionUpdateOptions, type
|
|
882
|
+
export { type AdminDomainConfig, type AdminEmailConfig, type AdminOAuthProviderConfig, type AdminOwnedProject, type AdminProject, type AdminProjectConfig, type AdminProjectConfigUpdateOptions, type AdminProjectCreateOptions, type AdminProjectPermission, type AdminProjectPermissionDefinition, type AdminProjectPermissionDefinitionCreateOptions, type AdminProjectPermissionDefinitionUpdateOptions, type AdminProjectUpdateOptions, type AdminSentEmail, type AdminTeamPermission, type AdminTeamPermissionDefinition, type AdminTeamPermissionDefinitionCreateOptions, type AdminTeamPermissionDefinitionUpdateOptions, type Auth, type Connection, type ContactChannel, type CurrentInternalServerUser, type CurrentInternalUser, type CurrentServerUser, type CurrentUser, type EditableTeamMemberProfile, type GetUserOptions, type HandlerUrls, type InternalApiKey, type InternalApiKeyBase, type InternalApiKeyBaseCrudRead, type InternalApiKeyCreateOptions, type InternalApiKeyFirstView, type OAuthConnection, type OAuthProviderConfig, type OAuthScopesOnSignIn, type Project, type ProjectConfig, type ServerContactChannel, type ServerListUsersOptions, type ServerTeam, type ServerTeamCreateOptions, type ServerTeamMemberProfile, type ServerTeamUpdateOptions, type ServerTeamUser, type ServerUser, type Session, StackAdminApp, type StackAdminAppConstructor, type StackAdminAppConstructorOptions, StackClientApp, type StackClientAppConstructor, type StackClientAppConstructorOptions, type StackClientAppJson, StackServerApp, type StackServerAppConstructor, type StackServerAppConstructorOptions, type Team, type TeamCreateOptions, type TeamInvitation, type TeamMemberProfile, type TeamUpdateOptions, type TeamUser, type User, stackAppInternalsSymbol };
|
package/dist/lib/auth.js
CHANGED
|
@@ -36,8 +36,8 @@ async function signInWithOAuth(iface, options) {
|
|
|
36
36
|
const { codeChallenge, state } = await (0, import_cookie.saveVerifierAndState)();
|
|
37
37
|
const location = await iface.getOAuthUrl({
|
|
38
38
|
provider: options.provider,
|
|
39
|
-
redirectUrl: (0, import_url.constructRedirectUrl)(options.redirectUrl),
|
|
40
|
-
errorRedirectUrl: (0, import_url.constructRedirectUrl)(options.errorRedirectUrl),
|
|
39
|
+
redirectUrl: (0, import_url.constructRedirectUrl)(options.redirectUrl, "redirectUrl"),
|
|
40
|
+
errorRedirectUrl: (0, import_url.constructRedirectUrl)(options.errorRedirectUrl, "errorRedirectUrl"),
|
|
41
41
|
codeChallenge,
|
|
42
42
|
state,
|
|
43
43
|
type: "authenticate",
|
|
@@ -50,9 +50,9 @@ async function addNewOAuthProviderOrScope(iface, options, session) {
|
|
|
50
50
|
const { codeChallenge, state } = await (0, import_cookie.saveVerifierAndState)();
|
|
51
51
|
const location = await iface.getOAuthUrl({
|
|
52
52
|
provider: options.provider,
|
|
53
|
-
redirectUrl: (0, import_url.constructRedirectUrl)(options.redirectUrl),
|
|
54
|
-
errorRedirectUrl: (0, import_url.constructRedirectUrl)(options.errorRedirectUrl),
|
|
55
|
-
afterCallbackRedirectUrl: (0, import_url.constructRedirectUrl)(window.location.href),
|
|
53
|
+
redirectUrl: (0, import_url.constructRedirectUrl)(options.redirectUrl, "redirectUrl"),
|
|
54
|
+
errorRedirectUrl: (0, import_url.constructRedirectUrl)(options.errorRedirectUrl, "errorRedirectUrl"),
|
|
55
|
+
afterCallbackRedirectUrl: (0, import_url.constructRedirectUrl)(window.location.href, "afterCallbackRedirectUrl"),
|
|
56
56
|
codeChallenge,
|
|
57
57
|
state,
|
|
58
58
|
type: "link",
|
|
@@ -105,7 +105,7 @@ async function callOAuthCallback(iface, redirectUrl) {
|
|
|
105
105
|
try {
|
|
106
106
|
return import_results.Result.ok(await iface.callOAuthCallback({
|
|
107
107
|
oauthParams: consumed.originalUrl.searchParams,
|
|
108
|
-
redirectUri: (0, import_url.constructRedirectUrl)(redirectUrl),
|
|
108
|
+
redirectUri: (0, import_url.constructRedirectUrl)(redirectUrl, "redirectUri"),
|
|
109
109
|
codeVerifier: consumed.codeVerifier,
|
|
110
110
|
state: consumed.state
|
|
111
111
|
}));
|