@nopwdio/sdk-js
Version:
Nopwd JS SDK
55 lines (54 loc) • 2.14 kB
TypeScript
import { LitElement } from "lit";
import { Session } from "../core/session.js";
export declare enum State {
EMAIL_SENDING = "email:link:sending",// sending an email link
EMAIL_SENT = "email:link:sent",// the email link has been sent
EMAIL_VERIFYING = "email:link:verifying",// verifying the callback code from the email link
AUTHENTICATED = "authenticated",// the user is authenticated (using email or passkey)
PASSKEYS_VERIFYING = "passkeys:verifying",// the user is anthenticating with passkey
ERROR = "error"
}
/**
* @summary `np-login` is a custom element for user authentication via email link (magic-link) or Passkeys.
*
* @description
* This component manages the authentication process using WebAuthn passkeys or email link authentication.
* It handles sending email links, processing callback codes, and verifying passkey challenges.
* The component emits events for successful login and errors, allowing other parts of the application to
* respond accordingly. It also provides visual feedback for different states of the authentication process.
*
* @event np:login - Emitted when the session is successfully created.
* @event np:error - Emitted when an error occurs during the authentication process.
*
* @csspart button - The submit button wrapper.
* @csspart input - The email input wrapper.
*/
export declare class NpLogin extends LitElement {
/**
*/
state?: State;
passkeys?: boolean;
placeholder: string;
id: string;
lifetime?: number;
idletimeout?: number;
value: string;
private abortConditianal?;
connectedCallback(): Promise<void>;
disconnectedCallback(): Promise<void>;
loginWithEmail(): Promise<number | undefined>;
private handleCallbackIfNeeded;
private startConditionalUI;
getSession(): Promise<Session | null | undefined>;
private signalSuccess;
private signalError;
private onInput;
private onKeyUp;
render(): import("lit-html").TemplateResult<1>;
static styles: import("lit").CSSResult[];
}
declare global {
interface HTMLElementTagNameMap {
"np-login": NpLogin;
}
}