@stackframe/react 2.8.49 → 2.8.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/components-page/password-reset.js +6 -5
  3. package/dist/components-page/password-reset.js.map +1 -1
  4. package/dist/components-page/sign-out.js +2 -12
  5. package/dist/components-page/sign-out.js.map +1 -1
  6. package/dist/components-page/stack-handler-client.js +274 -0
  7. package/dist/components-page/stack-handler-client.js.map +1 -0
  8. package/dist/components-page/stack-handler.js +4 -239
  9. package/dist/components-page/stack-handler.js.map +1 -1
  10. package/dist/components-page/team-invitation.js +6 -5
  11. package/dist/components-page/team-invitation.js.map +1 -1
  12. package/dist/esm/components-page/password-reset.js +3 -2
  13. package/dist/esm/components-page/password-reset.js.map +1 -1
  14. package/dist/esm/components-page/sign-out.js +2 -2
  15. package/dist/esm/components-page/sign-out.js.map +1 -1
  16. package/dist/esm/components-page/stack-handler-client.js +250 -0
  17. package/dist/esm/components-page/stack-handler-client.js.map +1 -0
  18. package/dist/esm/components-page/stack-handler.js +4 -239
  19. package/dist/esm/components-page/stack-handler.js.map +1 -1
  20. package/dist/esm/components-page/team-invitation.js +3 -2
  21. package/dist/esm/components-page/team-invitation.js.map +1 -1
  22. package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js +7 -0
  23. package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
  24. package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js +49 -32
  25. package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
  26. package/dist/esm/lib/stack-app/apps/implementations/common.js +3 -3
  27. package/dist/esm/lib/stack-app/apps/implementations/common.js.map +1 -1
  28. package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js +39 -0
  29. package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
  30. package/dist/esm/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
  31. package/dist/esm/lib/stack-app/common.js.map +1 -1
  32. package/dist/esm/lib/stack-app/users/index.js.map +1 -1
  33. package/dist/index.d.mts +119 -89
  34. package/dist/index.d.ts +119 -89
  35. package/dist/lib/stack-app/apps/implementations/admin-app-impl.js +7 -0
  36. package/dist/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
  37. package/dist/lib/stack-app/apps/implementations/client-app-impl.js +49 -32
  38. package/dist/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
  39. package/dist/lib/stack-app/apps/implementations/common.js +2 -2
  40. package/dist/lib/stack-app/apps/implementations/common.js.map +1 -1
  41. package/dist/lib/stack-app/apps/implementations/server-app-impl.js +49 -0
  42. package/dist/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
  43. package/dist/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
  44. package/dist/lib/stack-app/common.js.map +1 -1
  45. package/dist/lib/stack-app/users/index.js.map +1 -1
  46. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/lib/stack-app/apps/implementations/server-app-impl.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { KnownErrors, StackServerInterface } from \"@stackframe/stack-shared\";\nimport { ContactChannelsCrud } from \"@stackframe/stack-shared/dist/interface/crud/contact-channels\";\nimport { ItemCrud } from \"@stackframe/stack-shared/dist/interface/crud/items\";\nimport { NotificationPreferenceCrud } from \"@stackframe/stack-shared/dist/interface/crud/notification-preferences\";\nimport { OAuthProviderCrud } from \"@stackframe/stack-shared/dist/interface/crud/oauth-providers\";\nimport type { CustomerProductsListResponse } from \"@stackframe/stack-shared/dist/interface/crud/products\";\nimport { TeamApiKeysCrud, UserApiKeysCrud, teamApiKeysCreateOutputSchema, userApiKeysCreateOutputSchema } from \"@stackframe/stack-shared/dist/interface/crud/project-api-keys\";\nimport { ProjectPermissionDefinitionsCrud, ProjectPermissionsCrud } from \"@stackframe/stack-shared/dist/interface/crud/project-permissions\";\nimport { TeamInvitationCrud } from \"@stackframe/stack-shared/dist/interface/crud/team-invitation\";\nimport { TeamMemberProfilesCrud } from \"@stackframe/stack-shared/dist/interface/crud/team-member-profiles\";\nimport { TeamPermissionDefinitionsCrud, TeamPermissionsCrud } from \"@stackframe/stack-shared/dist/interface/crud/team-permissions\";\nimport { TeamsCrud } from \"@stackframe/stack-shared/dist/interface/crud/teams\";\nimport { UsersCrud } from \"@stackframe/stack-shared/dist/interface/crud/users\";\nimport { InternalSession } from \"@stackframe/stack-shared/dist/sessions\";\nimport type { AsyncCache } from \"@stackframe/stack-shared/dist/utils/caches\";\nimport { StackAssertionError, throwErr } from \"@stackframe/stack-shared/dist/utils/errors\";\nimport { ProviderType } from \"@stackframe/stack-shared/dist/utils/oauth\";\nimport { runAsynchronously } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport { suspend } from \"@stackframe/stack-shared/dist/utils/react\";\nimport { Result } from \"@stackframe/stack-shared/dist/utils/results\";\nimport { useMemo } from \"react\"; // THIS_LINE_PLATFORM react-like\nimport * as yup from \"yup\";\nimport { constructRedirectUrl } from \"../../../../utils/url\";\nimport { ApiKey, ApiKeyCreationOptions, ApiKeyUpdateOptions, apiKeyCreationOptionsToCrud, apiKeyUpdateOptionsToCrud } from \"../../api-keys\";\nimport { ConvexCtx, GetCurrentUserOptions } from \"../../common\";\nimport { OAuthConnection } from \"../../connected-accounts\";\nimport { ServerContactChannel, ServerContactChannelCreateOptions, ServerContactChannelUpdateOptions, serverContactChannelCreateOptionsToCrud, serverContactChannelUpdateOptionsToCrud } from \"../../contact-channels\";\nimport { Customer, InlineProduct, ServerItem } from \"../../customers\";\nimport { DataVaultStore } from \"../../data-vault\";\nimport { SendEmailOptions } from \"../../email\";\nimport { NotificationCategory } from \"../../notification-categories\";\nimport { AdminProjectPermissionDefinition, AdminTeamPermission, AdminTeamPermissionDefinition } from \"../../permissions\";\nimport { EditableTeamMemberProfile, ServerListUsersOptions, ServerTeam, ServerTeamCreateOptions, ServerTeamUpdateOptions, ServerTeamUser, Team, TeamInvitation, serverTeamCreateOptionsToCrud, serverTeamUpdateOptionsToCrud } from \"../../teams\";\nimport { ProjectCurrentServerUser, ServerOAuthProvider, ServerUser, ServerUserCreateOptions, ServerUserUpdateOptions, attachUserDestructureGuard, serverUserCreateOptionsToCrud, serverUserUpdateOptionsToCrud } from \"../../users\";\nimport { StackServerAppConstructorOptions } from \"../interfaces/server-app\";\nimport { _StackClientAppImplIncomplete } from \"./client-app-impl\";\nimport { clientVersion, createCache, createCacheBySession, getBaseUrl, getDefaultExtraRequestHeaders, getDefaultProjectId, getDefaultPublishableClientKey, getDefaultSecretServerKey, resolveConstructorOptions } from \"./common\";\n\nimport { useAsyncCache } from \"./common\"; // THIS_LINE_PLATFORM react-like\n\nexport class _StackServerAppImplIncomplete<HasTokenStore extends boolean, ProjectId extends string> extends _StackClientAppImplIncomplete<HasTokenStore, ProjectId> {\n declare protected _interface: StackServerInterface;\n\n // TODO override the client user cache to use the server user cache, so we save some requests\n private readonly _currentServerUserCache = createCacheBySession(async (session) => {\n if (session.isKnownToBeInvalid()) {\n // see comment in _currentUserCache for more details on why we do this\n return null;\n }\n return await this._interface.getServerUserByToken(session);\n });\n private readonly _serverUsersCache = createCache<[\n cursor?: string,\n limit?: number,\n orderBy?: 'signedUpAt',\n desc?: boolean,\n query?: string,\n includeAnonymous?: boolean,\n ], UsersCrud['Server']['List']>(async ([cursor, limit, orderBy, desc, query, includeAnonymous]) => {\n return await this._interface.listServerUsers({ cursor, limit, orderBy, desc, query, includeAnonymous });\n });\n private readonly _serverUserCache = createCache<string[], UsersCrud['Server']['Read'] | null>(async ([userId]) => {\n const user = await this._interface.getServerUserById(userId);\n return Result.or(user, null);\n });\n private readonly _serverTeamsCache = createCache<[string | undefined], TeamsCrud['Server']['Read'][]>(async ([userId]) => {\n return await this._interface.listServerTeams({ userId });\n });\n private readonly _serverTeamUserPermissionsCache = createCache<\n [string, string, boolean],\n TeamPermissionsCrud['Server']['Read'][]\n >(async ([teamId, userId, recursive]) => {\n return await this._interface.listServerTeamPermissions({ teamId, userId, recursive }, null);\n });\n private readonly _serverUserProjectPermissionsCache = createCache<\n [string, boolean],\n ProjectPermissionsCrud['Server']['Read'][]\n >(async ([userId, recursive]) => {\n return await this._interface.listServerProjectPermissions({ userId, recursive }, null);\n });\n private readonly _serverUserOAuthConnectionAccessTokensCache = createCache<[string, string, string], { accessToken: string } | null>(\n async ([userId, providerId, scope]) => {\n try {\n const result = await this._interface.createServerProviderAccessToken(userId, providerId, scope || \"\");\n return { accessToken: result.access_token };\n } catch (err) {\n if (!(KnownErrors.OAuthConnectionDoesNotHaveRequiredScope.isInstance(err) || KnownErrors.OAuthConnectionNotConnectedToUser.isInstance(err))) {\n throw err;\n }\n }\n return null;\n }\n );\n private readonly _serverUserOAuthConnectionCache = createCache<[string, ProviderType, string, boolean], OAuthConnection | null>(\n async ([userId, providerId, scope, redirect]) => {\n return await this._getUserOAuthConnectionCacheFn({\n getUser: async () => Result.orThrow(await this._serverUserCache.getOrWait([userId], \"write-only\")),\n getOrWaitOAuthToken: async () => Result.orThrow(await this._serverUserOAuthConnectionAccessTokensCache.getOrWait([userId, providerId, scope || \"\"] as const, \"write-only\")),\n useOAuthToken: () => useAsyncCache(this._serverUserOAuthConnectionAccessTokensCache, [userId, providerId, scope || \"\"] as const, \"user.useConnectedAccount()\"),\n providerId,\n scope,\n redirect,\n session: null,\n });\n }\n );\n private readonly _serverTeamMemberProfilesCache = createCache<[string], TeamMemberProfilesCrud['Server']['Read'][]>(\n async ([teamId]) => {\n return await this._interface.listServerTeamMemberProfiles({ teamId });\n }\n );\n private readonly _serverTeamInvitationsCache = createCache<[string], TeamInvitationCrud['Server']['Read'][]>(\n async ([teamId]) => {\n return await this._interface.listServerTeamInvitations({ teamId });\n }\n );\n private readonly _serverUserTeamProfileCache = createCache<[string, string], TeamMemberProfilesCrud['Client']['Read']>(\n async ([teamId, userId]) => {\n return await this._interface.getServerTeamMemberProfile({ teamId, userId });\n }\n );\n private readonly _serverContactChannelsCache = createCache<[string], ContactChannelsCrud['Server']['Read'][]>(\n async ([userId]) => {\n return await this._interface.listServerContactChannels(userId);\n }\n );\n private readonly _serverNotificationCategoriesCache = createCache<[string], NotificationPreferenceCrud['Server']['Read'][]>(\n async ([userId]) => {\n return await this._interface.listServerNotificationCategories(userId);\n }\n );\n private readonly _serverDataVaultStoreValueCache = createCache<[string, string, string], string | null>(async ([storeId, key, secret]) => {\n return await this._interface.getDataVaultStoreValue(secret, storeId, key);\n });\n\n private readonly _serverUserApiKeysCache = createCache<[string], UserApiKeysCrud['Server']['Read'][]>(\n async ([userId]) => {\n const result = await this._interface.listProjectApiKeys({\n user_id: userId,\n }, null, \"server\");\n return result as UserApiKeysCrud['Server']['Read'][];\n }\n );\n\n private readonly _serverTeamApiKeysCache = createCache<[string], TeamApiKeysCrud['Server']['Read'][]>(\n async ([teamId]) => {\n const result = await this._interface.listProjectApiKeys({\n team_id: teamId,\n }, null, \"server\");\n return result as TeamApiKeysCrud['Server']['Read'][];\n }\n );\n\n private readonly _convexIdentitySubjectCache = createCache<[ConvexCtx], string | null>(\n async ([ctx]) => {\n const identity = await ctx.auth.getUserIdentity();\n return identity ? identity.subject : null;\n }\n );\n\n private readonly _serverCheckApiKeyCache = createCache<[\"user\" | \"team\", string], UserApiKeysCrud['Server']['Read'] | TeamApiKeysCrud['Server']['Read'] | null>(async ([type, apiKey]) => {\n const result = await this._interface.checkProjectApiKey(\n type,\n apiKey,\n null,\n \"server\",\n );\n return result;\n });\n\n private readonly _serverOAuthProvidersCache = createCache<[string], OAuthProviderCrud['Server']['Read'][]>(\n async ([userId]) => {\n return await this._interface.listServerOAuthProviders({ user_id: userId });\n }\n );\n\n private readonly _serverTeamItemsCache = createCache<[string, string], ItemCrud['Client']['Read']>(\n async ([teamId, itemId]) => {\n return await this._interface.getItem({ teamId, itemId }, null);\n }\n );\n\n private readonly _serverUserItemsCache = createCache<[string, string], ItemCrud['Client']['Read']>(\n async ([userId, itemId]) => {\n return await this._interface.getItem({ userId, itemId }, null);\n }\n );\n\n private readonly _serverCustomItemsCache = createCache<[string, string], ItemCrud['Client']['Read']>(\n async ([customCustomerId, itemId]) => {\n return await this._interface.getItem({ customCustomerId, itemId }, null);\n }\n );\n\n private readonly _serverUserProductsCache = createCache<[string, string | null, number | null], CustomerProductsListResponse>(\n async ([userId, cursor, limit]) => {\n return await this._interface.listProducts({\n customer_type: \"user\",\n customer_id: userId,\n cursor: cursor ?? undefined,\n limit: limit ?? undefined,\n }, null);\n }\n );\n\n private readonly _serverTeamProductsCache = createCache<[string, string | null, number | null], CustomerProductsListResponse>(\n async ([teamId, cursor, limit]) => {\n return await this._interface.listProducts({\n customer_type: \"team\",\n customer_id: teamId,\n cursor: cursor ?? undefined,\n limit: limit ?? undefined,\n }, null);\n }\n );\n\n private readonly _serverCustomProductsCache = createCache<[string, string | null, number | null], CustomerProductsListResponse>(\n async ([customCustomerId, cursor, limit]) => {\n return await this._interface.listProducts({\n customer_type: \"custom\",\n customer_id: customCustomerId,\n cursor: cursor ?? undefined,\n limit: limit ?? undefined,\n }, null);\n }\n );\n\n protected _createServerCustomer(userIdOrTeamId: string, type: \"user\" | \"team\"): Omit<Customer<true>, \"id\"> {\n const app = this;\n const productsCache = type === \"user\" ? app._serverUserProductsCache : app._serverTeamProductsCache;\n const customerOptions = type === \"user\" ? { userId: userIdOrTeamId } : { teamId: userIdOrTeamId };\n return {\n ...this._createCustomer(userIdOrTeamId, type, null),\n async getItem(itemId: string) {\n return await app.getItem({ itemId, ...customerOptions });\n },\n useItem(itemId: string) {\n return app.useItem({ itemId, ...customerOptions });\n },\n async grantProduct(productOptions: { productId: string, quantity?: number } | { product: InlineProduct, quantity?: number }) {\n if (type === \"user\") {\n if (\"productId\" in productOptions) {\n await app.grantProduct({ userId: userIdOrTeamId, productId: productOptions.productId, quantity: productOptions.quantity });\n } else {\n await app.grantProduct({ userId: userIdOrTeamId, product: productOptions.product, quantity: productOptions.quantity });\n }\n } else {\n if (\"productId\" in productOptions) {\n await app.grantProduct({ teamId: userIdOrTeamId, productId: productOptions.productId, quantity: productOptions.quantity });\n } else {\n await app.grantProduct({ teamId: userIdOrTeamId, product: productOptions.product, quantity: productOptions.quantity });\n }\n }\n await productsCache.refresh([userIdOrTeamId, null, null]);\n },\n async createCheckoutUrl(options: { productId: string, returnUrl?: string } | { product: InlineProduct, returnUrl?: string }) {\n const productIdOrInline = \"productId\" in options ? options.productId : options.product;\n return await app._interface.createCheckoutUrl(type, userIdOrTeamId, productIdOrInline, null, options.returnUrl);\n },\n };\n }\n\n private async _updateServerUser(userId: string, update: ServerUserUpdateOptions): Promise<UsersCrud['Server']['Read']> {\n const result = await this._interface.updateServerUser(userId, serverUserUpdateOptionsToCrud(update));\n await this._refreshUsers();\n return result;\n }\n\n protected _serverEditableTeamProfileFromCrud(crud: TeamMemberProfilesCrud['Client']['Read']): EditableTeamMemberProfile {\n const app = this;\n return {\n displayName: crud.display_name,\n profileImageUrl: crud.profile_image_url,\n async update(update: { displayName?: string, profileImageUrl?: string }) {\n await app._interface.updateServerTeamMemberProfile({\n teamId: crud.team_id,\n userId: crud.user_id,\n profile: {\n display_name: update.displayName,\n profile_image_url: update.profileImageUrl,\n },\n });\n await app._serverUserTeamProfileCache.refresh([crud.team_id, crud.user_id]);\n }\n };\n }\n\n protected _serverContactChannelFromCrud(userId: string, crud: ContactChannelsCrud['Server']['Read']): ServerContactChannel {\n const app = this;\n return {\n id: crud.id,\n value: crud.value,\n type: crud.type,\n isVerified: crud.is_verified,\n isPrimary: crud.is_primary,\n usedForAuth: crud.used_for_auth,\n async sendVerificationEmail(options?: { callbackUrl?: string }) {\n await app._interface.sendServerContactChannelVerificationEmail(userId, crud.id, options?.callbackUrl ?? constructRedirectUrl(app.urls.emailVerification, \"callbackUrl\"));\n },\n async update(data: ServerContactChannelUpdateOptions) {\n await app._interface.updateServerContactChannel(userId, crud.id, serverContactChannelUpdateOptionsToCrud(data));\n await Promise.all([\n app._serverContactChannelsCache.refresh([userId]),\n app._serverUserCache.refresh([userId])\n ]);\n },\n async delete() {\n await app._interface.deleteServerContactChannel(userId, crud.id);\n await Promise.all([\n app._serverContactChannelsCache.refresh([userId]),\n app._serverUserCache.refresh([userId])\n ]);\n },\n };\n }\n\n protected _serverNotificationCategoryFromCrud(userId: string, crud: NotificationPreferenceCrud['Server']['Read']): NotificationCategory {\n const app = this;\n return {\n id: crud.notification_category_id,\n name: crud.notification_category_name,\n enabled: crud.enabled,\n canDisable: crud.can_disable,\n\n async setEnabled(enabled: boolean) {\n await app._interface.setServerNotificationsEnabled(userId, crud.notification_category_id, enabled);\n await app._serverNotificationCategoriesCache.refresh([userId]);\n },\n };\n }\n\n protected _serverOAuthProviderFromCrud(crud: OAuthProviderCrud['Server']['Read']) {\n const app = this;\n return {\n id: crud.id,\n type: crud.type,\n userId: crud.user_id,\n accountId: crud.account_id,\n email: crud.email,\n allowSignIn: crud.allow_sign_in,\n allowConnectedAccounts: crud.allow_connected_accounts,\n\n async update(data: { accountId?: string, email?: string, allowSignIn?: boolean, allowConnectedAccounts?: boolean }): Promise<Result<void,\n InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>\n >> {\n try {\n await app._interface.updateServerOAuthProvider(crud.user_id, crud.id, {\n account_id: data.accountId,\n email: data.email,\n allow_sign_in: data.allowSignIn,\n allow_connected_accounts: data.allowConnectedAccounts,\n });\n await app._serverOAuthProvidersCache.refresh([crud.user_id]);\n return Result.ok(undefined);\n } catch (error) {\n if (KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn.isInstance(error)) {\n return Result.error(error);\n }\n throw error;\n }\n },\n\n async delete() {\n await app._interface.deleteServerOAuthProvider(crud.user_id, crud.id);\n await app._serverOAuthProvidersCache.refresh([crud.user_id]);\n },\n };\n }\n\n constructor(options: StackServerAppConstructorOptions<HasTokenStore, ProjectId>, extraOptions?: { uniqueIdentifier?: string, checkString?: string, interface?: StackServerInterface }) {\n const resolvedOptions = resolveConstructorOptions(options);\n\n super(resolvedOptions, {\n ...extraOptions,\n interface: extraOptions?.interface ?? new StackServerInterface({\n getBaseUrl: () => getBaseUrl(resolvedOptions.baseUrl),\n projectId: resolvedOptions.projectId ?? getDefaultProjectId(),\n extraRequestHeaders: resolvedOptions.extraRequestHeaders ?? getDefaultExtraRequestHeaders(),\n clientVersion,\n publishableClientKey: resolvedOptions.publishableClientKey ?? getDefaultPublishableClientKey(),\n secretServerKey: resolvedOptions.secretServerKey ?? getDefaultSecretServerKey(),\n }),\n });\n }\n\n\n protected _serverApiKeyFromCrud(crud: TeamApiKeysCrud['Client']['Read']): ApiKey<\"team\">;\n protected _serverApiKeyFromCrud(crud: UserApiKeysCrud['Client']['Read']): ApiKey<\"user\">;\n protected _serverApiKeyFromCrud(crud: yup.InferType<typeof teamApiKeysCreateOutputSchema>): ApiKey<\"team\", true>;\n protected _serverApiKeyFromCrud(crud: yup.InferType<typeof userApiKeysCreateOutputSchema>): ApiKey<\"user\", true>;\n protected _serverApiKeyFromCrud(crud: TeamApiKeysCrud['Client']['Read'] | UserApiKeysCrud['Client']['Read'] | yup.InferType<typeof teamApiKeysCreateOutputSchema> | yup.InferType<typeof userApiKeysCreateOutputSchema>): ApiKey<\"user\" | \"team\", boolean> {\n return {\n ...this._baseApiKeyFromCrud(crud),\n async revoke() {\n await this.update({ revoked: true });\n },\n update: async (options: ApiKeyUpdateOptions) => {\n await this._interface.updateProjectApiKey(\n crud.type === \"team\" ? { team_id: crud.team_id } : { user_id: crud.user_id },\n crud.id,\n await apiKeyUpdateOptionsToCrud(crud.type, options),\n null,\n \"server\");\n if (crud.type === \"team\") {\n await this._serverTeamApiKeysCache.refresh([crud.team_id]);\n } else {\n await this._serverUserApiKeysCache.refresh([crud.user_id]);\n }\n },\n };\n }\n\n protected _serverUserFromCrud(crud: UsersCrud['Server']['Read']): ServerUser {\n const app = this;\n\n async function getConnectedAccount(id: ProviderType, options?: { scopes?: string[] }): Promise<OAuthConnection | null>;\n async function getConnectedAccount(id: ProviderType, options: { or: 'redirect', scopes?: string[] }): Promise<OAuthConnection>;\n async function getConnectedAccount(id: ProviderType, options?: { or?: 'redirect', scopes?: string[] }): Promise<OAuthConnection | null> {\n const scopeString = options?.scopes?.join(\" \");\n return Result.orThrow(await app._serverUserOAuthConnectionCache.getOrWait([crud.id, id, scopeString || \"\", options?.or === 'redirect'], \"write-only\"));\n }\n\n function useConnectedAccount(id: ProviderType, options?: { scopes?: string[] }): OAuthConnection | null;\n function useConnectedAccount(id: ProviderType, options: { or: 'redirect', scopes?: string[] }): OAuthConnection;\n function useConnectedAccount(id: ProviderType, options?: { or?: 'redirect', scopes?: string[] }): OAuthConnection | null {\n const scopeString = options?.scopes?.join(\" \");\n return useAsyncCache(app._serverUserOAuthConnectionCache, [crud.id, id, scopeString || \"\", options?.or === 'redirect'] as const, \"user.useConnectedAccount()\");\n }\n\n const serverUser = {\n ...super._createBaseUser(crud),\n lastActiveAt: new Date(crud.last_active_at_millis),\n serverMetadata: crud.server_metadata,\n async setPrimaryEmail(email: string | null, options?: { verified?: boolean }) {\n await app._updateServerUser(crud.id, { primaryEmail: email, primaryEmailVerified: options?.verified });\n },\n async grantPermission(scopeOrPermissionId: Team | string, permissionId?: string): Promise<void> {\n if (scopeOrPermissionId && typeof scopeOrPermissionId !== 'string' && permissionId) {\n const scope = scopeOrPermissionId;\n await app._interface.grantServerTeamUserPermission(scope.id, crud.id, permissionId);\n\n for (const recursive of [true, false]) {\n await app._serverTeamUserPermissionsCache.refresh([scope.id, crud.id, recursive]);\n }\n } else {\n const pId = scopeOrPermissionId as string;\n await app._interface.grantServerProjectPermission(crud.id, pId);\n\n for (const recursive of [true, false]) {\n await app._serverUserProjectPermissionsCache.refresh([crud.id, recursive]);\n }\n }\n },\n async revokePermission(scopeOrPermissionId: Team | string, permissionId?: string): Promise<void> {\n if (scopeOrPermissionId && typeof scopeOrPermissionId !== 'string' && permissionId) {\n const scope = scopeOrPermissionId;\n await app._interface.revokeServerTeamUserPermission(scope.id, crud.id, permissionId);\n\n for (const recursive of [true, false]) {\n await app._serverTeamUserPermissionsCache.refresh([scope.id, crud.id, recursive]);\n }\n } else {\n const pId = scopeOrPermissionId as string;\n await app._interface.revokeServerProjectPermission(crud.id, pId);\n\n for (const recursive of [true, false]) {\n await app._serverUserProjectPermissionsCache.refresh([crud.id, recursive]);\n }\n }\n },\n async delete() {\n const res = await app._interface.deleteServerUser(crud.id);\n await app._refreshUsers();\n return res;\n },\n async createSession(options: { expiresInMillis?: number, isImpersonation?: boolean }) {\n // TODO this should also refresh the access token when it expires (like InternalSession)\n const tokens = await app._interface.createServerUserSession(crud.id, options.expiresInMillis ?? 1000 * 60 * 60 * 24 * 365, options.isImpersonation ?? false);\n return {\n async getTokens() {\n return tokens;\n },\n };\n },\n\n async getActiveSessions() {\n const sessions = await app._interface.listServerSessions(crud.id);\n return sessions.map((session) => app._clientSessionFromCrud(session));\n },\n\n async revokeSession(sessionId: string) {\n await app._interface.deleteServerSession(sessionId);\n },\n async setDisplayName(displayName: string) {\n return await this.update({ displayName });\n },\n async setClientMetadata(metadata: Record<string, any>) {\n return await this.update({ clientMetadata: metadata });\n },\n async setClientReadOnlyMetadata(metadata: Record<string, any>) {\n return await this.update({ clientReadOnlyMetadata: metadata });\n },\n async setServerMetadata(metadata: Record<string, any>) {\n return await this.update({ serverMetadata: metadata });\n },\n async setSelectedTeam(team: Team | null) {\n return await this.update({ selectedTeamId: team?.id ?? null });\n },\n getConnectedAccount,\n useConnectedAccount, // THIS_LINE_PLATFORM react-like\n selectedTeam: crud.selected_team ? app._serverTeamFromCrud(crud.selected_team) : null,\n async getTeam(teamId: string) {\n const teams = await this.listTeams();\n return teams.find((t) => t.id === teamId) ?? null;\n },\n useTeam(teamId: string) {\n const teams = this.useTeams();\n return useMemo(() => {\n return teams.find((t) => t.id === teamId) ?? null;\n }, [teams, teamId]);\n },\n async listTeams() {\n const teams = Result.orThrow(await app._serverTeamsCache.getOrWait([crud.id], \"write-only\"));\n return teams.map((t) => app._serverTeamFromCrud(t));\n },\n useTeams() {\n const teams = useAsyncCache(app._serverTeamsCache, [crud.id], \"user.useTeams()\");\n return useMemo(() => teams.map((t) => app._serverTeamFromCrud(t)), [teams]);\n },\n createTeam: async (data: Omit<ServerTeamCreateOptions, \"creatorUserId\">) => {\n const team = await app._interface.createServerTeam(serverTeamCreateOptionsToCrud({\n creatorUserId: crud.id,\n ...data,\n }));\n await app._serverTeamsCache.refresh([undefined]);\n await app._updateServerUser(crud.id, { selectedTeamId: team.id });\n return app._serverTeamFromCrud(team);\n },\n leaveTeam: async (team: Team) => {\n await app._interface.leaveServerTeam({ teamId: team.id, userId: crud.id });\n // TODO: refresh cache\n },\n async listPermissions(scopeOrOptions?: Team | { recursive?: boolean }, options?: { recursive?: boolean }): Promise<AdminTeamPermission[]> {\n if (scopeOrOptions && 'id' in scopeOrOptions) {\n const scope = scopeOrOptions;\n const recursive = options?.recursive ?? true;\n const permissions = Result.orThrow(await app._serverTeamUserPermissionsCache.getOrWait([scope.id, crud.id, recursive], \"write-only\"));\n return permissions.map((crud) => app._serverPermissionFromCrud(crud));\n } else {\n const opts = scopeOrOptions;\n const recursive = opts?.recursive ?? true;\n const permissions = Result.orThrow(await app._serverUserProjectPermissionsCache.getOrWait([crud.id, recursive], \"write-only\"));\n return permissions.map((crud) => app._serverPermissionFromCrud(crud));\n }\n },\n usePermissions(scopeOrOptions?: Team | { recursive?: boolean }, options?: { recursive?: boolean }): AdminTeamPermission[] {\n if (scopeOrOptions && 'id' in scopeOrOptions) {\n const scope = scopeOrOptions;\n const recursive = options?.recursive ?? true;\n const permissions = useAsyncCache(app._serverTeamUserPermissionsCache, [scope.id, crud.id, recursive] as const, \"user.usePermissions()\");\n return useMemo(() => permissions.map((crud) => app._serverPermissionFromCrud(crud)), [permissions]);\n } else {\n const opts = scopeOrOptions;\n const recursive = opts?.recursive ?? true;\n const permissions = useAsyncCache(app._serverUserProjectPermissionsCache, [crud.id, recursive] as const, \"user.usePermissions()\");\n return useMemo(() => permissions.map((crud) => app._serverPermissionFromCrud(crud)), [permissions]);\n }\n },\n async getPermission(scopeOrPermissionId: Team | string, permissionId?: string): Promise<AdminTeamPermission | null> {\n if (scopeOrPermissionId && typeof scopeOrPermissionId !== 'string') {\n const scope = scopeOrPermissionId;\n const permissions = await this.listPermissions(scope);\n return permissions.find((p) => p.id === permissionId) ?? null;\n } else {\n const pid = scopeOrPermissionId;\n const permissions = await this.listPermissions();\n return permissions.find((p) => p.id === pid) ?? null;\n }\n },\n usePermission(scopeOrPermissionId: Team | string, permissionId?: string): AdminTeamPermission | null {\n if (scopeOrPermissionId && typeof scopeOrPermissionId !== 'string') {\n const scope = scopeOrPermissionId;\n const permissions = this.usePermissions(scope);\n return useMemo(() => permissions.find((p) => p.id === permissionId) ?? null, [permissions, permissionId]);\n } else {\n const pid = scopeOrPermissionId;\n const permissions = this.usePermissions();\n return useMemo(() => permissions.find((p) => p.id === pid) ?? null, [permissions, pid]);\n }\n },\n async hasPermission(scopeOrPermissionId: Team | string, permissionId?: string): Promise<boolean> {\n if (scopeOrPermissionId && typeof scopeOrPermissionId !== 'string') {\n const scope = scopeOrPermissionId;\n return (await this.getPermission(scope, permissionId as string)) !== null;\n } else {\n const pid = scopeOrPermissionId;\n return (await this.getPermission(pid)) !== null;\n }\n },\n async update(update: ServerUserUpdateOptions) {\n await app._updateServerUser(crud.id, update);\n },\n async sendVerificationEmail() {\n return await app._checkFeatureSupport(\"sendVerificationEmail() on ServerUser\", {});\n },\n async updatePassword(options: { oldPassword: string, newPassword: string }) {\n const result = await app._interface.updatePassword(options);\n await app._serverUserCache.refresh([crud.id]);\n return result;\n },\n async setPassword(options: { password: string }) {\n const result = await this.update(options);\n await app._serverUserCache.refresh([crud.id]);\n return result;\n },\n async getTeamProfile(team: Team) {\n const result = Result.orThrow(await app._serverUserTeamProfileCache.getOrWait([team.id, crud.id], \"write-only\"));\n return app._serverEditableTeamProfileFromCrud(result);\n },\n useTeamProfile(team: Team) {\n const result = useAsyncCache(app._serverUserTeamProfileCache, [team.id, crud.id] as const, \"user.useTeamProfile()\");\n return useMemo(() => app._serverEditableTeamProfileFromCrud(result), [result]);\n },\n async listContactChannels() {\n const result = Result.orThrow(await app._serverContactChannelsCache.getOrWait([crud.id], \"write-only\"));\n return result.map((data) => app._serverContactChannelFromCrud(crud.id, data));\n },\n useContactChannels() {\n const result = useAsyncCache(app._serverContactChannelsCache, [crud.id] as const, \"user.useContactChannels()\");\n return useMemo(() => result.map((data) => app._serverContactChannelFromCrud(crud.id, data)), [result]);\n },\n createContactChannel: async (data: ServerContactChannelCreateOptions) => {\n const contactChannel = await app._interface.createServerContactChannel(serverContactChannelCreateOptionsToCrud(crud.id, data));\n await Promise.all([\n app._serverContactChannelsCache.refresh([crud.id]),\n app._serverUserCache.refresh([crud.id])\n ]);\n return app._serverContactChannelFromCrud(crud.id, contactChannel);\n },\n useNotificationCategories() {\n const results = useAsyncCache(app._serverNotificationCategoriesCache, [crud.id] as const, \"user.useNotificationCategories()\");\n return results.map((category) => app._serverNotificationCategoryFromCrud(crud.id, category));\n },\n async listNotificationCategories() {\n const results = Result.orThrow(await app._serverNotificationCategoriesCache.getOrWait([crud.id], \"write-only\"));\n return results.map((category) => app._serverNotificationCategoryFromCrud(crud.id, category));\n },\n useApiKeys() {\n const result = useAsyncCache(app._serverUserApiKeysCache, [crud.id] as const, \"user.useApiKeys()\");\n return result.map((apiKey) => app._serverApiKeyFromCrud(apiKey));\n },\n async listApiKeys() {\n const result = Result.orThrow(await app._serverUserApiKeysCache.getOrWait([crud.id], \"write-only\"));\n return result.map((apiKey) => app._serverApiKeyFromCrud(apiKey));\n },\n async createApiKey(options: ApiKeyCreationOptions<\"user\">) {\n const result = await app._interface.createProjectApiKey(\n await apiKeyCreationOptionsToCrud(\"user\", crud.id, options),\n null,\n \"server\",\n );\n await app._serverUserApiKeysCache.refresh([crud.id]);\n return app._serverApiKeyFromCrud(result);\n },\n useOAuthProviders() {\n const results = useAsyncCache(app._serverOAuthProvidersCache, [crud.id] as const, \"user.useOAuthProviders()\");\n return useMemo(() => results.map((oauthCrud) => app._serverOAuthProviderFromCrud(oauthCrud)), [results]);\n },\n\n async listOAuthProviders() {\n const results = Result.orThrow(await app._serverOAuthProvidersCache.getOrWait([crud.id], \"write-only\"));\n return results.map((oauthCrud) => app._serverOAuthProviderFromCrud(oauthCrud));\n },\n\n useOAuthProvider(id: string) {\n const providers = this.useOAuthProviders();\n return useMemo(() => providers.find((p) => p.id === id) ?? null, [providers, id]);\n },\n async getOAuthProvider(id: string) {\n const providers = await this.listOAuthProviders();\n return providers.find((p) => p.id === id) ?? null;\n },\n ...app._createServerCustomer(crud.id, \"user\"),\n } satisfies ServerUser;\n\n attachUserDestructureGuard(serverUser);\n\n return serverUser;\n }\n\n protected _serverTeamUserFromCrud(crud: TeamMemberProfilesCrud[\"Server\"][\"Read\"]): ServerTeamUser {\n const teamUser = {\n ...this._serverUserFromCrud(crud.user),\n teamProfile: {\n displayName: crud.display_name,\n profileImageUrl: crud.profile_image_url,\n },\n } satisfies ServerTeamUser;\n\n attachUserDestructureGuard(teamUser);\n return teamUser;\n }\n\n protected _serverTeamInvitationFromCrud(crud: TeamInvitationCrud['Server']['Read']): TeamInvitation {\n return {\n id: crud.id,\n recipientEmail: crud.recipient_email,\n expiresAt: new Date(crud.expires_at_millis),\n revoke: async () => {\n await this._interface.revokeServerTeamInvitation(crud.id, crud.team_id);\n await this._serverTeamInvitationsCache.refresh([crud.team_id]);\n },\n };\n }\n\n protected override _currentUserFromCrud(crud: UsersCrud['Server']['Read'], session: InternalSession): ProjectCurrentServerUser<ProjectId> {\n const currentUser = {\n ...this._serverUserFromCrud(crud),\n ...this._createAuth(session),\n ...this._isInternalProject() ? this._createInternalUserExtra(session) : {},\n } satisfies ServerUser;\n\n attachUserDestructureGuard(currentUser);\n Object.freeze(currentUser);\n return currentUser as ProjectCurrentServerUser<ProjectId>;\n }\n\n protected _serverTeamFromCrud(crud: TeamsCrud['Server']['Read']): ServerTeam {\n const app = this;\n return {\n id: crud.id,\n displayName: crud.display_name,\n profileImageUrl: crud.profile_image_url,\n createdAt: new Date(crud.created_at_millis),\n clientMetadata: crud.client_metadata,\n clientReadOnlyMetadata: crud.client_read_only_metadata,\n serverMetadata: crud.server_metadata,\n async update(update: Partial<ServerTeamUpdateOptions>) {\n await app._interface.updateServerTeam(crud.id, serverTeamUpdateOptionsToCrud(update));\n await app._serverTeamsCache.refresh([undefined]);\n },\n async delete() {\n await app._interface.deleteServerTeam(crud.id);\n await app._serverTeamsCache.refresh([undefined]);\n },\n async listUsers() {\n const result = Result.orThrow(await app._serverTeamMemberProfilesCache.getOrWait([crud.id], \"write-only\"));\n return result.map(u => app._serverTeamUserFromCrud(u));\n },\n useUsers() {\n const result = useAsyncCache(app._serverTeamMemberProfilesCache, [crud.id] as const, \"team.useUsers()\");\n return useMemo(() => result.map(u => app._serverTeamUserFromCrud(u)), [result]);\n },\n async addUser(userId) {\n await app._interface.addServerUserToTeam({\n teamId: crud.id,\n userId,\n });\n await app._serverTeamMemberProfilesCache.refresh([crud.id]);\n },\n async removeUser(userId) {\n await app._interface.removeServerUserFromTeam({\n teamId: crud.id,\n userId,\n });\n await app._serverTeamMemberProfilesCache.refresh([crud.id]);\n },\n async inviteUser(options: { email: string, callbackUrl?: string }) {\n await app._interface.sendServerTeamInvitation({\n teamId: crud.id,\n email: options.email,\n callbackUrl: options.callbackUrl ?? constructRedirectUrl(app.urls.teamInvitation, \"callbackUrl\"),\n });\n await app._serverTeamInvitationsCache.refresh([crud.id]);\n },\n async listInvitations() {\n const result = Result.orThrow(await app._serverTeamInvitationsCache.getOrWait([crud.id], \"write-only\"));\n return result.map((crud) => app._serverTeamInvitationFromCrud(crud));\n },\n useInvitations() {\n const result = useAsyncCache(app._serverTeamInvitationsCache, [crud.id] as const, \"team.useInvitations()\");\n return useMemo(() => result.map((crud) => app._serverTeamInvitationFromCrud(crud)), [result]);\n },\n useApiKeys() {\n const result = useAsyncCache(app._serverTeamApiKeysCache, [crud.id] as const, \"team.useApiKeys()\");\n return result.map((apiKey) => app._serverApiKeyFromCrud(apiKey));\n },\n async listApiKeys() {\n const result = Result.orThrow(await app._serverTeamApiKeysCache.getOrWait([crud.id], \"write-only\"));\n return result.map((apiKey) => app._serverApiKeyFromCrud(apiKey));\n },\n async createApiKey(options: ApiKeyCreationOptions<\"team\">) {\n const result = await app._interface.createProjectApiKey(\n await apiKeyCreationOptionsToCrud(\"team\", crud.id, options),\n null,\n \"server\",\n );\n await app._serverTeamApiKeysCache.refresh([crud.id]);\n return app._serverApiKeyFromCrud(result);\n },\n ...app._createServerCustomer(crud.id, \"team\"),\n };\n }\n\n protected _serverItemFromCrud(customer: { type: \"user\" | \"team\" | \"custom\", id: string }, crud: ItemCrud['Client']['Read']): ServerItem {\n const app = this;\n return {\n displayName: crud.display_name,\n quantity: crud.quantity,\n nonNegativeQuantity: Math.max(0, crud.quantity),\n increaseQuantity: async (delta: number) => {\n const updateOptions = customer.type === \"user\"\n ? { itemId: crud.id, userId: customer.id }\n : customer.type === \"team\"\n ? { itemId: crud.id, teamId: customer.id }\n : { itemId: crud.id, customCustomerId: customer.id };\n await app._interface.updateItemQuantity(updateOptions, { delta });\n if (customer.type === \"user\") await app._serverUserItemsCache.refresh([customer.id, crud.id]);\n else if (customer.type === \"team\") await app._serverTeamItemsCache.refresh([customer.id, crud.id]);\n else await app._serverCustomItemsCache.refresh([customer.id, crud.id]);\n },\n decreaseQuantity: async (delta: number) => {\n const updateOptions = customer.type === \"user\"\n ? { itemId: crud.id, userId: customer.id }\n : customer.type === \"team\"\n ? { itemId: crud.id, teamId: customer.id }\n : { itemId: crud.id, customCustomerId: customer.id };\n await app._interface.updateItemQuantity(updateOptions, { delta: -delta, allow_negative: true });\n if (customer.type === \"user\") await app._serverUserItemsCache.refresh([customer.id, crud.id]);\n else if (customer.type === \"team\") await app._serverTeamItemsCache.refresh([customer.id, crud.id]);\n else await app._serverCustomItemsCache.refresh([customer.id, crud.id]);\n },\n tryDecreaseQuantity: async (delta: number) => {\n try {\n const updateOptions = customer.type === \"user\"\n ? { itemId: crud.id, userId: customer.id }\n : customer.type === \"team\"\n ? { itemId: crud.id, teamId: customer.id }\n : { itemId: crud.id, customCustomerId: customer.id };\n await app._interface.updateItemQuantity(updateOptions, { delta: -delta });\n if (customer.type === \"user\") await app._serverUserItemsCache.refresh([customer.id, crud.id]);\n else if (customer.type === \"team\") await app._serverTeamItemsCache.refresh([customer.id, crud.id]);\n else await app._serverCustomItemsCache.refresh([customer.id, crud.id]);\n return true;\n } catch (error) {\n if (error instanceof KnownErrors.ItemQuantityInsufficientAmount) {\n return false;\n }\n throw error;\n }\n },\n };\n }\n\n protected async _getUserApiKey(options: { apiKey: string }): Promise<ApiKey<\"user\"> | null> {\n const crud = Result.orThrow(await this._serverCheckApiKeyCache.getOrWait([\"user\", options.apiKey], \"write-only\")) as UserApiKeysCrud['Server']['Read'] | null;\n return crud ? this._serverApiKeyFromCrud(crud) : null;\n }\n\n protected async _getTeamApiKey(options: { apiKey: string }): Promise<ApiKey<\"team\"> | null> {\n const crud = Result.orThrow(await this._serverCheckApiKeyCache.getOrWait([\"team\", options.apiKey], \"write-only\")) as TeamApiKeysCrud['Server']['Read'] | null;\n return crud ? this._serverApiKeyFromCrud(crud) : null;\n }\n protected _useUserApiKey(options: { apiKey: string }): ApiKey<\"user\"> | null {\n const crud = useAsyncCache(this._serverCheckApiKeyCache, [\"user\", options.apiKey] as const, \"serverApp.useUserApiKey()\") as UserApiKeysCrud['Server']['Read'] | null;\n return useMemo(() => crud ? this._serverApiKeyFromCrud(crud) : null, [crud]);\n }\n protected _useTeamApiKey(options: { apiKey: string }): ApiKey<\"team\"> | null {\n const crud = useAsyncCache(this._serverCheckApiKeyCache, [\"team\", options.apiKey] as const, \"serverApp.useTeamApiKey()\") as TeamApiKeysCrud['Server']['Read'] | null;\n return useMemo(() => crud ? this._serverApiKeyFromCrud(crud) : null, [crud]);\n }\n protected async _getUserByApiKey(apiKey: string): Promise<ServerUser | null> {\n const apiKeyObject = await this._getUserApiKey({ apiKey });\n if (apiKeyObject === null) {\n return null;\n }\n return await this.getServerUserById(apiKeyObject.userId);\n }\n\n protected async _getUserByConvex(ctx: ConvexCtx, includeAnonymous: boolean): Promise<ServerUser | null> {\n const identity = await ctx.auth.getUserIdentity();\n if (identity === null) {\n return null;\n }\n const user = await this.getServerUserById(identity.subject);\n if (user?.isAnonymous && !includeAnonymous) {\n return null;\n }\n return user;\n }\n protected _useUserByConvex(ctx: ConvexCtx, includeAnonymous: boolean): ServerUser | null {\n const subject = useAsyncCache(this._convexIdentitySubjectCache, [ctx] as const, \"serverApp.useUserByConvex()\");\n if (subject === null) {\n return null;\n }\n const user = this.useUserById(subject);\n if (user?.isAnonymous && !includeAnonymous) {\n return null;\n }\n return user;\n }\n protected _useUserByApiKey(apiKey: string): ServerUser | null {\n const apiKeyObject = this._useUserApiKey({ apiKey });\n if (apiKeyObject === null) {\n return null;\n }\n return this.useUserById(apiKeyObject.userId);\n }\n\n protected async _getTeamByApiKey(apiKey: string): Promise<ServerTeam | null> {\n const apiKeyObject = await this._getTeamApiKey({ apiKey });\n if (apiKeyObject === null) {\n return null;\n }\n return await this.getTeam(apiKeyObject.teamId);\n }\n protected _useTeamByApiKey(apiKey: string): ServerTeam | null {\n const apiKeyObject = this._useTeamApiKey({ apiKey });\n if (apiKeyObject === null) {\n return null;\n }\n return this.useTeam(apiKeyObject.teamId);\n }\n\n async createUser(options: ServerUserCreateOptions): Promise<ServerUser> {\n const crud = await this._interface.createServerUser(serverUserCreateOptionsToCrud(options));\n await this._refreshUsers();\n return this._serverUserFromCrud(crud);\n }\n\n async getUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'redirect' }): Promise<ProjectCurrentServerUser<ProjectId>>;\n async getUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'throw' }): Promise<ProjectCurrentServerUser<ProjectId>>;\n async getUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'anonymous' }): Promise<ProjectCurrentServerUser<ProjectId>>;\n async getUser(options?: GetCurrentUserOptions<HasTokenStore>): Promise<ProjectCurrentServerUser<ProjectId> | null>;\n async getUser(id: string): Promise<ServerUser | null>;\n async getUser(options: { apiKey: string }): Promise<ServerUser | null>;\n async getUser(options: { from: \"convex\", ctx: ConvexCtx, or?: \"return-null\" | \"anonymous\" }): Promise<ServerUser | null>;\n async getUser(options?: string | GetCurrentUserOptions<HasTokenStore> | { apiKey: string } | { from: \"convex\", ctx: ConvexCtx }): Promise<ProjectCurrentServerUser<ProjectId> | ServerUser | null> {\n if (typeof options === \"string\") {\n return await this.getServerUserById(options);\n } else if (typeof options === \"object\" && \"apiKey\" in options) {\n return await this._getUserByApiKey(options.apiKey);\n } else if (typeof options === \"object\" && \"from\" in options && options.from as string === \"convex\") {\n return await this._getUserByConvex(options.ctx, \"or\" in options && options.or === \"anonymous\");\n } else {\n options = options as GetCurrentUserOptions<HasTokenStore> | undefined;\n // TODO this code is duplicated from the client app; fix that\n this._ensurePersistentTokenStore(options?.tokenStore);\n const session = await this._getSession(options?.tokenStore);\n let crud = Result.orThrow(await this._currentServerUserCache.getOrWait([session], \"write-only\"));\n if (crud?.is_anonymous && options?.or !== \"anonymous\" && options?.or !== \"anonymous-if-exists[deprecated]\") {\n crud = null;\n }\n\n if (crud === null) {\n switch (options?.or) {\n case 'redirect': {\n await this.redirectToSignIn({ replace: true });\n break;\n }\n case 'throw': {\n throw new Error(\"User is not signed in but getUser was called with { or: 'throw' }\");\n }\n case 'anonymous': {\n const tokens = await this._signUpAnonymously();\n return await this.getUser({ tokenStore: tokens, or: \"anonymous-if-exists[deprecated]\" }) ?? throwErr(\"Something went wrong while signing up anonymously\");\n }\n case undefined:\n case \"anonymous-if-exists[deprecated]\":\n case \"return-null\": {\n return null;\n }\n }\n }\n\n return crud && this._currentUserFromCrud(crud, session);\n }\n }\n\n async getServerUser(): Promise<ProjectCurrentServerUser<ProjectId> | null> {\n console.warn(\"stackServerApp.getServerUser is deprecated; use stackServerApp.getUser instead\");\n return await this.getUser();\n }\n\n async getServerUserById(userId: string): Promise<ServerUser | null> {\n const crud = Result.orThrow(await this._serverUserCache.getOrWait([userId], \"write-only\"));\n return crud && this._serverUserFromCrud(crud);\n }\n\n useUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'redirect' }): ProjectCurrentServerUser<ProjectId>;\n useUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'throw' }): ProjectCurrentServerUser<ProjectId>;\n useUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'anonymous' }): ProjectCurrentServerUser<ProjectId>;\n useUser(options?: GetCurrentUserOptions<HasTokenStore>): ProjectCurrentServerUser<ProjectId> | null;\n useUser(id: string): ServerUser | null;\n useUser(options: { apiKey: string }): ServerUser | null;\n useUser(options: { from: \"convex\", ctx: ConvexCtx, or?: \"return-null\" | \"anonymous\" }): ServerUser | null;\n useUser(options?: GetCurrentUserOptions<HasTokenStore> | string | { apiKey: string } | { from: \"convex\", ctx: ConvexCtx }): ProjectCurrentServerUser<ProjectId> | ServerUser | null {\n if (typeof options === \"string\") {\n return this.useUserById(options);\n } else if (typeof options === \"object\" && \"apiKey\" in options) {\n return this._useUserByApiKey(options.apiKey);\n } else if (typeof options === \"object\" && \"from\" in options && options.from as string === \"convex\") {\n return this._useUserByConvex(options.ctx, \"or\" in options && options.or === \"anonymous\");\n } else {\n options = options as GetCurrentUserOptions<HasTokenStore> | undefined;\n // TODO this code is duplicated from the client app; fix that\n this._ensurePersistentTokenStore(options?.tokenStore);\n\n const session = this._useSession(options?.tokenStore);\n let crud = useAsyncCache(this._currentServerUserCache, [session] as const, \"serverApp.useUser()\");\n if (crud?.is_anonymous && options?.or !== \"anonymous\" && options?.or !== \"anonymous-if-exists[deprecated]\") {\n crud = null;\n }\n\n if (crud === null) {\n switch (options?.or) {\n case 'redirect': {\n runAsynchronously(this.redirectToSignIn({ replace: true }));\n suspend();\n throw new StackAssertionError(\"suspend should never return\");\n }\n case 'throw': {\n throw new Error(\"User is not signed in but useUser was called with { or: 'throw' }\");\n }\n case 'anonymous': {\n // TODO we should think about the behavior when calling useUser (or getUser) in anonymous with a custom token store. signUpAnonymously always sets the current token store on app level, instead of the one passed to this function\n // TODO we shouldn't reload & suspend here, instead we should use a promise that resolves to the new anonymous user\n runAsynchronously(async () => {\n await this._signUpAnonymously();\n if (typeof window !== \"undefined\") {\n window.location.reload();\n }\n });\n suspend();\n throw new StackAssertionError(\"suspend should never return\");\n }\n case undefined:\n case \"anonymous-if-exists[deprecated]\":\n case \"return-null\": {\n // do nothing\n }\n }\n }\n\n return useMemo(() => {\n return crud && this._currentUserFromCrud(crud, session);\n }, [crud, session, options?.or]);\n }\n }\n useUserById(userId: string): ServerUser | null {\n const crud = useAsyncCache(this._serverUserCache, [userId], \"serverApp.useUserById()\");\n return useMemo(() => {\n return crud && this._serverUserFromCrud(crud);\n }, [crud]);\n }\n\n async listUsers(options?: ServerListUsersOptions): Promise<ServerUser[] & { nextCursor: string | null }> {\n const crud = Result.orThrow(await this._serverUsersCache.getOrWait([options?.cursor, options?.limit, options?.orderBy, options?.desc, options?.query, options?.includeAnonymous], \"write-only\"));\n const result: any = crud.items.map((j) => this._serverUserFromCrud(j));\n result.nextCursor = crud.pagination?.next_cursor ?? null;\n return result as any;\n }\n\n useUsers(options?: ServerListUsersOptions): ServerUser[] & { nextCursor: string | null } {\n const crud = useAsyncCache(this._serverUsersCache, [options?.cursor, options?.limit, options?.orderBy, options?.desc, options?.query, options?.includeAnonymous] as const, \"serverApp.useUsers()\");\n const result: any = crud.items.map((j) => this._serverUserFromCrud(j));\n result.nextCursor = crud.pagination?.next_cursor ?? null;\n return result as any;\n }\n\n _serverPermissionFromCrud(crud: TeamPermissionsCrud['Server']['Read'] | ProjectPermissionsCrud['Server']['Read']): AdminTeamPermission {\n return {\n id: crud.id,\n };\n }\n\n _serverTeamPermissionDefinitionFromCrud(crud: TeamPermissionDefinitionsCrud['Admin']['Read']): AdminTeamPermissionDefinition {\n return {\n id: crud.id,\n description: crud.description,\n containedPermissionIds: crud.contained_permission_ids,\n };\n }\n\n _serverProjectPermissionDefinitionFromCrud(crud: ProjectPermissionDefinitionsCrud['Admin']['Read']): AdminProjectPermissionDefinition {\n return {\n id: crud.id,\n description: crud.description,\n containedPermissionIds: crud.contained_permission_ids,\n };\n }\n\n async listTeams(): Promise<ServerTeam[]> {\n const teams = Result.orThrow(await this._serverTeamsCache.getOrWait([undefined], \"write-only\"));\n return teams.map((t) => this._serverTeamFromCrud(t));\n }\n\n async getItem(options: { itemId: string, userId: string } | { itemId: string, teamId: string } | { itemId: string, customCustomerId: string }): Promise<ServerItem> {\n if (\"userId\" in options) {\n const result = Result.orThrow(await this._serverUserItemsCache.getOrWait([options.userId, options.itemId], \"write-only\"));\n return this._serverItemFromCrud({ type: \"user\", id: options.userId }, result);\n } else if (\"teamId\" in options) {\n const result = Result.orThrow(await this._serverTeamItemsCache.getOrWait([options.teamId, options.itemId], \"write-only\"));\n return this._serverItemFromCrud({ type: \"team\", id: options.teamId }, result);\n } else {\n const result = Result.orThrow(await this._serverCustomItemsCache.getOrWait([options.customCustomerId, options.itemId], \"write-only\"));\n return this._serverItemFromCrud({ type: \"custom\", id: options.customCustomerId }, result);\n }\n }\n\n useItem(options: { itemId: string, userId: string } | { itemId: string, teamId: string } | { itemId: string, customCustomerId: string }): ServerItem {\n let type: \"user\" | \"team\" | \"custom\";\n let id: string;\n let cache: AsyncCache<[string, string], Result<ItemCrud['Client']['Read']>>;\n if (\"userId\" in options) {\n type = \"user\";\n id = options.userId;\n cache = this._serverUserItemsCache;\n } else if (\"teamId\" in options) {\n type = \"team\";\n id = options.teamId;\n cache = this._serverTeamItemsCache;\n } else {\n type = \"custom\";\n id = options.customCustomerId;\n cache = this._serverCustomItemsCache;\n }\n\n const cacheKey = [id, options.itemId] as [string, string];\n const debugLabel = \"serverApp.useItem()\";\n const result = useAsyncCache(cache, cacheKey, debugLabel);\n return useMemo(() => this._serverItemFromCrud({ type, id }, result), [result]);\n }\n async grantProduct(options: (\n ({ userId: string } | { teamId: string } | { customCustomerId: string }) &\n ({ productId: string } | { product: InlineProduct }) &\n { quantity?: number }\n )): Promise<void> {\n let customerType: \"user\" | \"team\" | \"custom\";\n let customerId: string;\n if (\"userId\" in options) {\n customerType = \"user\";\n customerId = options.userId;\n } else if (\"teamId\" in options) {\n customerType = \"team\";\n customerId = options.teamId;\n } else {\n customerType = \"custom\";\n customerId = options.customCustomerId;\n }\n\n await this._interface.grantProduct({\n customerType,\n customerId,\n productId: \"productId\" in options ? options.productId : undefined,\n product: \"product\" in options ? options.product : undefined,\n quantity: options.quantity,\n });\n\n const cache = customerType === \"user\"\n ? this._serverUserProductsCache\n : customerType === \"team\"\n ? this._serverTeamProductsCache\n : this._serverCustomProductsCache;\n await cache.refresh([customerId, null, null]);\n }\n\n async createTeam(data: ServerTeamCreateOptions): Promise<ServerTeam> {\n const team = await this._interface.createServerTeam(serverTeamCreateOptionsToCrud(data));\n await this._serverTeamsCache.refresh([undefined]);\n return this._serverTeamFromCrud(team);\n }\n\n useTeams(): ServerTeam[] {\n const teams = useAsyncCache(this._serverTeamsCache, [undefined], \"serverApp.useTeams()\");\n return useMemo(() => {\n return teams.map((t) => this._serverTeamFromCrud(t));\n }, [teams]);\n }\n\n async getTeam(options: { apiKey: string }): Promise<ServerTeam | null>;\n async getTeam(teamId: string): Promise<ServerTeam | null>;\n async getTeam(options?: { apiKey: string } | string): Promise<ServerTeam | null> {\n if (typeof options === \"object\" && \"apiKey\" in options) {\n return await this._getTeamByApiKey(options.apiKey);\n } else {\n const teamId = options;\n const teams = await this.listTeams();\n return teams.find((t) => t.id === teamId) ?? null;\n }\n }\n\n useTeam(options: { apiKey: string }): ServerTeam | null;\n useTeam(teamId: string): ServerTeam | null;\n useTeam(options?: { apiKey: string } | string): ServerTeam | null {\n if (typeof options === \"object\" && \"apiKey\" in options) {\n return this._useTeamByApiKey(options.apiKey);\n } else {\n const teamId = options;\n const teams = this.useTeams();\n return useMemo(() => {\n return teams.find((t) => t.id === teamId) ?? null;\n }, [teams, teamId]);\n }\n }\n\n protected _createServerDataVaultStore(id: string): DataVaultStore {\n const validateOptions = (options: { secret: string }) => {\n if (typeof options.secret !== \"string\") throw new Error(\"secret must be a string, got \" + typeof options.secret);\n };\n return {\n id,\n setValue: async (key, value, options) => {\n validateOptions(options);\n await this._interface.setDataVaultStoreValue(options.secret, id, key, value);\n },\n getValue: async (key, options) => {\n validateOptions(options);\n return Result.orThrow(await this._serverDataVaultStoreValueCache.getOrWait([id, key, options.secret], \"write-only\"));\n },\n useValue: (key, options) => {\n validateOptions(options);\n return useAsyncCache(this._serverDataVaultStoreValueCache, [id, key, options.secret] as const, \"store.useValue()\");\n },\n };\n }\n\n async getDataVaultStore(id: string): Promise<DataVaultStore> {\n return this._createServerDataVaultStore(id);\n }\n\n useDataVaultStore(id: string): DataVaultStore {\n return useMemo(() => this._createServerDataVaultStore(id), [id]);\n }\n\n async sendEmail(options: SendEmailOptions): Promise<void> {\n await this._interface.sendEmail(options);\n }\n\n protected override async _refreshSession(session: InternalSession) {\n await Promise.all([\n super._refreshUser(session),\n this._currentServerUserCache.refresh([session]),\n ]);\n }\n\n protected override async _refreshUsers() {\n await Promise.all([\n super._refreshUsers(),\n this._serverUserCache.refreshWhere(() => true),\n this._serverUsersCache.refreshWhere(() => true),\n this._serverContactChannelsCache.refreshWhere(() => true),\n this._serverOAuthProvidersCache.refreshWhere(() => true),\n ]);\n }\n\n async createOAuthProvider(options: {\n userId: string,\n providerConfigId: string,\n accountId: string,\n email: string,\n allowSignIn: boolean,\n allowConnectedAccounts: boolean,\n }): Promise<Result<ServerOAuthProvider, InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>>> {\n try {\n const crud = await this._interface.createServerOAuthProvider({\n user_id: options.userId,\n provider_config_id: options.providerConfigId,\n account_id: options.accountId,\n email: options.email,\n allow_sign_in: options.allowSignIn,\n allow_connected_accounts: options.allowConnectedAccounts,\n });\n\n await this._serverOAuthProvidersCache.refresh([options.userId]);\n return Result.ok(this._serverOAuthProviderFromCrud(crud));\n } catch (error) {\n if (KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn.isInstance(error)) {\n return Result.error(error);\n }\n throw error;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,0BAAkD;AAelD,oBAA8C;AAE9C,sBAAkC;AAClC,mBAAwB;AACxB,qBAAuB;AACvB,IAAAA,gBAAwB;AAExB,iBAAqC;AACrC,sBAA2H;AAG3H,8BAA6L;AAM7L,mBAAoO;AACpO,mBAAsN;AAEtN,6BAA8C;AAC9C,oBAAuN;AAEvN,IAAAC,iBAA8B;AAEvB,IAAM,gCAAN,cAAqG,qDAAwD;AAAA,EAyUlK,YAAY,SAAqE,cAAsG;AACrL,UAAM,sBAAkB,yCAA0B,OAAO;AAEzD,UAAM,iBAAiB;AAAA,MACrB,GAAG;AAAA,MACH,WAAW,cAAc,aAAa,IAAI,yCAAqB;AAAA,QAC7D,YAAY,UAAM,0BAAW,gBAAgB,OAAO;AAAA,QACpD,WAAW,gBAAgB,iBAAa,mCAAoB;AAAA,QAC5D,qBAAqB,gBAAgB,2BAAuB,6CAA8B;AAAA,QAC1F;AAAA,QACA,sBAAsB,gBAAgB,4BAAwB,8CAA+B;AAAA,QAC7F,iBAAiB,gBAAgB,uBAAmB,yCAA0B;AAAA,MAChF,CAAC;AAAA,IACH,CAAC;AAlVH;AAAA,SAAiB,8BAA0B,oCAAqB,OAAO,YAAY;AACjF,UAAI,QAAQ,mBAAmB,GAAG;AAEhC,eAAO;AAAA,MACT;AACA,aAAO,MAAM,KAAK,WAAW,qBAAqB,OAAO;AAAA,IAC3D,CAAC;AACD,SAAiB,wBAAoB,2BAOL,OAAO,CAAC,QAAQ,OAAO,SAA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UAAM,KAAK,WAAW,UAAU,OAAO;AAAA,EACzC;AAAA,EAEA,MAAyB,gBAAgB,SAA0B;AACjE,UAAM,QAAQ,IAAI;AAAA,MAChB,MAAM,aAAa,OAAO;AAAA,MAC1B,KAAK,wBAAwB,QAAQ,CAAC,OAAO,CAAC;AAAA,IAChD,CAAC;AAAA,EACH;AAAA,EAEA,MAAyB,gBAAgB;AACvC,UAAM,QAAQ,IAAI;AAAA,MAChB,MAAM,cAAc;AAAA,MACpB,KAAK,iBAAiB,aAAa,MAAM,IAAI;AAAA,MAC7C,KAAK,kBAAkB,aAAa,MAAM,IAAI;AAAA,MAC9C,KAAK,4BAA4B,aAAa,MAAM,IAAI;AAAA,MACxD,KAAK,2BAA2B,aAAa,MAAM,IAAI;AAAA,IACzD,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,oBAAoB,SAO4F;AACpH,QAAI;AACF,YAAM,OAAO,MAAM,KAAK,WAAW,0BAA0B;AAAA,QAC3D,SAAS,QAAQ;AAAA,QACjB,oBAAoB,QAAQ;AAAA,QAC5B,YAAY,QAAQ;AAAA,QACpB,OAAO,QAAQ;AAAA,QACf,eAAe,QAAQ;AAAA,QACvB,0BAA0B,QAAQ;AAAA,MACpC,CAAC;AAED,YAAM,KAAK,2BAA2B,QAAQ,CAAC,QAAQ,MAAM,CAAC;AAC9D,aAAO,sBAAO,GAAG,KAAK,6BAA6B,IAAI,CAAC;AAAA,IAC1D,SAAS,OAAO;AACd,UAAI,gCAAY,2CAA2C,WAAW,KAAK,GAAG;AAC5E,eAAO,sBAAO,MAAM,KAAK;AAAA,MAC3B;AACA,YAAM;AAAA,IACR;AAAA,EACF;AACF;","names":["import_react","import_common","crud"]}
1
+ {"version":3,"sources":["../../../../../src/lib/stack-app/apps/implementations/server-app-impl.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { KnownErrors, StackServerInterface } from \"@stackframe/stack-shared\";\nimport { ContactChannelsCrud } from \"@stackframe/stack-shared/dist/interface/crud/contact-channels\";\nimport { ItemCrud } from \"@stackframe/stack-shared/dist/interface/crud/items\";\nimport { NotificationPreferenceCrud } from \"@stackframe/stack-shared/dist/interface/crud/notification-preferences\";\nimport { OAuthProviderCrud } from \"@stackframe/stack-shared/dist/interface/crud/oauth-providers\";\nimport type { CustomerProductsListResponse } from \"@stackframe/stack-shared/dist/interface/crud/products\";\nimport { TeamApiKeysCrud, UserApiKeysCrud, teamApiKeysCreateOutputSchema, userApiKeysCreateOutputSchema } from \"@stackframe/stack-shared/dist/interface/crud/project-api-keys\";\nimport { ProjectPermissionDefinitionsCrud, ProjectPermissionsCrud } from \"@stackframe/stack-shared/dist/interface/crud/project-permissions\";\nimport { TeamInvitationCrud } from \"@stackframe/stack-shared/dist/interface/crud/team-invitation\";\nimport { TeamMemberProfilesCrud } from \"@stackframe/stack-shared/dist/interface/crud/team-member-profiles\";\nimport { TeamPermissionDefinitionsCrud, TeamPermissionsCrud } from \"@stackframe/stack-shared/dist/interface/crud/team-permissions\";\nimport { TeamsCrud } from \"@stackframe/stack-shared/dist/interface/crud/teams\";\nimport { UsersCrud } from \"@stackframe/stack-shared/dist/interface/crud/users\";\nimport { InternalSession } from \"@stackframe/stack-shared/dist/sessions\";\nimport type { AsyncCache } from \"@stackframe/stack-shared/dist/utils/caches\";\nimport { StackAssertionError, throwErr } from \"@stackframe/stack-shared/dist/utils/errors\";\nimport { ProviderType } from \"@stackframe/stack-shared/dist/utils/oauth\";\nimport { runAsynchronously } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport { suspend } from \"@stackframe/stack-shared/dist/utils/react\";\nimport { Result } from \"@stackframe/stack-shared/dist/utils/results\";\nimport { useMemo } from \"react\"; // THIS_LINE_PLATFORM react-like\nimport * as yup from \"yup\";\nimport { constructRedirectUrl } from \"../../../../utils/url\";\nimport { ApiKey, ApiKeyCreationOptions, ApiKeyUpdateOptions, apiKeyCreationOptionsToCrud, apiKeyUpdateOptionsToCrud } from \"../../api-keys\";\nimport { ConvexCtx, GetCurrentUserOptions } from \"../../common\";\nimport { OAuthConnection } from \"../../connected-accounts\";\nimport { ServerContactChannel, ServerContactChannelCreateOptions, ServerContactChannelUpdateOptions, serverContactChannelCreateOptionsToCrud, serverContactChannelUpdateOptionsToCrud } from \"../../contact-channels\";\nimport { Customer, InlineProduct, ServerItem } from \"../../customers\";\nimport { DataVaultStore } from \"../../data-vault\";\nimport { SendEmailOptions } from \"../../email\";\nimport { NotificationCategory } from \"../../notification-categories\";\nimport { AdminProjectPermissionDefinition, AdminTeamPermission, AdminTeamPermissionDefinition } from \"../../permissions\";\nimport { EditableTeamMemberProfile, ServerListUsersOptions, ServerTeam, ServerTeamCreateOptions, ServerTeamUpdateOptions, ServerTeamUser, Team, TeamInvitation, serverTeamCreateOptionsToCrud, serverTeamUpdateOptionsToCrud } from \"../../teams\";\nimport { ProjectCurrentServerUser, ServerOAuthProvider, ServerUser, ServerUserCreateOptions, ServerUserUpdateOptions, attachUserDestructureGuard, serverUserCreateOptionsToCrud, serverUserUpdateOptionsToCrud } from \"../../users\";\nimport { StackServerAppConstructorOptions } from \"../interfaces/server-app\";\nimport { _StackClientAppImplIncomplete } from \"./client-app-impl\";\nimport { clientVersion, createCache, createCacheBySession, getBaseUrl, getDefaultExtraRequestHeaders, getDefaultProjectId, getDefaultPublishableClientKey, getDefaultSecretServerKey, resolveConstructorOptions } from \"./common\";\n\nimport { useAsyncCache } from \"./common\"; // THIS_LINE_PLATFORM react-like\n\nexport class _StackServerAppImplIncomplete<HasTokenStore extends boolean, ProjectId extends string> extends _StackClientAppImplIncomplete<HasTokenStore, ProjectId> {\n declare protected _interface: StackServerInterface;\n\n // TODO override the client user cache to use the server user cache, so we save some requests\n private readonly _currentServerUserCache = createCacheBySession(async (session) => {\n if (session.isKnownToBeInvalid()) {\n // see comment in _currentUserCache for more details on why we do this\n return null;\n }\n return await this._interface.getServerUserByToken(session);\n });\n private readonly _serverUsersCache = createCache<[\n cursor?: string,\n limit?: number,\n orderBy?: 'signedUpAt',\n desc?: boolean,\n query?: string,\n includeAnonymous?: boolean,\n ], UsersCrud['Server']['List']>(async ([cursor, limit, orderBy, desc, query, includeAnonymous]) => {\n return await this._interface.listServerUsers({ cursor, limit, orderBy, desc, query, includeAnonymous });\n });\n private readonly _serverUserCache = createCache<string[], UsersCrud['Server']['Read'] | null>(async ([userId]) => {\n const user = await this._interface.getServerUserById(userId);\n return Result.or(user, null);\n });\n private readonly _serverTeamsCache = createCache<[string | undefined], TeamsCrud['Server']['Read'][]>(async ([userId]) => {\n return await this._interface.listServerTeams({ userId });\n });\n private readonly _serverTeamUserPermissionsCache = createCache<\n [string, string, boolean],\n TeamPermissionsCrud['Server']['Read'][]\n >(async ([teamId, userId, recursive]) => {\n return await this._interface.listServerTeamPermissions({ teamId, userId, recursive }, null);\n });\n private readonly _serverUserProjectPermissionsCache = createCache<\n [string, boolean],\n ProjectPermissionsCrud['Server']['Read'][]\n >(async ([userId, recursive]) => {\n return await this._interface.listServerProjectPermissions({ userId, recursive }, null);\n });\n private readonly _serverUserOAuthConnectionAccessTokensCache = createCache<[string, string, string], { accessToken: string } | null>(\n async ([userId, providerId, scope]) => {\n try {\n const result = await this._interface.createServerProviderAccessToken(userId, providerId, scope || \"\");\n return { accessToken: result.access_token };\n } catch (err) {\n if (!(KnownErrors.OAuthConnectionDoesNotHaveRequiredScope.isInstance(err) || KnownErrors.OAuthConnectionNotConnectedToUser.isInstance(err))) {\n throw err;\n }\n }\n return null;\n }\n );\n private readonly _serverUserOAuthConnectionCache = createCache<[string, ProviderType, string, boolean], OAuthConnection | null>(\n async ([userId, providerId, scope, redirect]) => {\n return await this._getUserOAuthConnectionCacheFn({\n getUser: async () => Result.orThrow(await this._serverUserCache.getOrWait([userId], \"write-only\")),\n getOrWaitOAuthToken: async () => Result.orThrow(await this._serverUserOAuthConnectionAccessTokensCache.getOrWait([userId, providerId, scope || \"\"] as const, \"write-only\")),\n useOAuthToken: () => useAsyncCache(this._serverUserOAuthConnectionAccessTokensCache, [userId, providerId, scope || \"\"] as const, \"user.useConnectedAccount()\"),\n providerId,\n scope,\n redirect,\n session: null,\n });\n }\n );\n private readonly _serverTeamMemberProfilesCache = createCache<[string], TeamMemberProfilesCrud['Server']['Read'][]>(\n async ([teamId]) => {\n return await this._interface.listServerTeamMemberProfiles({ teamId });\n }\n );\n private readonly _serverTeamInvitationsCache = createCache<[string], TeamInvitationCrud['Server']['Read'][]>(\n async ([teamId]) => {\n return await this._interface.listServerTeamInvitations({ teamId });\n }\n );\n private readonly _serverUserTeamProfileCache = createCache<[string, string], TeamMemberProfilesCrud['Client']['Read']>(\n async ([teamId, userId]) => {\n return await this._interface.getServerTeamMemberProfile({ teamId, userId });\n }\n );\n private readonly _serverContactChannelsCache = createCache<[string], ContactChannelsCrud['Server']['Read'][]>(\n async ([userId]) => {\n return await this._interface.listServerContactChannels(userId);\n }\n );\n private readonly _serverNotificationCategoriesCache = createCache<[string], NotificationPreferenceCrud['Server']['Read'][]>(\n async ([userId]) => {\n return await this._interface.listServerNotificationCategories(userId);\n }\n );\n private readonly _serverDataVaultStoreValueCache = createCache<[string, string, string], string | null>(async ([storeId, key, secret]) => {\n return await this._interface.getDataVaultStoreValue(secret, storeId, key);\n });\n\n private readonly _serverUserApiKeysCache = createCache<[string], UserApiKeysCrud['Server']['Read'][]>(\n async ([userId]) => {\n const result = await this._interface.listProjectApiKeys({\n user_id: userId,\n }, null, \"server\");\n return result as UserApiKeysCrud['Server']['Read'][];\n }\n );\n\n private readonly _serverTeamApiKeysCache = createCache<[string], TeamApiKeysCrud['Server']['Read'][]>(\n async ([teamId]) => {\n const result = await this._interface.listProjectApiKeys({\n team_id: teamId,\n }, null, \"server\");\n return result as TeamApiKeysCrud['Server']['Read'][];\n }\n );\n\n private readonly _convexIdentitySubjectCache = createCache<[ConvexCtx], string | null>(\n async ([ctx]) => {\n const identity = await ctx.auth.getUserIdentity();\n return identity ? identity.subject : null;\n }\n );\n\n private readonly _serverCheckApiKeyCache = createCache<[\"user\" | \"team\", string], UserApiKeysCrud['Server']['Read'] | TeamApiKeysCrud['Server']['Read'] | null>(async ([type, apiKey]) => {\n const result = await this._interface.checkProjectApiKey(\n type,\n apiKey,\n null,\n \"server\",\n );\n return result;\n });\n\n private readonly _serverOAuthProvidersCache = createCache<[string], OAuthProviderCrud['Server']['Read'][]>(\n async ([userId]) => {\n return await this._interface.listServerOAuthProviders({ user_id: userId });\n }\n );\n\n private readonly _serverTeamItemsCache = createCache<[string, string], ItemCrud['Client']['Read']>(\n async ([teamId, itemId]) => {\n return await this._interface.getItem({ teamId, itemId }, null);\n }\n );\n\n private readonly _serverUserItemsCache = createCache<[string, string], ItemCrud['Client']['Read']>(\n async ([userId, itemId]) => {\n return await this._interface.getItem({ userId, itemId }, null);\n }\n );\n\n private readonly _serverCustomItemsCache = createCache<[string, string], ItemCrud['Client']['Read']>(\n async ([customCustomerId, itemId]) => {\n return await this._interface.getItem({ customCustomerId, itemId }, null);\n }\n );\n\n private readonly _serverUserProductsCache = createCache<[string, string | null, number | null], CustomerProductsListResponse>(\n async ([userId, cursor, limit]) => {\n return await this._interface.listProducts({\n customer_type: \"user\",\n customer_id: userId,\n cursor: cursor ?? undefined,\n limit: limit ?? undefined,\n }, null);\n }\n );\n\n private readonly _serverTeamProductsCache = createCache<[string, string | null, number | null], CustomerProductsListResponse>(\n async ([teamId, cursor, limit]) => {\n return await this._interface.listProducts({\n customer_type: \"team\",\n customer_id: teamId,\n cursor: cursor ?? undefined,\n limit: limit ?? undefined,\n }, null);\n }\n );\n\n private readonly _serverCustomProductsCache = createCache<[string, string | null, number | null], CustomerProductsListResponse>(\n async ([customCustomerId, cursor, limit]) => {\n return await this._interface.listProducts({\n customer_type: \"custom\",\n customer_id: customCustomerId,\n cursor: cursor ?? undefined,\n limit: limit ?? undefined,\n }, null);\n }\n );\n\n protected _createServerCustomer(userIdOrTeamId: string, type: \"user\" | \"team\"): Omit<Customer<true>, \"id\"> {\n const app = this;\n const productsCache = type === \"user\" ? app._serverUserProductsCache : app._serverTeamProductsCache;\n const customerOptions = type === \"user\" ? { userId: userIdOrTeamId } : { teamId: userIdOrTeamId };\n return {\n ...this._createCustomer(userIdOrTeamId, type, null),\n async getItem(itemId: string) {\n return await app.getItem({ itemId, ...customerOptions });\n },\n useItem(itemId: string) {\n return app.useItem({ itemId, ...customerOptions });\n },\n async grantProduct(productOptions: { productId: string, quantity?: number } | { product: InlineProduct, quantity?: number }) {\n if (type === \"user\") {\n if (\"productId\" in productOptions) {\n await app.grantProduct({ userId: userIdOrTeamId, productId: productOptions.productId, quantity: productOptions.quantity });\n } else {\n await app.grantProduct({ userId: userIdOrTeamId, product: productOptions.product, quantity: productOptions.quantity });\n }\n } else {\n if (\"productId\" in productOptions) {\n await app.grantProduct({ teamId: userIdOrTeamId, productId: productOptions.productId, quantity: productOptions.quantity });\n } else {\n await app.grantProduct({ teamId: userIdOrTeamId, product: productOptions.product, quantity: productOptions.quantity });\n }\n }\n await productsCache.refresh([userIdOrTeamId, null, null]);\n },\n async createCheckoutUrl(options: { productId: string, returnUrl?: string } | { product: InlineProduct, returnUrl?: string }) {\n const productIdOrInline = \"productId\" in options ? options.productId : options.product;\n return await app._interface.createCheckoutUrl(type, userIdOrTeamId, productIdOrInline, null, options.returnUrl);\n },\n };\n }\n\n private async _updateServerUser(userId: string, update: ServerUserUpdateOptions): Promise<UsersCrud['Server']['Read']> {\n const result = await this._interface.updateServerUser(userId, serverUserUpdateOptionsToCrud(update));\n await this._refreshUsers();\n return result;\n }\n\n protected _serverEditableTeamProfileFromCrud(crud: TeamMemberProfilesCrud['Client']['Read']): EditableTeamMemberProfile {\n const app = this;\n return {\n displayName: crud.display_name,\n profileImageUrl: crud.profile_image_url,\n async update(update: { displayName?: string, profileImageUrl?: string }) {\n await app._interface.updateServerTeamMemberProfile({\n teamId: crud.team_id,\n userId: crud.user_id,\n profile: {\n display_name: update.displayName,\n profile_image_url: update.profileImageUrl,\n },\n });\n await app._serverUserTeamProfileCache.refresh([crud.team_id, crud.user_id]);\n }\n };\n }\n\n protected _serverContactChannelFromCrud(userId: string, crud: ContactChannelsCrud['Server']['Read']): ServerContactChannel {\n const app = this;\n return {\n id: crud.id,\n value: crud.value,\n type: crud.type,\n isVerified: crud.is_verified,\n isPrimary: crud.is_primary,\n usedForAuth: crud.used_for_auth,\n async sendVerificationEmail(options?: { callbackUrl?: string }) {\n await app._interface.sendServerContactChannelVerificationEmail(userId, crud.id, options?.callbackUrl ?? constructRedirectUrl(app.urls.emailVerification, \"callbackUrl\"));\n },\n async update(data: ServerContactChannelUpdateOptions) {\n await app._interface.updateServerContactChannel(userId, crud.id, serverContactChannelUpdateOptionsToCrud(data));\n await Promise.all([\n app._serverContactChannelsCache.refresh([userId]),\n app._serverUserCache.refresh([userId])\n ]);\n },\n async delete() {\n await app._interface.deleteServerContactChannel(userId, crud.id);\n await Promise.all([\n app._serverContactChannelsCache.refresh([userId]),\n app._serverUserCache.refresh([userId])\n ]);\n },\n };\n }\n\n protected _serverNotificationCategoryFromCrud(userId: string, crud: NotificationPreferenceCrud['Server']['Read']): NotificationCategory {\n const app = this;\n return {\n id: crud.notification_category_id,\n name: crud.notification_category_name,\n enabled: crud.enabled,\n canDisable: crud.can_disable,\n\n async setEnabled(enabled: boolean) {\n await app._interface.setServerNotificationsEnabled(userId, crud.notification_category_id, enabled);\n await app._serverNotificationCategoriesCache.refresh([userId]);\n },\n };\n }\n\n protected _serverOAuthProviderFromCrud(crud: OAuthProviderCrud['Server']['Read']) {\n const app = this;\n return {\n id: crud.id,\n type: crud.type,\n userId: crud.user_id,\n accountId: crud.account_id,\n email: crud.email,\n allowSignIn: crud.allow_sign_in,\n allowConnectedAccounts: crud.allow_connected_accounts,\n\n async update(data: { accountId?: string, email?: string, allowSignIn?: boolean, allowConnectedAccounts?: boolean }): Promise<Result<void,\n InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>\n >> {\n try {\n await app._interface.updateServerOAuthProvider(crud.user_id, crud.id, {\n account_id: data.accountId,\n email: data.email,\n allow_sign_in: data.allowSignIn,\n allow_connected_accounts: data.allowConnectedAccounts,\n });\n await app._serverOAuthProvidersCache.refresh([crud.user_id]);\n return Result.ok(undefined);\n } catch (error) {\n if (KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn.isInstance(error)) {\n return Result.error(error);\n }\n throw error;\n }\n },\n\n async delete() {\n await app._interface.deleteServerOAuthProvider(crud.user_id, crud.id);\n await app._serverOAuthProvidersCache.refresh([crud.user_id]);\n },\n };\n }\n\n constructor(options: StackServerAppConstructorOptions<HasTokenStore, ProjectId>, extraOptions?: { uniqueIdentifier?: string, checkString?: string, interface?: StackServerInterface }) {\n const resolvedOptions = resolveConstructorOptions(options);\n\n super(resolvedOptions, {\n ...extraOptions,\n interface: extraOptions?.interface ?? new StackServerInterface({\n getBaseUrl: () => getBaseUrl(resolvedOptions.baseUrl),\n projectId: resolvedOptions.projectId ?? getDefaultProjectId(),\n extraRequestHeaders: resolvedOptions.extraRequestHeaders ?? getDefaultExtraRequestHeaders(),\n clientVersion,\n publishableClientKey: resolvedOptions.publishableClientKey ?? getDefaultPublishableClientKey(),\n secretServerKey: resolvedOptions.secretServerKey ?? getDefaultSecretServerKey(),\n }),\n });\n }\n\n\n protected _serverApiKeyFromCrud(crud: TeamApiKeysCrud['Client']['Read']): ApiKey<\"team\">;\n protected _serverApiKeyFromCrud(crud: UserApiKeysCrud['Client']['Read']): ApiKey<\"user\">;\n protected _serverApiKeyFromCrud(crud: yup.InferType<typeof teamApiKeysCreateOutputSchema>): ApiKey<\"team\", true>;\n protected _serverApiKeyFromCrud(crud: yup.InferType<typeof userApiKeysCreateOutputSchema>): ApiKey<\"user\", true>;\n protected _serverApiKeyFromCrud(crud: TeamApiKeysCrud['Client']['Read'] | UserApiKeysCrud['Client']['Read'] | yup.InferType<typeof teamApiKeysCreateOutputSchema> | yup.InferType<typeof userApiKeysCreateOutputSchema>): ApiKey<\"user\" | \"team\", boolean> {\n return {\n ...this._baseApiKeyFromCrud(crud),\n async revoke() {\n await this.update({ revoked: true });\n },\n update: async (options: ApiKeyUpdateOptions) => {\n await this._interface.updateProjectApiKey(\n crud.type === \"team\" ? { team_id: crud.team_id } : { user_id: crud.user_id },\n crud.id,\n await apiKeyUpdateOptionsToCrud(crud.type, options),\n null,\n \"server\");\n if (crud.type === \"team\") {\n await this._serverTeamApiKeysCache.refresh([crud.team_id]);\n } else {\n await this._serverUserApiKeysCache.refresh([crud.user_id]);\n }\n },\n };\n }\n\n protected _serverUserFromCrud(crud: UsersCrud['Server']['Read']): ServerUser {\n const app = this;\n\n async function getConnectedAccount(id: ProviderType, options?: { scopes?: string[] }): Promise<OAuthConnection | null>;\n async function getConnectedAccount(id: ProviderType, options: { or: 'redirect', scopes?: string[] }): Promise<OAuthConnection>;\n async function getConnectedAccount(id: ProviderType, options?: { or?: 'redirect', scopes?: string[] }): Promise<OAuthConnection | null> {\n const scopeString = options?.scopes?.join(\" \");\n return Result.orThrow(await app._serverUserOAuthConnectionCache.getOrWait([crud.id, id, scopeString || \"\", options?.or === 'redirect'], \"write-only\"));\n }\n\n function useConnectedAccount(id: ProviderType, options?: { scopes?: string[] }): OAuthConnection | null;\n function useConnectedAccount(id: ProviderType, options: { or: 'redirect', scopes?: string[] }): OAuthConnection;\n function useConnectedAccount(id: ProviderType, options?: { or?: 'redirect', scopes?: string[] }): OAuthConnection | null {\n const scopeString = options?.scopes?.join(\" \");\n return useAsyncCache(app._serverUserOAuthConnectionCache, [crud.id, id, scopeString || \"\", options?.or === 'redirect'] as const, \"user.useConnectedAccount()\");\n }\n\n const serverUser = {\n ...super._createBaseUser(crud),\n lastActiveAt: new Date(crud.last_active_at_millis),\n serverMetadata: crud.server_metadata,\n async setPrimaryEmail(email: string | null, options?: { verified?: boolean }) {\n await app._updateServerUser(crud.id, { primaryEmail: email, primaryEmailVerified: options?.verified });\n },\n async grantPermission(scopeOrPermissionId: Team | string, permissionId?: string): Promise<void> {\n if (scopeOrPermissionId && typeof scopeOrPermissionId !== 'string' && permissionId) {\n const scope = scopeOrPermissionId;\n await app._interface.grantServerTeamUserPermission(scope.id, crud.id, permissionId);\n\n for (const recursive of [true, false]) {\n await app._serverTeamUserPermissionsCache.refresh([scope.id, crud.id, recursive]);\n }\n } else {\n const pId = scopeOrPermissionId as string;\n await app._interface.grantServerProjectPermission(crud.id, pId);\n\n for (const recursive of [true, false]) {\n await app._serverUserProjectPermissionsCache.refresh([crud.id, recursive]);\n }\n }\n },\n async revokePermission(scopeOrPermissionId: Team | string, permissionId?: string): Promise<void> {\n if (scopeOrPermissionId && typeof scopeOrPermissionId !== 'string' && permissionId) {\n const scope = scopeOrPermissionId;\n await app._interface.revokeServerTeamUserPermission(scope.id, crud.id, permissionId);\n\n for (const recursive of [true, false]) {\n await app._serverTeamUserPermissionsCache.refresh([scope.id, crud.id, recursive]);\n }\n } else {\n const pId = scopeOrPermissionId as string;\n await app._interface.revokeServerProjectPermission(crud.id, pId);\n\n for (const recursive of [true, false]) {\n await app._serverUserProjectPermissionsCache.refresh([crud.id, recursive]);\n }\n }\n },\n async delete() {\n const res = await app._interface.deleteServerUser(crud.id);\n await app._refreshUsers();\n return res;\n },\n async createSession(options: { expiresInMillis?: number, isImpersonation?: boolean }) {\n // TODO this should also refresh the access token when it expires (like InternalSession)\n const tokens = await app._interface.createServerUserSession(crud.id, options.expiresInMillis ?? 1000 * 60 * 60 * 24 * 365, options.isImpersonation ?? false);\n return {\n async getTokens() {\n return tokens;\n },\n };\n },\n\n async getActiveSessions() {\n const sessions = await app._interface.listServerSessions(crud.id);\n return sessions.map((session) => app._clientSessionFromCrud(session));\n },\n\n async revokeSession(sessionId: string) {\n await app._interface.deleteServerSession(sessionId);\n },\n async setDisplayName(displayName: string) {\n return await this.update({ displayName });\n },\n async setClientMetadata(metadata: Record<string, any>) {\n return await this.update({ clientMetadata: metadata });\n },\n async setClientReadOnlyMetadata(metadata: Record<string, any>) {\n return await this.update({ clientReadOnlyMetadata: metadata });\n },\n async setServerMetadata(metadata: Record<string, any>) {\n return await this.update({ serverMetadata: metadata });\n },\n async setSelectedTeam(team: Team | null) {\n return await this.update({ selectedTeamId: team?.id ?? null });\n },\n getConnectedAccount,\n useConnectedAccount, // THIS_LINE_PLATFORM react-like\n selectedTeam: crud.selected_team ? app._serverTeamFromCrud(crud.selected_team) : null,\n async getTeam(teamId: string) {\n const teams = await this.listTeams();\n return teams.find((t) => t.id === teamId) ?? null;\n },\n useTeam(teamId: string) {\n const teams = this.useTeams();\n return useMemo(() => {\n return teams.find((t) => t.id === teamId) ?? null;\n }, [teams, teamId]);\n },\n async listTeams() {\n const teams = Result.orThrow(await app._serverTeamsCache.getOrWait([crud.id], \"write-only\"));\n return teams.map((t) => app._serverTeamFromCrud(t));\n },\n useTeams() {\n const teams = useAsyncCache(app._serverTeamsCache, [crud.id], \"user.useTeams()\");\n return useMemo(() => teams.map((t) => app._serverTeamFromCrud(t)), [teams]);\n },\n createTeam: async (data: Omit<ServerTeamCreateOptions, \"creatorUserId\">) => {\n const team = await app._interface.createServerTeam(serverTeamCreateOptionsToCrud({\n creatorUserId: crud.id,\n ...data,\n }));\n await app._serverTeamsCache.refresh([undefined]);\n await app._updateServerUser(crud.id, { selectedTeamId: team.id });\n return app._serverTeamFromCrud(team);\n },\n leaveTeam: async (team: Team) => {\n await app._interface.leaveServerTeam({ teamId: team.id, userId: crud.id });\n // TODO: refresh cache\n },\n async listPermissions(scopeOrOptions?: Team | { recursive?: boolean }, options?: { recursive?: boolean }): Promise<AdminTeamPermission[]> {\n if (scopeOrOptions && 'id' in scopeOrOptions) {\n const scope = scopeOrOptions;\n const recursive = options?.recursive ?? true;\n const permissions = Result.orThrow(await app._serverTeamUserPermissionsCache.getOrWait([scope.id, crud.id, recursive], \"write-only\"));\n return permissions.map((crud) => app._serverPermissionFromCrud(crud));\n } else {\n const opts = scopeOrOptions;\n const recursive = opts?.recursive ?? true;\n const permissions = Result.orThrow(await app._serverUserProjectPermissionsCache.getOrWait([crud.id, recursive], \"write-only\"));\n return permissions.map((crud) => app._serverPermissionFromCrud(crud));\n }\n },\n usePermissions(scopeOrOptions?: Team | { recursive?: boolean }, options?: { recursive?: boolean }): AdminTeamPermission[] {\n if (scopeOrOptions && 'id' in scopeOrOptions) {\n const scope = scopeOrOptions;\n const recursive = options?.recursive ?? true;\n const permissions = useAsyncCache(app._serverTeamUserPermissionsCache, [scope.id, crud.id, recursive] as const, \"user.usePermissions()\");\n return useMemo(() => permissions.map((crud) => app._serverPermissionFromCrud(crud)), [permissions]);\n } else {\n const opts = scopeOrOptions;\n const recursive = opts?.recursive ?? true;\n const permissions = useAsyncCache(app._serverUserProjectPermissionsCache, [crud.id, recursive] as const, \"user.usePermissions()\");\n return useMemo(() => permissions.map((crud) => app._serverPermissionFromCrud(crud)), [permissions]);\n }\n },\n async getPermission(scopeOrPermissionId: Team | string, permissionId?: string): Promise<AdminTeamPermission | null> {\n if (scopeOrPermissionId && typeof scopeOrPermissionId !== 'string') {\n const scope = scopeOrPermissionId;\n const permissions = await this.listPermissions(scope);\n return permissions.find((p) => p.id === permissionId) ?? null;\n } else {\n const pid = scopeOrPermissionId;\n const permissions = await this.listPermissions();\n return permissions.find((p) => p.id === pid) ?? null;\n }\n },\n usePermission(scopeOrPermissionId: Team | string, permissionId?: string): AdminTeamPermission | null {\n if (scopeOrPermissionId && typeof scopeOrPermissionId !== 'string') {\n const scope = scopeOrPermissionId;\n const permissions = this.usePermissions(scope);\n return useMemo(() => permissions.find((p) => p.id === permissionId) ?? null, [permissions, permissionId]);\n } else {\n const pid = scopeOrPermissionId;\n const permissions = this.usePermissions();\n return useMemo(() => permissions.find((p) => p.id === pid) ?? null, [permissions, pid]);\n }\n },\n async hasPermission(scopeOrPermissionId: Team | string, permissionId?: string): Promise<boolean> {\n if (scopeOrPermissionId && typeof scopeOrPermissionId !== 'string') {\n const scope = scopeOrPermissionId;\n return (await this.getPermission(scope, permissionId as string)) !== null;\n } else {\n const pid = scopeOrPermissionId;\n return (await this.getPermission(pid)) !== null;\n }\n },\n async update(update: ServerUserUpdateOptions) {\n await app._updateServerUser(crud.id, update);\n },\n async sendVerificationEmail() {\n return await app._checkFeatureSupport(\"sendVerificationEmail() on ServerUser\", {});\n },\n async updatePassword(options: { oldPassword: string, newPassword: string }) {\n const result = await app._interface.updatePassword(options);\n await app._serverUserCache.refresh([crud.id]);\n return result;\n },\n async setPassword(options: { password: string }) {\n const result = await this.update(options);\n await app._serverUserCache.refresh([crud.id]);\n return result;\n },\n async getTeamProfile(team: Team) {\n const result = Result.orThrow(await app._serverUserTeamProfileCache.getOrWait([team.id, crud.id], \"write-only\"));\n return app._serverEditableTeamProfileFromCrud(result);\n },\n useTeamProfile(team: Team) {\n const result = useAsyncCache(app._serverUserTeamProfileCache, [team.id, crud.id] as const, \"user.useTeamProfile()\");\n return useMemo(() => app._serverEditableTeamProfileFromCrud(result), [result]);\n },\n async listContactChannels() {\n const result = Result.orThrow(await app._serverContactChannelsCache.getOrWait([crud.id], \"write-only\"));\n return result.map((data) => app._serverContactChannelFromCrud(crud.id, data));\n },\n useContactChannels() {\n const result = useAsyncCache(app._serverContactChannelsCache, [crud.id] as const, \"user.useContactChannels()\");\n return useMemo(() => result.map((data) => app._serverContactChannelFromCrud(crud.id, data)), [result]);\n },\n createContactChannel: async (data: ServerContactChannelCreateOptions) => {\n const contactChannel = await app._interface.createServerContactChannel(serverContactChannelCreateOptionsToCrud(crud.id, data));\n await Promise.all([\n app._serverContactChannelsCache.refresh([crud.id]),\n app._serverUserCache.refresh([crud.id])\n ]);\n return app._serverContactChannelFromCrud(crud.id, contactChannel);\n },\n useNotificationCategories() {\n const results = useAsyncCache(app._serverNotificationCategoriesCache, [crud.id] as const, \"user.useNotificationCategories()\");\n return results.map((category) => app._serverNotificationCategoryFromCrud(crud.id, category));\n },\n async listNotificationCategories() {\n const results = Result.orThrow(await app._serverNotificationCategoriesCache.getOrWait([crud.id], \"write-only\"));\n return results.map((category) => app._serverNotificationCategoryFromCrud(crud.id, category));\n },\n useApiKeys() {\n const result = useAsyncCache(app._serverUserApiKeysCache, [crud.id] as const, \"user.useApiKeys()\");\n return result.map((apiKey) => app._serverApiKeyFromCrud(apiKey));\n },\n async listApiKeys() {\n const result = Result.orThrow(await app._serverUserApiKeysCache.getOrWait([crud.id], \"write-only\"));\n return result.map((apiKey) => app._serverApiKeyFromCrud(apiKey));\n },\n async createApiKey(options: ApiKeyCreationOptions<\"user\">) {\n const result = await app._interface.createProjectApiKey(\n await apiKeyCreationOptionsToCrud(\"user\", crud.id, options),\n null,\n \"server\",\n );\n await app._serverUserApiKeysCache.refresh([crud.id]);\n return app._serverApiKeyFromCrud(result);\n },\n useOAuthProviders() {\n const results = useAsyncCache(app._serverOAuthProvidersCache, [crud.id] as const, \"user.useOAuthProviders()\");\n return useMemo(() => results.map((oauthCrud) => app._serverOAuthProviderFromCrud(oauthCrud)), [results]);\n },\n\n async listOAuthProviders() {\n const results = Result.orThrow(await app._serverOAuthProvidersCache.getOrWait([crud.id], \"write-only\"));\n return results.map((oauthCrud) => app._serverOAuthProviderFromCrud(oauthCrud));\n },\n\n useOAuthProvider(id: string) {\n const providers = this.useOAuthProviders();\n return useMemo(() => providers.find((p) => p.id === id) ?? null, [providers, id]);\n },\n async getOAuthProvider(id: string) {\n const providers = await this.listOAuthProviders();\n return providers.find((p) => p.id === id) ?? null;\n },\n async registerPasskey(options?: { hostname?: string }): Promise<Result<undefined, KnownErrors[\"PasskeyRegistrationFailed\"] | KnownErrors[\"PasskeyWebAuthnError\"]>> {\n // TODO remove duplicated code between this and the function in client-app-impl.ts\n const hostname = options?.hostname || (await app._getCurrentUrl())?.hostname;\n if (!hostname) {\n throw new StackAssertionError(\"hostname must be provided if the Stack App does not have a redirect method\");\n }\n\n // Use server interface to initiate passkey registration for this specific user\n const initiationResult = await app._interface.initiateServerPasskeyRegistration(crud.id);\n\n if (initiationResult.status !== \"ok\") {\n return Result.error(new KnownErrors.PasskeyRegistrationFailed(\"Failed to get initiation options for passkey registration\"));\n }\n\n const { options_json, code } = initiationResult.data;\n\n // HACK: Override the rpID to be the actual domain\n if (options_json.rp.id !== \"THIS_VALUE_WILL_BE_REPLACED.example.com\") {\n throw new StackAssertionError(`Expected returned RP ID from server to equal sentinel, but found ${options_json.rp.id}`);\n }\n\n options_json.rp.id = hostname;\n\n let attResp;\n try {\n const { startRegistration } = await import(\"@simplewebauthn/browser\");\n attResp = await startRegistration({ optionsJSON: options_json });\n } catch (error: any) {\n const { WebAuthnError } = await import(\"@simplewebauthn/browser\");\n if (error instanceof WebAuthnError) {\n return Result.error(new KnownErrors.PasskeyWebAuthnError(error.message, error.name));\n } else {\n // This should never happen\n const { captureError } = await import(\"@stackframe/stack-shared/dist/utils/errors\");\n captureError(\"passkey-registration-failed\", error);\n return Result.error(new KnownErrors.PasskeyRegistrationFailed(\"Failed to start passkey registration due to unknown error\"));\n }\n }\n\n // Create a temporary session to complete the registration\n // TODO instead of creating a new session, this should just call the endpoint in a way in which it doesn't require a session\n // (currently this shows up on session history etc... not ideal)\n const { accessToken, refreshToken } = await app._interface.createServerUserSession(crud.id, 60000 * 2, false);\n const tempSession = new InternalSession({\n accessToken,\n refreshToken,\n refreshAccessTokenCallback: async () => null,\n });\n\n const registrationResult = await app._interface.registerPasskey({ credential: attResp, code }, tempSession);\n\n await app._serverUserCache.refresh([crud.id]);\n return registrationResult;\n },\n ...app._createServerCustomer(crud.id, \"user\"),\n } satisfies ServerUser;\n\n attachUserDestructureGuard(serverUser);\n\n return serverUser;\n }\n\n protected _serverTeamUserFromCrud(crud: TeamMemberProfilesCrud[\"Server\"][\"Read\"]): ServerTeamUser {\n const teamUser = {\n ...this._serverUserFromCrud(crud.user),\n teamProfile: {\n displayName: crud.display_name,\n profileImageUrl: crud.profile_image_url,\n },\n } satisfies ServerTeamUser;\n\n attachUserDestructureGuard(teamUser);\n return teamUser;\n }\n\n protected _serverTeamInvitationFromCrud(crud: TeamInvitationCrud['Server']['Read']): TeamInvitation {\n return {\n id: crud.id,\n recipientEmail: crud.recipient_email,\n expiresAt: new Date(crud.expires_at_millis),\n revoke: async () => {\n await this._interface.revokeServerTeamInvitation(crud.id, crud.team_id);\n await this._serverTeamInvitationsCache.refresh([crud.team_id]);\n },\n };\n }\n\n protected override _currentUserFromCrud(crud: UsersCrud['Server']['Read'], session: InternalSession): ProjectCurrentServerUser<ProjectId> {\n const currentUser = {\n ...this._serverUserFromCrud(crud),\n ...this._createAuth(session),\n ...this._isInternalProject() ? this._createInternalUserExtra(session) : {},\n } satisfies ServerUser;\n\n attachUserDestructureGuard(currentUser);\n Object.freeze(currentUser);\n return currentUser as ProjectCurrentServerUser<ProjectId>;\n }\n\n protected _serverTeamFromCrud(crud: TeamsCrud['Server']['Read']): ServerTeam {\n const app = this;\n return {\n id: crud.id,\n displayName: crud.display_name,\n profileImageUrl: crud.profile_image_url,\n createdAt: new Date(crud.created_at_millis),\n clientMetadata: crud.client_metadata,\n clientReadOnlyMetadata: crud.client_read_only_metadata,\n serverMetadata: crud.server_metadata,\n async update(update: Partial<ServerTeamUpdateOptions>) {\n await app._interface.updateServerTeam(crud.id, serverTeamUpdateOptionsToCrud(update));\n await app._serverTeamsCache.refresh([undefined]);\n },\n async delete() {\n await app._interface.deleteServerTeam(crud.id);\n await app._serverTeamsCache.refresh([undefined]);\n },\n async listUsers() {\n const result = Result.orThrow(await app._serverTeamMemberProfilesCache.getOrWait([crud.id], \"write-only\"));\n return result.map(u => app._serverTeamUserFromCrud(u));\n },\n useUsers() {\n const result = useAsyncCache(app._serverTeamMemberProfilesCache, [crud.id] as const, \"team.useUsers()\");\n return useMemo(() => result.map(u => app._serverTeamUserFromCrud(u)), [result]);\n },\n async addUser(userId) {\n await app._interface.addServerUserToTeam({\n teamId: crud.id,\n userId,\n });\n await app._serverTeamMemberProfilesCache.refresh([crud.id]);\n },\n async removeUser(userId) {\n await app._interface.removeServerUserFromTeam({\n teamId: crud.id,\n userId,\n });\n await app._serverTeamMemberProfilesCache.refresh([crud.id]);\n },\n async inviteUser(options: { email: string, callbackUrl?: string }) {\n await app._interface.sendServerTeamInvitation({\n teamId: crud.id,\n email: options.email,\n callbackUrl: options.callbackUrl ?? constructRedirectUrl(app.urls.teamInvitation, \"callbackUrl\"),\n });\n await app._serverTeamInvitationsCache.refresh([crud.id]);\n },\n async listInvitations() {\n const result = Result.orThrow(await app._serverTeamInvitationsCache.getOrWait([crud.id], \"write-only\"));\n return result.map((crud) => app._serverTeamInvitationFromCrud(crud));\n },\n useInvitations() {\n const result = useAsyncCache(app._serverTeamInvitationsCache, [crud.id] as const, \"team.useInvitations()\");\n return useMemo(() => result.map((crud) => app._serverTeamInvitationFromCrud(crud)), [result]);\n },\n useApiKeys() {\n const result = useAsyncCache(app._serverTeamApiKeysCache, [crud.id] as const, \"team.useApiKeys()\");\n return result.map((apiKey) => app._serverApiKeyFromCrud(apiKey));\n },\n async listApiKeys() {\n const result = Result.orThrow(await app._serverTeamApiKeysCache.getOrWait([crud.id], \"write-only\"));\n return result.map((apiKey) => app._serverApiKeyFromCrud(apiKey));\n },\n async createApiKey(options: ApiKeyCreationOptions<\"team\">) {\n const result = await app._interface.createProjectApiKey(\n await apiKeyCreationOptionsToCrud(\"team\", crud.id, options),\n null,\n \"server\",\n );\n await app._serverTeamApiKeysCache.refresh([crud.id]);\n return app._serverApiKeyFromCrud(result);\n },\n ...app._createServerCustomer(crud.id, \"team\"),\n };\n }\n\n protected _serverItemFromCrud(customer: { type: \"user\" | \"team\" | \"custom\", id: string }, crud: ItemCrud['Client']['Read']): ServerItem {\n const app = this;\n return {\n displayName: crud.display_name,\n quantity: crud.quantity,\n nonNegativeQuantity: Math.max(0, crud.quantity),\n increaseQuantity: async (delta: number) => {\n const updateOptions = customer.type === \"user\"\n ? { itemId: crud.id, userId: customer.id }\n : customer.type === \"team\"\n ? { itemId: crud.id, teamId: customer.id }\n : { itemId: crud.id, customCustomerId: customer.id };\n await app._interface.updateItemQuantity(updateOptions, { delta });\n if (customer.type === \"user\") await app._serverUserItemsCache.refresh([customer.id, crud.id]);\n else if (customer.type === \"team\") await app._serverTeamItemsCache.refresh([customer.id, crud.id]);\n else await app._serverCustomItemsCache.refresh([customer.id, crud.id]);\n },\n decreaseQuantity: async (delta: number) => {\n const updateOptions = customer.type === \"user\"\n ? { itemId: crud.id, userId: customer.id }\n : customer.type === \"team\"\n ? { itemId: crud.id, teamId: customer.id }\n : { itemId: crud.id, customCustomerId: customer.id };\n await app._interface.updateItemQuantity(updateOptions, { delta: -delta, allow_negative: true });\n if (customer.type === \"user\") await app._serverUserItemsCache.refresh([customer.id, crud.id]);\n else if (customer.type === \"team\") await app._serverTeamItemsCache.refresh([customer.id, crud.id]);\n else await app._serverCustomItemsCache.refresh([customer.id, crud.id]);\n },\n tryDecreaseQuantity: async (delta: number) => {\n try {\n const updateOptions = customer.type === \"user\"\n ? { itemId: crud.id, userId: customer.id }\n : customer.type === \"team\"\n ? { itemId: crud.id, teamId: customer.id }\n : { itemId: crud.id, customCustomerId: customer.id };\n await app._interface.updateItemQuantity(updateOptions, { delta: -delta });\n if (customer.type === \"user\") await app._serverUserItemsCache.refresh([customer.id, crud.id]);\n else if (customer.type === \"team\") await app._serverTeamItemsCache.refresh([customer.id, crud.id]);\n else await app._serverCustomItemsCache.refresh([customer.id, crud.id]);\n return true;\n } catch (error) {\n if (error instanceof KnownErrors.ItemQuantityInsufficientAmount) {\n return false;\n }\n throw error;\n }\n },\n };\n }\n\n protected async _getUserApiKey(options: { apiKey: string }): Promise<ApiKey<\"user\"> | null> {\n const crud = Result.orThrow(await this._serverCheckApiKeyCache.getOrWait([\"user\", options.apiKey], \"write-only\")) as UserApiKeysCrud['Server']['Read'] | null;\n return crud ? this._serverApiKeyFromCrud(crud) : null;\n }\n\n protected async _getTeamApiKey(options: { apiKey: string }): Promise<ApiKey<\"team\"> | null> {\n const crud = Result.orThrow(await this._serverCheckApiKeyCache.getOrWait([\"team\", options.apiKey], \"write-only\")) as TeamApiKeysCrud['Server']['Read'] | null;\n return crud ? this._serverApiKeyFromCrud(crud) : null;\n }\n protected _useUserApiKey(options: { apiKey: string }): ApiKey<\"user\"> | null {\n const crud = useAsyncCache(this._serverCheckApiKeyCache, [\"user\", options.apiKey] as const, \"serverApp.useUserApiKey()\") as UserApiKeysCrud['Server']['Read'] | null;\n return useMemo(() => crud ? this._serverApiKeyFromCrud(crud) : null, [crud]);\n }\n protected _useTeamApiKey(options: { apiKey: string }): ApiKey<\"team\"> | null {\n const crud = useAsyncCache(this._serverCheckApiKeyCache, [\"team\", options.apiKey] as const, \"serverApp.useTeamApiKey()\") as TeamApiKeysCrud['Server']['Read'] | null;\n return useMemo(() => crud ? this._serverApiKeyFromCrud(crud) : null, [crud]);\n }\n protected async _getUserByApiKey(apiKey: string): Promise<ServerUser | null> {\n const apiKeyObject = await this._getUserApiKey({ apiKey });\n if (apiKeyObject === null) {\n return null;\n }\n return await this.getServerUserById(apiKeyObject.userId);\n }\n\n protected async _getUserByConvex(ctx: ConvexCtx, includeAnonymous: boolean): Promise<ServerUser | null> {\n const identity = await ctx.auth.getUserIdentity();\n if (identity === null) {\n return null;\n }\n const user = await this.getServerUserById(identity.subject);\n if (user?.isAnonymous && !includeAnonymous) {\n return null;\n }\n return user;\n }\n protected _useUserByConvex(ctx: ConvexCtx, includeAnonymous: boolean): ServerUser | null {\n const subject = useAsyncCache(this._convexIdentitySubjectCache, [ctx] as const, \"serverApp.useUserByConvex()\");\n if (subject === null) {\n return null;\n }\n const user = this.useUserById(subject);\n if (user?.isAnonymous && !includeAnonymous) {\n return null;\n }\n return user;\n }\n protected _useUserByApiKey(apiKey: string): ServerUser | null {\n const apiKeyObject = this._useUserApiKey({ apiKey });\n if (apiKeyObject === null) {\n return null;\n }\n return this.useUserById(apiKeyObject.userId);\n }\n\n protected async _getTeamByApiKey(apiKey: string): Promise<ServerTeam | null> {\n const apiKeyObject = await this._getTeamApiKey({ apiKey });\n if (apiKeyObject === null) {\n return null;\n }\n return await this.getTeam(apiKeyObject.teamId);\n }\n protected _useTeamByApiKey(apiKey: string): ServerTeam | null {\n const apiKeyObject = this._useTeamApiKey({ apiKey });\n if (apiKeyObject === null) {\n return null;\n }\n return this.useTeam(apiKeyObject.teamId);\n }\n\n async createUser(options: ServerUserCreateOptions): Promise<ServerUser> {\n const crud = await this._interface.createServerUser(serverUserCreateOptionsToCrud(options));\n await this._refreshUsers();\n return this._serverUserFromCrud(crud);\n }\n\n async getUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'redirect' }): Promise<ProjectCurrentServerUser<ProjectId>>;\n async getUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'throw' }): Promise<ProjectCurrentServerUser<ProjectId>>;\n async getUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'anonymous' }): Promise<ProjectCurrentServerUser<ProjectId>>;\n async getUser(options?: GetCurrentUserOptions<HasTokenStore>): Promise<ProjectCurrentServerUser<ProjectId> | null>;\n async getUser(id: string): Promise<ServerUser | null>;\n async getUser(options: { apiKey: string }): Promise<ServerUser | null>;\n async getUser(options: { from: \"convex\", ctx: ConvexCtx, or?: \"return-null\" | \"anonymous\" }): Promise<ServerUser | null>;\n async getUser(options?: string | GetCurrentUserOptions<HasTokenStore> | { apiKey: string } | { from: \"convex\", ctx: ConvexCtx }): Promise<ProjectCurrentServerUser<ProjectId> | ServerUser | null> {\n if (typeof options === \"string\") {\n return await this.getServerUserById(options);\n } else if (typeof options === \"object\" && \"apiKey\" in options) {\n return await this._getUserByApiKey(options.apiKey);\n } else if (typeof options === \"object\" && \"from\" in options && options.from as string === \"convex\") {\n return await this._getUserByConvex(options.ctx, \"or\" in options && options.or === \"anonymous\");\n } else {\n options = options as GetCurrentUserOptions<HasTokenStore> | undefined;\n // TODO this code is duplicated from the client app; fix that\n this._ensurePersistentTokenStore(options?.tokenStore);\n const session = await this._getSession(options?.tokenStore);\n let crud = Result.orThrow(await this._currentServerUserCache.getOrWait([session], \"write-only\"));\n if (crud?.is_anonymous && options?.or !== \"anonymous\" && options?.or !== \"anonymous-if-exists[deprecated]\") {\n crud = null;\n }\n\n if (crud === null) {\n switch (options?.or) {\n case 'redirect': {\n await this.redirectToSignIn({ replace: true });\n break;\n }\n case 'throw': {\n throw new Error(\"User is not signed in but getUser was called with { or: 'throw' }\");\n }\n case 'anonymous': {\n const tokens = await this._signUpAnonymously();\n return await this.getUser({ tokenStore: tokens, or: \"anonymous-if-exists[deprecated]\" }) ?? throwErr(\"Something went wrong while signing up anonymously\");\n }\n case undefined:\n case \"anonymous-if-exists[deprecated]\":\n case \"return-null\": {\n return null;\n }\n }\n }\n\n return crud && this._currentUserFromCrud(crud, session);\n }\n }\n\n async getServerUser(): Promise<ProjectCurrentServerUser<ProjectId> | null> {\n console.warn(\"stackServerApp.getServerUser is deprecated; use stackServerApp.getUser instead\");\n return await this.getUser();\n }\n\n async getServerUserById(userId: string): Promise<ServerUser | null> {\n const crud = Result.orThrow(await this._serverUserCache.getOrWait([userId], \"write-only\"));\n return crud && this._serverUserFromCrud(crud);\n }\n\n useUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'redirect' }): ProjectCurrentServerUser<ProjectId>;\n useUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'throw' }): ProjectCurrentServerUser<ProjectId>;\n useUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'anonymous' }): ProjectCurrentServerUser<ProjectId>;\n useUser(options?: GetCurrentUserOptions<HasTokenStore>): ProjectCurrentServerUser<ProjectId> | null;\n useUser(id: string): ServerUser | null;\n useUser(options: { apiKey: string }): ServerUser | null;\n useUser(options: { from: \"convex\", ctx: ConvexCtx, or?: \"return-null\" | \"anonymous\" }): ServerUser | null;\n useUser(options?: GetCurrentUserOptions<HasTokenStore> | string | { apiKey: string } | { from: \"convex\", ctx: ConvexCtx }): ProjectCurrentServerUser<ProjectId> | ServerUser | null {\n if (typeof options === \"string\") {\n return this.useUserById(options);\n } else if (typeof options === \"object\" && \"apiKey\" in options) {\n return this._useUserByApiKey(options.apiKey);\n } else if (typeof options === \"object\" && \"from\" in options && options.from as string === \"convex\") {\n return this._useUserByConvex(options.ctx, \"or\" in options && options.or === \"anonymous\");\n } else {\n options = options as GetCurrentUserOptions<HasTokenStore> | undefined;\n // TODO this code is duplicated from the client app; fix that\n this._ensurePersistentTokenStore(options?.tokenStore);\n\n const session = this._useSession(options?.tokenStore);\n let crud = useAsyncCache(this._currentServerUserCache, [session] as const, \"serverApp.useUser()\");\n if (crud?.is_anonymous && options?.or !== \"anonymous\" && options?.or !== \"anonymous-if-exists[deprecated]\") {\n crud = null;\n }\n\n if (crud === null) {\n switch (options?.or) {\n case 'redirect': {\n runAsynchronously(this.redirectToSignIn({ replace: true }));\n suspend();\n throw new StackAssertionError(\"suspend should never return\");\n }\n case 'throw': {\n throw new Error(\"User is not signed in but useUser was called with { or: 'throw' }\");\n }\n case 'anonymous': {\n // TODO we should think about the behavior when calling useUser (or getUser) in anonymous with a custom token store. signUpAnonymously always sets the current token store on app level, instead of the one passed to this function\n // TODO we shouldn't reload & suspend here, instead we should use a promise that resolves to the new anonymous user\n runAsynchronously(async () => {\n await this._signUpAnonymously();\n if (typeof window !== \"undefined\") {\n window.location.reload();\n }\n });\n suspend();\n throw new StackAssertionError(\"suspend should never return\");\n }\n case undefined:\n case \"anonymous-if-exists[deprecated]\":\n case \"return-null\": {\n // do nothing\n }\n }\n }\n\n return useMemo(() => {\n return crud && this._currentUserFromCrud(crud, session);\n }, [crud, session, options?.or]);\n }\n }\n useUserById(userId: string): ServerUser | null {\n const crud = useAsyncCache(this._serverUserCache, [userId], \"serverApp.useUserById()\");\n return useMemo(() => {\n return crud && this._serverUserFromCrud(crud);\n }, [crud]);\n }\n\n async listUsers(options?: ServerListUsersOptions): Promise<ServerUser[] & { nextCursor: string | null }> {\n const crud = Result.orThrow(await this._serverUsersCache.getOrWait([options?.cursor, options?.limit, options?.orderBy, options?.desc, options?.query, options?.includeAnonymous], \"write-only\"));\n const result: any = crud.items.map((j) => this._serverUserFromCrud(j));\n result.nextCursor = crud.pagination?.next_cursor ?? null;\n return result as any;\n }\n\n useUsers(options?: ServerListUsersOptions): ServerUser[] & { nextCursor: string | null } {\n const crud = useAsyncCache(this._serverUsersCache, [options?.cursor, options?.limit, options?.orderBy, options?.desc, options?.query, options?.includeAnonymous] as const, \"serverApp.useUsers()\");\n const result: any = crud.items.map((j) => this._serverUserFromCrud(j));\n result.nextCursor = crud.pagination?.next_cursor ?? null;\n return result as any;\n }\n\n _serverPermissionFromCrud(crud: TeamPermissionsCrud['Server']['Read'] | ProjectPermissionsCrud['Server']['Read']): AdminTeamPermission {\n return {\n id: crud.id,\n };\n }\n\n _serverTeamPermissionDefinitionFromCrud(crud: TeamPermissionDefinitionsCrud['Admin']['Read']): AdminTeamPermissionDefinition {\n return {\n id: crud.id,\n description: crud.description,\n containedPermissionIds: crud.contained_permission_ids,\n };\n }\n\n _serverProjectPermissionDefinitionFromCrud(crud: ProjectPermissionDefinitionsCrud['Admin']['Read']): AdminProjectPermissionDefinition {\n return {\n id: crud.id,\n description: crud.description,\n containedPermissionIds: crud.contained_permission_ids,\n };\n }\n\n async listTeams(): Promise<ServerTeam[]> {\n const teams = Result.orThrow(await this._serverTeamsCache.getOrWait([undefined], \"write-only\"));\n return teams.map((t) => this._serverTeamFromCrud(t));\n }\n\n async getItem(options: { itemId: string, userId: string } | { itemId: string, teamId: string } | { itemId: string, customCustomerId: string }): Promise<ServerItem> {\n if (\"userId\" in options) {\n const result = Result.orThrow(await this._serverUserItemsCache.getOrWait([options.userId, options.itemId], \"write-only\"));\n return this._serverItemFromCrud({ type: \"user\", id: options.userId }, result);\n } else if (\"teamId\" in options) {\n const result = Result.orThrow(await this._serverTeamItemsCache.getOrWait([options.teamId, options.itemId], \"write-only\"));\n return this._serverItemFromCrud({ type: \"team\", id: options.teamId }, result);\n } else {\n const result = Result.orThrow(await this._serverCustomItemsCache.getOrWait([options.customCustomerId, options.itemId], \"write-only\"));\n return this._serverItemFromCrud({ type: \"custom\", id: options.customCustomerId }, result);\n }\n }\n\n useItem(options: { itemId: string, userId: string } | { itemId: string, teamId: string } | { itemId: string, customCustomerId: string }): ServerItem {\n let type: \"user\" | \"team\" | \"custom\";\n let id: string;\n let cache: AsyncCache<[string, string], Result<ItemCrud['Client']['Read']>>;\n if (\"userId\" in options) {\n type = \"user\";\n id = options.userId;\n cache = this._serverUserItemsCache;\n } else if (\"teamId\" in options) {\n type = \"team\";\n id = options.teamId;\n cache = this._serverTeamItemsCache;\n } else {\n type = \"custom\";\n id = options.customCustomerId;\n cache = this._serverCustomItemsCache;\n }\n\n const cacheKey = [id, options.itemId] as [string, string];\n const debugLabel = \"serverApp.useItem()\";\n const result = useAsyncCache(cache, cacheKey, debugLabel);\n return useMemo(() => this._serverItemFromCrud({ type, id }, result), [result]);\n }\n async grantProduct(options: (\n ({ userId: string } | { teamId: string } | { customCustomerId: string }) &\n ({ productId: string } | { product: InlineProduct }) &\n { quantity?: number }\n )): Promise<void> {\n let customerType: \"user\" | \"team\" | \"custom\";\n let customerId: string;\n if (\"userId\" in options) {\n customerType = \"user\";\n customerId = options.userId;\n } else if (\"teamId\" in options) {\n customerType = \"team\";\n customerId = options.teamId;\n } else {\n customerType = \"custom\";\n customerId = options.customCustomerId;\n }\n\n await this._interface.grantProduct({\n customerType,\n customerId,\n productId: \"productId\" in options ? options.productId : undefined,\n product: \"product\" in options ? options.product : undefined,\n quantity: options.quantity,\n });\n\n const cache = customerType === \"user\"\n ? this._serverUserProductsCache\n : customerType === \"team\"\n ? this._serverTeamProductsCache\n : this._serverCustomProductsCache;\n await cache.refresh([customerId, null, null]);\n }\n\n async createTeam(data: ServerTeamCreateOptions): Promise<ServerTeam> {\n const team = await this._interface.createServerTeam(serverTeamCreateOptionsToCrud(data));\n await this._serverTeamsCache.refresh([undefined]);\n return this._serverTeamFromCrud(team);\n }\n\n useTeams(): ServerTeam[] {\n const teams = useAsyncCache(this._serverTeamsCache, [undefined], \"serverApp.useTeams()\");\n return useMemo(() => {\n return teams.map((t) => this._serverTeamFromCrud(t));\n }, [teams]);\n }\n\n async getTeam(options: { apiKey: string }): Promise<ServerTeam | null>;\n async getTeam(teamId: string): Promise<ServerTeam | null>;\n async getTeam(options?: { apiKey: string } | string): Promise<ServerTeam | null> {\n if (typeof options === \"object\" && \"apiKey\" in options) {\n return await this._getTeamByApiKey(options.apiKey);\n } else {\n const teamId = options;\n const teams = await this.listTeams();\n return teams.find((t) => t.id === teamId) ?? null;\n }\n }\n\n useTeam(options: { apiKey: string }): ServerTeam | null;\n useTeam(teamId: string): ServerTeam | null;\n useTeam(options?: { apiKey: string } | string): ServerTeam | null {\n if (typeof options === \"object\" && \"apiKey\" in options) {\n return this._useTeamByApiKey(options.apiKey);\n } else {\n const teamId = options;\n const teams = this.useTeams();\n return useMemo(() => {\n return teams.find((t) => t.id === teamId) ?? null;\n }, [teams, teamId]);\n }\n }\n\n protected _createServerDataVaultStore(id: string): DataVaultStore {\n const validateOptions = (options: { secret: string }) => {\n if (typeof options.secret !== \"string\") throw new Error(\"secret must be a string, got \" + typeof options.secret);\n };\n return {\n id,\n setValue: async (key, value, options) => {\n validateOptions(options);\n await this._interface.setDataVaultStoreValue(options.secret, id, key, value);\n },\n getValue: async (key, options) => {\n validateOptions(options);\n return Result.orThrow(await this._serverDataVaultStoreValueCache.getOrWait([id, key, options.secret], \"write-only\"));\n },\n useValue: (key, options) => {\n validateOptions(options);\n return useAsyncCache(this._serverDataVaultStoreValueCache, [id, key, options.secret] as const, \"store.useValue()\");\n },\n };\n }\n\n async getDataVaultStore(id: string): Promise<DataVaultStore> {\n return this._createServerDataVaultStore(id);\n }\n\n useDataVaultStore(id: string): DataVaultStore {\n return useMemo(() => this._createServerDataVaultStore(id), [id]);\n }\n\n async sendEmail(options: SendEmailOptions): Promise<void> {\n await this._interface.sendEmail(options);\n }\n\n protected override async _refreshSession(session: InternalSession) {\n await Promise.all([\n super._refreshUser(session),\n this._currentServerUserCache.refresh([session]),\n ]);\n }\n\n protected override async _refreshUsers() {\n await Promise.all([\n super._refreshUsers(),\n this._serverUserCache.refreshWhere(() => true),\n this._serverUsersCache.refreshWhere(() => true),\n this._serverContactChannelsCache.refreshWhere(() => true),\n this._serverOAuthProvidersCache.refreshWhere(() => true),\n ]);\n }\n\n async createOAuthProvider(options: {\n userId: string,\n providerConfigId: string,\n accountId: string,\n email: string,\n allowSignIn: boolean,\n allowConnectedAccounts: boolean,\n }): Promise<Result<ServerOAuthProvider, InstanceType<typeof KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn>>> {\n try {\n const crud = await this._interface.createServerOAuthProvider({\n user_id: options.userId,\n provider_config_id: options.providerConfigId,\n account_id: options.accountId,\n email: options.email,\n allow_sign_in: options.allowSignIn,\n allow_connected_accounts: options.allowConnectedAccounts,\n });\n\n await this._serverOAuthProvidersCache.refresh([options.userId]);\n return Result.ok(this._serverOAuthProviderFromCrud(crud));\n } catch (error) {\n if (KnownErrors.OAuthProviderAccountIdAlreadyUsedForSignIn.isInstance(error)) {\n return Result.error(error);\n }\n throw error;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,0BAAkD;AAalD,sBAAgC;AAEhC,oBAA8C;AAE9C,sBAAkC;AAClC,mBAAwB;AACxB,qBAAuB;AACvB,IAAAA,gBAAwB;AAExB,iBAAqC;AACrC,sBAA2H;AAG3H,8BAA6L;AAM7L,mBAAoO;AACpO,mBAAsN;AAEtN,6BAA8C;AAC9C,oBAAuN;AAEvN,IAAAC,iBAA8B;AAEvB,IAAM,gCAAN,cAAqG,qDAAwD;AAAA,EAyUlK,YAAY,SAAqE,cAAsG;AACrL,UAAM,sBAAkB,yCAA0B,OAAO;AAEzD,UAAM,iBAAiB;AAAA,MACrB,GAAG;AAAA,MACH,WAAW,cAAc,aAAa,IAAI,yCAAqB;AAAA,QAC7D,YAAY,UAAM,0BAAW,gBAAgB,OAAO;AA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,QAC5B,YAAY,QAAQ;AAAA,QACpB,OAAO,QAAQ;AAAA,QACf,eAAe,QAAQ;AAAA,QACvB,0BAA0B,QAAQ;AAAA,MACpC,CAAC;AAED,YAAM,KAAK,2BAA2B,QAAQ,CAAC,QAAQ,MAAM,CAAC;AAC9D,aAAO,sBAAO,GAAG,KAAK,6BAA6B,IAAI,CAAC;AAAA,IAC1D,SAAS,OAAO;AACd,UAAI,gCAAY,2CAA2C,WAAW,KAAK,GAAG;AAC5E,eAAO,sBAAO,MAAM,KAAK;AAAA,MAC3B;AACA,YAAM;AAAA,IACR;AAAA,EACF;AACF;","names":["import_react","import_common","crud"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/lib/stack-app/apps/interfaces/client-app.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { KnownErrors } from \"@stackframe/stack-shared\";\nimport { CurrentUserCrud } from \"@stackframe/stack-shared/dist/interface/crud/current-user\";\nimport { Result } from \"@stackframe/stack-shared/dist/utils/results\";\nimport { AsyncStoreProperty, GetCurrentPartialUserOptions, GetCurrentUserOptions, HandlerUrls, OAuthScopesOnSignIn, RedirectMethod, RedirectToOptions, TokenStoreInit, stackAppInternalsSymbol } from \"../../common\";\nimport { CustomerProductsList, CustomerProductsRequestOptions, Item } from \"../../customers\";\nimport { Project } from \"../../projects\";\nimport { ProjectCurrentUser, SyncedPartialUser, TokenPartialUser } from \"../../users\";\nimport { _StackClientAppImpl } from \"../implementations\";\n\nexport type StackClientAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = {\n baseUrl?: string | { browser: string, server: string },\n extraRequestHeaders?: Record<string, string>,\n projectId?: ProjectId,\n publishableClientKey?: string,\n urls?: Partial<HandlerUrls>,\n oauthScopesOnSignIn?: Partial<OAuthScopesOnSignIn>,\n tokenStore?: TokenStoreInit<HasTokenStore>,\n redirectMethod?: RedirectMethod,\n inheritsFrom?: StackClientApp<any, any>,\n\n /**\n * By default, the Stack app will automatically prefetch some data from Stack's server when this app is first\n * constructed. This improves the performance of your app, but will create network requests that are unnecessary if\n * the app is never used or disposed of immediately. To disable this behavior, set this option to true.\n */\n noAutomaticPrefetch?: boolean,\n} & (\n { tokenStore: TokenStoreInit<HasTokenStore> } | { tokenStore?: undefined, inheritsFrom: StackClientApp<HasTokenStore, any> }\n) & (\n string extends ProjectId ? unknown : ({ projectId: ProjectId } | { inheritsFrom: StackClientApp<any, ProjectId> })\n);\n\n\nexport type StackClientAppJson<HasTokenStore extends boolean, ProjectId extends string> = StackClientAppConstructorOptions<HasTokenStore, ProjectId> & { inheritsFrom?: undefined } & {\n uniqueIdentifier: string,\n // note: if you add more fields here, make sure to ensure the checkString in the constructor has/doesn't have them\n};\n\nexport type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = (\n & {\n readonly projectId: ProjectId,\n\n readonly urls: Readonly<HandlerUrls>,\n\n signInWithOAuth(provider: string, options?: { returnTo?: string }): Promise<void>,\n signInWithCredential(options: { email: string, password: string, noRedirect?: boolean }): Promise<Result<undefined, KnownErrors[\"EmailPasswordMismatch\"] | KnownErrors[\"InvalidTotpCode\"]>>,\n signUpWithCredential(options: { email: string, password: string, noRedirect?: boolean } & ({ noVerificationCallback: true } | { noVerificationCallback?: false, verificationCallbackUrl?: string })): Promise<Result<undefined, KnownErrors[\"UserWithEmailAlreadyExists\"] | KnownErrors[\"PasswordRequirementsNotMet\"]>>,\n signInWithPasskey(): Promise<Result<undefined, KnownErrors[\"PasskeyAuthenticationFailed\"] | KnownErrors[\"InvalidTotpCode\"] | KnownErrors[\"PasskeyWebAuthnError\"]>>,\n callOAuthCallback(): Promise<boolean>,\n promptCliLogin(options: { appUrl: string, expiresInMillis?: number }): Promise<Result<string, KnownErrors[\"CliAuthError\"] | KnownErrors[\"CliAuthExpiredError\"] | KnownErrors[\"CliAuthUsedError\"]>>,\n sendForgotPasswordEmail(email: string, options?: { callbackUrl?: string }): Promise<Result<undefined, KnownErrors[\"UserNotFound\"]>>,\n sendMagicLinkEmail(email: string, options?: { callbackUrl?: string }): Promise<Result<{ nonce: string }, KnownErrors[\"RedirectUrlNotWhitelisted\"]>>,\n resetPassword(options: { code: string, password: string }): Promise<Result<undefined, KnownErrors[\"VerificationCodeError\"]>>,\n verifyPasswordResetCode(code: string): Promise<Result<undefined, KnownErrors[\"VerificationCodeError\"]>>,\n verifyTeamInvitationCode(code: string): Promise<Result<undefined, KnownErrors[\"VerificationCodeError\"]>>,\n acceptTeamInvitation(code: string): Promise<Result<undefined, KnownErrors[\"VerificationCodeError\"]>>,\n getTeamInvitationDetails(code: string): Promise<Result<{ teamDisplayName: string }, KnownErrors[\"VerificationCodeError\"]>>,\n verifyEmail(code: string): Promise<Result<undefined, KnownErrors[\"VerificationCodeError\"]>>,\n signInWithMagicLink(code: string, options?: { noRedirect?: boolean }): Promise<Result<undefined, KnownErrors[\"VerificationCodeError\"] | KnownErrors[\"InvalidTotpCode\"]>>,\n signInWithMfa(otp: string, code: string, options?: { noRedirect?: boolean }): Promise<Result<undefined, KnownErrors[\"VerificationCodeError\"] | KnownErrors[\"InvalidTotpCode\"]>>,\n\n redirectToOAuthCallback(): Promise<void>,\n\n getConvexClientAuth(options: HasTokenStore extends false ? { tokenStore: TokenStoreInit } : { tokenStore?: TokenStoreInit }): (args: { forceRefreshToken: boolean }) => Promise<string | null>,\n getConvexHttpClientAuth(options: { tokenStore: TokenStoreInit }): Promise<string>,\n\n useUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'redirect' }): ProjectCurrentUser<ProjectId>,\n useUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'throw' }): ProjectCurrentUser<ProjectId>,\n useUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'anonymous' }): ProjectCurrentUser<ProjectId>,\n useUser(options?: GetCurrentUserOptions<HasTokenStore>): ProjectCurrentUser<ProjectId> | null,\n\n getUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'redirect' }): Promise<ProjectCurrentUser<ProjectId>>,\n getUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'throw' }): Promise<ProjectCurrentUser<ProjectId>>,\n getUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'anonymous' }): Promise<ProjectCurrentUser<ProjectId>>,\n getUser(options?: GetCurrentUserOptions<HasTokenStore>): Promise<ProjectCurrentUser<ProjectId> | null>,\n\n // note: we don't special-case 'anonymous' here to return non-null, see GetPartialUserOptions for more details\n getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & { from: 'token' }): Promise<TokenPartialUser | null>,\n getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & { from: 'convex' }): Promise<TokenPartialUser | null>,\n getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore>): Promise<SyncedPartialUser | TokenPartialUser | null>,\n usePartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & { from: 'token' }): TokenPartialUser | null,\n usePartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & { from: 'convex' }): TokenPartialUser | null,\n usePartialUser(options: GetCurrentPartialUserOptions<HasTokenStore>): SyncedPartialUser | TokenPartialUser | null,\n useNavigate(): (to: string) => void, // THIS_LINE_PLATFORM react-like\n\n [stackAppInternalsSymbol]: {\n toClientJson(): StackClientAppJson<HasTokenStore, ProjectId>,\n setCurrentUser(userJsonPromise: Promise<CurrentUserCrud['Client']['Read'] | null>): void,\n getConstructorOptions(): StackClientAppConstructorOptions<HasTokenStore, ProjectId> & { inheritsFrom?: undefined },\n },\n }\n & AsyncStoreProperty<\"project\", [], Project, false>\n & AsyncStoreProperty<\n \"item\",\n [{ itemId: string, userId: string } | { itemId: string, teamId: string } | { itemId: string, customCustomerId: string }],\n Item,\n false\n >\n & AsyncStoreProperty<\n \"products\",\n [options: CustomerProductsRequestOptions],\n CustomerProductsList,\n true\n >\n & { [K in `redirectTo${Capitalize<keyof Omit<HandlerUrls, 'handler' | 'oauthCallback'>>}`]: (options?: RedirectToOptions) => Promise<void> }\n);\nexport type StackClientAppConstructor = {\n new <\n TokenStoreType extends string,\n HasTokenStore extends (TokenStoreType extends {} ? true : boolean),\n ProjectId extends string\n >(options: StackClientAppConstructorOptions<HasTokenStore, ProjectId>): StackClientApp<HasTokenStore, ProjectId>,\n new(options: StackClientAppConstructorOptions<boolean, string>): StackClientApp<boolean, string>,\n\n [stackAppInternalsSymbol]: {\n fromClientJson<HasTokenStore extends boolean, ProjectId extends string>(\n json: StackClientAppJson<HasTokenStore, ProjectId>\n ): StackClientApp<HasTokenStore, ProjectId>,\n },\n};\nexport const StackClientApp: StackClientAppConstructor = _StackClientAppImpl;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,6BAAoC;AAiH7B,IAAM,iBAA4C;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/lib/stack-app/apps/interfaces/client-app.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { KnownErrors } from \"@stackframe/stack-shared\";\nimport { CurrentUserCrud } from \"@stackframe/stack-shared/dist/interface/crud/current-user\";\nimport { Result } from \"@stackframe/stack-shared/dist/utils/results\";\nimport { AsyncStoreProperty, AuthLike, GetCurrentPartialUserOptions, GetCurrentUserOptions, HandlerUrls, OAuthScopesOnSignIn, RedirectMethod, RedirectToOptions, TokenStoreInit, stackAppInternalsSymbol } from \"../../common\";\nimport { CustomerProductsList, CustomerProductsRequestOptions, Item } from \"../../customers\";\nimport { Project } from \"../../projects\";\nimport { ProjectCurrentUser, SyncedPartialUser, TokenPartialUser } from \"../../users\";\nimport { _StackClientAppImpl } from \"../implementations\";\n\nexport type StackClientAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = {\n baseUrl?: string | { browser: string, server: string },\n extraRequestHeaders?: Record<string, string>,\n projectId?: ProjectId,\n publishableClientKey?: string,\n urls?: Partial<HandlerUrls>,\n oauthScopesOnSignIn?: Partial<OAuthScopesOnSignIn>,\n tokenStore?: TokenStoreInit<HasTokenStore>,\n redirectMethod?: RedirectMethod,\n inheritsFrom?: StackClientApp<any, any>,\n\n /**\n * By default, the Stack app will automatically prefetch some data from Stack's server when this app is first\n * constructed. This improves the performance of your app, but will create network requests that are unnecessary if\n * the app is never used or disposed of immediately. To disable this behavior, set this option to true.\n */\n noAutomaticPrefetch?: boolean,\n} & (\n { tokenStore: TokenStoreInit<HasTokenStore> } | { tokenStore?: undefined, inheritsFrom: StackClientApp<HasTokenStore, any> }\n) & (\n string extends ProjectId ? unknown : ({ projectId: ProjectId } | { inheritsFrom: StackClientApp<any, ProjectId> })\n);\n\n\nexport type StackClientAppJson<HasTokenStore extends boolean, ProjectId extends string> = StackClientAppConstructorOptions<HasTokenStore, ProjectId> & { inheritsFrom?: undefined } & {\n uniqueIdentifier: string,\n // note: if you add more fields here, make sure to ensure the checkString in the constructor has/doesn't have them\n};\n\nexport type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = (\n & {\n readonly projectId: ProjectId,\n\n readonly urls: Readonly<HandlerUrls>,\n\n signInWithOAuth(provider: string, options?: { returnTo?: string }): Promise<void>,\n signInWithCredential(options: { email: string, password: string, noRedirect?: boolean }): Promise<Result<undefined, KnownErrors[\"EmailPasswordMismatch\"] | KnownErrors[\"InvalidTotpCode\"]>>,\n signUpWithCredential(options: { email: string, password: string, noRedirect?: boolean } & ({ noVerificationCallback: true } | { noVerificationCallback?: false, verificationCallbackUrl?: string })): Promise<Result<undefined, KnownErrors[\"UserWithEmailAlreadyExists\"] | KnownErrors[\"PasswordRequirementsNotMet\"]>>,\n signInWithPasskey(): Promise<Result<undefined, KnownErrors[\"PasskeyAuthenticationFailed\"] | KnownErrors[\"InvalidTotpCode\"] | KnownErrors[\"PasskeyWebAuthnError\"]>>,\n callOAuthCallback(): Promise<boolean>,\n promptCliLogin(options: { appUrl: string, expiresInMillis?: number }): Promise<Result<string, KnownErrors[\"CliAuthError\"] | KnownErrors[\"CliAuthExpiredError\"] | KnownErrors[\"CliAuthUsedError\"]>>,\n sendForgotPasswordEmail(email: string, options?: { callbackUrl?: string }): Promise<Result<undefined, KnownErrors[\"UserNotFound\"]>>,\n sendMagicLinkEmail(email: string, options?: { callbackUrl?: string }): Promise<Result<{ nonce: string }, KnownErrors[\"RedirectUrlNotWhitelisted\"]>>,\n resetPassword(options: { code: string, password: string }): Promise<Result<undefined, KnownErrors[\"VerificationCodeError\"]>>,\n verifyPasswordResetCode(code: string): Promise<Result<undefined, KnownErrors[\"VerificationCodeError\"]>>,\n verifyTeamInvitationCode(code: string): Promise<Result<undefined, KnownErrors[\"VerificationCodeError\"]>>,\n acceptTeamInvitation(code: string): Promise<Result<undefined, KnownErrors[\"VerificationCodeError\"]>>,\n getTeamInvitationDetails(code: string): Promise<Result<{ teamDisplayName: string }, KnownErrors[\"VerificationCodeError\"]>>,\n verifyEmail(code: string): Promise<Result<undefined, KnownErrors[\"VerificationCodeError\"]>>,\n signInWithMagicLink(code: string, options?: { noRedirect?: boolean }): Promise<Result<undefined, KnownErrors[\"VerificationCodeError\"] | KnownErrors[\"InvalidTotpCode\"]>>,\n signInWithMfa(otp: string, code: string, options?: { noRedirect?: boolean }): Promise<Result<undefined, KnownErrors[\"VerificationCodeError\"] | KnownErrors[\"InvalidTotpCode\"]>>,\n\n redirectToOAuthCallback(): Promise<void>,\n\n getConvexClientAuth(options: HasTokenStore extends false ? { tokenStore: TokenStoreInit } : { tokenStore?: TokenStoreInit }): (args: { forceRefreshToken: boolean }) => Promise<string | null>,\n getConvexHttpClientAuth(options: { tokenStore: TokenStoreInit }): Promise<string>,\n\n useUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'redirect' }): ProjectCurrentUser<ProjectId>,\n useUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'throw' }): ProjectCurrentUser<ProjectId>,\n useUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'anonymous' }): ProjectCurrentUser<ProjectId>,\n useUser(options?: GetCurrentUserOptions<HasTokenStore>): ProjectCurrentUser<ProjectId> | null,\n\n getUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'redirect' }): Promise<ProjectCurrentUser<ProjectId>>,\n getUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'throw' }): Promise<ProjectCurrentUser<ProjectId>>,\n getUser(options: GetCurrentUserOptions<HasTokenStore> & { or: 'anonymous' }): Promise<ProjectCurrentUser<ProjectId>>,\n getUser(options?: GetCurrentUserOptions<HasTokenStore>): Promise<ProjectCurrentUser<ProjectId> | null>,\n\n // note: we don't special-case 'anonymous' here to return non-null, see GetPartialUserOptions for more details\n getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & { from: 'token' }): Promise<TokenPartialUser | null>,\n getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & { from: 'convex' }): Promise<TokenPartialUser | null>,\n getPartialUser(options: GetCurrentPartialUserOptions<HasTokenStore>): Promise<SyncedPartialUser | TokenPartialUser | null>,\n usePartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & { from: 'token' }): TokenPartialUser | null,\n usePartialUser(options: GetCurrentPartialUserOptions<HasTokenStore> & { from: 'convex' }): TokenPartialUser | null,\n usePartialUser(options: GetCurrentPartialUserOptions<HasTokenStore>): SyncedPartialUser | TokenPartialUser | null,\n useNavigate(): (to: string) => void, // THIS_LINE_PLATFORM react-like\n\n [stackAppInternalsSymbol]: {\n toClientJson(): StackClientAppJson<HasTokenStore, ProjectId>,\n setCurrentUser(userJsonPromise: Promise<CurrentUserCrud['Client']['Read'] | null>): void,\n getConstructorOptions(): StackClientAppConstructorOptions<HasTokenStore, ProjectId> & { inheritsFrom?: undefined },\n },\n }\n & AsyncStoreProperty<\"project\", [], Project, false>\n & AsyncStoreProperty<\n \"item\",\n [{ itemId: string, userId: string } | { itemId: string, teamId: string } | { itemId: string, customCustomerId: string }],\n Item,\n false\n >\n & AsyncStoreProperty<\n \"products\",\n [options: CustomerProductsRequestOptions],\n CustomerProductsList,\n true\n >\n & { [K in `redirectTo${Capitalize<keyof Omit<HandlerUrls, 'handler' | 'oauthCallback'>>}`]: (options?: RedirectToOptions) => Promise<void> }\n & AuthLike<HasTokenStore extends false ? { tokenStore: TokenStoreInit } : { tokenStore?: TokenStoreInit }>\n);\nexport type StackClientAppConstructor = {\n new <\n TokenStoreType extends string,\n HasTokenStore extends (TokenStoreType extends {} ? true : boolean),\n ProjectId extends string\n >(options: StackClientAppConstructorOptions<HasTokenStore, ProjectId>): StackClientApp<HasTokenStore, ProjectId>,\n new(options: StackClientAppConstructorOptions<boolean, string>): StackClientApp<boolean, string>,\n\n [stackAppInternalsSymbol]: {\n fromClientJson<HasTokenStore extends boolean, ProjectId extends string>(\n json: StackClientAppJson<HasTokenStore, ProjectId>\n ): StackClientApp<HasTokenStore, ProjectId>,\n },\n};\nexport const StackClientApp: StackClientAppConstructor = _StackClientAppImpl;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,6BAAoC;AAkH7B,IAAM,iBAA4C;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/stack-app/common.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { ProviderType } from \"@stackframe/stack-shared/dist/utils/oauth\";\nimport type { GenericQueryCtx, UserIdentity } from \"convex/server\";\n\nexport type RedirectToOptions = {\n replace?: boolean,\n noRedirectBack?: boolean,\n};\n\nexport type AsyncStoreProperty<Name extends string, Args extends any[], Value, IsMultiple extends boolean> =\n & { [key in `${IsMultiple extends true ? \"list\" : \"get\"}${Capitalize<Name>}`]: (...args: Args) => Promise<Value> }\n & { [key in `use${Capitalize<Name>}`]: (...args: Args) => Value } // THIS_LINE_PLATFORM react-like\n\nexport type EmailConfig = {\n host: string,\n port: number,\n username: string,\n password: string,\n senderEmail: string,\n senderName: string,\n}\n\nexport type RedirectMethod = \"window\"\n | \"none\"\n | {\n useNavigate: () => (to: string) => void,\n navigate?: (to: string) => void,\n }\n\n\nexport type GetCurrentUserOptions<HasTokenStore> =\n & {\n or?: 'redirect' | 'throw' | 'return-null' | 'anonymous' | /** @deprecated */ 'anonymous-if-exists[deprecated]',\n tokenStore?: TokenStoreInit,\n }\n & (HasTokenStore extends false ? {\n tokenStore: TokenStoreInit,\n } : {});\n\nexport type ConvexCtx =\n| GenericQueryCtx<any>\n| { auth: { getUserIdentity: () => Promise<UserIdentity | null> } };\n\nexport type GetCurrentPartialUserOptions<HasTokenStore> =\n & {\n or?: 'return-null' | 'anonymous', // note: unlike normal getUser, 'anonymous' still returns null sometimes (eg. if no token is present)\n tokenStore?: TokenStoreInit,\n }\n & (\n | {\n from: 'token',\n }\n | {\n from: 'convex',\n ctx: ConvexCtx,\n }\n )\n & (HasTokenStore extends false ? {\n tokenStore: TokenStoreInit,\n } : {});\n\nexport type RequestLike = {\n headers: {\n get: (name: string) => string | null,\n },\n};\n\nexport type TokenStoreInit<HasTokenStore extends boolean = boolean> =\n HasTokenStore extends true ? (\n | \"cookie\"\n | \"nextjs-cookie\"\n | \"memory\"\n | RequestLike\n | { accessToken: string, refreshToken: string }\n )\n : HasTokenStore extends false ? null\n : TokenStoreInit<true> | TokenStoreInit<false>;\n\nexport type HandlerUrls = {\n handler: string,\n signIn: string,\n signUp: string,\n afterSignIn: string,\n afterSignUp: string,\n signOut: string,\n afterSignOut: string,\n emailVerification: string,\n passwordReset: string,\n forgotPassword: string,\n home: string,\n oauthCallback: string,\n magicLinkCallback: string,\n accountSettings: string,\n teamInvitation: string,\n mfa: string,\n error: string,\n}\n\nexport type OAuthScopesOnSignIn = {\n [key in ProviderType]: string[];\n};\n\n/** @internal */\nexport const stackAppInternalsSymbol = Symbol.for(\"StackAuth--DO-NOT-USE-OR-YOU-WILL-BE-FIRED--StackAppInternals\");\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA0GO,IAAM,0BAA0B,OAAO,IAAI,+DAA+D;","names":[]}
1
+ {"version":3,"sources":["../../../src/lib/stack-app/common.ts"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY\n//===========================================\nimport { ProviderType } from \"@stackframe/stack-shared/dist/utils/oauth\";\nimport type { GenericQueryCtx, UserIdentity } from \"convex/server\";\n\nexport type RedirectToOptions = {\n replace?: boolean,\n noRedirectBack?: boolean,\n};\n\nexport type AsyncStoreProperty<Name extends string, Args extends any[], Value, IsMultiple extends boolean> =\n & { [key in `${IsMultiple extends true ? \"list\" : \"get\"}${Capitalize<Name>}`]: (...args: Args) => Promise<Value> }\n & { [key in `use${Capitalize<Name>}`]: (...args: Args) => Value } // THIS_LINE_PLATFORM react-like\n\nexport type EmailConfig = {\n host: string,\n port: number,\n username: string,\n password: string,\n senderEmail: string,\n senderName: string,\n}\n\nexport type RedirectMethod = \"window\"\n | \"none\"\n | {\n useNavigate: () => (to: string) => void,\n navigate?: (to: string) => void,\n }\n\n\nexport type GetCurrentUserOptions<HasTokenStore> =\n & {\n or?: 'redirect' | 'throw' | 'return-null' | 'anonymous' | /** @deprecated */ 'anonymous-if-exists[deprecated]',\n tokenStore?: TokenStoreInit,\n }\n & (HasTokenStore extends false ? {\n tokenStore: TokenStoreInit,\n } : {});\n\nexport type ConvexCtx =\n| GenericQueryCtx<any>\n| { auth: { getUserIdentity: () => Promise<UserIdentity | null> } };\n\nexport type GetCurrentPartialUserOptions<HasTokenStore> =\n & {\n or?: 'return-null' | 'anonymous', // note: unlike normal getUser, 'anonymous' still returns null sometimes (eg. if no token is present)\n tokenStore?: TokenStoreInit,\n }\n & (\n | {\n from: 'token',\n }\n | {\n from: 'convex',\n ctx: ConvexCtx,\n }\n )\n & (HasTokenStore extends false ? {\n tokenStore: TokenStoreInit,\n } : {});\n\nexport type RequestLike = {\n headers: {\n get: (name: string) => string | null,\n },\n};\n\nexport type TokenStoreInit<HasTokenStore extends boolean = boolean> =\n HasTokenStore extends true ? (\n | \"cookie\"\n | \"nextjs-cookie\"\n | \"memory\"\n | RequestLike\n | { accessToken: string, refreshToken: string }\n )\n : HasTokenStore extends false ? null\n : TokenStoreInit<true> | TokenStoreInit<false>;\n\nexport type HandlerUrls = {\n handler: string,\n signIn: string,\n signUp: string,\n afterSignIn: string,\n afterSignUp: string,\n signOut: string,\n afterSignOut: string,\n emailVerification: string,\n passwordReset: string,\n forgotPassword: string,\n home: string,\n oauthCallback: string,\n magicLinkCallback: string,\n accountSettings: string,\n teamInvitation: string,\n mfa: string,\n error: string,\n}\n\nexport type OAuthScopesOnSignIn = {\n [key in ProviderType]: string[];\n};\n\n/**\n * Contains the authentication methods without session-related fields.\n * Used for apps that have token storage capabilities.\n */\nexport type AuthLike<ExtraOptions = {}> = {\n signOut(options?: { redirectUrl?: URL | string } & ExtraOptions): Promise<void>,\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(options?: {} & ExtraOptions): 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(options?: {} & ExtraOptions): Promise<{ accessToken: string | null, refreshToken: string | null }>,\n};\n\n/** @internal */\nexport const stackAppInternalsSymbol = Symbol.for(\"StackAuth--DO-NOT-USE-OR-YOU-WILL-BE-FIRED--StackAppInternals\");\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAuLO,IAAM,0BAA0B,OAAO,IAAI,+DAA+D;","names":[]}