@supabase/gotrue-js
Advanced tools
Comparing version 1.9.1 to 1.9.2
@@ -316,4 +316,15 @@ "use strict"; | ||
if (expiresAt < timeNow) { | ||
console.log('Saved session has expired.'); | ||
this._removeSession(); | ||
if (this.autoRefreshToken && currentSession.refresh_token) { | ||
const { error } = yield this._callRefreshToken(currentSession.refresh_token); | ||
if (error) { | ||
console.log(error.message); | ||
yield this._removeSession(); | ||
} | ||
else { | ||
this._notifyAllSubscribers('SIGNED_IN'); | ||
} | ||
} | ||
else { | ||
this._removeSession(); | ||
} | ||
} | ||
@@ -340,12 +351,13 @@ else if (!currentSession || !currentSession.user) { | ||
} | ||
_callRefreshToken() { | ||
var _a, _b; | ||
_callRefreshToken(refresh_token) { | ||
var _a; | ||
if (refresh_token === void 0) { refresh_token = (_a = this.currentSession) === null || _a === void 0 ? void 0 : _a.refresh_token; } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
if ((_a = this.currentSession) === null || _a === void 0 ? void 0 : _a.refresh_token) { | ||
let data = yield this.api.refreshAccessToken((_b = this.currentSession) === null || _b === void 0 ? void 0 : _b.refresh_token); | ||
if (refresh_token) { | ||
const { data, error } = yield this.api.refreshAccessToken(refresh_token); | ||
if (data === null || data === void 0 ? void 0 : data.access_token) { | ||
this.currentSession.access_token = data.body['access_token']; | ||
this.currentSession.refresh_token = data.body['refresh_token']; | ||
let tokenExpirySeconds = data.body['expires_in']; | ||
this.currentSession = data; | ||
this.currentUser = this.currentSession.user; | ||
const tokenExpirySeconds = data.expires_in; | ||
if (this.autoRefreshToken && tokenExpirySeconds) { | ||
@@ -358,4 +370,10 @@ setTimeout(this._callRefreshToken, (tokenExpirySeconds - 60) * 1000); | ||
} | ||
else { | ||
throw error; | ||
} | ||
return { data, error: null }; | ||
} | ||
else { | ||
throw new Error('No current session.'); | ||
} | ||
} | ||
@@ -362,0 +380,0 @@ catch (error) { |
@@ -311,4 +311,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
if (expiresAt < timeNow) { | ||
console.log('Saved session has expired.'); | ||
this._removeSession(); | ||
if (this.autoRefreshToken && currentSession.refresh_token) { | ||
const { error } = yield this._callRefreshToken(currentSession.refresh_token); | ||
if (error) { | ||
console.log(error.message); | ||
yield this._removeSession(); | ||
} | ||
else { | ||
this._notifyAllSubscribers('SIGNED_IN'); | ||
} | ||
} | ||
else { | ||
this._removeSession(); | ||
} | ||
} | ||
@@ -335,12 +346,13 @@ else if (!currentSession || !currentSession.user) { | ||
} | ||
_callRefreshToken() { | ||
var _a, _b; | ||
_callRefreshToken(refresh_token) { | ||
var _a; | ||
if (refresh_token === void 0) { refresh_token = (_a = this.currentSession) === null || _a === void 0 ? void 0 : _a.refresh_token; } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
if ((_a = this.currentSession) === null || _a === void 0 ? void 0 : _a.refresh_token) { | ||
let data = yield this.api.refreshAccessToken((_b = this.currentSession) === null || _b === void 0 ? void 0 : _b.refresh_token); | ||
if (refresh_token) { | ||
const { data, error } = yield this.api.refreshAccessToken(refresh_token); | ||
if (data === null || data === void 0 ? void 0 : data.access_token) { | ||
this.currentSession.access_token = data.body['access_token']; | ||
this.currentSession.refresh_token = data.body['refresh_token']; | ||
let tokenExpirySeconds = data.body['expires_in']; | ||
this.currentSession = data; | ||
this.currentUser = this.currentSession.user; | ||
const tokenExpirySeconds = data.expires_in; | ||
if (this.autoRefreshToken && tokenExpirySeconds) { | ||
@@ -353,4 +365,10 @@ setTimeout(this._callRefreshToken, (tokenExpirySeconds - 60) * 1000); | ||
} | ||
else { | ||
throw error; | ||
} | ||
return { data, error: null }; | ||
} | ||
else { | ||
throw new Error('No current session.'); | ||
} | ||
} | ||
@@ -357,0 +375,0 @@ catch (error) { |
{ | ||
"name": "@supabase/gotrue-js", | ||
"version": "1.9.1", | ||
"version": "1.9.2", | ||
"description": "Isomorphic GoTrue client", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
132101
2039