@bitblit/ratchet-warden-server
Version:
Typescript library to simplify using simplewebauthn and secondary auth methods over GraphQL
44 lines (43 loc) • 4.02 kB
TypeScript
import { AuthenticationResponseJSON, PublicKeyCredentialCreationOptionsJSON, PublicKeyCredentialRequestOptionsJSON, RegistrationResponseJSON } from "@simplewebauthn/server";
import { WardenServiceOptions } from "./warden-service-options.js";
import { WardenContact } from "@bitblit/ratchet-warden-common/common/model/warden-contact";
import { WardenCustomTemplateDescriptor } from "@bitblit/ratchet-warden-common/common/command/warden-custom-template-descriptor";
import { WardenEntry } from "@bitblit/ratchet-warden-common/common/model/warden-entry";
import { WardenLoginRequest } from "@bitblit/ratchet-warden-common/common/model/warden-login-request";
import { WardenCommand } from "@bitblit/ratchet-warden-common/common/command/warden-command";
import { WardenCommandResponse } from "@bitblit/ratchet-warden-common/common/command/warden-command-response";
import { WardenStoreRegistrationResponse } from "@bitblit/ratchet-warden-common/common/model/warden-store-registration-response";
import { WardenSingleUseCodeProvider } from "./provider/warden-single-use-code-provider.js";
import { WardenThirdPartyAuthentication } from "@bitblit/ratchet-warden-common/common/model/warden-third-party-authentication";
import { WardenAuthorizer } from "./warden-authorizer.ts";
export declare class WardenService {
private inOptions;
private opts;
private cacheAuthorizer;
constructor(inOptions: WardenServiceOptions);
get authorizer(): WardenAuthorizer;
get options(): WardenServiceOptions;
findEntryByContact(contact: WardenContact): Promise<WardenEntry>;
findEntryById(userId: string): Promise<WardenEntry>;
processCommandStringToString(cmdString: string, origin: string, loggedInUserId: string): Promise<string>;
processCommandToResponse(cmd: WardenCommand, origin: string, loggedInUserId: string): Promise<WardenCommandResponse>;
exportWebAuthnRegistrationEntry(origin: string, userId: string): Promise<string>;
importWebAuthnRegistrationEntry(token: string, userId: string): Promise<boolean>;
urlIsOnAllowedOrigin(url: string): boolean;
singleUseCodeProvider(contact: WardenContact, requireMagicLinkSupport: boolean, returnNullIfNoProviders?: boolean): WardenSingleUseCodeProvider;
sendMagicLink(contact: WardenContact, overrideDestinationContact: WardenContact, relyingPartyName: string, landingUrl: string, metaIn?: Record<string, string>, ttlSeconds?: number, customTemplate?: WardenCustomTemplateDescriptor): Promise<boolean>;
createAccountByThirdParty(thirdParty: WardenThirdPartyAuthentication, origin: string, inLabel?: string): Promise<WardenEntry>;
createAccount(contact: WardenContact, origin: string, sendCode?: boolean, label?: string, tags?: string[]): Promise<WardenEntry>;
saveNewUser(newUser: WardenEntry): Promise<WardenEntry>;
addContactMethodToUser(userId: string, contact: WardenContact): Promise<boolean>;
removeContactMethodFromUser(userId: string, contact: WardenContact): Promise<WardenEntry>;
generateWebAuthnRegistrationChallengeForLoggedInUser(userId: string, origin: string): Promise<PublicKeyCredentialCreationOptionsJSON>;
storeAuthnRegistration(userId: string, origin: string, applicationName: string, deviceLabel: string, data: RegistrationResponseJSON): Promise<WardenStoreRegistrationResponse>;
generateWebAuthnAuthenticationChallengeForUserId(userId: string, origin: string): Promise<PublicKeyCredentialRequestOptionsJSON>;
generateWebAuthnAuthenticationChallenge(user: WardenEntry, origin: string): Promise<PublicKeyCredentialRequestOptionsJSON>;
sendExpiringValidationToken(request: WardenContact, origin: string): Promise<boolean>;
processLogin(request: WardenLoginRequest, origin: string): Promise<WardenEntry | null>;
loginWithWebAuthnRequest(user: WardenEntry, origin: string, data: AuthenticationResponseJSON): Promise<boolean>;
removeSingleWebAuthnRegistration(userId: string, key: string): Promise<WardenEntry>;
removeUser(userId: string): Promise<boolean>;
}