UNPKG

@kilterset/auth0-actions-testing

Version:

Test and develop Auth0 Actions or Okta CIC Actions locally.

53 lines 1.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.preUserRegistration = preUserRegistration; const cache_1 = require("./cache"); const user_1 = require("../user"); function preUserRegistration({ user, cache, } = {}) { const apiCache = (0, cache_1.cache)(cache); const userValue = user !== null && user !== void 0 ? user : (0, user_1.user)(); const state = { user: userValue, access: { denied: false }, cache: apiCache, validation: { error: null, }, }; const api = { access: { deny: (code, reason) => { state.access = { denied: { code, reason } }; return api; }, }, cache: apiCache, user: { setAppMetadata: (key, value) => { var _a; var _b; (_a = (_b = state.user).app_metadata) !== null && _a !== void 0 ? _a : (_b.app_metadata = {}); state.user.app_metadata[key] = value; return api; }, setUserMetadata: (key, value) => { var _a; var _b; (_a = (_b = state.user).user_metadata) !== null && _a !== void 0 ? _a : (_b.user_metadata = {}); state.user.user_metadata[key] = value; return api; }, }, validation: { error: (code, message) => { state.validation.error = { code, message }; return api; }, }, }; return { implementation: api, state, }; } //# sourceMappingURL=pre-user-registration.js.map