UNPKG

@keycloakify/keycloak-account-ui

Version:
27 lines 883 B
/** * Extracts the environment variables from the document, these variables are injected by Keycloak as a script tag, the contents of which can be parsed as JSON. For example: * *```html * <script id="environment" type="application/json"> * { * "realm": "master", * "clientId": "security-admin-console", * "etc": "..." * } * </script> * ``` */ export function getInjectedEnvironment() { const element = document.getElementById("environment"); const contents = element === null || element === void 0 ? void 0 : element.textContent; if (typeof contents !== "string") { throw new Error("Environment variables not found in the document."); } try { return JSON.parse(contents); } catch (_a) { throw new Error("Unable to parse environment variables as JSON."); } } //# sourceMappingURL=environment.js.map