-
Notifications
You must be signed in to change notification settings - Fork 195
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
[Don't review yet] Access hostname for app's #2328
base: main
Are you sure you want to change the base?
Conversation
try { | ||
setWindows(undefined); | ||
Communication.parentOrigin = '*'; | ||
return sendMessageToParentAsync(apiVersionTag, 'getHostName', request); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at how this function is called in app.ts
, it looks in some cases the app won't be initialized yet when you hit this line. Can I call like this actually work before the app is initialized? I think it wouldn't but maybe I'm forgetting/missing something. I think if there's no host to send it to the message will just sit forever and never receive a response.
If I assume that this won't work before initialize
then I think this approach will have some problems. setWindows
will not throw an error right now if the app is hosted in an iframe that isn't the hub-sdk for example.
I wonder if a slightly different approach could work. There are two different configurations TeamsJS can be in if the app that is using it is being hosted:
- Frameless (app is hosted inside something like a webview)
- Framed (app is hosted in an iframe).
For case 1, I think you could check if that one is the case relatively easily: if the current window is an ExtendedWindow
that has nativeInterface
defined on it, we can assume that the app is probably hosted by a host that is using a webview. Theoretically, someone that is not an official host could be running the app in a webview, but if they are it is unlikely that they have set up the WebView this way. See lines 104-107
For case 2 it is probably trickier. One thing you might be able to do is look at the domain that window.top
is running at and then compare that domain to the list of validOrigins from the CDN. We may want to let the app developer pass in an additional set of "valid" host origins to check for in addition to the CDN list (the same list of valid origins they can pass to initialize).
If either of the cases above are true, we can tell the developer that they are probably being hosted by a host that will respond to their initialize call. We still might sometimes get it wrong, but in the worst case app developers will still be doing the same thing they are now: calling initialize and waiting for it to timeout.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at how this function is called in app.ts, it looks in some cases the app won't be initialized yet when you hit this line. Can I call like this actually work before the app is initialized? I think it wouldn't but maybe I'm forgetting/missing something. I think if there's no host to send it to the message will just sit forever and never receive a response.
When the app is not hosted the set windows will throw error Initialization failed. ...
and we can catch that error and tell the developer that app is not hosted. In app.ts
we check if GlobalVars.isInitializeCompleted
then use sendAndMessageToParentAsync
as this will straight give the host name. For the second part where the app is not initialized setWindows
sets the windows for communication and if it doesn't find any then it just throws error, if it finds the top window we send the message which will be handled by the hubSDK.
* Publish xctest result for screenshots * update * update * update * update * update * update * update * update * update * update * add attempts * update * update yml file to use original junit file path * update copy file process * generate test result in original places * copy testResults * fix yaml file indent error * add generating xchtmlreport process for published artifacts * remove useless task * update:
* Add url search parameters for insecure e2e testing * Update * Update
… team recommendation (#2335) * Update 2.0.0 version references in docs to be TeamsJS v2.0.0 * Changefile
* Add react router for navigation testing * Removing beta tag - Vikramtha/update pages current app (#2283) * Removed beta tage on Pages.currentApp namespace and APIs * Added changefile * Update change/@microsoft-teams-js-51421b73-089f-43de-9076-75563e1f064c.json --------- Co-authored-by: Trevor Harris <[email protected]> * Private MessageChannels: split capability and add dataLayer.getDataLayerPort (#2277) Update Message Channel capability to support sub capabilities, add data layer capability with getDataLayerPort --------- Co-authored-by: sumathin <[email protected]> Co-authored-by: sumathin <[email protected]> Co-authored-by: Trevor Harris <[email protected]> * Exported Const Enum Backout (#2285) * backed out all exported const enums * Add release yaml (#2274) * add sdf release yaml --------- Co-authored-by: jadahiya-MSFT <[email protected]> Co-authored-by: Trevor Harris <[email protected]> * Add description for pop-up auth window. (#2291) * Update comment * Update changefile * Adding API to support external app authenticate with Power Platform Connector Plugins (#2272) * Adding PPC auth * Adding PPCauth UTs * adding change file * Resolving comments * Resolving comments * Modify hasScriptTags function to handle encoded Input * Modify hasScriptTags function to handle encoded Input * updating default input * Modify hasScriptTags function to handle encoded Input * adding telemetry tag for ppc auth * Removing pluginId and adding unit tests * Changing url to string before passign to psotmessage * Removing regualr expression for html entities * Removing regualr expression for html entities * Modifying comments * Modifying comments * Resolving comments * Resolving comments --------- Co-authored-by: Lakhveer Kaur <[email protected]> Co-authored-by: Erin <[email protected]> * Turn webStorage capability into a "real" capability (#2289) * Webstorage becomes capability * Update webstorage in test app * Update webstorage test json * Add changefile * Test updates * Test updates * Final test updates * Helpful util * Empty json test file * Send `validMessageOrigins` to `parentWindow` for verification. (#2293) * Update webStorage.json to not be blank, but almost blank (#2294) * Not blank, but almost blank * Updated * Add webstorage E2E tests (#2295) * Publish android artifacts (#2284) * Publish android artifacts * Use 1ES publishing steps * task names * Use updated artifact location * Add job attempt * Cleanup configuration files (#2296) * Added in new valid domains for Copilot Chat (#2287) * Added in new valid domains for Copilot Chat * Added in changefile --------- Co-authored-by: AE ( ͡ಠ ʖ̯ ͡ಠ) <[email protected]> * Trharris/authenticate https (#2270) * Restrict authentication.authenticate to only accept https urls * Create @microsoft-teams-js-40968a44-8220-4162-a289-038e99f5bee3.json * Updated based on PR feedback * Updated to use new validation functions and added(?) support for URL encoded strings * abstract out the auth code's use of the a tag and then add tests to make sure URL encoded partial urls work correctly * Re-order imports * Updated based on PR feedback --------- Co-authored-by: AE ( ͡ಠ ʖ̯ ͡ಠ) <[email protected]> * Fixed incorrect API telemetry label for Pages_NavigateToApp API (#2299) * Fix incorrect API telemetry label for Pages_NavigateToApp API * update * Update @microsoft-teams-js-d2040181-a9a1-42d2-9080-35acb3a380cd.json --------- Co-authored-by: AE ( ͡ಠ ʖ̯ ͡ಠ) <[email protected]> * Update sdf-release.yml for Azure Pipelines (#2292) * Update sdf-release.yml for Azure Pipelines * Update sdf-release.yml for Azure Pipelines * Update custom API test (#2282) Co-authored-by: sthousto <[email protected]_odspmdb> Co-authored-by: Trevor Harris <[email protected]> * Upgrade `pnpm` to v9 (#2301) * Initial commit * Update ci * Update ci * remove deprecated sub dependencies * Specify exact version in ci * Update .npmrc location in release helper scripts (#2303) * Update .npmrc location * Changefile * Update @microsoft-teams-js-b63da2d9-3e02-4b83-9664-78aa8f49c713.json * use new scripts for onebranch pipelines --------- Co-authored-by: AE ( ͡ಠ ʖ̯ ͡ಠ) <[email protected]> * Update the SDF release yaml (#2308) * Use inline scripts * Exclude _manifest artifact from version * Whitespace * Removed importing from the entire public index.ts file (#2307) * cleaned up some imports in the private folder --------- Co-authored-by: Trevor Harris <[email protected]> * Updated and e2e tests data in teams-js (#2311) * Add production pipeline YAML (#2310) * add prod pipeline * restrict branches for prod pipeline * add DDL pipeline * update routes to properly describe the new page * Revert "update routes to properly describe the new page" This reverts commit 7d8a421. * Revert "Revert "update routes to properly describe the new page"" This reverts commit 53cf983. --------- Co-authored-by: Trevor Harris <[email protected]> Co-authored-by: Vikram Thanigaivelan <[email protected]> Co-authored-by: Kerryn Frampton <[email protected]> Co-authored-by: sumathin <[email protected]> Co-authored-by: sumathin <[email protected]> Co-authored-by: noahdarveau-MSFT <[email protected]> Co-authored-by: Jeff Klouda <[email protected]> Co-authored-by: jadahiya-MSFT <[email protected]> Co-authored-by: Shreyas <[email protected]> Co-authored-by: ndangudubiyyam <[email protected]> Co-authored-by: Lakhveer Kaur <[email protected]> Co-authored-by: Erin <[email protected]> Co-authored-by: AE ( ͡ಠ ʖ̯ ͡ಠ) <[email protected]> Co-authored-by: KangxuanYe <[email protected]> Co-authored-by: Stephen Houston <[email protected]> Co-authored-by: sthousto <[email protected]_odspmdb> Co-authored-by: Ella-ly <[email protected]>
For more information about how to contribute to this repo, visit this page.
Description
Main changes in the PR:
Validation
Validation performed:
Unit Tests added:
<Yes/No>
End-to-end tests added:
<Yes/No>
Additional Requirements
Change file added:
<Yes/No>
Related PRs:
Next/remaining steps:
Screenshots: