UNPKG

@simulacrum/auth0-simulator

Version:

Run local instance of Auth0 API for local development and integration testing

43 lines 2.27 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.extendRouter = void 0; const express_1 = __importDefault(require("express")); const create_cors_ts_1 = require("../middleware/create-cors.js"); const no_cache_ts_1 = require("../middleware/no-cache.js"); const session_ts_1 = require("../middleware/session.js"); const error_handling_ts_1 = require("../middleware/error-handling.js"); const auth0_handlers_ts_1 = require("./auth0-handlers.js"); const openid_handlers_ts_1 = require("./openid-handlers.js"); const path_1 = __importDefault(require("path")); const publicDir = path_1.default.join(__dirname, "..", "views", "public"); const extendRouter = (config, debug = false) => (router, simulationStore) => { const serviceURL = (request) => `${request.protocol}://${request.get("Host")}/`; const auth0 = (0, auth0_handlers_ts_1.createAuth0Handlers)(simulationStore, serviceURL, config, debug); const openid = (0, openid_handlers_ts_1.createOpenIdHandlers)(serviceURL); router .use(express_1.default.static(publicDir)) .use((0, session_ts_1.createSession)()) .use((0, create_cors_ts_1.createCors)()) .use((0, no_cache_ts_1.noCache)()) .get("/health", (_, response) => { response.send({ status: "ok" }); }) .get("/heartbeat", auth0["/heartbeat"]) .get("/authorize", auth0["/authorize"]) .get("/login", auth0["/login"]) .get("/u/login", auth0["/usernamepassword/login"]) .post("/usernamepassword/login", auth0["/usernamepassword/login"]) .post("/login/callback", auth0["/login/callback"]) .post("/oauth/token", auth0["/oauth/token"]) .get("/userinfo", auth0["/userinfo"]) .get("/v2/logout", auth0["/v2/logout"]) .get("/.well-known/jwks.json", openid["/.well-known/jwks.json"]) .get("/.well-known/openid-configuration", openid["/.well-known/openid-configuration"]); // needs to be the last middleware added router.use(error_handling_ts_1.defaultErrorHandler); }; exports.extendRouter = extendRouter; //# sourceMappingURL=index.js.map