AzureAD / azure-activedirectory-library-for-cordova

ADAL for Cordova
59 stars 111 forks source link

Exception thrown when merging exports.Clients from ADAL3Compat #175

Open FBNitro opened 6 years ago

FBNitro commented 6 years ago

Issue Description

Upgraded from 0.9.0 to 0.10.1, after doing so I started getting exceptions at startup on Windows 10 Desktop.

cordova.define("cordova-plugin-ms-adal.ADAL3Compat", function(require, exports, module) {
// Copyright (c) Microsoft Open Technologies, Inc.  All rights reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.
(function () {
    if (WinJS.Utilities.isPhone) {
        return;
    }

    exports.Clients = {
        // Microsoft.IdentityModel.Clients
        ActiveDirectory: {
                PromptBehavior: ADAL3WinMDProxy.PromptBehavior,
                UserIdentifier: ADAL3WinMDProxy.UserIdentifier,
                UserIdentifierType: ADAL3WinMDProxy.UserIdentifierType,
                AuthenticationContext: ADAL3WinMDProxy.AuthenticationContext
        }
    };

When the exports.Clients is merged it is throwing an exception: "JavaScript runtime error: Cannot redefine non-configurable property 'PromptBehavior'"

I can temporarily work around this by commenting out the exports.Clients block above, I'm just not sure of the side-effects yet.

Here is a callstack: image

Repro Environment Details

  1. Installed plugin version: 0.10.1
  2. Target Platform: Windows 10 (Desktop, not phone)
  3. Cordova and platform versions: 6.5.0 and Windows 4.4.2
  4. Test device and OS version: Windows 10 Desktop (no issues on Android/iOS)
  5. Are you using Cordova from command line or special Cordova IDE: Command line.
  6. If Windows related, please specify whether SSO option is enabled or not. - No
  7. [optional] Logs: set logger to get internal logs from SDK libraries (https://github.com/AzureAD/azure-activedirectory-library-for-cordova#logging)
FBNitro commented 6 years ago

Follow up: I upgraded to Cordova Windows 4.4.3 and that seems to have resolved the issue. So it appears that the minimum version for the plugin is not set correctly.

FBNitro commented 6 years ago

And now release builds in Windows don't work, but debug builds do (seems like a different issue, but to me it's all the same, I can't get this plugin to work after upgrading).