@imajin/rx-otp
Version:
HMAC-based (HOTP) and Time-based (TOTP) One-Time Password manager. Works with Google Authenticator for Two-Factor Authentication.
13 lines (12 loc) • 644 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Validator = void 0;
const rxjs_1 = require("rxjs");
const operators_1 = require("rxjs/operators");
const ajv_1 = require("./ajv");
class Validator {
}
exports.Validator = Validator;
Validator.validateDataWithSchemaReference = (keyRef, data) => (0, rxjs_1.of)(ajv_1.ajv.getSchema(keyRef))
.pipe((0, rxjs_1.mergeMap)(validator => (0, rxjs_1.of)(validator(data))
.pipe((0, operators_1.filter)(_ => !_), (0, rxjs_1.mergeMap)(() => (0, rxjs_1.throwError)(() => new Error(ajv_1.ajv.errorsText(validator.errors)))), (0, operators_1.defaultIfEmpty)(data))));