Fix jackson build error (#7641)

* Fixing prettier build issue with jackson

* Refactor to clean up code

* Now using globalThis to reference jackson objects
This commit is contained in:
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

View File

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