UNPKG

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

Version:

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

69 lines (66 loc) 2.84 kB
"use strict"; /** * Copyright © 2025 Nevis Security AG. All rights reserved. */ import uuid from 'react-native-uuid'; import { FidoUafAttestationInformationErrorConverter } from '../error/attestationInformation/FidoUafAttestationInformationErrorConverter'; import NevisMobileAuthenticationSdkReact from '../MobileAuthenticationSdk'; import { OnSuccessMessage } from '../model/messages/in/OnSuccessMessage'; import { FidoUafAttestationInformationMessage } from '../model/messages/out/FidoUafAttestationInformationMessage'; import { Operation } from '../operations/Operation'; /** * The object that can be used to obtain the information regarding the support of * {@link https://docs.nevis.net/configurationguide/mobile-auth-concept-and-integration-guide/use-cases-and-best-practices/uaf-surrogate-full-basic-comparison | Full Basic Attestation} * in this device. * * **IMPORTANT** \ * This operation is Android specific. On iOS the {@link onSuccess} will be invoked with `undefined` * FIDO UAF attestation information. * * If full basic attestation is required by the backend during registration, and this device does not * support it, registration will fail. This information can be used to preemptively inform the user * that the device is not supported. * * Usage example: * ```ts * async function getAttestationInformation( * client: MobileAuthenticationClient, * ): Promise<void> { * await client.deviceCapabilities * .androidDeviceCapabilities * .fidoUafAttestationInformationGetter * .onSuccess((FidoUafAttestationInformation? info) { * // handle success * }) * .onError((error) { * // handle error * }) * .execute(); * } * ``` * * @see {@link AndroidDeviceCapabilities.fidoUafAttestationInformationGetter} */ export class FidoUafAttestationInformationGetter extends Operation {} export class FidoUafAttestationInformationGetterImpl extends FidoUafAttestationInformationGetter { onSuccess(onSuccess) { this._onSuccess = onSuccess; return this; } onError(onError) { this._onError = onError; return this; } async execute() { const operationId = uuid.v4(); const message = new FidoUafAttestationInformationMessage(operationId, this._onSuccess !== undefined, this._onError !== undefined); return NevisMobileAuthenticationSdkReact.fidoUafAttestationInformation(message).then(result => { const successMessage = OnSuccessMessage.fromJson(result); this._onSuccess?.(successMessage.fidoUafAttestationInformation); }).catch(error => { const attestationError = new FidoUafAttestationInformationErrorConverter(error).convert(); this._onError?.(attestationError); }); } } //# sourceMappingURL=FidoUafAttestationInformationGetter.js.map