UNPKG

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

Version:

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

72 lines (69 loc) 2.84 kB
"use strict"; /** * Copyright © 2024 Nevis Security AG. All rights reserved. */ import uuid from 'react-native-uuid'; import { DeviceInformationCheckPlatformOperation } from '../../cache/operation/DeviceInformationCheckPlatformOperation'; import { PlatformOperationCache } from '../../cache/PlatformOperationCache'; import NevisMobileAuthenticationSdkReact from '../../MobileAuthenticationSdk'; import { DeviceInformationCheckResultMessage } from '../../model/messages/in/DeviceInformationCheckResultMessage'; import { DeviceInformationCheckMessage } from '../../model/messages/out/DeviceInformationCheckMessage'; import { HttpOperation, HttpOperationImpl } from '../HttpOperation'; /** * The operation retrieving the mismatches that exist between the configuration in the server and in * the mobile device application. * * The configuration mismatches can be fixed by providing them to the {@link DeviceInformationSync} * operation. * * This is supported only with FIDO UAF registrations made against a backend with nevisFIDO 7.2408.** * or later. With registrations made with earlier versions of nevisFIDO, this operation can return * {@link MissingAuthenticatorInServer} false positives, that is, it can report mismatches, when the * credentials of backend and server are in sync. * * Usage example: * ```ts * [...] * async retrieveDeviceInformationMismatches( * operations: Operations * ): Promise<void> { * operations.deviceInformationCheck * .onResult((result) => { * // handle the retrieved mismatches. They can be fixed by * // running a DeviceInformationSync operation. * }) * .execute(); * } * [...] * ``` * * @see * - {@link DeviceInformationCheckResult} * - {@link DeviceInformationSync} * - {@link Operations.deviceInformationCheck} */ export class DeviceInformationCheck extends HttpOperation {} export class DeviceInformationCheckImpl extends HttpOperationImpl { constructor() { super(); } onResult(onResult) { this._onResult = onResult; return this; } async execute() { const operationId = uuid.v4(); const operation = new DeviceInformationCheckPlatformOperation(operationId, this._onResult); PlatformOperationCache.getInstance().put(operation); const message = new DeviceInformationCheckMessage(operationId, this.onResult !== undefined, this.httpRequestHeaders); function finish() { PlatformOperationCache.getInstance().delete(operationId); } return NevisMobileAuthenticationSdkReact.deviceInformationCheck(message).then(result => { const resultMessage = DeviceInformationCheckResultMessage.fromJson(result); operation.handleResult(resultMessage.result); finish(); }); } } //# sourceMappingURL=DeviceInformationCheck.js.map