UNPKG

@5minds/processcube_engine

Version:

The ProcessCube Engine. Stores and executes BPMNs.

55 lines 2.05 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.IAMFetchClient = void 0; const cross_fetch_1 = __importDefault(require("cross-fetch")); const processcube_engine_sdk_1 = require("@5minds/processcube_engine_sdk"); const Configurator_1 = __importDefault(require("../../Configurator")); class IAMFetchClient { logger; openIdBaseUrl; openIdConfig = null; constructor() { this.openIdBaseUrl = Configurator_1.default.iam().baseUrl; this.logger = new processcube_engine_sdk_1.Logger('iam:iam_fetch_client'); } async getOpenIdConfig() { if (this.openIdConfig != null) { return this.openIdConfig; } const getOpenIdConfigUri = `${this.openIdBaseUrl.replace(/\/$/, '')}/.well-known/openid-configuration`; try { const getOpenIdConfigResponse = await (0, cross_fetch_1.default)(getOpenIdConfigUri); const openIdConfig = await getOpenIdConfigResponse.json(); this.openIdConfig = openIdConfig; return openIdConfig; } catch (error) { this.logger.error('Failed to retrieve OpenID configuration.', { err: error, openIdConfigUri: getOpenIdConfigUri, }); throw error; } } async getJwks() { const openIdConfig = await this.getOpenIdConfig(); const jwksUri = openIdConfig.jwks_uri; try { const jwksResponse = await (0, cross_fetch_1.default)(jwksUri); const jwks = await jwksResponse.json(); return jwks; } catch (error) { this.logger.error('Failed to retrieve JWKS.', { err: error, jwksUri: jwksUri, }); throw error; } } } exports.IAMFetchClient = IAMFetchClient; //# sourceMappingURL=IamFetchClient.js.map