import * as yup from 'yup'; import { KnownErrors } from '../known-errors.js'; import { InternalSession, RefreshToken, AccessToken } from '../sessions.js'; import { ReadonlyJson } from '../utils/json.js'; import { PublicKeyCredentialCreationOptionsJSON, RegistrationResponseJSON, PublicKeyCredentialRequestOptionsJSON, AuthenticationResponseJSON } from '@simplewebauthn/types'; import { Result } from '../utils/results.js'; import { ContactChannelsCrud } from './crud/contact-channels.js'; import { CurrentUserCrud } from './crud/current-user.js'; import { ConnectedAccountAccessTokenCrud } from './crud/oauth.js'; import { UserApiKeysCrud, TeamApiKeysCrud, userApiKeysCreateInputSchema, userApiKeysCreateOutputSchema, teamApiKeysCreateInputSchema, teamApiKeysCreateOutputSchema } from './crud/project-api-keys.js'; import { ProjectPermissionsCrud } from './crud/project-permissions.js'; import { ClientProjectsCrud, AdminUserProjectsCrud } from './crud/projects.js'; import { SessionsCrud } from './crud/sessions.js'; import { TeamInvitationCrud } from './crud/team-invitation.js'; import { TeamMemberProfilesCrud } from './crud/team-member-profiles.js'; import { TeamPermissionsCrud } from './crud/team-permissions.js'; import { TeamsCrud } from './crud/teams.js'; import '../utils/errors.js'; import 'jose'; import '../crud.js'; import '../utils/types.js'; type ClientInterfaceOptions = { clientVersion: string; getBaseUrl: () => string; extraRequestHeaders: Record; projectId: string; prepareRequest?: () => Promise; } & ({ publishableClientKey: string; } | { projectOwnerSession: InternalSession; }); declare class StackClientInterface { readonly options: ClientInterfaceOptions; constructor(options: ClientInterfaceOptions); get projectId(): string; getApiUrl(): string; runNetworkDiagnostics(session?: InternalSession | null, requestType?: "client" | "server" | "admin"): Promise<{ "navigator?.onLine": any; cfTrace: string; apiRoot: string; baseUrlBackend: string; prodDashboard: string; prodBackend: string; }>; protected _createNetworkError(cause: Error, session?: InternalSession | null, requestType?: "client" | "server" | "admin"): Promise; protected _networkRetry(cb: () => Promise>, session?: InternalSession | null, requestType?: "client" | "server" | "admin"): Promise; protected _networkRetryException(cb: () => Promise, session?: InternalSession | null, requestType?: "client" | "server" | "admin"): Promise; fetchNewAccessToken(refreshToken: RefreshToken): Promise; sendClientRequest(path: string, requestOptions: RequestInit, session: InternalSession | null, requestType?: "client" | "server" | "admin"): Promise; createSession(options: Omit[0], "refreshAccessTokenCallback">): InternalSession; protected sendClientRequestAndCatchKnownError(path: string, requestOptions: RequestInit, tokenStoreOrNull: InternalSession | null, errorsToCatch: readonly E[]): Promise>>; private sendClientRequestInner; private _processResponse; checkFeatureSupport(options: { featureName?: string; } & ReadonlyJson): Promise; sendForgotPasswordEmail(email: string, callbackUrl: string): Promise>; sendVerificationEmail(email: string, callbackUrl: string, session: InternalSession): Promise; sendMagicLinkEmail(email: string, callbackUrl: string): Promise>; resetPassword(options: { code: string; } & ({ password: string; } | { onlyVerifyCode: true; })): Promise>; updatePassword(options: { oldPassword: string; newPassword: string; }, session: InternalSession): Promise; setPassword(options: { password: string; }, session: InternalSession): Promise; verifyPasswordResetCode(code: string): Promise>; verifyEmail(code: string): Promise>; initiatePasskeyRegistration(options: {}, session: InternalSession): Promise>; registerPasskey(options: { credential: RegistrationResponseJSON; code: string; }, session: InternalSession): Promise>; initiatePasskeyAuthentication(options: {}, session: InternalSession): Promise>; sendTeamInvitation(options: { email: string; teamId: string; callbackUrl: string; session: InternalSession; }): Promise; acceptTeamInvitation(options: { code: string; session: InternalSession; type: T; }): Promise>; totpMfa(attemptCode: string, totp: string, session: InternalSession): Promise<{ accessToken: any; refreshToken: any; newUser: any; }>; signInWithCredential(email: string, password: string, session: InternalSession): Promise>; signUpWithCredential(email: string, password: string, emailVerificationRedirectUrl: string, session: InternalSession): Promise>; signUpAnonymously(session: InternalSession): Promise>; signInWithMagicLink(code: string): Promise>; signInWithPasskey(body: { authentication_response: AuthenticationResponseJSON; code: string; }): Promise>; getOAuthUrl(options: { provider: string; redirectUrl: string; errorRedirectUrl: string; afterCallbackRedirectUrl?: string; codeChallenge: string; state: string; type: "authenticate" | "link"; providerScope?: string; } & ({ type: "authenticate"; } | { type: "link"; session: InternalSession; })): Promise; callOAuthCallback(options: { oauthParams: URLSearchParams; redirectUri: string; codeVerifier: string; state: string; }): Promise<{ newUser: boolean; afterCallbackRedirectUrl?: string; accessToken: string; refreshToken: string; }>; signOut(session: InternalSession): Promise; getClientUserByToken(session: InternalSession): Promise; listTeamInvitations(options: { teamId: string; }, session: InternalSession): Promise; revokeTeamInvitation(invitationId: string, teamId: string, session: InternalSession): Promise; listTeamMemberProfiles(options: { teamId?: string; userId?: string; }, session: InternalSession): Promise; getTeamMemberProfile(options: { teamId: string; userId: string; }, session: InternalSession): Promise; leaveTeam(teamId: string, session: InternalSession): Promise; updateTeamMemberProfile(options: { teamId: string; userId: string; profile: TeamMemberProfilesCrud['Client']['Update']; }, session: InternalSession): Promise; updateTeam(options: { teamId: string; data: TeamsCrud['Client']['Update']; }, session: InternalSession): Promise; listCurrentUserTeamPermissions(options: { teamId: string; recursive: boolean; }, session: InternalSession): Promise; listCurrentUserProjectPermissions(options: { recursive: boolean; }, session: InternalSession): Promise; listCurrentUserTeams(session: InternalSession): Promise; getClientProject(): Promise>; updateClientUser(update: CurrentUserCrud["Client"]["Update"], session: InternalSession): Promise; listProjects(session: InternalSession): Promise; createProject(project: AdminUserProjectsCrud['Client']['Create'], session: InternalSession): Promise; createProviderAccessToken(provider: string, scope: string, session: InternalSession): Promise; createClientTeam(data: TeamsCrud['Client']['Create'], session: InternalSession): Promise; deleteTeam(teamId: string, session: InternalSession): Promise; deleteCurrentUser(session: InternalSession): Promise; createClientContactChannel(data: ContactChannelsCrud['Client']['Create'], session: InternalSession): Promise; updateClientContactChannel(id: string, data: ContactChannelsCrud['Client']['Update'], session: InternalSession): Promise; deleteClientContactChannel(id: string, session: InternalSession): Promise; deleteSession(sessionId: string, session: InternalSession): Promise; listSessions(session: InternalSession): Promise; listClientContactChannels(session: InternalSession): Promise; sendCurrentUserContactChannelVerificationEmail(contactChannelId: string, callbackUrl: string, session: InternalSession): Promise>; cliLogin(loginCode: string, refreshToken: string, session: InternalSession): Promise>; private _getApiKeyRequestInfo; listProjectApiKeys(options: { user_id: string; }, session: InternalSession | null, requestType: "client" | "server" | "admin"): Promise; listProjectApiKeys(options: { team_id: string; }, session: InternalSession | null, requestType: "client" | "server" | "admin"): Promise; listProjectApiKeys(options: { user_id: string; } | { team_id: string; }, session: InternalSession | null, requestType: "client" | "server" | "admin"): Promise<(UserApiKeysCrud['Client']['Read'] | TeamApiKeysCrud['Client']['Read'])[]>; createProjectApiKey(data: yup.InferType, session: InternalSession | null, requestType: "client" | "server" | "admin"): Promise>; createProjectApiKey(data: yup.InferType, session: InternalSession | null, requestType: "client" | "server" | "admin"): Promise>; createProjectApiKey(data: yup.InferType | yup.InferType, session: InternalSession | null, requestType: "client" | "server" | "admin"): Promise | yup.InferType>; getProjectApiKey(options: { user_id: string | null; }, keyId: string, session: InternalSession | null, requestType: "client" | "server" | "admin"): Promise; getProjectApiKey(options: { team_id: string; }, keyId: string, session: InternalSession | null, requestType: "client" | "server" | "admin"): Promise; getProjectApiKey(options: { user_id: string | null; } | { team_id: string; }, keyId: string, session: InternalSession | null, requestType: "client" | "server" | "admin"): Promise; updateProjectApiKey(options: { user_id: string; }, keyId: string, data: UserApiKeysCrud['Client']['Update'], session: InternalSession | null, requestType: "client" | "server" | "admin"): Promise; updateProjectApiKey(options: { team_id: string; }, keyId: string, data: TeamApiKeysCrud['Client']['Update'], session: InternalSession | null, requestType: "client" | "server" | "admin"): Promise; updateProjectApiKey(options: { user_id: string; } | { team_id: string; }, keyId: string, data: UserApiKeysCrud['Client']['Update'] | TeamApiKeysCrud['Client']['Update'], session: InternalSession | null, requestType: "client" | "server" | "admin"): Promise; checkProjectApiKey(type: "user", apiKey: string, session: InternalSession | null, requestType: "client" | "server" | "admin"): Promise; checkProjectApiKey(type: "team", apiKey: string, session: InternalSession | null, requestType: "client" | "server" | "admin"): Promise; checkProjectApiKey(type: "user" | "team", apiKey: string, session: InternalSession | null, requestType: "client" | "server" | "admin"): Promise; } export { type ClientInterfaceOptions, StackClientInterface };