@noauth/browser
Shared types
type NoAuthConfig = {
apiKey: string;
};
type AuthenticateResponse = {
verified: boolean;
accessToken: string | null;
emailVerified: boolean;
};
Sign in / Sign up
type SigninOptions = {
otp?: string | undefined;
} & NoAuthConfig;
const signin: (
email: string,
options: SigninOptions
) => Promise<AuthenticateResponse>;
Account recovery (OTP)
const sendOTP: (email: string, options: NoAuthConfig) => Promise<boolean>;
const verifyOTP: (
token: string,
otp: string,
options: NoAuthConfig
) => Promise<boolean>;
QR authentication
type RemoteSigninResponse = {
qr: string;
attempt: Promise<AuthenticateResponse>;
cancel: () => void;
};
const remoteSignin: (
email: string,
options: NoAuthConfig
) => Promise<RemoteSigninResponse>;
const verifyQR: (
attempt: string,
token: string,
options: NoAuthConfig
) => Promise<boolean>;
Helpers
Check if the browser is capable of supporting WebAuthn.
const hasBrowserSupport: () => Promise<boolean>;
Encapsulates the API for easy usage.
class NoAuth {
constructor(options: NoAuthConfig);
signin(email: string, otp?: string): Promise<AuthenticateResponse>;
get otp(): {
create: (email: string) => Promise<boolean>;
verify: (token: string, otp: string) => Promise<boolean>;
};
get qr(): {
create: (email: string) => Promise<RemoteSigninResponse>;
verify: (attempt: string, token: string) => Promise<boolean>;
};
}