@stackframe/js 2.8.41 → 2.8.44
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 +29 -0
- package/dist/esm/integrations/convex/component/convex.config.js +8 -0
- package/dist/esm/integrations/convex/component/convex.config.js.map +1 -0
- package/dist/esm/integrations/convex.js +5 -4
- package/dist/esm/integrations/convex.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js +17 -28
- 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 +89 -24
- 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 +12 -3
- 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 +107 -43
- 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/projects/index.js.map +1 -1
- package/dist/esm/lib/stack-app/users/index.js +16 -0
- package/dist/esm/lib/stack-app/users/index.js.map +1 -1
- package/dist/index.d.mts +86 -23
- package/dist/index.d.ts +86 -23
- package/dist/integrations/convex/component/convex.config.d.mts +5 -0
- package/dist/integrations/convex/component/convex.config.d.ts +5 -0
- package/dist/integrations/convex/component/convex.config.js +29 -0
- package/dist/integrations/convex/component/convex.config.js.map +1 -0
- package/dist/integrations/convex.js +4 -3
- package/dist/integrations/convex.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js +16 -27
- 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 +87 -22
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/common.js +14 -3
- package/dist/lib/stack-app/apps/implementations/common.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js +105 -41
- 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/customers/index.js.map +1 -1
- package/dist/lib/stack-app/projects/index.js.map +1 -1
- package/dist/lib/stack-app/users/index.js +17 -0
- package/dist/lib/stack-app/users/index.js.map +1 -1
- package/package.json +12 -3
|
@@ -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 { Customer } from \"../customers\";\nimport { NotificationCategory } from \"../notification-categories\";\nimport { AdminTeamPermission, TeamPermission } from \"../permissions\";\nimport { AdminOwnedProject, AdminProjectCreateOptions } from \"../projects\";\nimport { EditableTeamMemberProfile, ServerTeam, ServerTeamCreateOptions, Team, TeamCreateOptions } from \"../teams\";\n\nexport type OAuthProvider = {\n readonly id: string,\n readonly type: string,\n readonly userId: string,\n readonly accountId?: string,\n readonly email?: string,\n readonly allowSignIn: boolean,\n readonly allowConnectedAccounts: boolean,\n update(data: { allowSignIn?: boolean, allowConnectedAccounts?: boolean }): Promise<Result<void,\n InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>\n >>,\n delete(): Promise<void>,\n};\n\nexport type ServerOAuthProvider = {\n readonly id: string,\n readonly type: string,\n readonly userId: string,\n readonly accountId: string,\n readonly email?: string,\n readonly allowSignIn: boolean,\n readonly allowConnectedAccounts: boolean,\n update(data: { accountId?: string, email?: string, allowSignIn?: boolean, allowConnectedAccounts?: boolean }): Promise<Result<void,\n InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>\n >>,\n delete(): Promise<void>,\n};\n\n\nexport type Session = {\n getTokens(): Promise<{ accessToken: string | null, refreshToken: string | null }>,\n};\n\n/**\n * Contains everything related to the current user session.\n */\nexport type Auth = {\n readonly _internalSession: InternalSession,\n readonly currentSession: Session,\n signOut(options?: { redirectUrl?: URL | string }): Promise<void>,\n\n /**\n * Returns headers for sending authenticated HTTP requests to external servers. Most commonly used in cross-origin\n * requests. Similar to `getAuthJson`, but specifically for HTTP requests.\n *\n * If you are using `tokenStore: \"cookie\"`, you don't need this for same-origin requests. However, most\n * browsers now disable third-party cookies by default, so we must pass authentication tokens by header instead\n * if the client and server are on different origins.\n *\n * This function returns a header object that can be used with `fetch` or other HTTP request libraries to send\n * authenticated requests.\n *\n * On the server, you can then pass in the `Request` object to the `tokenStore` option\n * of your Stack app. Please note that CORS does not allow most headers by default, so you\n * must include `x-stack-auth` in the [`Access-Control-Allow-Headers` header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers)\n * of the CORS preflight response.\n *\n * If you are not using HTTP (and hence cannot set headers), you will need to use the `getAuthJson()` function\n * instead.\n *\n * Example:\n *\n * ```ts\n * // client\n * const res = await fetch(\"https://api.example.com\", {\n * headers: {\n * ...await stackApp.getAuthHeaders()\n * // you can also add your own headers here\n * },\n * });\n *\n * // server\n * function handleRequest(req: Request) {\n * const user = await stackServerApp.getUser({ tokenStore: req });\n * return new Response(\"Welcome, \" + user.displayName);\n * }\n * ```\n */\n getAuthHeaders(): Promise<{ \"x-stack-auth\": string }>,\n\n /**\n * Creates a JSON-serializable object containing the information to authenticate a user on an external server.\n * Similar to `getAuthHeaders`, but returns an object that can be sent over any protocol instead of just\n * HTTP headers.\n *\n * While `getAuthHeaders` is the recommended way to send authentication tokens over HTTP, your app may use\n * a different protocol, for example WebSockets or gRPC. This function returns a token object that can be JSON-serialized and sent to the server in any way you like.\n *\n * On the server, you can pass in this token object into the `tokenStore` option to fetch user details.\n *\n * Example:\n *\n * ```ts\n * // client\n * const res = await rpcCall(rpcEndpoint, {\n * data: {\n * auth: await stackApp.getAuthJson(),\n * },\n * });\n *\n * // server\n * function handleRequest(data) {\n * const user = await stackServerApp.getUser({ tokenStore: data.auth });\n * return new Response(\"Welcome, \" + user.displayName);\n * }\n * ```\n */\n getAuthJson(): Promise<{ accessToken: string | null, refreshToken: string | null }>,\n registerPasskey(options?: { hostname?: string }): Promise<Result<undefined, KnownErrors[\"PasskeyRegistrationFailed\"] | KnownErrors[\"PasskeyWebAuthnError\"]>>,\n};\n\n/**\n * ```\n * +----------+-------------+-------------------+\n * | \\ | !Server | Server |\n * +----------+-------------+-------------------+\n * | !Session | User | ServerUser |\n * | Session | CurrentUser | CurrentServerUser |\n * +----------+-------------+-------------------+\n * ```\n *\n * The fields on each of these types are available iff:\n * BaseUser: true\n * Auth: Session\n * ServerBaseUser: Server\n * UserExtra: Session OR Server\n *\n * The types are defined as follows (in the typescript manner):\n * User = BaseUser\n * CurrentUser = BaseUser & Auth & UserExtra\n * ServerUser = BaseUser & ServerBaseUser & UserExtra\n * CurrentServerUser = BaseUser & ServerBaseUser & Auth & UserExtra\n **/\n\nexport type BaseUser = {\n readonly id: string,\n\n readonly displayName: string | null,\n\n /**\n * The user's email address.\n *\n * Note: This might NOT be unique across multiple users, so always use `id` for unique identification.\n */\n readonly primaryEmail: string | null,\n readonly primaryEmailVerified: boolean,\n readonly profileImageUrl: string | null,\n\n readonly signedUpAt: Date,\n\n readonly clientMetadata: any,\n readonly clientReadOnlyMetadata: any,\n\n /**\n * Whether the user has a password set.\n */\n readonly hasPassword: boolean,\n readonly otpAuthEnabled: boolean,\n readonly passkeyAuthEnabled: boolean,\n\n readonly isMultiFactorRequired: boolean,\n readonly isAnonymous: boolean,\n toClientJson(): CurrentUserCrud[\"Client\"][\"Read\"],\n\n /**\n * @deprecated, use contact channel's usedForAuth instead\n */\n readonly emailAuthEnabled: boolean,\n /**\n * @deprecated\n */\n readonly oauthProviders: readonly { id: string }[],\n}\n\nexport type UserExtra = {\n setDisplayName(displayName: string): Promise<void>,\n /** @deprecated Use contact channel's sendVerificationEmail instead */\n sendVerificationEmail(): Promise<KnownErrors[\"EmailAlreadyVerified\"] | void>,\n setClientMetadata(metadata: any): Promise<void>,\n updatePassword(options: { oldPassword: string, newPassword: string}): Promise<KnownErrors[\"PasswordConfirmationMismatch\"] | KnownErrors[\"PasswordRequirementsNotMet\"] | void>,\n setPassword(options: { password: string }): Promise<KnownErrors[\"PasswordRequirementsNotMet\"] | void>,\n\n /**\n * A shorthand method to update multiple fields of the user at once.\n */\n update(update: UserUpdateOptions): Promise<void>,\n\n listContactChannels(): Promise<ContactChannel[]>,\n createContactChannel(data: ContactChannelCreateOptions): Promise<ContactChannel>,\n\n listNotificationCategories(): Promise<NotificationCategory[]>,\n\n delete(): Promise<void>,\n\n getConnectedAccount(id: ProviderType, options: { or: 'redirect', scopes?: string[] }): Promise<OAuthConnection>,\n getConnectedAccount(id: ProviderType, options?: { or?: 'redirect' | 'throw' | 'return-null', scopes?: string[] }): Promise<OAuthConnection | null>,\n\n\n hasPermission(scope: Team, permissionId: string): Promise<boolean>,\n hasPermission(permissionId: string): Promise<boolean>,\n\n getPermission(scope: Team, permissionId: string): Promise<TeamPermission | null>,\n getPermission(permissionId: string): Promise<TeamPermission | null>,\n\n listPermissions(scope: Team, options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n listPermissions(options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n\n\n readonly selectedTeam: Team | null,\n setSelectedTeam(team: Team | null): Promise<void>,\n createTeam(data: TeamCreateOptions): Promise<Team>,\n leaveTeam(team: Team): Promise<void>,\n\n getActiveSessions(): Promise<ActiveSession[]>,\n revokeSession(sessionId: string): Promise<void>,\n getTeamProfile(team: Team): Promise<EditableTeamMemberProfile>,\n\n createApiKey(options: ApiKeyCreationOptions<\"user\">): Promise<UserApiKeyFirstView>,\n\n listOAuthProviders(): Promise<OAuthProvider[]>,\n\n getOAuthProvider(id: string): Promise<OAuthProvider | null>,\n}\n& AsyncStoreProperty<\"apiKeys\", [], UserApiKey[], true>\n& AsyncStoreProperty<\"team\", [id: string], Team | null, false>\n& AsyncStoreProperty<\"teams\", [], Team[], true>\n& AsyncStoreProperty<\"permission\", [scope: Team, permissionId: string, options?: { recursive?: boolean }], TeamPermission | null, false>\n& AsyncStoreProperty<\"permissions\", [scope: Team, options?: { recursive?: boolean }], TeamPermission[], true>;\n\nexport type InternalUserExtra =\n & {\n createProject(newProject: AdminProjectCreateOptions): Promise<AdminOwnedProject>,\n }\n & AsyncStoreProperty<\"ownedProjects\", [], AdminOwnedProject[], true>\n\nexport type User = BaseUser;\n\nexport type CurrentUser = BaseUser & Auth & UserExtra & Customer;\n\nexport type CurrentInternalUser = CurrentUser & InternalUserExtra;\n\nexport type ProjectCurrentUser<ProjectId> = ProjectId extends \"internal\" ? CurrentInternalUser : CurrentUser;\n\nexport type TokenPartialUser = Pick<\n User,\n | \"id\"\n | \"displayName\"\n | \"primaryEmail\"\n | \"primaryEmailVerified\"\n | \"isAnonymous\"\n>\n\nexport type SyncedPartialUser = TokenPartialUser & Pick<\n User,\n | \"id\"\n | \"displayName\"\n | \"primaryEmail\"\n | \"primaryEmailVerified\"\n | \"profileImageUrl\"\n | \"signedUpAt\"\n | \"clientMetadata\"\n | \"clientReadOnlyMetadata\"\n | \"isAnonymous\"\n | \"hasPassword\"\n>;\n\n\nexport type ActiveSession = {\n id: string,\n userId: string,\n createdAt: Date,\n isImpersonation: boolean,\n lastUsedAt: Date | undefined,\n isCurrentSession: boolean,\n geoInfo?: GeoInfo,\n};\n\nexport type UserUpdateOptions = {\n displayName?: string,\n clientMetadata?: ReadonlyJson,\n selectedTeamId?: string | null,\n totpMultiFactorSecret?: Uint8Array | null,\n profileImageUrl?: string | null,\n otpAuthEnabled?: boolean,\n passkeyAuthEnabled?:boolean,\n}\nexport function userUpdateOptionsToCrud(options: UserUpdateOptions): CurrentUserCrud[\"Client\"][\"Update\"] {\n return {\n display_name: options.displayName,\n client_metadata: options.clientMetadata,\n selected_team_id: options.selectedTeamId,\n totp_secret_base64: options.totpMultiFactorSecret != null ? encodeBase64(options.totpMultiFactorSecret) : options.totpMultiFactorSecret,\n profile_image_url: options.profileImageUrl,\n otp_auth_enabled: options.otpAuthEnabled,\n passkey_auth_enabled: options.passkeyAuthEnabled,\n };\n}\n\n\nexport type ServerBaseUser = {\n setPrimaryEmail(email: string | null, options?: { verified?: boolean | undefined }): Promise<void>,\n\n readonly lastActiveAt: Date,\n\n readonly serverMetadata: any,\n setServerMetadata(metadata: any): Promise<void>,\n setClientReadOnlyMetadata(metadata: any): Promise<void>,\n\n createTeam(data: Omit<ServerTeamCreateOptions, \"creatorUserId\">): Promise<ServerTeam>,\n\n listContactChannels(): Promise<ServerContactChannel[]>,\n createContactChannel(data: ServerContactChannelCreateOptions): Promise<ServerContactChannel>,\n\n update(user: ServerUserUpdateOptions): Promise<void>,\n\n grantPermission(scope: Team, permissionId: string): Promise<void>,\n grantPermission(permissionId: string): Promise<void>,\n\n revokePermission(scope: Team, permissionId: string): Promise<void>,\n revokePermission(permissionId: string): Promise<void>,\n\n getPermission(scope: Team, permissionId: string): Promise<TeamPermission | null>,\n getPermission(permissionId: string): Promise<TeamPermission | null>,\n\n hasPermission(scope: Team, permissionId: string): Promise<boolean>,\n hasPermission(permissionId: string): Promise<boolean>,\n\n listPermissions(scope: Team, options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n listPermissions(options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n\n\n listOAuthProviders(): Promise<ServerOAuthProvider[]>,\n\n getOAuthProvider(id: string): Promise<ServerOAuthProvider | null>,\n\n /**\n * Creates a new session object with a refresh token for this user. Can be used to impersonate them.\n */\n createSession(options?: { expiresInMillis?: number, isImpersonation?: boolean }): Promise<Session>,\n}\n& AsyncStoreProperty<\"team\", [id: string], ServerTeam | null, false>\n& AsyncStoreProperty<\"teams\", [], ServerTeam[], true>\n& AsyncStoreProperty<\"permission\", [scope: Team, permissionId: string, options?: { direct?: boolean }], AdminTeamPermission | null, false>\n& AsyncStoreProperty<\"permissions\", [scope: Team, options?: { direct?: boolean }], AdminTeamPermission[], true>;\n\n/**\n * A user including sensitive fields that should only be used on the server, never sent to the client\n * (such as sensitive information and serverMetadata).\n */\nexport type ServerUser = ServerBaseUser & BaseUser & UserExtra & Customer<true>;\n\nexport type CurrentServerUser = Auth & ServerUser;\n\nexport type CurrentInternalServerUser = CurrentServerUser & InternalUserExtra;\n\nexport type ProjectCurrentServerUser<ProjectId> = ProjectId extends \"internal\" ? CurrentInternalServerUser : CurrentServerUser;\n\nexport type SyncedPartialServerUser = SyncedPartialUser & Pick<\n ServerUser,\n | \"serverMetadata\"\n>;\n\nexport type ServerUserUpdateOptions = {\n primaryEmail?: string | null,\n primaryEmailVerified?: boolean,\n primaryEmailAuthEnabled?: boolean,\n clientReadOnlyMetadata?: ReadonlyJson,\n serverMetadata?: ReadonlyJson,\n password?: string,\n} & UserUpdateOptions;\nexport function serverUserUpdateOptionsToCrud(options: ServerUserUpdateOptions): CurrentUserCrud[\"Server\"][\"Update\"] {\n return {\n display_name: options.displayName,\n primary_email: options.primaryEmail,\n client_metadata: options.clientMetadata,\n client_read_only_metadata: options.clientReadOnlyMetadata,\n server_metadata: options.serverMetadata,\n selected_team_id: options.selectedTeamId,\n primary_email_auth_enabled: options.primaryEmailAuthEnabled,\n primary_email_verified: options.primaryEmailVerified,\n password: options.password,\n profile_image_url: options.profileImageUrl,\n totp_secret_base64: options.totpMultiFactorSecret != null ? encodeBase64(options.totpMultiFactorSecret) : options.totpMultiFactorSecret,\n };\n}\n\n\nexport type ServerUserCreateOptions = {\n primaryEmail?: string | null,\n primaryEmailAuthEnabled?: boolean,\n password?: string,\n otpAuthEnabled?: boolean,\n displayName?: string,\n primaryEmailVerified?: boolean,\n clientMetadata?: any,\n clientReadOnlyMetadata?: any,\n serverMetadata?: any,\n}\nexport function serverUserCreateOptionsToCrud(options: ServerUserCreateOptions): UsersCrud[\"Server\"][\"Create\"] {\n return {\n primary_email: options.primaryEmail,\n password: options.password,\n otp_auth_enabled: options.otpAuthEnabled,\n primary_email_auth_enabled: options.primaryEmailAuthEnabled,\n display_name: options.displayName,\n primary_email_verified: options.primaryEmailVerified,\n client_metadata: options.clientMetadata,\n client_read_only_metadata: options.clientReadOnlyMetadata,\n server_metadata: options.serverMetadata,\n };\n}\n"],"mappings":";AAQA,SAAS,oBAAoB;AA6StB,SAAS,wBAAwB,SAAiE;AACvG,SAAO;AAAA,IACL,cAAc,QAAQ;AAAA,IACtB,iBAAiB,QAAQ;AAAA,IACzB,kBAAkB,QAAQ;AAAA,IAC1B,oBAAoB,QAAQ,yBAAyB,OAAO,aAAa,QAAQ,qBAAqB,IAAI,QAAQ;AAAA,IAClH,mBAAmB,QAAQ;AAAA,IAC3B,kBAAkB,QAAQ;AAAA,IAC1B,sBAAsB,QAAQ;AAAA,EAChC;AACF;AA0EO,SAAS,8BAA8B,SAAuE;AACnH,SAAO;AAAA,IACL,cAAc,QAAQ;AAAA,IACtB,eAAe,QAAQ;AAAA,IACvB,iBAAiB,QAAQ;AAAA,IACzB,2BAA2B,QAAQ;AAAA,IACnC,iBAAiB,QAAQ;AAAA,IACzB,kBAAkB,QAAQ;AAAA,IAC1B,4BAA4B,QAAQ;AAAA,IACpC,wBAAwB,QAAQ;AAAA,IAChC,UAAU,QAAQ;AAAA,IAClB,mBAAmB,QAAQ;AAAA,IAC3B,oBAAoB,QAAQ,yBAAyB,OAAO,aAAa,QAAQ,qBAAqB,IAAI,QAAQ;AAAA,EACpH;AACF;AAcO,SAAS,8BAA8B,SAAiE;AAC7G,SAAO;AAAA,IACL,eAAe,QAAQ;AAAA,IACvB,UAAU,QAAQ;AAAA,IAClB,kBAAkB,QAAQ;AAAA,IAC1B,4BAA4B,QAAQ;AAAA,IACpC,cAAc,QAAQ;AAAA,IACtB,wBAAwB,QAAQ;AAAA,IAChC,iBAAiB,QAAQ;AAAA,IACzB,2BAA2B,QAAQ;AAAA,IACnC,iBAAiB,QAAQ;AAAA,EAC3B;AACF;","names":[]}
|
|
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\nconst userGetterErrorMessage = \"Stack Auth: useUser() already returns the user object. Use `const user = useUser()` (or `const user = await app.getUser()`) instead of destructuring it like `const { user } = ...`.\";\n\nexport function attachUserDestructureGuard(target: object): void {\n const descriptor = Object.getOwnPropertyDescriptor(target, \"user\");\n if (descriptor?.get === guardGetter) {\n return;\n }\n\n Object.defineProperty(target, \"user\", {\n get: guardGetter,\n configurable: false,\n enumerable: false,\n });\n}\n\nfunction guardGetter(): never {\n throw new Error(userGetterErrorMessage);\n}\n\nexport type OAuthProvider = {\n readonly id: string,\n readonly type: string,\n readonly userId: string,\n readonly accountId?: string,\n readonly email?: string,\n readonly allowSignIn: boolean,\n readonly allowConnectedAccounts: boolean,\n update(data: { allowSignIn?: boolean, allowConnectedAccounts?: boolean }): Promise<Result<void,\n InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>\n >>,\n delete(): Promise<void>,\n};\n\nexport type ServerOAuthProvider = {\n readonly id: string,\n readonly type: string,\n readonly userId: string,\n readonly accountId: string,\n readonly email?: string,\n readonly allowSignIn: boolean,\n readonly allowConnectedAccounts: boolean,\n update(data: { accountId?: string, email?: string, allowSignIn?: boolean, allowConnectedAccounts?: boolean }): Promise<Result<void,\n InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>\n >>,\n delete(): Promise<void>,\n};\n\n\nexport type Session = {\n getTokens(): Promise<{ accessToken: string | null, refreshToken: string | null }>,\n};\n\n/**\n * Contains everything related to the current user session.\n */\nexport type Auth = {\n readonly _internalSession: InternalSession,\n readonly currentSession: Session,\n signOut(options?: { redirectUrl?: URL | string }): Promise<void>,\n\n /**\n * Returns headers for sending authenticated HTTP requests to external servers. Most commonly used in cross-origin\n * requests. Similar to `getAuthJson`, but specifically for HTTP requests.\n *\n * If you are using `tokenStore: \"cookie\"`, you don't need this for same-origin requests. However, most\n * browsers now disable third-party cookies by default, so we must pass authentication tokens by header instead\n * if the client and server are on different origins.\n *\n * This function returns a header object that can be used with `fetch` or other HTTP request libraries to send\n * authenticated requests.\n *\n * On the server, you can then pass in the `Request` object to the `tokenStore` option\n * of your Stack app. Please note that CORS does not allow most headers by default, so you\n * must include `x-stack-auth` in the [`Access-Control-Allow-Headers` header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers)\n * of the CORS preflight response.\n *\n * If you are not using HTTP (and hence cannot set headers), you will need to use the `getAuthJson()` function\n * instead.\n *\n * Example:\n *\n * ```ts\n * // client\n * const res = await fetch(\"https://api.example.com\", {\n * headers: {\n * ...await stackApp.getAuthHeaders()\n * // you can also add your own headers here\n * },\n * });\n *\n * // server\n * function handleRequest(req: Request) {\n * const user = await stackServerApp.getUser({ tokenStore: req });\n * return new Response(\"Welcome, \" + user.displayName);\n * }\n * ```\n */\n getAuthHeaders(): Promise<{ \"x-stack-auth\": string }>,\n\n /**\n * Creates a JSON-serializable object containing the information to authenticate a user on an external server.\n * Similar to `getAuthHeaders`, but returns an object that can be sent over any protocol instead of just\n * HTTP headers.\n *\n * While `getAuthHeaders` is the recommended way to send authentication tokens over HTTP, your app may use\n * a different protocol, for example WebSockets or gRPC. This function returns a token object that can be JSON-serialized and sent to the server in any way you like.\n *\n * On the server, you can pass in this token object into the `tokenStore` option to fetch user details.\n *\n * Example:\n *\n * ```ts\n * // client\n * const res = await rpcCall(rpcEndpoint, {\n * data: {\n * auth: await stackApp.getAuthJson(),\n * },\n * });\n *\n * // server\n * function handleRequest(data) {\n * const user = await stackServerApp.getUser({ tokenStore: data.auth });\n * return new Response(\"Welcome, \" + user.displayName);\n * }\n * ```\n */\n getAuthJson(): Promise<{ accessToken: string | null, refreshToken: string | null }>,\n registerPasskey(options?: { hostname?: string }): Promise<Result<undefined, KnownErrors[\"PasskeyRegistrationFailed\"] | KnownErrors[\"PasskeyWebAuthnError\"]>>,\n};\n\n/**\n * ```\n * +----------+-------------+-------------------+\n * | \\ | !Server | Server |\n * +----------+-------------+-------------------+\n * | !Session | User | ServerUser |\n * | Session | CurrentUser | CurrentServerUser |\n * +----------+-------------+-------------------+\n * ```\n *\n * The fields on each of these types are available iff:\n * BaseUser: true\n * Auth: Session\n * ServerBaseUser: Server\n * UserExtra: Session OR Server\n *\n * The types are defined as follows (in the typescript manner):\n * User = BaseUser\n * CurrentUser = BaseUser & Auth & UserExtra\n * ServerUser = BaseUser & ServerBaseUser & UserExtra\n * CurrentServerUser = BaseUser & ServerBaseUser & Auth & UserExtra\n **/\n\nexport type BaseUser = {\n readonly id: string,\n\n readonly displayName: string | null,\n\n /**\n * The user's email address.\n *\n * Note: This might NOT be unique across multiple users, so always use `id` for unique identification.\n */\n readonly primaryEmail: string | null,\n readonly primaryEmailVerified: boolean,\n readonly profileImageUrl: string | null,\n\n readonly signedUpAt: Date,\n\n readonly clientMetadata: any,\n readonly clientReadOnlyMetadata: any,\n\n /**\n * Whether the user has a password set.\n */\n readonly hasPassword: boolean,\n readonly otpAuthEnabled: boolean,\n readonly passkeyAuthEnabled: boolean,\n\n readonly isMultiFactorRequired: boolean,\n readonly isAnonymous: boolean,\n toClientJson(): CurrentUserCrud[\"Client\"][\"Read\"],\n\n /**\n * @deprecated, use contact channel's usedForAuth instead\n */\n readonly emailAuthEnabled: boolean,\n /**\n * @deprecated\n */\n readonly oauthProviders: readonly { id: string }[],\n}\n\nexport type UserExtra = {\n setDisplayName(displayName: string): Promise<void>,\n /** @deprecated Use contact channel's sendVerificationEmail instead */\n sendVerificationEmail(): Promise<KnownErrors[\"EmailAlreadyVerified\"] | void>,\n setClientMetadata(metadata: any): Promise<void>,\n updatePassword(options: { oldPassword: string, newPassword: string}): Promise<KnownErrors[\"PasswordConfirmationMismatch\"] | KnownErrors[\"PasswordRequirementsNotMet\"] | void>,\n setPassword(options: { password: string }): Promise<KnownErrors[\"PasswordRequirementsNotMet\"] | void>,\n\n /**\n * A shorthand method to update multiple fields of the user at once.\n */\n update(update: UserUpdateOptions): Promise<void>,\n\n listContactChannels(): Promise<ContactChannel[]>,\n createContactChannel(data: ContactChannelCreateOptions): Promise<ContactChannel>,\n\n listNotificationCategories(): Promise<NotificationCategory[]>,\n\n delete(): Promise<void>,\n\n getConnectedAccount(id: ProviderType, options: { or: 'redirect', scopes?: string[] }): Promise<OAuthConnection>,\n getConnectedAccount(id: ProviderType, options?: { or?: 'redirect' | 'throw' | 'return-null', scopes?: string[] }): Promise<OAuthConnection | null>,\n\n\n hasPermission(scope: Team, permissionId: string): Promise<boolean>,\n hasPermission(permissionId: string): Promise<boolean>,\n\n getPermission(scope: Team, permissionId: string): Promise<TeamPermission | null>,\n getPermission(permissionId: string): Promise<TeamPermission | null>,\n\n listPermissions(scope: Team, options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n listPermissions(options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n\n\n readonly selectedTeam: Team | null,\n setSelectedTeam(team: Team | null): Promise<void>,\n createTeam(data: TeamCreateOptions): Promise<Team>,\n leaveTeam(team: Team): Promise<void>,\n\n getActiveSessions(): Promise<ActiveSession[]>,\n revokeSession(sessionId: string): Promise<void>,\n getTeamProfile(team: Team): Promise<EditableTeamMemberProfile>,\n\n createApiKey(options: ApiKeyCreationOptions<\"user\">): Promise<UserApiKeyFirstView>,\n\n listOAuthProviders(): Promise<OAuthProvider[]>,\n\n getOAuthProvider(id: string): Promise<OAuthProvider | null>,\n}\n& AsyncStoreProperty<\"apiKeys\", [], UserApiKey[], true>\n& AsyncStoreProperty<\"team\", [id: string], Team | null, false>\n& AsyncStoreProperty<\"teams\", [], Team[], true>\n& AsyncStoreProperty<\"permission\", [scope: Team, permissionId: string, options?: { recursive?: boolean }], TeamPermission | null, false>\n& AsyncStoreProperty<\"permissions\", [scope: Team, options?: { recursive?: boolean }], TeamPermission[], true>;\n\nexport type InternalUserExtra =\n & {\n createProject(newProject: AdminProjectCreateOptions): Promise<AdminOwnedProject>,\n transferProject(projectIdToTransfer: string, newTeamId: string): Promise<void>,\n }\n & AsyncStoreProperty<\"ownedProjects\", [], AdminOwnedProject[], true>\n\nexport type User = BaseUser;\n\nexport type CurrentUser = BaseUser & Auth & UserExtra & Customer;\n\nexport type CurrentInternalUser = CurrentUser & InternalUserExtra;\n\nexport type ProjectCurrentUser<ProjectId> = ProjectId extends \"internal\" ? CurrentInternalUser : CurrentUser;\n\nexport type TokenPartialUser = Pick<\n User,\n | \"id\"\n | \"displayName\"\n | \"primaryEmail\"\n | \"primaryEmailVerified\"\n | \"isAnonymous\"\n>\n\nexport type SyncedPartialUser = TokenPartialUser & Pick<\n User,\n | \"id\"\n | \"displayName\"\n | \"primaryEmail\"\n | \"primaryEmailVerified\"\n | \"profileImageUrl\"\n | \"signedUpAt\"\n | \"clientMetadata\"\n | \"clientReadOnlyMetadata\"\n | \"isAnonymous\"\n | \"hasPassword\"\n>;\n\n\nexport type ActiveSession = {\n id: string,\n userId: string,\n createdAt: Date,\n isImpersonation: boolean,\n lastUsedAt: Date | undefined,\n isCurrentSession: boolean,\n geoInfo?: GeoInfo,\n};\n\nexport type UserUpdateOptions = {\n displayName?: string,\n clientMetadata?: ReadonlyJson,\n selectedTeamId?: string | null,\n totpMultiFactorSecret?: Uint8Array | null,\n profileImageUrl?: string | null,\n otpAuthEnabled?: boolean,\n passkeyAuthEnabled?:boolean,\n}\nexport function userUpdateOptionsToCrud(options: UserUpdateOptions): CurrentUserCrud[\"Client\"][\"Update\"] {\n return {\n display_name: options.displayName,\n client_metadata: options.clientMetadata,\n selected_team_id: options.selectedTeamId,\n totp_secret_base64: options.totpMultiFactorSecret != null ? encodeBase64(options.totpMultiFactorSecret) : options.totpMultiFactorSecret,\n profile_image_url: options.profileImageUrl,\n otp_auth_enabled: options.otpAuthEnabled,\n passkey_auth_enabled: options.passkeyAuthEnabled,\n };\n}\n\n\nexport type ServerBaseUser = {\n setPrimaryEmail(email: string | null, options?: { verified?: boolean | undefined }): Promise<void>,\n\n readonly lastActiveAt: Date,\n\n readonly serverMetadata: any,\n setServerMetadata(metadata: any): Promise<void>,\n setClientReadOnlyMetadata(metadata: any): Promise<void>,\n\n createTeam(data: Omit<ServerTeamCreateOptions, \"creatorUserId\">): Promise<ServerTeam>,\n\n listContactChannels(): Promise<ServerContactChannel[]>,\n createContactChannel(data: ServerContactChannelCreateOptions): Promise<ServerContactChannel>,\n\n update(user: ServerUserUpdateOptions): Promise<void>,\n\n grantPermission(scope: Team, permissionId: string): Promise<void>,\n grantPermission(permissionId: string): Promise<void>,\n\n revokePermission(scope: Team, permissionId: string): Promise<void>,\n revokePermission(permissionId: string): Promise<void>,\n\n getPermission(scope: Team, permissionId: string): Promise<TeamPermission | null>,\n getPermission(permissionId: string): Promise<TeamPermission | null>,\n\n hasPermission(scope: Team, permissionId: string): Promise<boolean>,\n hasPermission(permissionId: string): Promise<boolean>,\n\n listPermissions(scope: Team, options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n listPermissions(options?: { recursive?: boolean }): Promise<TeamPermission[]>,\n\n\n listOAuthProviders(): Promise<ServerOAuthProvider[]>,\n\n getOAuthProvider(id: string): Promise<ServerOAuthProvider | null>,\n\n /**\n * Creates a new session object with a refresh token for this user. Can be used to impersonate them.\n */\n createSession(options?: { expiresInMillis?: number, isImpersonation?: boolean }): Promise<Session>,\n}\n& AsyncStoreProperty<\"team\", [id: string], ServerTeam | null, false>\n& AsyncStoreProperty<\"teams\", [], ServerTeam[], true>\n& AsyncStoreProperty<\"permission\", [scope: Team, permissionId: string, options?: { direct?: boolean }], AdminTeamPermission | null, false>\n& AsyncStoreProperty<\"permissions\", [scope: Team, options?: { direct?: boolean }], AdminTeamPermission[], true>;\n\n/**\n * A user including sensitive fields that should only be used on the server, never sent to the client\n * (such as sensitive information and serverMetadata).\n */\nexport type ServerUser = ServerBaseUser & BaseUser & UserExtra & Customer<true>;\n\nexport type CurrentServerUser = Auth & ServerUser;\n\nexport type CurrentInternalServerUser = CurrentServerUser & InternalUserExtra;\n\nexport type ProjectCurrentServerUser<ProjectId> = ProjectId extends \"internal\" ? CurrentInternalServerUser : CurrentServerUser;\n\nexport type SyncedPartialServerUser = SyncedPartialUser & Pick<\n ServerUser,\n | \"serverMetadata\"\n>;\n\nexport type ServerUserUpdateOptions = {\n primaryEmail?: string | null,\n primaryEmailVerified?: boolean,\n primaryEmailAuthEnabled?: boolean,\n clientReadOnlyMetadata?: ReadonlyJson,\n serverMetadata?: ReadonlyJson,\n password?: string,\n} & UserUpdateOptions;\nexport function serverUserUpdateOptionsToCrud(options: ServerUserUpdateOptions): CurrentUserCrud[\"Server\"][\"Update\"] {\n return {\n display_name: options.displayName,\n primary_email: options.primaryEmail,\n client_metadata: options.clientMetadata,\n client_read_only_metadata: options.clientReadOnlyMetadata,\n server_metadata: options.serverMetadata,\n selected_team_id: options.selectedTeamId,\n primary_email_auth_enabled: options.primaryEmailAuthEnabled,\n primary_email_verified: options.primaryEmailVerified,\n password: options.password,\n profile_image_url: options.profileImageUrl,\n totp_secret_base64: options.totpMultiFactorSecret != null ? encodeBase64(options.totpMultiFactorSecret) : options.totpMultiFactorSecret,\n };\n}\n\n\nexport type ServerUserCreateOptions = {\n primaryEmail?: string | null,\n primaryEmailAuthEnabled?: boolean,\n password?: string,\n otpAuthEnabled?: boolean,\n displayName?: string,\n primaryEmailVerified?: boolean,\n clientMetadata?: any,\n clientReadOnlyMetadata?: any,\n serverMetadata?: any,\n}\nexport function serverUserCreateOptionsToCrud(options: ServerUserCreateOptions): UsersCrud[\"Server\"][\"Create\"] {\n return {\n primary_email: options.primaryEmail,\n password: options.password,\n otp_auth_enabled: options.otpAuthEnabled,\n primary_email_auth_enabled: options.primaryEmailAuthEnabled,\n display_name: options.displayName,\n primary_email_verified: options.primaryEmailVerified,\n client_metadata: options.clientMetadata,\n client_read_only_metadata: options.clientReadOnlyMetadata,\n server_metadata: options.serverMetadata,\n };\n}\n"],"mappings":";AAQA,SAAS,oBAAoB;AAe7B,IAAM,yBAAyB;AAExB,SAAS,2BAA2B,QAAsB;AAC/D,QAAM,aAAa,OAAO,yBAAyB,QAAQ,MAAM;AACjE,MAAI,YAAY,QAAQ,aAAa;AACnC;AAAA,EACF;AAEA,SAAO,eAAe,QAAQ,QAAQ;AAAA,IACpC,KAAK;AAAA,IACL,cAAc;AAAA,IACd,YAAY;AAAA,EACd,CAAC;AACH;AAEA,SAAS,cAAqB;AAC5B,QAAM,IAAI,MAAM,sBAAsB;AACxC;AAiSO,SAAS,wBAAwB,SAAiE;AACvG,SAAO;AAAA,IACL,cAAc,QAAQ;AAAA,IACtB,iBAAiB,QAAQ;AAAA,IACzB,kBAAkB,QAAQ;AAAA,IAC1B,oBAAoB,QAAQ,yBAAyB,OAAO,aAAa,QAAQ,qBAAqB,IAAI,QAAQ;AAAA,IAClH,mBAAmB,QAAQ;AAAA,IAC3B,kBAAkB,QAAQ;AAAA,IAC1B,sBAAsB,QAAQ;AAAA,EAChC;AACF;AA0EO,SAAS,8BAA8B,SAAuE;AACnH,SAAO;AAAA,IACL,cAAc,QAAQ;AAAA,IACtB,eAAe,QAAQ;AAAA,IACvB,iBAAiB,QAAQ;AAAA,IACzB,2BAA2B,QAAQ;AAAA,IACnC,iBAAiB,QAAQ;AAAA,IACzB,kBAAkB,QAAQ;AAAA,IAC1B,4BAA4B,QAAQ;AAAA,IACpC,wBAAwB,QAAQ;AAAA,IAChC,UAAU,QAAQ;AAAA,IAClB,mBAAmB,QAAQ;AAAA,IAC3B,oBAAoB,QAAQ,yBAAyB,OAAO,aAAa,QAAQ,qBAAqB,IAAI,QAAQ;AAAA,EACpH;AACF;AAcO,SAAS,8BAA8B,SAAiE;AAC7G,SAAO;AAAA,IACL,eAAe,QAAQ;AAAA,IACvB,UAAU,QAAQ;AAAA,IAClB,kBAAkB,QAAQ;AAAA,IAC1B,4BAA4B,QAAQ;AAAA,IACpC,cAAc,QAAQ;AAAA,IACtB,wBAAwB,QAAQ;AAAA,IAChC,iBAAiB,QAAQ;AAAA,IACzB,2BAA2B,QAAQ;AAAA,IACnC,iBAAiB,QAAQ;AAAA,EAC3B;AACF;","names":[]}
|
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import { CurrentUserCrud } from '@stackframe/stack-shared/dist/interface/crud/cu
|
|
|
3
3
|
import { Result } from '@stackframe/stack-shared/dist/utils/results';
|
|
4
4
|
import { ProviderType } from '@stackframe/stack-shared/dist/utils/oauth';
|
|
5
5
|
import { GenericQueryCtx, UserIdentity } from 'convex/server';
|
|
6
|
-
import {
|
|
6
|
+
import { inlineProductSchema } from '@stackframe/stack-shared/dist/schema-fields';
|
|
7
7
|
import * as yup from 'yup';
|
|
8
8
|
import { ProductionModeError } from '@stackframe/stack-shared/dist/helpers/production-mode';
|
|
9
9
|
import { CompleteConfig, EnvironmentConfigOverrideOverride } from '@stackframe/stack-shared/dist/config/schema';
|
|
@@ -90,7 +90,7 @@ type OAuthScopesOnSignIn = {
|
|
|
90
90
|
/** @internal */
|
|
91
91
|
declare const stackAppInternalsSymbol: unique symbol;
|
|
92
92
|
|
|
93
|
-
type
|
|
93
|
+
type InlineProduct = yup.InferType<typeof inlineProductSchema>;
|
|
94
94
|
type Item = {
|
|
95
95
|
displayName: string;
|
|
96
96
|
/**
|
|
@@ -117,16 +117,50 @@ type ServerItem = Item & {
|
|
|
117
117
|
*/
|
|
118
118
|
tryDecreaseQuantity(amount: number): Promise<boolean>;
|
|
119
119
|
};
|
|
120
|
+
type CustomerProduct = {
|
|
121
|
+
id: string | null;
|
|
122
|
+
quantity: number;
|
|
123
|
+
displayName: string;
|
|
124
|
+
customerType: "user" | "team" | "custom";
|
|
125
|
+
isServerOnly: boolean;
|
|
126
|
+
stackable: boolean;
|
|
127
|
+
};
|
|
128
|
+
type CustomerProductsList = CustomerProduct[] & {
|
|
129
|
+
nextCursor: string | null;
|
|
130
|
+
};
|
|
131
|
+
type CustomerProductsListOptions = {
|
|
132
|
+
cursor?: string;
|
|
133
|
+
limit?: number;
|
|
134
|
+
};
|
|
135
|
+
type CustomerProductsRequestOptions = ({
|
|
136
|
+
userId: string;
|
|
137
|
+
} & CustomerProductsListOptions) | ({
|
|
138
|
+
teamId: string;
|
|
139
|
+
} & CustomerProductsListOptions) | ({
|
|
140
|
+
customCustomerId: string;
|
|
141
|
+
} & CustomerProductsListOptions);
|
|
120
142
|
type Customer<IsServer extends boolean = false> = {
|
|
121
143
|
readonly id: string;
|
|
122
144
|
createCheckoutUrl(options: ({
|
|
123
|
-
|
|
145
|
+
productId: string;
|
|
146
|
+
returnUrl?: string;
|
|
124
147
|
} | (IsServer extends true ? {
|
|
125
|
-
|
|
148
|
+
product: InlineProduct;
|
|
149
|
+
returnUrl?: string;
|
|
126
150
|
} : never))): Promise<string>;
|
|
127
151
|
} & AsyncStoreProperty<"item", [
|
|
128
152
|
itemId: string
|
|
129
|
-
], IsServer extends true ? ServerItem : Item, false
|
|
153
|
+
], IsServer extends true ? ServerItem : Item, false> & AsyncStoreProperty<"products", [
|
|
154
|
+
options?: CustomerProductsListOptions
|
|
155
|
+
], CustomerProductsList, true> & (IsServer extends true ? {
|
|
156
|
+
grantProduct(product: {
|
|
157
|
+
productId: string;
|
|
158
|
+
quantity?: number;
|
|
159
|
+
} | {
|
|
160
|
+
product: InlineProduct;
|
|
161
|
+
quantity?: number;
|
|
162
|
+
}): Promise<void>;
|
|
163
|
+
} : {});
|
|
130
164
|
|
|
131
165
|
type AdminSentEmail = {
|
|
132
166
|
id: string;
|
|
@@ -560,6 +594,7 @@ type UserExtra = {
|
|
|
560
594
|
}], TeamPermission[], true>;
|
|
561
595
|
type InternalUserExtra = {
|
|
562
596
|
createProject(newProject: AdminProjectCreateOptions): Promise<AdminOwnedProject>;
|
|
597
|
+
transferProject(projectIdToTransfer: string, newTeamId: string): Promise<void>;
|
|
563
598
|
} & AsyncStoreProperty<"ownedProjects", [], AdminOwnedProject[], true>;
|
|
564
599
|
type User = BaseUser;
|
|
565
600
|
type CurrentUser = BaseUser & Auth & UserExtra & Customer;
|
|
@@ -747,6 +782,19 @@ type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
747
782
|
*/
|
|
748
783
|
getServerUser(): Promise<ProjectCurrentServerUser<ProjectId> | null>;
|
|
749
784
|
createUser(options: ServerUserCreateOptions): Promise<ServerUser>;
|
|
785
|
+
grantProduct(options: (({
|
|
786
|
+
userId: string;
|
|
787
|
+
} | {
|
|
788
|
+
teamId: string;
|
|
789
|
+
} | {
|
|
790
|
+
customCustomerId: string;
|
|
791
|
+
}) & ({
|
|
792
|
+
productId: string;
|
|
793
|
+
} | {
|
|
794
|
+
product: InlineProduct;
|
|
795
|
+
}) & {
|
|
796
|
+
quantity?: number;
|
|
797
|
+
})): Promise<void>;
|
|
750
798
|
getUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
751
799
|
or: 'redirect';
|
|
752
800
|
}): Promise<ProjectCurrentServerUser<ProjectId>>;
|
|
@@ -801,14 +849,15 @@ type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
801
849
|
itemId: string;
|
|
802
850
|
customCustomerId: string;
|
|
803
851
|
}
|
|
804
|
-
], ServerItem, false> &
|
|
852
|
+
], ServerItem, false> & AsyncStoreProperty<"products", [
|
|
853
|
+
options: CustomerProductsRequestOptions
|
|
854
|
+
], CustomerProductsList, true> & StackClientApp<HasTokenStore, ProjectId>);
|
|
805
855
|
declare const StackServerApp: StackServerAppConstructor;
|
|
806
856
|
|
|
807
|
-
type StackAdminAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = (
|
|
857
|
+
type StackAdminAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = (StackServerAppConstructorOptions<HasTokenStore, ProjectId> & {
|
|
808
858
|
superSecretAdminKey?: string;
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
}));
|
|
859
|
+
projectOwnerSession?: InternalSession;
|
|
860
|
+
});
|
|
812
861
|
type StackAdminAppConstructor = {
|
|
813
862
|
new <HasTokenStore extends boolean, ProjectId extends string>(options: StackAdminAppConstructorOptions<HasTokenStore, ProjectId>): StackAdminApp<HasTokenStore, ProjectId>;
|
|
814
863
|
new (options: StackAdminAppConstructorOptions<boolean, string>): StackAdminApp<boolean, string>;
|
|
@@ -920,11 +969,6 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
|
|
|
920
969
|
expiresAt?: string;
|
|
921
970
|
description?: string;
|
|
922
971
|
})): Promise<void>;
|
|
923
|
-
testModePurchase(options: {
|
|
924
|
-
priceId: string;
|
|
925
|
-
fullCode: string;
|
|
926
|
-
quantity?: number;
|
|
927
|
-
}): Promise<void>;
|
|
928
972
|
} & StackServerApp<HasTokenStore, ProjectId>);
|
|
929
973
|
declare const StackAdminApp: StackAdminAppConstructor;
|
|
930
974
|
|
|
@@ -1035,7 +1079,6 @@ type AdminProject = {
|
|
|
1035
1079
|
readonly config: AdminProjectConfig;
|
|
1036
1080
|
update(this: AdminProject, update: AdminProjectUpdateOptions): Promise<void>;
|
|
1037
1081
|
delete(this: AdminProject): Promise<void>;
|
|
1038
|
-
transfer(this: AdminProject, user: CurrentUser, newTeamId: string): Promise<void>;
|
|
1039
1082
|
getConfig(this: AdminProject): Promise<CompleteConfig>;
|
|
1040
1083
|
updateConfig(this: AdminProject, config: EnvironmentConfigOverrideOverride): Promise<void>;
|
|
1041
1084
|
getProductionModeErrors(this: AdminProject): Promise<ProductionModeError[]>;
|
|
@@ -1066,16 +1109,28 @@ type StackClientAppConstructorOptions<HasTokenStore extends boolean, ProjectId e
|
|
|
1066
1109
|
publishableClientKey?: string;
|
|
1067
1110
|
urls?: Partial<HandlerUrls>;
|
|
1068
1111
|
oauthScopesOnSignIn?: Partial<OAuthScopesOnSignIn>;
|
|
1069
|
-
tokenStore
|
|
1112
|
+
tokenStore?: TokenStoreInit<HasTokenStore>;
|
|
1070
1113
|
redirectMethod?: RedirectMethod;
|
|
1114
|
+
inheritsFrom?: StackClientApp<any, any>;
|
|
1071
1115
|
/**
|
|
1072
1116
|
* By default, the Stack app will automatically prefetch some data from Stack's server when this app is first
|
|
1073
1117
|
* constructed. This improves the performance of your app, but will create network requests that are unnecessary if
|
|
1074
1118
|
* the app is never used or disposed of immediately. To disable this behavior, set this option to true.
|
|
1075
1119
|
*/
|
|
1076
1120
|
noAutomaticPrefetch?: boolean;
|
|
1077
|
-
}
|
|
1121
|
+
} & ({
|
|
1122
|
+
tokenStore: TokenStoreInit<HasTokenStore>;
|
|
1123
|
+
} | {
|
|
1124
|
+
tokenStore?: undefined;
|
|
1125
|
+
inheritsFrom: StackClientApp<HasTokenStore, any>;
|
|
1126
|
+
}) & (string extends ProjectId ? unknown : ({
|
|
1127
|
+
projectId: ProjectId;
|
|
1128
|
+
} | {
|
|
1129
|
+
inheritsFrom: StackClientApp<any, ProjectId>;
|
|
1130
|
+
}));
|
|
1078
1131
|
type StackClientAppJson<HasTokenStore extends boolean, ProjectId extends string> = StackClientAppConstructorOptions<HasTokenStore, ProjectId> & {
|
|
1132
|
+
inheritsFrom?: undefined;
|
|
1133
|
+
} & {
|
|
1079
1134
|
uniqueIdentifier: string;
|
|
1080
1135
|
};
|
|
1081
1136
|
type StackClientAppConstructor = {
|
|
@@ -1134,8 +1189,10 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
1134
1189
|
noRedirect?: boolean;
|
|
1135
1190
|
}): Promise<Result<undefined, KnownErrors["VerificationCodeError"] | KnownErrors["InvalidTotpCode"]>>;
|
|
1136
1191
|
redirectToOAuthCallback(): Promise<void>;
|
|
1137
|
-
getConvexClientAuth(options: {
|
|
1192
|
+
getConvexClientAuth(options: HasTokenStore extends false ? {
|
|
1138
1193
|
tokenStore: TokenStoreInit;
|
|
1194
|
+
} : {
|
|
1195
|
+
tokenStore?: TokenStoreInit;
|
|
1139
1196
|
}): (args: {
|
|
1140
1197
|
forceRefreshToken: boolean;
|
|
1141
1198
|
}) => Promise<string | null>;
|
|
@@ -1162,6 +1219,9 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
1162
1219
|
[stackAppInternalsSymbol]: {
|
|
1163
1220
|
toClientJson(): StackClientAppJson<HasTokenStore, ProjectId>;
|
|
1164
1221
|
setCurrentUser(userJsonPromise: Promise<CurrentUserCrud['Client']['Read'] | null>): void;
|
|
1222
|
+
getConstructorOptions(): StackClientAppConstructorOptions<HasTokenStore, ProjectId> & {
|
|
1223
|
+
inheritsFrom?: undefined;
|
|
1224
|
+
};
|
|
1165
1225
|
};
|
|
1166
1226
|
} & AsyncStoreProperty<"project", [], Project, false> & AsyncStoreProperty<"item", [
|
|
1167
1227
|
{
|
|
@@ -1174,17 +1234,20 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
1174
1234
|
itemId: string;
|
|
1175
1235
|
customCustomerId: string;
|
|
1176
1236
|
}
|
|
1177
|
-
], Item, false> &
|
|
1237
|
+
], Item, false> & AsyncStoreProperty<"products", [
|
|
1238
|
+
options: CustomerProductsRequestOptions
|
|
1239
|
+
], CustomerProductsList, true> & {
|
|
1178
1240
|
[K in `redirectTo${Capitalize<keyof Omit<HandlerUrls, 'handler' | 'oauthCallback'>>}`]: (options?: RedirectToOptions) => Promise<void>;
|
|
1179
1241
|
});
|
|
1180
1242
|
declare const StackClientApp: StackClientAppConstructor;
|
|
1181
1243
|
|
|
1182
1244
|
declare function getConvexProvidersConfig(options: {
|
|
1183
|
-
|
|
1245
|
+
baseUrl?: string;
|
|
1246
|
+
projectId: string;
|
|
1184
1247
|
}): {
|
|
1185
1248
|
type: string;
|
|
1186
|
-
issuer:
|
|
1187
|
-
jwks:
|
|
1249
|
+
issuer: URL;
|
|
1250
|
+
jwks: URL;
|
|
1188
1251
|
algorithm: string;
|
|
1189
1252
|
}[];
|
|
1190
1253
|
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { CurrentUserCrud } from '@stackframe/stack-shared/dist/interface/crud/cu
|
|
|
3
3
|
import { Result } from '@stackframe/stack-shared/dist/utils/results';
|
|
4
4
|
import { ProviderType } from '@stackframe/stack-shared/dist/utils/oauth';
|
|
5
5
|
import { GenericQueryCtx, UserIdentity } from 'convex/server';
|
|
6
|
-
import {
|
|
6
|
+
import { inlineProductSchema } from '@stackframe/stack-shared/dist/schema-fields';
|
|
7
7
|
import * as yup from 'yup';
|
|
8
8
|
import { ProductionModeError } from '@stackframe/stack-shared/dist/helpers/production-mode';
|
|
9
9
|
import { CompleteConfig, EnvironmentConfigOverrideOverride } from '@stackframe/stack-shared/dist/config/schema';
|
|
@@ -90,7 +90,7 @@ type OAuthScopesOnSignIn = {
|
|
|
90
90
|
/** @internal */
|
|
91
91
|
declare const stackAppInternalsSymbol: unique symbol;
|
|
92
92
|
|
|
93
|
-
type
|
|
93
|
+
type InlineProduct = yup.InferType<typeof inlineProductSchema>;
|
|
94
94
|
type Item = {
|
|
95
95
|
displayName: string;
|
|
96
96
|
/**
|
|
@@ -117,16 +117,50 @@ type ServerItem = Item & {
|
|
|
117
117
|
*/
|
|
118
118
|
tryDecreaseQuantity(amount: number): Promise<boolean>;
|
|
119
119
|
};
|
|
120
|
+
type CustomerProduct = {
|
|
121
|
+
id: string | null;
|
|
122
|
+
quantity: number;
|
|
123
|
+
displayName: string;
|
|
124
|
+
customerType: "user" | "team" | "custom";
|
|
125
|
+
isServerOnly: boolean;
|
|
126
|
+
stackable: boolean;
|
|
127
|
+
};
|
|
128
|
+
type CustomerProductsList = CustomerProduct[] & {
|
|
129
|
+
nextCursor: string | null;
|
|
130
|
+
};
|
|
131
|
+
type CustomerProductsListOptions = {
|
|
132
|
+
cursor?: string;
|
|
133
|
+
limit?: number;
|
|
134
|
+
};
|
|
135
|
+
type CustomerProductsRequestOptions = ({
|
|
136
|
+
userId: string;
|
|
137
|
+
} & CustomerProductsListOptions) | ({
|
|
138
|
+
teamId: string;
|
|
139
|
+
} & CustomerProductsListOptions) | ({
|
|
140
|
+
customCustomerId: string;
|
|
141
|
+
} & CustomerProductsListOptions);
|
|
120
142
|
type Customer<IsServer extends boolean = false> = {
|
|
121
143
|
readonly id: string;
|
|
122
144
|
createCheckoutUrl(options: ({
|
|
123
|
-
|
|
145
|
+
productId: string;
|
|
146
|
+
returnUrl?: string;
|
|
124
147
|
} | (IsServer extends true ? {
|
|
125
|
-
|
|
148
|
+
product: InlineProduct;
|
|
149
|
+
returnUrl?: string;
|
|
126
150
|
} : never))): Promise<string>;
|
|
127
151
|
} & AsyncStoreProperty<"item", [
|
|
128
152
|
itemId: string
|
|
129
|
-
], IsServer extends true ? ServerItem : Item, false
|
|
153
|
+
], IsServer extends true ? ServerItem : Item, false> & AsyncStoreProperty<"products", [
|
|
154
|
+
options?: CustomerProductsListOptions
|
|
155
|
+
], CustomerProductsList, true> & (IsServer extends true ? {
|
|
156
|
+
grantProduct(product: {
|
|
157
|
+
productId: string;
|
|
158
|
+
quantity?: number;
|
|
159
|
+
} | {
|
|
160
|
+
product: InlineProduct;
|
|
161
|
+
quantity?: number;
|
|
162
|
+
}): Promise<void>;
|
|
163
|
+
} : {});
|
|
130
164
|
|
|
131
165
|
type AdminSentEmail = {
|
|
132
166
|
id: string;
|
|
@@ -560,6 +594,7 @@ type UserExtra = {
|
|
|
560
594
|
}], TeamPermission[], true>;
|
|
561
595
|
type InternalUserExtra = {
|
|
562
596
|
createProject(newProject: AdminProjectCreateOptions): Promise<AdminOwnedProject>;
|
|
597
|
+
transferProject(projectIdToTransfer: string, newTeamId: string): Promise<void>;
|
|
563
598
|
} & AsyncStoreProperty<"ownedProjects", [], AdminOwnedProject[], true>;
|
|
564
599
|
type User = BaseUser;
|
|
565
600
|
type CurrentUser = BaseUser & Auth & UserExtra & Customer;
|
|
@@ -747,6 +782,19 @@ type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
747
782
|
*/
|
|
748
783
|
getServerUser(): Promise<ProjectCurrentServerUser<ProjectId> | null>;
|
|
749
784
|
createUser(options: ServerUserCreateOptions): Promise<ServerUser>;
|
|
785
|
+
grantProduct(options: (({
|
|
786
|
+
userId: string;
|
|
787
|
+
} | {
|
|
788
|
+
teamId: string;
|
|
789
|
+
} | {
|
|
790
|
+
customCustomerId: string;
|
|
791
|
+
}) & ({
|
|
792
|
+
productId: string;
|
|
793
|
+
} | {
|
|
794
|
+
product: InlineProduct;
|
|
795
|
+
}) & {
|
|
796
|
+
quantity?: number;
|
|
797
|
+
})): Promise<void>;
|
|
750
798
|
getUser(options: GetCurrentUserOptions<HasTokenStore> & {
|
|
751
799
|
or: 'redirect';
|
|
752
800
|
}): Promise<ProjectCurrentServerUser<ProjectId>>;
|
|
@@ -801,14 +849,15 @@ type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
801
849
|
itemId: string;
|
|
802
850
|
customCustomerId: string;
|
|
803
851
|
}
|
|
804
|
-
], ServerItem, false> &
|
|
852
|
+
], ServerItem, false> & AsyncStoreProperty<"products", [
|
|
853
|
+
options: CustomerProductsRequestOptions
|
|
854
|
+
], CustomerProductsList, true> & StackClientApp<HasTokenStore, ProjectId>);
|
|
805
855
|
declare const StackServerApp: StackServerAppConstructor;
|
|
806
856
|
|
|
807
|
-
type StackAdminAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = (
|
|
857
|
+
type StackAdminAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = (StackServerAppConstructorOptions<HasTokenStore, ProjectId> & {
|
|
808
858
|
superSecretAdminKey?: string;
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
}));
|
|
859
|
+
projectOwnerSession?: InternalSession;
|
|
860
|
+
});
|
|
812
861
|
type StackAdminAppConstructor = {
|
|
813
862
|
new <HasTokenStore extends boolean, ProjectId extends string>(options: StackAdminAppConstructorOptions<HasTokenStore, ProjectId>): StackAdminApp<HasTokenStore, ProjectId>;
|
|
814
863
|
new (options: StackAdminAppConstructorOptions<boolean, string>): StackAdminApp<boolean, string>;
|
|
@@ -920,11 +969,6 @@ type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends st
|
|
|
920
969
|
expiresAt?: string;
|
|
921
970
|
description?: string;
|
|
922
971
|
})): Promise<void>;
|
|
923
|
-
testModePurchase(options: {
|
|
924
|
-
priceId: string;
|
|
925
|
-
fullCode: string;
|
|
926
|
-
quantity?: number;
|
|
927
|
-
}): Promise<void>;
|
|
928
972
|
} & StackServerApp<HasTokenStore, ProjectId>);
|
|
929
973
|
declare const StackAdminApp: StackAdminAppConstructor;
|
|
930
974
|
|
|
@@ -1035,7 +1079,6 @@ type AdminProject = {
|
|
|
1035
1079
|
readonly config: AdminProjectConfig;
|
|
1036
1080
|
update(this: AdminProject, update: AdminProjectUpdateOptions): Promise<void>;
|
|
1037
1081
|
delete(this: AdminProject): Promise<void>;
|
|
1038
|
-
transfer(this: AdminProject, user: CurrentUser, newTeamId: string): Promise<void>;
|
|
1039
1082
|
getConfig(this: AdminProject): Promise<CompleteConfig>;
|
|
1040
1083
|
updateConfig(this: AdminProject, config: EnvironmentConfigOverrideOverride): Promise<void>;
|
|
1041
1084
|
getProductionModeErrors(this: AdminProject): Promise<ProductionModeError[]>;
|
|
@@ -1066,16 +1109,28 @@ type StackClientAppConstructorOptions<HasTokenStore extends boolean, ProjectId e
|
|
|
1066
1109
|
publishableClientKey?: string;
|
|
1067
1110
|
urls?: Partial<HandlerUrls>;
|
|
1068
1111
|
oauthScopesOnSignIn?: Partial<OAuthScopesOnSignIn>;
|
|
1069
|
-
tokenStore
|
|
1112
|
+
tokenStore?: TokenStoreInit<HasTokenStore>;
|
|
1070
1113
|
redirectMethod?: RedirectMethod;
|
|
1114
|
+
inheritsFrom?: StackClientApp<any, any>;
|
|
1071
1115
|
/**
|
|
1072
1116
|
* By default, the Stack app will automatically prefetch some data from Stack's server when this app is first
|
|
1073
1117
|
* constructed. This improves the performance of your app, but will create network requests that are unnecessary if
|
|
1074
1118
|
* the app is never used or disposed of immediately. To disable this behavior, set this option to true.
|
|
1075
1119
|
*/
|
|
1076
1120
|
noAutomaticPrefetch?: boolean;
|
|
1077
|
-
}
|
|
1121
|
+
} & ({
|
|
1122
|
+
tokenStore: TokenStoreInit<HasTokenStore>;
|
|
1123
|
+
} | {
|
|
1124
|
+
tokenStore?: undefined;
|
|
1125
|
+
inheritsFrom: StackClientApp<HasTokenStore, any>;
|
|
1126
|
+
}) & (string extends ProjectId ? unknown : ({
|
|
1127
|
+
projectId: ProjectId;
|
|
1128
|
+
} | {
|
|
1129
|
+
inheritsFrom: StackClientApp<any, ProjectId>;
|
|
1130
|
+
}));
|
|
1078
1131
|
type StackClientAppJson<HasTokenStore extends boolean, ProjectId extends string> = StackClientAppConstructorOptions<HasTokenStore, ProjectId> & {
|
|
1132
|
+
inheritsFrom?: undefined;
|
|
1133
|
+
} & {
|
|
1079
1134
|
uniqueIdentifier: string;
|
|
1080
1135
|
};
|
|
1081
1136
|
type StackClientAppConstructor = {
|
|
@@ -1134,8 +1189,10 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
1134
1189
|
noRedirect?: boolean;
|
|
1135
1190
|
}): Promise<Result<undefined, KnownErrors["VerificationCodeError"] | KnownErrors["InvalidTotpCode"]>>;
|
|
1136
1191
|
redirectToOAuthCallback(): Promise<void>;
|
|
1137
|
-
getConvexClientAuth(options: {
|
|
1192
|
+
getConvexClientAuth(options: HasTokenStore extends false ? {
|
|
1138
1193
|
tokenStore: TokenStoreInit;
|
|
1194
|
+
} : {
|
|
1195
|
+
tokenStore?: TokenStoreInit;
|
|
1139
1196
|
}): (args: {
|
|
1140
1197
|
forceRefreshToken: boolean;
|
|
1141
1198
|
}) => Promise<string | null>;
|
|
@@ -1162,6 +1219,9 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
1162
1219
|
[stackAppInternalsSymbol]: {
|
|
1163
1220
|
toClientJson(): StackClientAppJson<HasTokenStore, ProjectId>;
|
|
1164
1221
|
setCurrentUser(userJsonPromise: Promise<CurrentUserCrud['Client']['Read'] | null>): void;
|
|
1222
|
+
getConstructorOptions(): StackClientAppConstructorOptions<HasTokenStore, ProjectId> & {
|
|
1223
|
+
inheritsFrom?: undefined;
|
|
1224
|
+
};
|
|
1165
1225
|
};
|
|
1166
1226
|
} & AsyncStoreProperty<"project", [], Project, false> & AsyncStoreProperty<"item", [
|
|
1167
1227
|
{
|
|
@@ -1174,17 +1234,20 @@ type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends s
|
|
|
1174
1234
|
itemId: string;
|
|
1175
1235
|
customCustomerId: string;
|
|
1176
1236
|
}
|
|
1177
|
-
], Item, false> &
|
|
1237
|
+
], Item, false> & AsyncStoreProperty<"products", [
|
|
1238
|
+
options: CustomerProductsRequestOptions
|
|
1239
|
+
], CustomerProductsList, true> & {
|
|
1178
1240
|
[K in `redirectTo${Capitalize<keyof Omit<HandlerUrls, 'handler' | 'oauthCallback'>>}`]: (options?: RedirectToOptions) => Promise<void>;
|
|
1179
1241
|
});
|
|
1180
1242
|
declare const StackClientApp: StackClientAppConstructor;
|
|
1181
1243
|
|
|
1182
1244
|
declare function getConvexProvidersConfig(options: {
|
|
1183
|
-
|
|
1245
|
+
baseUrl?: string;
|
|
1246
|
+
projectId: string;
|
|
1184
1247
|
}): {
|
|
1185
1248
|
type: string;
|
|
1186
|
-
issuer:
|
|
1187
|
-
jwks:
|
|
1249
|
+
issuer: URL;
|
|
1250
|
+
jwks: URL;
|
|
1188
1251
|
algorithm: string;
|
|
1189
1252
|
}[];
|
|
1190
1253
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/integrations/convex/component/convex.config.ts
|
|
21
|
+
var convex_config_exports = {};
|
|
22
|
+
__export(convex_config_exports, {
|
|
23
|
+
default: () => convex_config_default
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(convex_config_exports);
|
|
26
|
+
var import_server = require("convex/server");
|
|
27
|
+
var component = (0, import_server.defineComponent)("stack_auth");
|
|
28
|
+
var convex_config_default = component;
|
|
29
|
+
//# sourceMappingURL=convex.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/integrations/convex/component/convex.config.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { defineComponent } from \"convex/server\";\n\nconst component = defineComponent(\"stack_auth\");\n\nexport default component;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,oBAAgC;AAEhC,IAAM,gBAAY,+BAAgB,YAAY;AAE9C,IAAO,wBAAQ;","names":[]}
|
|
@@ -26,12 +26,13 @@ module.exports = __toCommonJS(convex_exports);
|
|
|
26
26
|
var import_urls = require("@stackframe/stack-shared/dist/utils/urls");
|
|
27
27
|
var import_common = require("../lib/stack-app/apps/implementations/common.js");
|
|
28
28
|
function getConvexProvidersConfig(options) {
|
|
29
|
-
const
|
|
29
|
+
const baseUrl = options.baseUrl || import_common.defaultBaseUrl;
|
|
30
|
+
const projectId = options.projectId;
|
|
30
31
|
return [
|
|
31
32
|
{
|
|
32
33
|
type: "customJwt",
|
|
33
|
-
issuer: import_urls.urlString
|
|
34
|
-
jwks: import_urls.urlString
|
|
34
|
+
issuer: new URL(import_urls.urlString`/api/v1/projects/${projectId}`, baseUrl),
|
|
35
|
+
jwks: new URL(import_urls.urlString`/api/v1/projects/${projectId}/.well-known/jwks.json?include_anonymous=true`, baseUrl),
|
|
35
36
|
algorithm: "ES256"
|
|
36
37
|
}
|
|
37
38
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/integrations/convex.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { urlString } from \"@stackframe/stack-shared/dist/utils/urls\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/integrations/convex.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { urlString } from \"@stackframe/stack-shared/dist/utils/urls\";\nimport { defaultBaseUrl } from \"../lib/stack-app/apps/implementations/common\";\n\nexport function getConvexProvidersConfig(options: {\n baseUrl?: string,\n projectId: string,\n}) {\n const baseUrl = options.baseUrl || defaultBaseUrl;\n const projectId = options.projectId;\n return [\n {\n type: \"customJwt\",\n issuer: new URL(urlString`/api/v1/projects/${projectId}`, baseUrl),\n jwks: new URL(urlString`/api/v1/projects/${projectId}/.well-known/jwks.json?include_anonymous=true`, baseUrl),\n algorithm: \"ES256\",\n },\n ];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,kBAA0B;AAC1B,oBAA+B;AAExB,SAAS,yBAAyB,SAGtC;AACD,QAAM,UAAU,QAAQ,WAAW;AACnC,QAAM,YAAY,QAAQ;AAC1B,SAAO;AAAA,IACL;AAAA,MACE,MAAM;AAAA,MACN,QAAQ,IAAI,IAAI,yCAA6B,SAAS,IAAI,OAAO;AAAA,MACjE,MAAM,IAAI,IAAI,yCAA6B,SAAS,iDAAiD,OAAO;AAAA,MAC5G,WAAW;AAAA,IACb;AAAA,EACF;AACF;","names":[]}
|