UNPKG

@graphteon/juricode

Version:

We are forging the future with lines of digital steel

20 lines 1.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.generateAuthUrl = void 0; const generateAuthUrl = (identityProvider, requestUrl) => { const redirectUri = `${requestUrl.origin}/oauth/keycloak/callback`; let authUrl = requestUrl.hostname .replace(/(^|\.)staging\.all-hands\.dev$/, "$1auth.staging.all-hands.dev") .replace(/(^|\.)app\.all-hands\.dev$/, "auth.app.all-hands.dev") .replace(/(^|\.)localhost$/, "auth.staging.all-hands.dev"); if (authUrl === requestUrl.hostname && requestUrl.hostname !== "localhost") { authUrl = `auth.${requestUrl.hostname}`; } const scope = "openid email profile"; const separator = requestUrl.search ? "&" : "?"; const cleanHref = requestUrl.href.replace(/\/$/, ""); const state = `${cleanHref}${separator}login_method=${identityProvider}`; return `https://${authUrl}/realms/allhands/protocol/openid-connect/auth?client_id=allhands&kc_idp_hint=${identityProvider}&response_type=code&redirect_uri=${encodeURIComponent(redirectUri)}&scope=${encodeURIComponent(scope)}&state=${encodeURIComponent(state)}`; }; exports.generateAuthUrl = generateAuthUrl; //# sourceMappingURL=generate-auth-url.js.map