@simulacrum/auth0-simulator
Version:
Run local instance of Auth0 API for local development and integration testing
39 lines • 1.6 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getConfig = exports.DefaultArgs = void 0;
exports.getConfigCreator = getConfigCreator;
const cosmiconfig_1 = require("cosmiconfig");
const types_ts_1 = require("../types.js");
const DefaultAuth0Port = 4400;
exports.DefaultArgs = {
clientID: "00000000000000000000000000000000",
audience: "https://thefrontside.auth0.com/api/v1/",
scope: "openid profile email offline_access",
};
function getPort({ domain, port }) {
if (typeof port === "number") {
return port;
}
if (domain) {
if (domain.split(":").length === 2) {
return parseInt(domain.split(":")[1]);
}
}
return DefaultAuth0Port;
}
// This higher order function would only be used for testing and
// allows different cosmiconfig instances to be used for testing
function getConfigCreator(explorer) {
return function getConfig(options) {
let searchResult = explorer.search();
let config = searchResult === null ? exports.DefaultArgs : searchResult.config;
let strippedOptions = options !== null && options !== void 0 ? options : {};
let configuration = Object.assign(Object.assign(Object.assign({}, exports.DefaultArgs), config), strippedOptions);
configuration.port = getPort(configuration);
types_ts_1.configurationSchema.parse(configuration);
return configuration;
};
}
const explorer = (0, cosmiconfig_1.cosmiconfigSync)("auth0Simulator");
exports.getConfig = getConfigCreator(explorer);
//# sourceMappingURL=get-config.js.map