From 890129bfdabbb2c27d1e9c9796e1055f58eb4b3a Mon Sep 17 00:00:00 2001 From: ratnakar24 Date: Sat, 15 Sep 2018 14:09:41 +0530 Subject: [PATCH] fix(ms-adal): Update createAuthenticationContext (#2705) * Update createAuthenticationContext Update createAuthenticationContext to include validateAuthority flag since it is throwing Error: Fail to valid authority with errors: [50049]. Without the flag it is throwing Error: Fail to valid authority with errors: [50049]. * Update index.ts --- src/@ionic-native/plugins/ms-adal/index.ts | 42 +++++++++++++++------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/src/@ionic-native/plugins/ms-adal/index.ts b/src/@ionic-native/plugins/ms-adal/index.ts index ab0e55d88..3de6c2b66 100644 --- a/src/@ionic-native/plugins/ms-adal/index.ts +++ b/src/@ionic-native/plugins/ms-adal/index.ts @@ -1,8 +1,7 @@ -import { Plugin, IonicNativePlugin, checkAvailability, InstanceProperty, CordovaInstance } from '@ionic-native/core'; import { Injectable } from '@angular/core'; +import { checkAvailability, CordovaInstance, InstanceProperty, IonicNativePlugin, Plugin } from '@ionic-native/core'; export interface AuthenticationResult { - accessToken: string; accesSTokenType: string; expiresOn: Date; @@ -18,7 +17,6 @@ export interface AuthenticationResult { * @returns {String} The authorization header. */ createAuthorizationHeader(): string; - } export interface TokenCache { @@ -50,7 +48,6 @@ export interface UserInfo { uniqueId: string; } - /** * @name MS ADAL * @description @@ -96,22 +93,28 @@ export interface UserInfo { }) @Injectable() export class MSAdal extends IonicNativePlugin { - - createAuthenticationContext(authority: string, validateAuthority: boolean = true) { + createAuthenticationContext( + authority: string, + validateAuthority: boolean = true + ) { let authContext: any; - if (checkAvailability(MSAdal.getPluginRef(), null, MSAdal.getPluginName()) === true) { - authContext = new (MSAdal.getPlugin()).AuthenticationContext(authority); + if ( + checkAvailability(MSAdal.getPluginRef(), null, MSAdal.getPluginName()) === + true + ) { + authContext = new (MSAdal.getPlugin()).AuthenticationContext( + authority, + validateAuthority + ); } return new AuthenticationContext(authContext); } - } /** * @hidden */ export class AuthenticationContext { - @InstanceProperty authority: string; @@ -138,7 +141,15 @@ export class AuthenticationContext { @CordovaInstance({ otherPromise: true }) - acquireTokenAsync(resourceUrl: string, clientId: string, redirectUrl: string, userId?: string, extraQueryParameters?: any): Promise { return; } + acquireTokenAsync( + resourceUrl: string, + clientId: string, + redirectUrl: string, + userId?: string, + extraQueryParameters?: any + ): Promise { + return; + } /** * Acquires token WITHOUT using interactive flow. It checks the cache to return existing result @@ -153,6 +164,11 @@ export class AuthenticationContext { @CordovaInstance({ otherPromise: true }) - acquireTokenSilentAsync(resourceUrl: string, clientId: string, userId?: string): Promise { return; } - + acquireTokenSilentAsync( + resourceUrl: string, + clientId: string, + userId?: string + ): Promise { + return; + } }