UNPKG

@accounts/magic-link

Version:

[![npm](https://img.shields.io/npm/v/@accounts/magic-link)](https://www.npmjs.com/package/@accounts/magic-link) [![npm downloads](https://img.shields.io/npm/dm/@accounts/magic-link)](https://www.npmjs.com/package/@accounts/magic-link) [![codecov](https://

28 lines (27 loc) 1.29 kB
import { type User, type DatabaseInterface, type AuthenticationService, type LoginUserMagicLinkService, type TokenRecord, type DatabaseInterfaceUser } from '@accounts/types'; import { AccountsServer } from '@accounts/server'; import { type ErrorMessages } from './types'; export interface AccountsMagicLinkOptions { /** * Accounts token module errors */ errors?: ErrorMessages; /** * The number of milliseconds from when a link with a login token is sent until token expires and user can't login with it. * Defaults to 15 minutes. */ loginTokenExpiration?: number; } export default class AccountsMagicLink<CustomUser extends User = User> implements AuthenticationService { serviceName: string; server: AccountsServer; private options; private db; constructor(options?: AccountsMagicLinkOptions, server?: AccountsServer, db?: DatabaseInterface<CustomUser> | DatabaseInterfaceUser<CustomUser>); setUserStore(store: DatabaseInterfaceUser<CustomUser>): void; setSessionsStore(): void; requestMagicLinkEmail(email: string): Promise<void>; authenticate(params: LoginUserMagicLinkService): Promise<CustomUser>; isTokenExpired(tokenRecord: TokenRecord, expiryDate: number): boolean; private magicLinkAuthenticator; }