@nevis-security/nevis-mobile-authentication-sdk-react
Version:
React Native plugin for Nevis Mobile Authentication SDK. Supports only mobile.
83 lines (81 loc) • 3.62 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PendingOutOfBandOperationsImpl = exports.PendingOutOfBandOperations = void 0;
var _reactNativeUuid = _interopRequireDefault(require("react-native-uuid"));
var _PendingOutOfBandPlatformOperation = require("../../cache/operation/PendingOutOfBandPlatformOperation");
var _PlatformOperationCache = require("../../cache/PlatformOperationCache");
var _MobileAuthenticationSdk = _interopRequireDefault(require("../../MobileAuthenticationSdk"));
var _PendingOutOfBandOperationsResultMessage = require("../../model/messages/in/PendingOutOfBandOperationsResultMessage");
var _PendingOutOfBandOperationsMessage = require("../../model/messages/out/PendingOutOfBandOperationsMessage");
var _HttpOperation = require("../HttpOperation");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
/**
* Copyright © 2024 Nevis Security AG. All rights reserved.
*/
/**
* The operation retrieving the out-of-band operations that have been started in
* the server, and must be handled by the application running the Mobile Authentication
* SDK on the device.
*
* The retrieved operations have been neither timed-out, nor have been processed
* by the SDK, that is, they have not been processed using an {@link OutOfBandOperation}
* operation.
*
* **IMPORTANT** \
* It is recommended to use this operation as sparsely as possible, because of
* the performance impact that it can have in the server. Do not use it for example
* with a polling mechanism.
*
* This is supported only when the backend uses nevisFIDO 7.2402.** or later.
*
* Usage example:
* ```ts
* [...]
* async retrievePendingOutOfBandOperations(
* operations: Operations
* ): Promise<void> {
* await operations.pendingOutOfBandOperations
* .onResult((result) => {
* // handle the retrieved out-of-band operations. For example
* // they can be processed using an OutOfBandOperation.
* })
* .execute();
* }
* [...]
* ```
*
* @see
* - {@link PendingOutOfBandOperationsResult}
* - {@link PendingOutOfBandOperation.payload}
* - {@link OutOfBandOperation}
* - {@link Operations#pendingOutOfBandOperations}
*/
class PendingOutOfBandOperations extends _HttpOperation.HttpOperation {}
exports.PendingOutOfBandOperations = PendingOutOfBandOperations;
class PendingOutOfBandOperationsImpl extends _HttpOperation.HttpOperationImpl {
constructor() {
super();
}
onResult(onResult) {
this._onResult = onResult;
return this;
}
async execute() {
const operationId = _reactNativeUuid.default.v4();
const operation = new _PendingOutOfBandPlatformOperation.PendingOutOfBandPlatformOperation(operationId, this._onResult);
_PlatformOperationCache.PlatformOperationCache.getInstance().put(operation);
const message = new _PendingOutOfBandOperationsMessage.PendingOutOfBandOperationsMessage(operationId, this._onResult !== undefined, this.httpRequestHeaders);
function finish() {
_PlatformOperationCache.PlatformOperationCache.getInstance().delete(operationId);
}
return _MobileAuthenticationSdk.default.pendingOutOfBandOperations(message).then(result => {
const resultMessage = _PendingOutOfBandOperationsResultMessage.PendingOutOfBandOperationsResultMessage.fromJson(result);
operation.handleResult(resultMessage.result);
finish();
});
}
}
exports.PendingOutOfBandOperationsImpl = PendingOutOfBandOperationsImpl;
//# sourceMappingURL=PendingOutOfBandOperations.js.map
;