diff --git a/auth-helper-salesforce.ts b/auth-helper-salesforce.ts index 6cf3bd1..17a5478 100644 --- a/auth-helper-salesforce.ts +++ b/auth-helper-salesforce.ts @@ -18,7 +18,7 @@ export class AuthHelperSalesforce extends AuthHelper implements TnsOAuth.ITnsAut redirectUri: string, responseType: string, scope: Array, - clientSecret?: string, + webviewSettingsIntercept?: (WebView) => void ) { super(); var scopeStr = scope.join('%20'); @@ -28,11 +28,11 @@ export class AuthHelperSalesforce extends AuthHelper implements TnsOAuth.ITnsAut tokenEndpoint: '/services/oauth2/token', revokeEndpoint: '/services/oauth2/revoke', clientId: clientId, - clientSecret: clientSecret, redirectUri: redirectUri, responseType: responseType, scope: scopeStr }; + this._webviewSettingsIntercept = webviewSettingsIntercept; } //Gets cookie domains for logging out public logout(): Promise { diff --git a/auth-helper.ts b/auth-helper.ts index 2c513d3..239accf 100644 --- a/auth-helper.ts +++ b/auth-helper.ts @@ -4,6 +4,7 @@ import * as tnsOauth from './tns-oauth'; import * as TnsOAuth from './tns-oauth-interfaces'; export class AuthHelper { + protected _webviewSettingsIntercept: (WebView) => void; public credentials: TnsOAuth.ITnsOAuthCredentials; public tokenResult: TnsOAuth.ITnsOAuthTokenResult; @@ -13,7 +14,7 @@ export class AuthHelper { public login(successPage?: string): Promise { return new Promise((resolve, reject) => { - tnsOauth.loginViaAuthorizationCodeFlow(this.credentials, successPage) + tnsOauth.loginViaAuthorizationCodeFlow(this.credentials, this._webviewSettingsIntercept, successPage) .then((response: TnsOAuth.ITnsOAuthTokenResult) => { this.tokenResult = response; resolve(response.accessToken); diff --git a/index.ts b/index.ts index 06b48a5..8874822 100644 --- a/index.ts +++ b/index.ts @@ -115,7 +115,8 @@ export function initSalesforce(options: TnsOAuth.ITnsOAuthOptionsSalesforce): Pr options.clientId, options.redirectUri, options.responseType, - options.scope + options.scope, + options.webviewSettingsIntercept ); resolve(instance); } catch (ex) { diff --git a/tns-oauth-interfaces.d.ts b/tns-oauth-interfaces.d.ts index 3175248..5882e39 100644 --- a/tns-oauth-interfaces.d.ts +++ b/tns-oauth-interfaces.d.ts @@ -67,4 +67,5 @@ export interface ITnsOAuthOptionsSalesforce extends ITnsOAuthOptions { authority: string; redirectUri: string; responseType: string; + webviewSettingsIntercept: (WebView) => void; } diff --git a/tns-oauth.ts b/tns-oauth.ts index 2ab7a75..384e8e9 100644 --- a/tns-oauth.ts +++ b/tns-oauth.ts @@ -101,11 +101,14 @@ export function getTokenFromCache() { return TnsOAuthTokenCache.getToken(); } -export function loginViaAuthorizationCodeFlow(credentials: TnsOAuthModule.ITnsOAuthCredentials, successPage?: string): Promise { +export function loginViaAuthorizationCodeFlow(credentials: TnsOAuthModule.ITnsOAuthCredentials, + webviewSettingsIntercept?: (WebView) => void, + successPage?: string): Promise { return new Promise((resolve, reject) => { var navCount = 0; let checkCodeIntercept = (webView, error, url): boolean => { + webviewSettingsIntercept(webView); var retStr = ''; try { if (error && error.userInfo && error.userInfo.allValues && error.userInfo.allValues.count > 0) {