-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add JWT support which is enabled when useJWT is true in global config For iframe experiences, add iframe-jwt.js (along with prod and staging versions) which provide an `initAnswersFrameJWT` function. The answers experience will load once `initAnswersFrameJWT` is called. For non-iframe experiences, `initAnswersJWT` must be called rather than `initAnswersFrameJWT` The next PR will ensure that the apiKey from the jambo injected data will not appear in the output of any builds. This PR does not include JWT overlay support. J=SLAP-1118 TEST=manual Test iframe-jwt.js and see that the page doesn't load until initAnswersFrame is ran. Test supplying valid and invalid tokens. Test navigating between pages and refreshing the page. Test that if the answers experience with `useJWT=true` is loaded directly (not through the iframe), and error message appears in the console. Smoke test the non-iframe experience and the the overlay integration with `useJWT=false`. Test JWT locally and on SGS. Test in a cross-domain manner with a local test site which points to an answers experience on SGS which is running this branch. On SGS, test iframe-jwt-prod.js and iframe-jwt-staging.js Test JWT on non-iframe experiences.
- Loading branch information
Showing
12 changed files
with
93 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { generateIFrame } from './iframe-common'; | ||
import InjectedData from './models/InjectedData'; | ||
import getJwtNotProvidedTimeout from './utils/getJwtNotProvidedTimeout'; | ||
|
||
const prodDomain = new InjectedData().getProdDomain(); | ||
const jwtNotProvidedTimeout = getJwtNotProvidedTimeout(); | ||
|
||
window.initAnswersFrameJWT = function (token) { | ||
clearTimeout(jwtNotProvidedTimeout); | ||
generateIFrame(prodDomain, null, null, token); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { generateIFrame } from './iframe-common'; | ||
import InjectedData from './models/InjectedData'; | ||
import getJwtNotProvidedTimeout from './utils/getJwtNotProvidedTimeout'; | ||
|
||
const stagingDomain = new InjectedData().getStagingDomain(); | ||
const jwtNotProvidedTimeout = getJwtNotProvidedTimeout(); | ||
|
||
window.initAnswersFrameJWT = function (token) { | ||
clearTimeout(jwtNotProvidedTimeout); | ||
generateIFrame(stagingDomain, null, null, token); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { generateIFrame } from './iframe-common'; | ||
import InjectedData from './models/InjectedData'; | ||
import getJwtNotProvidedTimeout from './utils/getJwtNotProvidedTimeout'; | ||
|
||
const domain = new InjectedData().getDomain(); | ||
const jwtNotProvidedTimeout = getJwtNotProvidedTimeout(); | ||
|
||
window.initAnswersFrameJWT = function (token) { | ||
clearTimeout(jwtNotProvidedTimeout); | ||
generateIFrame(domain, null, null, token); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default function getJwtNotProvidedTimeout () { | ||
return setTimeout(() => { | ||
console.warn( | ||
'A JWT has not been received within 5 seconds of page load, and "useJWT" is set to true.\n' + | ||
'Load the experience by calling initAnswersFrameJWT(token).' | ||
); | ||
}, 5000); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<html><head><meta name="viewport" content="initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no,width=device-width"></head><body><div id="answers-container"></div><script src="iframe-jwt.js"></script></body></html> |