UNPKG

citi-hub-session-engine

Version:

Module for authentication methods for CITI hub

32 lines (26 loc) 957 B
const { logger } = require("../utils/Logger"); const { configurations_key } = require("../utils/Constants"); const evaluateUserProviders = async (token, body) => { try { logger.info(`Initiating Active User`); const config = global[configurations_key]; const endpoint = config?.evaluateUserProviders?.endpoint || ""; logger.info(`endpoint: ${endpoint}`); //INVOKE ENDPOINT, POST, headers: authorization, body: params const response = await fetch(endpoint, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}`, }, body: JSON.stringify(body), }); const data = await response.json(); logger.info(`Response from Active User: ${data.code}`); return data; } catch (e) { logger.error(`An error occurred while active user :: ${e}`); return null; } }; module.exports = evaluateUserProviders;