OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
686 stars 95 forks source link

Cross-domain messageParent not working on Outlook for Mac desktop even when targetOrigin is set #2484

Closed jbindert closed 1 year ago

jbindert commented 2 years ago

Your Environment

Expected behavior

When setting the second argument in Office.context.ui.messageParent as { targetOrigin: "https://mydomain.com" } in my dialog, a DialogMessageReceived event should be triggered on the Add-in if it is hosted on https://mydomain.com.

Current behavior

The message gets posted in the web version of the Add-in as well as the Windows desktop version, but does not get posted to the Add-in when using the Mac desktop app.

Steps to reproduce

  1. From Add-in hosted at https://a.mydomain.com, open dialog (using Office.context.ui.displayDialogAsync) on Mac desktop version of Outlook Add in to page hosted on https://b.mydomain.com like so:
    Office.context.ui.displayDialogAsync('https://b.mydomain.com', { height: 50, width: 50 }, function (asyncResult) {
    dialog = asyncResult.value;
    dialog.addEventHandler(Office.EventType.DialogMessageReceived, function (dialogResult) {    
        // this function is never called    
        if (dialogResult) {
            var tokenInfo = JSON.parse(dialogResult.message);
            if (tokenInfo) {
                // etc
            }
        }
    });
    });
  2. From page hosted on https://b.mydomain.com, use the following code:
    Office.context.ui.messageParent(
            JSON.stringify({
              type: 'tokenData',
              token: 'tokengoeshere'
            }),
            {
              targetOrigin: 'https://a.mydomain.com'
            }
          )
  3. The function from step 1 that contains "this function is never called" is not executed.

Note again that this does work correctly on the web and Windows desktop apps.

Context

The issue exists in a pre-release version of our product, but if/when released, will prevent Outlook for Mac users from logging in to our Add-in whatsoever.

exextoc commented 2 years ago

Do you have the test add-in hosted anywhere? If so, could you provide us with the manifest so that we could get an in-house repro for this?

jbindert commented 2 years ago

Sure, see the attached zip file containing a manifest for a working example.

CrossDomainTest.zip

exextoc commented 2 years ago

With the manifest provided by you, the pop-up opens and closes. Could you please create a video while you reproduce the bug? This will help us understand the issue and debug it better.

jbindert commented 2 years ago

Sure, see attached - the popup stays open on the Mac desktop app still when testing

https://user-images.githubusercontent.com/11153496/159943272-11edbf21-2d26-42f4-adae-a7e6e2386255.mov

.

exextoc commented 2 years ago

Thanks for reporting this issue regarding the issue, and we are able to repro it. It has been put on our backlog. We, unfortunately, have no timelines to share at this point.

Internal tracking id: Eg: Office- 2684952

jasonleehodges commented 2 years ago

@exextoc Any update on this by chance? I think I'm running into the same issue on Mac desktop.

jipjan commented 2 years ago

Same issue here...

nbnataraj7 commented 2 years ago

@jbindert were you able to find any fix for this or any workaround? I am also facing a similar issue on Mac Desktop

ivankenig commented 2 years ago

Same issue here... We are on publishing of our addin written in angular and we have some critical validations. Among other things: Predictable Behavior 1120.3.7.3 Office for Mac

Your offer does not work in Office for Mac connected to an M365 subscription. OSx Version: Office Version.

Addin is not loading properly when launched.

  1. Launch outlook.
  2. Select any mail.
  3. Launch the addin.
  4. Issue is observed.

Update the offer to be fully functional in all required environments and resubmit your offer.

But this is a known issue for the Mac...Any workaround?

jbindert commented 2 years ago

@jbindert were you able to find any fix for this or any workaround? I am also facing a similar issue on Mac Desktop

Unfortunately not, still waiting to hear that this has been resolved.

ivankenig commented 2 years ago

What we have:


Office.context.ui.displayDialogAsync(`our-url-to...../auth-outlook.html`, { width: 30, height: 50 },
              (result) => {
                const dialog = result.value;
                const dialogClosed = async (args: any): Promise<void> => {
                  if (args['type'] === 'dialogMessageReceived' && args['message'] === 'completed') {
                    dialog.close();
                   // other things
                  }
                };
                dialog.addEventHandler(Office.EventType.DialogMessageReceived, dialogClosed);
              }
            );

auth-outlook.html site contents:

.......
<script>
      Office.initialize = function (reason) {
        $(document).ready(function () {
          document.location.href = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=CLIENT-ID&response_type=code&redirect_uri=https://OUR-CALLBACK-URL/auth-completed.html&response_mode=query&scope=https%3A%2F%2Fgraph.microsoft.com%2Fmail.read&prompt=consent";
        });
      }
    </script>
......

So auth-completed.html contents:

<script>
      Office.initialize = function (reason) {
        $(document).ready(function () {
          Office.context.ui.messageParent('completed');
        });
      }
    </script>

This works fine on all other platforms: Web outlook (in all browsers), outlook on Windows, but now on outlook on Mac...

There is a similar issue: https://github.com/OfficeDev/office-js/issues/378 solved by param _host_Info using angular Router from '@angular/router'...But we are not using router to build the URL

jbindert commented 1 year ago

@exextoc Any update on the fix for this?

exextoc commented 1 year ago

Hey @jbindert ,

We are following up internally over this issue, but we have no timelines to share for the same. We will keep this thread posted about any updates on this issue.

moshikonachmias commented 1 year ago

@exextoc Any update on the fix for this? Is there an alternative to targetOrigin that will work on Mac?

pbbr commented 1 year ago

@exextoc Same issue here. Any workarounds / alternatives for this issue?

Pixxiedust95 commented 1 year ago

Any news on this? Alternative to targetOrigin that operates on a Mac?

sonejakonciv commented 1 year ago

Hello , i am facing same issue in outlook addin for window desktop application. My addin is working absolutely fine on outlook web but its facing issue in window desktop application.

I am facing issue in authentication part. I am opening a iframe window using "displayDialogAsync" for authentication and its generating code which i need in parent window for generating access token. I am not able to pass that code from iframe window to parent window. I have tried using messageParent, window.postMessage , nothing is working in desktop application.

Anyone can help , please

jbindert commented 1 year ago

@exextoc Can you please provide an update to where this is at? We're at over a year and a half here that our Outlook Add-in is unusable for our Mac desktop app users, and based on the other comments in this task, I can see we aren't the only ones affected by this. Please let us know when you expect to fix this.

exextoc commented 1 year ago

This issue is fixed, and fix is available in version 16.75(23070200) or later.

jbindert commented 1 year ago

@exextoc Just to confirm, you're saying that if I upgrade the Outlook for Mac desktop app to 16.78.2, the latest version as of this date, the issue should be resolved?

hello-chenchen commented 2 days ago

hi @exextoc @jbindert , i still have the same issue in Mac Outlook Version 16.90.3 (24110120). my case is the pop up dialog domain is a.mydomain.com, the main receive domain is mydomain.com. but when a.mydomain.com send message to mydomain.com by Office.context.ui.messageParent('111222', { targetOrigin: '*' }), it's not available.