import { createRemoteJWKSet } from 'jose'; import { IronSessionProvider } from '../common/iron-session/iron-session-provider'; import { AutoPaginatable } from '../common/utils/pagination'; import { Challenge } from '../mfa/interfaces'; import { WorkOS } from '../workos'; import { AuthenticateWithCodeOptions, AuthenticateWithCodeAndVerifierOptions, AuthenticateWithMagicAuthOptions, AuthenticateWithPasswordOptions, AuthenticateWithRefreshTokenOptions, AuthenticateWithTotpOptions, AuthenticationResponse, CreateMagicAuthOptions, CreatePasswordResetOptions, CreateUserOptions, EmailVerification, EnrollAuthFactorOptions, ListAuthFactorsOptions, ListSessionsOptions, ListUsersOptions, MagicAuth, PasswordReset, ResetPasswordOptions, SendMagicAuthCodeOptions, SendPasswordResetEmailOptions, SendVerificationEmailOptions, Session, UpdateUserOptions, User, VerifyEmailOptions } from './interfaces'; import { AuthenticateWithEmailVerificationOptions } from './interfaces/authenticate-with-email-verification-options.interface'; import { AuthenticateWithOrganizationSelectionOptions } from './interfaces/authenticate-with-organization-selection.interface'; import { AuthenticateWithSessionCookieFailedResponse, AuthenticateWithSessionCookieOptions, AuthenticateWithSessionCookieSuccessResponse, SessionCookieData } from './interfaces/authenticate-with-session-cookie.interface'; import { UserManagementAuthorizationURLOptions } from './interfaces/authorization-url-options.interface'; import { CreateOrganizationMembershipOptions } from './interfaces/create-organization-membership-options.interface'; import { Factor, FactorWithSecrets } from './interfaces/factor.interface'; import { Identity } from './interfaces/identity.interface'; import { Invitation } from './interfaces/invitation.interface'; import { ListInvitationsOptions } from './interfaces/list-invitations-options.interface'; import { ListOrganizationMembershipsOptions } from './interfaces/list-organization-memberships-options.interface'; import { OrganizationMembership } from './interfaces/organization-membership.interface'; import { RefreshAndSealSessionDataResponse } from './interfaces/refresh-and-seal-session-data.interface'; import { RevokeSessionOptions } from './interfaces/revoke-session-options.interface'; import { SendInvitationOptions } from './interfaces/send-invitation-options.interface'; import { SessionHandlerOptions } from './interfaces/session-handler-options.interface'; import { UpdateOrganizationMembershipOptions } from './interfaces/update-organization-membership-options.interface'; import { CookieSession } from './session'; export declare class UserManagement { private readonly workos; private _jwks; clientId: string | undefined; ironSessionProvider: IronSessionProvider; constructor(workos: WorkOS, ironSessionProvider: IronSessionProvider); get jwks(): ReturnType | undefined; /** * Loads a sealed session using the provided session data and cookie password. * * @param options - The options for loading the sealed session. * @param options.sessionData - The sealed session data. * @param options.cookiePassword - The password used to encrypt the session data. * @returns The session class. */ loadSealedSession(options: { sessionData: string; cookiePassword: string; }): CookieSession; getUser(userId: string): Promise; getUserByExternalId(externalId: string): Promise; listUsers(options?: ListUsersOptions): Promise>; createUser(payload: CreateUserOptions): Promise; authenticateWithMagicAuth(payload: AuthenticateWithMagicAuthOptions): Promise; authenticateWithPassword(payload: AuthenticateWithPasswordOptions): Promise; authenticateWithCode(payload: AuthenticateWithCodeOptions): Promise; authenticateWithCodeAndVerifier(payload: AuthenticateWithCodeAndVerifierOptions): Promise; authenticateWithRefreshToken(payload: AuthenticateWithRefreshTokenOptions): Promise; authenticateWithTotp(payload: AuthenticateWithTotpOptions): Promise; authenticateWithEmailVerification(payload: AuthenticateWithEmailVerificationOptions): Promise; authenticateWithOrganizationSelection(payload: AuthenticateWithOrganizationSelectionOptions): Promise; authenticateWithSessionCookie({ sessionData, cookiePassword, }: AuthenticateWithSessionCookieOptions): Promise; private isValidJwt; /** * @deprecated This method is deprecated and will be removed in a future major version. * Please use the new `loadSealedSession` helper and its corresponding methods instead. */ refreshAndSealSessionData({ sessionData, organizationId, cookiePassword, }: SessionHandlerOptions): Promise; private prepareAuthenticationResponse; private sealSessionDataFromAuthenticationResponse; getSessionFromCookie({ sessionData, cookiePassword, }: SessionHandlerOptions): Promise; getEmailVerification(emailVerificationId: string): Promise; sendVerificationEmail({ userId, }: SendVerificationEmailOptions): Promise<{ user: User; }>; getMagicAuth(magicAuthId: string): Promise; createMagicAuth(options: CreateMagicAuthOptions): Promise; /** * @deprecated Please use `createMagicAuth` instead. * This method will be removed in a future major version. */ sendMagicAuthCode(options: SendMagicAuthCodeOptions): Promise; verifyEmail({ code, userId, }: VerifyEmailOptions): Promise<{ user: User; }>; getPasswordReset(passwordResetId: string): Promise; createPasswordReset(options: CreatePasswordResetOptions): Promise; /** * @deprecated Please use `createPasswordReset` instead. This method will be removed in a future major version. */ sendPasswordResetEmail(payload: SendPasswordResetEmailOptions): Promise; resetPassword(payload: ResetPasswordOptions): Promise<{ user: User; }>; updateUser(payload: UpdateUserOptions): Promise; enrollAuthFactor(payload: EnrollAuthFactorOptions): Promise<{ authenticationFactor: FactorWithSecrets; authenticationChallenge: Challenge; }>; listAuthFactors(options: ListAuthFactorsOptions): Promise>; listSessions(userId: string, options?: ListSessionsOptions): Promise>; deleteUser(userId: string): Promise; getUserIdentities(userId: string): Promise; getOrganizationMembership(organizationMembershipId: string): Promise; listOrganizationMemberships(options: ListOrganizationMembershipsOptions): Promise>; createOrganizationMembership(options: CreateOrganizationMembershipOptions): Promise; updateOrganizationMembership(organizationMembershipId: string, options: UpdateOrganizationMembershipOptions): Promise; deleteOrganizationMembership(organizationMembershipId: string): Promise; deactivateOrganizationMembership(organizationMembershipId: string): Promise; reactivateOrganizationMembership(organizationMembershipId: string): Promise; getInvitation(invitationId: string): Promise; findInvitationByToken(invitationToken: string): Promise; listInvitations(options: ListInvitationsOptions): Promise>; sendInvitation(payload: SendInvitationOptions): Promise; acceptInvitation(invitationId: string): Promise; revokeInvitation(invitationId: string): Promise; revokeSession(payload: RevokeSessionOptions): Promise; getAuthorizationUrl({ connectionId, codeChallenge, codeChallengeMethod, context, clientId, domainHint, loginHint, organizationId, provider, providerQueryParams, providerScopes, prompt, redirectUri, state, screenHint, }: UserManagementAuthorizationURLOptions): string; getLogoutUrl({ sessionId, returnTo, }: { sessionId: string; returnTo?: string; }): string; /** * @deprecated This method is deprecated and will be removed in a future major version. * Please use the `loadSealedSession` helper and its `getLogoutUrl` method instead. * * getLogoutUrlFromSessionCookie takes in session cookie data, unseals the cookie, decodes the JWT claims, * and uses the session ID to generate the logout URL. * * Use this over `getLogoutUrl` if you'd like to the SDK to handle session cookies for you. */ getLogoutUrlFromSessionCookie({ sessionData, cookiePassword, }: SessionHandlerOptions): Promise; getJwksUrl(clientId: string): string; }