UNPKG

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

Version:

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

86 lines (84 loc) 3.62 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DeviceInformationSyncImpl = exports.DeviceInformationSync = void 0; var _reactNativeUuid = _interopRequireDefault(require("react-native-uuid")); var _DeviceInformationSyncPlatformOperation = require("../../cache/operation/DeviceInformationSyncPlatformOperation"); var _PlatformOperationCache = require("../../cache/PlatformOperationCache"); var _MobileAuthenticationSdk = _interopRequireDefault(require("../../MobileAuthenticationSdk")); var _DeviceInformationSyncResultMessage = require("../../model/messages/in/DeviceInformationSyncResultMessage"); var _DeviceInformationSyncMessage = require("../../model/messages/out/DeviceInformationSyncMessage"); var _HttpOperation = require("../HttpOperation"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } /** * Copyright © 2024 Nevis Security AG. All rights reserved. */ /** * The operation that can be executed to correct the {@link DeviceInformationMismatch} problems * that were found in a {@link DeviceInformationCheck}. * * The operation works in a best-effort mode: it will try to resolve as many mismatches as * possible and will report the errors that occurred (if any) through the {@link DeviceInformationSyncResult.errors} * method. * * **WARNING** \ * Some of the changes result in removal of credentials on both the server and client side. Use this * class with caution and understanding its implications. The changes that will be applied are * described on the documentation of each {@link DeviceInformationMismatch}. * * This is supported only when the backend uses nevisFIDO 7.2408.** or later. * * Usage example: * ```ts * [...] * async fixDeviceInformationMismatches( * operations: Operations, * mismatches: DeviceInformationMismatch[] * ): Promise<void> { * operations.deviceInformationSync * .mismatches(mismatches) * .onResult((result) => { * // handle the result * }) * .execute(); * } * [...] * ``` * * @see * - {@link DeviceInformationCheck} * - {@link DeviceInformationMismatch} * - {@link Operations.deviceInformationSync} */ class DeviceInformationSync extends _HttpOperation.HttpOperation {} exports.DeviceInformationSync = DeviceInformationSync; class DeviceInformationSyncImpl extends _HttpOperation.HttpOperationImpl { constructor() { super(); } mismatches(mismatches) { this._mismatches = mismatches; return this; } onResult(onResult) { this._onResult = onResult; return this; } async execute() { const operationId = _reactNativeUuid.default.v4(); const operation = new _DeviceInformationSyncPlatformOperation.DeviceInformationSyncPlatformOperation(operationId, this._onResult); _PlatformOperationCache.PlatformOperationCache.getInstance().put(operation); const message = new _DeviceInformationSyncMessage.DeviceInformationSyncMessage(operationId, this._onResult !== undefined, this._mismatches, this.httpRequestHeaders); function finish() { _PlatformOperationCache.PlatformOperationCache.getInstance().delete(operationId); } return _MobileAuthenticationSdk.default.deviceInformationSync(message).then(result => { const resultMessage = _DeviceInformationSyncResultMessage.DeviceInformationSyncResultMessage.fromJson(result); operation.handleResult(resultMessage.result); finish(); }); } } exports.DeviceInformationSyncImpl = DeviceInformationSyncImpl; //# sourceMappingURL=DeviceInformationSync.js.map