-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Runtime config and JWT support #843
Merged
Merged
Conversation
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
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.
Remove the apiKey from the build output when useJWT=true The apiKey needs to be removed in the templatedataformatter and in the JAMBO_INJECTED_DATA that weback puts in the bundles. J=J=SLAP-1118 TEST=manual, auto When useJWT is true, run a build and search for the apiKey and confirm that it does not appear anywhere in the build output. Test this with JAMBO_INJECTED_DATA which contains apiKeys. Smoke test the JWT integration and the standard integration. Add unit test.
Support runtime config and update the JWT support to use it This PR allows the parent to set arbitrary config for iframed Answers experiences with the `setRuntimeConfig` function. Data attributes on the '#answers-container' div are also loaded into the RuntimeConfig when the iframe is created. Inside the experience, the runtime config is available at the `RuntimeConfig` object on the window. The experience can be setup to allow be manually initialized rather than initialized automatically . To do this, the hitchhiker must set `"manuallyInitialize": true` inside global_config. With that option enabled, the experience must be started with `initAnswersExperienceFrame(config)` for iframe experiences or with `initAnswersExperience(config)` for non-iframe experiences. The manual initialization also allows the experience to be started with a JWT token. To use JWT, 'initializeManually' and 'useJWT' should be set in global_config. The 'useJWT' option simply ensures that any api key that may have been injected does not appear anywhere in the build output. The experience can then be started with `initAnswersExperienceFrame({ token: 'jwt-token-here' });` or with `initAnswersExperience({ token: 'jwt-token-here' });` for non-iframe experiences. J=SLAP-1315 TEST=manual Test JWT support with iframe and non-iframe experiences. Test supplying custom config and seeing it available within the iframe. Note that the config is set even before the cards render with initial searches set. Test navigating pages within the iframe and seeing the config maintained. Set data attributes and see them get set within the iframe.
Update the public interface of the runtime config in accordance with the product spec - All new functionality on the window is namespaced to AnswersExperience or AnswersExperienceFrame for iframe integrations - These namespaces each have an init function and a runtime config object - The runtime config object has public set get, and a getAll methods - The 'initAnswersExperience' boolean has been moved out the runtime config. This change lead me to create the iframe message queue to prevent messages from being sent and lost before the iframe has initialized - I also removed the lastUpdated logic. It was created for an older design where the entire runtime config object was being updated at once, but it's no longer necessary since the runtime config is now updated one key value pair at a time. - Remove the data attributes feature since we currently can't guarantee the run config will be set by the time answers initializes J=SLAP-1362 TEST=manual On both iframe and non-iframe experiences test initializing the experience with custom config. Test using the runtime config data models. Test that calling set on the parent runtime config will update the runtime config within the iframe. Test initialization with JWT.
Use link targets from runtime config, and default to "_top" if it is not specified Update all targets which include card title links, CTAS, phone links, RTF links, and direct answer links J=SLAP-1349 TEST=manual Load the test site, change the runtime config link target and see different link target behavior. Test title links, CTAs, phone links, RTF links, and direct answer links
Ensure that the page initializes upon page navigation when initializeManually=true This functionality broke during a recent re-factor when I moved the initAnswersExperience boolean out of the runtimeConfig and into the top-level of the message. Since this data was previously inside the runtimeConfig, it would persist and the experience would receive the message to re-initialize during page navigation. After moving that data outside of the runtimeConfig, the page would no longer receive that message and would fail to re-initialize. To fix this, I ensure that the parent indicates to the iframe that it needs to re-initialize. J=none TEST=manual Load an iframe test site with manuallyInitialize=true, and call the init function. See that the experience now initializes when navigating verticals within the iframe.
…842) Resolve conflicts to allow feature/jwt-support to merge into develop
Merged
cea2aj
added a commit
that referenced
this pull request
Jun 23, 2021
## Version 1.22.0 ### Changes - Code coverage reports are now generated automatically for the Theme. (#759) - A number of dependencies were updated in accordance with Dependabot's suggestions. (#780) - The build time in `Development` mode was reduced significantly. (#782, #829) Build times in `Production` mode were also decreased. (#783, #825) - Two new cards supporting videos were added: `product-prominentvideo` and `multilang-product-prominentvideo`. These cards work with either YouTube or Vimeo content. (#794) - The process for formatting hours was made more efficient, resulting in faster renders for cards with hours. (#784) - Any SDK branch can now be specified in the `global_config.sdkVersion` attribute. (#791) - Unused CSS was removed from the Theme. (#793, #798) - To reduce flashing related to the SDK Component lifecycle, placeholder skeletons were added for the `SearchBar` and `Navigation` components. (#797) - Additional acceptance tests were added for the `VerticalFullPageMap` and Percy snapshots are now generated for all cards. (#830, #820) - Multi-language tests were added for the Theme. (#826) - The `documentsearch-standard` card now supports rich text featured snippets. (#838) - A new concept, `RuntimeConfig` was added. This allows configuration, computed at run-time, to be injected into the Theme and SDK. This new concept enables JWT integrations as well. (#843) ### Bug Fixes - A number of changes were made to make the Theme's visual regression tests more reliable. (#764, #765, #766, #778) - Corrected how the CTA URLs for the `menuitem-standard` and `multilang-menuitem-standard` cards are computed. (#787) - The Google Streetview person icon is now visible when using the `VerticalFullPageMap` layout. (#801) - The size of the cluster and result pins are now configurable. (#807) - A double encoding error for `verticalUrl` was fixed. (#836) - The `Opens At` open status message is now properly translated in all languages. (#834)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add Runtime Config and JWT support