UNPKG

@nevis-security/nevis-mobile-authentication-sdk-react

Version:

React Native plugin for Nevis Mobile Authentication SDK. Supports only mobile.

46 lines (39 loc) 1.58 kB
/** * Copyright © 2024 Nevis Security AG. All rights reserved. */ import { UserVerificationHandler } from './UserVerificationHandler'; import NevisMobileAuthenticationSdkReact from '../../MobileAuthenticationSdk'; import { OperationIdMessage } from '../../model/messages/out/OperationIdMessage'; import { PasswordVerificationMessage } from '../../model/messages/out/PasswordVerificationMessage'; /** * The objects consuming the outcome of an interaction where the user provides * password credentials. * * This is used with the {@link Aaid.PASSWORD} authenticator attestation identifier. * * @see {@link PasswordUserVerifier.verifyPassword} */ export abstract class PasswordUserVerificationHandler extends UserVerificationHandler { /** * The method to be invoked when the password authenticator must be used. * * The SDK will verify that the provided password is valid. * @param password the password. */ abstract verifyPassword(password: string): Promise<void>; } export class PasswordUserVerificationHandlerImpl extends PasswordUserVerificationHandler { private readonly _operationId: string; constructor(operationId: string) { super(); this._operationId = operationId; } async verifyPassword(password: string): Promise<void> { const message = new PasswordVerificationMessage(this._operationId, password); return NevisMobileAuthenticationSdkReact.passwordVerify(message); } async cancel(): Promise<void> { const message = new OperationIdMessage(this._operationId); return NevisMobileAuthenticationSdkReact.cancel(message); } }