@kilterset/auth0-actions-testing
Version:
Test and develop Auth0 Actions or Okta CIC Actions locally.
49 lines • 2.47 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.postLogin = void 0;
const define_1 = require("../define");
const user_1 = require("../user");
const request_1 = require("../request");
const authentication_1 = require("../authentication");
const transaction_1 = require("../transaction");
const session_1 = require("../session");
const connection_1 = require("../connection");
const organization_1 = require("../organization");
const client_1 = require("../client");
const chance_1 = require("../chance");
const identity_1 = require("../identity");
exports.postLogin = (0, define_1.define)(({ params }) => {
var _a, _b, _c, _d;
const tenantId = ((_a = params.tenant) === null || _a === void 0 ? void 0 : _a.id) || chance_1.chance.auth0().tenantId();
const hostname = ((_b = params.request) === null || _b === void 0 ? void 0 : _b.hostname) || `${tenantId}.auth0.com`;
const connectionValue = params.connection
? params.connection
: (0, connection_1.connection)();
const identities = ((_c = params.user) === null || _c === void 0 ? void 0 : _c.identities) || [];
identities.splice(0, 1, (0, identity_1.identity)(Object.assign({ connection: connectionValue.name, provider: connectionValue.strategy }, (identities[0] || {}))));
const userValue = (0, user_1.user)(Object.assign(Object.assign({}, params.user), { identities }));
const requestValue = (0, request_1.request)(Object.assign(Object.assign({ hostname }, params.request), { query: Object.assign({ connection: connectionValue.name }, (_d = params.request) === null || _d === void 0 ? void 0 : _d.query) }));
const transactionValue = (0, transaction_1.transaction)();
return {
transaction: transactionValue,
authentication: (0, authentication_1.authentication)(),
authorization: {
roles: [],
},
connection: connectionValue,
organization: (0, organization_1.organization)(),
resource_server: {
identifier: `https://${hostname}/userinfo`,
},
tenant: { id: tenantId },
session: (0, session_1.session)({}, { ip: requestValue.ip, asn: requestValue.asn }),
client: (0, client_1.client)(),
request: requestValue,
stats: {
logins_count: chance_1.chance.integer({ min: 0, max: 1000 }),
},
user: userValue,
secrets: {},
};
});
//# sourceMappingURL=post-login.js.map