From 4d0e8fad096b4621531208941e4367790db0e67f Mon Sep 17 00:00:00 2001 From: Connor Anderson Date: Thu, 6 May 2021 11:36:27 -0400 Subject: [PATCH] global config checks --- script/core.hbs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/script/core.hbs b/script/core.hbs index daa6c55ed..d91773b32 100644 --- a/script/core.hbs +++ b/script/core.hbs @@ -12,7 +12,9 @@ const IS_STAGING = HitchhikerJS.isStaging(JAMBO_INJECTED_DATA?.pages?.stagingDomains || []); const injectedConfig = { experienceVersion: IS_STAGING ? 'STAGING' : 'PRODUCTION', - apiKey: HitchhikerJS.getInjectedProp('{{{global_config.experienceKey}}}', ['apiKey']), + {{#unless global_config.useJWT}} + apiKey: HitchhikerJS.getInjectedProp('{{{global_config.experienceKey}}}', ['apiKey']), + {{/unless}} {{#with env.JAMBO_INJECTED_DATA}} {{#if businessId}}businessId: "{{businessId}}",{{/if}} {{/with}} @@ -29,14 +31,16 @@ {{/with}} }; let token = null; - let iframeSearchParams = null; - if (window.frameElement) { - const iframeSrc = new URL(window.frameElement.src); - iframeSearchParams = new URLSearchParams(iframeSrc.search); - } else { - iframeSearchParams = new URLSearchParams(window.location.search); - } - token = iframeSearchParams?.get('token'); + {{#if global_config.useJWT}} + let iframeSearchParams = null; + if (window.frameElement) { // to support same-origin + const iframeSrc = new URL(window.frameElement.src); + iframeSearchParams = new URLSearchParams(iframeSrc.search); + } else { // to support cross-origin + iframeSearchParams = new URLSearchParams(window.location.search); + } + token = iframeSearchParams?.get('token'); + {{/if}} ANSWERS.init({ templateBundle: TemplateBundle.default, ...injectedConfig,