@noauth/browser
Shared types
typescript
type NoAuthConfig = {
apiKey: string;
};
type AuthenticateResponse = {
verified: boolean;
accessToken: string | null;
emailVerified: boolean;
};Sign in / Sign up
typescript
type SigninOptions = {
otp?: string | undefined;
} & NoAuthConfig;
const signin: (
email: string,
options: SigninOptions
) => Promise<AuthenticateResponse>;Account recovery (OTP)
typescript
const sendOTP: (email: string, options: NoAuthConfig) => Promise<boolean>;
const verifyOTP: (
token: string,
otp: string,
options: NoAuthConfig
) => Promise<boolean>;QR authentication
typescript
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.
typescript
const hasBrowserSupport: () => Promise<boolean>;Encapsulates the API for easy usage.
typescript
class NoAuth {
constructor(options: NoAuthConfig);
signin(email: string, otp?: string): Promise<AuthenticateResponse>;
otp: {
create: (email: string) => Promise<boolean>;
verify: (token: string, otp: string) => Promise<boolean>;
};
qr: {
create: (email: string) => Promise<RemoteSigninResponse>;
verify: (attempt: string, token: string) => Promise<boolean>;
};
}