Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions auth-helper-salesforce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class AuthHelperSalesforce extends AuthHelper implements TnsOAuth.ITnsAut
redirectUri: string,
responseType: string,
scope: Array<string>,
clientSecret?: string,
webviewSettingsIntercept?: (WebView) => void
) {
super();
var scopeStr = scope.join('%20');
Expand All @@ -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<void> {
Expand Down
3 changes: 2 additions & 1 deletion auth-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -13,7 +14,7 @@ export class AuthHelper {

public login(successPage?: string): Promise<string> {
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);
Expand Down
3 changes: 2 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions tns-oauth-interfaces.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,5 @@ export interface ITnsOAuthOptionsSalesforce extends ITnsOAuthOptions {
authority: string;
redirectUri: string;
responseType: string;
webviewSettingsIntercept: (WebView) => void;
}
5 changes: 4 additions & 1 deletion tns-oauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,14 @@ export function getTokenFromCache() {
return TnsOAuthTokenCache.getToken();
}

export function loginViaAuthorizationCodeFlow(credentials: TnsOAuthModule.ITnsOAuthCredentials, successPage?: string): Promise<TnsOAuthModule.ITnsOAuthTokenResult> {
export function loginViaAuthorizationCodeFlow(credentials: TnsOAuthModule.ITnsOAuthCredentials,
webviewSettingsIntercept?: (WebView) => void,
successPage?: string): Promise<TnsOAuthModule.ITnsOAuthTokenResult> {
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) {
Expand Down