nativescript-oauth2
Advanced tools
Comparing version 2.3.1 to 2.4.0
@@ -62,5 +62,5 @@ /// <reference path="./providers/providers.d.ts" /> | ||
urlScheme?: string, | ||
completion?: TnsOAuthClientLoginBlock | ||
completion?: TnsOAuthClientLogoutBlock | ||
); | ||
resumeWithUrl(url: string); | ||
} |
{ | ||
"name": "nativescript-oauth2", | ||
"version": "2.3.1", | ||
"version": "2.4.0", | ||
"description": "OAuth 2 generic authorization plugin for NativeScript that doesn't install third party native libraries", | ||
@@ -5,0 +5,0 @@ "main": "oauth", |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var TnsOAuthState = (function () { | ||
function TnsOAuthState(codeVerifier, loginCompletion, urlScheme) { | ||
function TnsOAuthState(codeVerifier, isLogout, loginCompletion, urlScheme) { | ||
this._loginCompletion = loginCompletion; | ||
this._codeVerifier = codeVerifier; | ||
this._urlScheme = urlScheme; | ||
this._isLogout = isLogout; | ||
} | ||
@@ -30,2 +31,9 @@ Object.defineProperty(TnsOAuthState.prototype, "loginCompletion", { | ||
}); | ||
Object.defineProperty(TnsOAuthState.prototype, "isLogout", { | ||
get: function () { | ||
return this._isLogout; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return TnsOAuthState; | ||
@@ -32,0 +40,0 @@ }()); |
@@ -22,3 +22,3 @@ "use strict"; | ||
} | ||
this.authState = new tns_oauth_auth_state_1.TnsOAuthState(this.client.codeVerifier, completion); | ||
this.authState = new tns_oauth_auth_state_1.TnsOAuthState(this.client.codeVerifier, false, completion); | ||
return tns_oauth_utils_1.getAuthUrlStr(this.client.provider, codeChallenge); | ||
@@ -32,3 +32,3 @@ }; | ||
} | ||
this.authState = new tns_oauth_auth_state_1.TnsOAuthState(this.client.codeVerifier, completion); | ||
this.authState = new tns_oauth_auth_state_1.TnsOAuthState(this.client.codeVerifier, true, completion); | ||
return tns_oauth_utils_1.getLogoutUrlStr(this.client.provider, this.client); | ||
@@ -38,7 +38,14 @@ }; | ||
if (this.authState) { | ||
var codeExchangeRequestUrl = this.codeExchangeRequestUrlFromRedirectUrl(url); | ||
if (codeExchangeRequestUrl) { | ||
this.codeExchangeWithUrlCompletion(codeExchangeRequestUrl, completion); | ||
if (this.authState.isLogout && url === this.client.provider.options.redirectUri) { | ||
this.client.logout(); | ||
completion(undefined); | ||
return true; | ||
} | ||
else { | ||
var codeExchangeRequestUrl = this.codeExchangeRequestUrlFromRedirectUrl(url); | ||
if (codeExchangeRequestUrl) { | ||
this.codeExchangeWithUrlCompletion(codeExchangeRequestUrl, completion); | ||
return true; | ||
} | ||
} | ||
} | ||
@@ -45,0 +52,0 @@ return false; |
83206
1381