UNPKG

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

Version:

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

44 lines (37 loc) 1.38 kB
/** * Copyright © 2024 Nevis Security AG. All rights reserved. */ import NevisMobileAuthenticationSdkReact from '../../MobileAuthenticationSdk'; import { OperationIdMessage } from '../../model/messages/out/OperationIdMessage'; import { PasswordEnrollMessage } from '../../model/messages/out/PasswordEnrollMessage'; import { CancellableHandler } from '../CancellableHandler'; /** * The object handling the password to be enrolled. * * @see {@link PasswordEnroller.enrollPassword} */ export abstract class PasswordEnrollmentHandler extends CancellableHandler { /** * Specify the password to be enrolled. * * When this method is invoked, the SDK will validate the password and, if valid, will enroll it. * * @param password the password. */ abstract password(password: string): Promise<void>; } export class PasswordEnrollmentHandlerImpl extends PasswordEnrollmentHandler { private readonly _operationId: string; constructor(operationId: string) { super(); this._operationId = operationId; } async password(password: string): Promise<void> { const message = new PasswordEnrollMessage(this._operationId, password); return NevisMobileAuthenticationSdkReact.passwordEnroll(message); } async cancel(): Promise<void> { const message = new OperationIdMessage(this._operationId); return NevisMobileAuthenticationSdkReact.cancel(message); } }