@kilterset/auth0-actions-testing
Version:
Test and develop Auth0 Actions or Okta CIC Actions locally.
64 lines • 2.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.postChallenge = postChallenge;
const cache_1 = require("./cache");
const user_1 = require("../user");
const request_1 = require("../request");
const redirect_1 = require("./redirect");
function postChallenge({ user, request, cache, now: nowValue, } = {}) {
const apiCache = (0, cache_1.cache)(cache);
const userValue = user !== null && user !== void 0 ? user : (0, user_1.user)();
const requestValue = request !== null && request !== void 0 ? request : (0, request_1.request)();
const now = new Date(nowValue || Date.now());
const redirect = (0, redirect_1.redirectMock)("PostChallenge", {
now,
request: requestValue,
user: userValue,
});
const state = {
authentication: {
challenge: false,
enrollment: false,
newlyRecordedMethods: [],
},
user: userValue,
access: { denied: false },
cache: apiCache,
get redirect() {
return redirect.state.target;
},
};
const api = {
access: {
deny: (reason) => {
state.access = { denied: { reason } };
return api;
},
},
authentication: {
challengeWith: (factor, options) => {
var _a;
const additionalFactors = (_a = options === null || options === void 0 ? void 0 : options.additionalFactors) !== null && _a !== void 0 ? _a : [];
state.authentication.challenge = {
allOptions: [factor, ...additionalFactors],
default: factor,
};
},
challengeWithAny(factors) {
state.authentication.challenge = {
allOptions: factors,
default: undefined,
};
},
},
cache: apiCache,
get redirect() {
return redirect.build(api);
},
};
return {
implementation: api,
state,
};
}
//# sourceMappingURL=post-challenge.js.map