Fix jackson build error (#7641)

* Fixing prettier build issue with jackson

* Refactor to clean up code

* Now using globalThis to reference jackson objects
pull/7662/head
Keith Williams 2023-03-10 10:28:57 -05:00 committed by GitHub
parent e24f1d8bdb
commit f3360e6476
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 23 deletions

View File

@ -6,7 +6,7 @@ import type {
ISPSAMLConfig,
} from "@boxyhq/saml-jackson";
import {WEBAPP_URL} from "@calcom/lib/constants";
import { WEBAPP_URL } from "@calcom/lib/constants";
import { samlDatabaseUrl, samlAudience, samlPath, oidcPath, clientSecretVerifier } from "./saml";
@ -26,38 +26,25 @@ const opts: JacksonOption = {
clientSecretVerifier,
};
let connectionController: IConnectionAPIController;
let oauthController: IOAuthController;
let samlSPConfig: ISPSAMLConfig;
const g = global;
declare global {
/* eslint-disable no-var */
var connectionController: IConnectionAPIController | undefined;
var oauthController: IOAuthController | undefined;
var samlSPConfig: ISPSAMLConfig | undefined;
/* eslint-enable no-var */
}
export default async function init() {
if (!g.connectionController || !g.oauthController || !g.samlSPConfig) {
if (!globalThis.connectionController || !globalThis.oauthController || !globalThis.samlSPConfig) {
const ret = await jackson(opts);
connectionController = ret.connectionAPIController;
oauthController = ret.oauthController;
samlSPConfig = ret.spConfig;
g.connectionController = connectionController;
g.oauthController = oauthController;
g.samlSPConfig = samlSPConfig;
} else {
connectionController = g.connectionController;
oauthController = g.oauthController;
samlSPConfig = g.samlSPConfig;
globalThis.connectionController = ret.connectionAPIController;
globalThis.oauthController = ret.oauthController;
globalThis.samlSPConfig = ret.spConfig;
}
return {
connectionController,
oauthController,
samlSPConfig,
connectionController: globalThis.connectionController,
oauthController: globalThis.oauthController,
samlSPConfig: globalThis.samlSPConfig,
};
}