Skip to content
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

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

shrshindeMSFT
Copy link
Contributor

For more information about how to contribute to this repo, visit this page.

Description

Summarize the changes, including the goals and reasons for this change. Be sure to call out any technical or behavior changes that reviewers should be aware of.

If this Pull Request should close/resolve any issues when merged, use the special syntax for that here.

Main changes in the PR:

  1. <Change 1>
  2. <Change 2>

Validation

Validation performed:

  1. <Step 1>
  2. <Step 2>

Unit Tests added:

Unit tests are required for all changes. If no unit tests were added as part of this change, please explain why they aren't necessary.

<Yes/No>

End-to-end tests added:

<Yes/No>

Additional Requirements

Change file added:

Ensure the change file meets the formatting requirements.

<Yes/No>

Related PRs:

Remove this section if n/a

Next/remaining steps:

List the next or remaining steps in implementing the overall feature in subsequent PRs (or is the feature 100% complete after this?).

Remove this section if n/a

  • Item 1
  • Item 2

Screenshots:

Remove this section if n/a

Before After
< image1 > < image2 >

@shrshindeMSFT shrshindeMSFT requested a review from a team as a code owner May 16, 2024 18:15
@shrshindeMSFT shrshindeMSFT marked this pull request as draft May 16, 2024 18:15
try {
setWindows(undefined);
Communication.parentOrigin = '*';
return sendMessageToParentAsync(apiVersionTag, 'getHostName', request);
Copy link
Contributor

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:

  1. Frameless (app is hosted inside something like a webview)
  2. 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?

Copy link
Contributor Author

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.

shrshindeMSFT and others added 11 commits May 17, 2024 11:47
)

* First pass at updated docs

* More doc updates

* More doc updates

* More doc updates

* More doc updates

* changefile

* Incorporate docs feedback
* 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 <trharris@microsoft.com>

* 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 <sum_nat1@yahoo.com>
Co-authored-by: sumathin <sunatara@microsoft.com>
Co-authored-by: Trevor Harris <trharris@microsoft.com>

* Exported Const Enum Backout (#2285)

* backed out all exported const enums

* Add release yaml (#2274)

* add sdf release yaml

---------

Co-authored-by: jadahiya-MSFT <95651173+jadahiya-MSFT@users.noreply.github.com>
Co-authored-by: Trevor Harris <trharris@microsoft.com>

* 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 <lakhveerkaur@microsoft.com>
Co-authored-by: Erin <erinha@microsoft.com>

* 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 ( ͡ಠ ʖ̯ ͡ಠ) <36546967+AE-MS@users.noreply.github.com>

* 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 ( ͡ಠ ʖ̯ ͡ಠ) <36546967+AE-MS@users.noreply.github.com>

* 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 ( ͡ಠ ʖ̯ ͡ಠ) <36546967+AE-MS@users.noreply.github.com>

* 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 <sthousto@microsoft.com_odspmdb>
Co-authored-by: Trevor Harris <trharris@microsoft.com>

* 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 ( ͡ಠ ʖ̯ ͡ಠ) <36546967+AE-MS@users.noreply.github.com>

* 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 <trharris@microsoft.com>

* 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 <trharris@microsoft.com>
Co-authored-by: Vikram Thanigaivelan <116702367+vikramtha@users.noreply.github.com>
Co-authored-by: Kerryn Frampton <56459261+kerrynf@users.noreply.github.com>
Co-authored-by: sumathin <sum_nat1@yahoo.com>
Co-authored-by: sumathin <sunatara@microsoft.com>
Co-authored-by: noahdarveau-MSFT <109628470+noahdarveau-MSFT@users.noreply.github.com>
Co-authored-by: Jeff Klouda <93734408+jekloudaMSFT@users.noreply.github.com>
Co-authored-by: jadahiya-MSFT <95651173+jadahiya-MSFT@users.noreply.github.com>
Co-authored-by: Shreyas <98348000+shrshindeMSFT@users.noreply.github.com>
Co-authored-by: ndangudubiyyam <90732984+ndangudubiyyam@users.noreply.github.com>
Co-authored-by: Lakhveer Kaur <lakhveerkaur@microsoft.com>
Co-authored-by: Erin <erinha@microsoft.com>
Co-authored-by: AE ( ͡ಠ ʖ̯ ͡ಠ) <36546967+AE-MS@users.noreply.github.com>
Co-authored-by: KangxuanYe <107154810+KangxuanYe@users.noreply.github.com>
Co-authored-by: Stephen Houston <5623311+cloudtx@users.noreply.github.com>
Co-authored-by: sthousto <sthousto@microsoft.com_odspmdb>
Co-authored-by: Ella-ly <85649572+Ella-ly@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants