UNPKG

@cityssm/authentication-helper

Version:

Handles the authentication requests for web applications.

24 lines (19 loc) 686 B
import type { BaseAuthenticator } from './_baseAuthenticator.js' export interface FunctionAuthenticatorConfiguration { authenticate: ( userName: string, password: string ) => boolean | Promise<boolean> } export class FunctionAuthenticator implements BaseAuthenticator { readonly #authenticateFunction: ( userName: string, password: string ) => boolean | Promise<boolean> constructor(config: FunctionAuthenticatorConfiguration) { this.#authenticateFunction = config.authenticate } async authenticate(userName: string, password: string): Promise<boolean> { return await this.#authenticateFunction(userName, password) } }