Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@supabase/gotrue-js

Package Overview
Dependencies
Maintainers
3
Versions
297
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@supabase/gotrue-js - npm Package Compare versions

Comparing version 1.5.4 to 1.5.5

3

dist/main/Client.d.ts

@@ -9,2 +9,3 @@ import Api from './Api';

persistSession: boolean;
localStorage: Storage;
stateChangeEmmitters: Map<string, Subscription>;

@@ -18,2 +19,3 @@ /**

* @param options.persistSession Set to "true" if you want to automatically save the user session into local storage.
* @param options.localStorage
*/

@@ -28,2 +30,3 @@ constructor(options: {

persistSession?: boolean;
localStorage?: Storage;
});

@@ -30,0 +33,0 @@ /**

63

dist/main/Client.js

@@ -23,2 +23,3 @@ "use strict";

persistSession: true,
localStorage: global.localStorage,
detectSessionInUrl: true,

@@ -35,2 +36,3 @@ headers: constants_1.DEFAULT_HEADERS,

* @param options.persistSession Set to "true" if you want to automatically save the user session into local storage.
* @param options.localStorage
*/

@@ -44,2 +46,3 @@ constructor(options) {

this.persistSession = settings.persistSession;
this.localStorage = new helpers_1.LocalStorage(settings.localStorage);
this.api = new Api_1.default({ url: settings.url, headers: settings.headers });

@@ -281,37 +284,41 @@ this._recoverSession();

const data = { currentSession, expiresAt };
helpers_1.isBrowser() && localStorage.setItem(constants_1.STORAGE_KEY, JSON.stringify(data));
helpers_1.isBrowser() && this.localStorage.setItem(constants_1.STORAGE_KEY, JSON.stringify(data));
}
_removeSession() {
this.currentSession = null;
this.currentUser = null;
helpers_1.isBrowser() && localStorage.removeItem(constants_1.STORAGE_KEY);
return __awaiter(this, void 0, void 0, function* () {
this.currentSession = null;
this.currentUser = null;
helpers_1.isBrowser() && (yield this.localStorage.removeItem(constants_1.STORAGE_KEY));
});
}
_recoverSession() {
const json = helpers_1.isBrowser() && localStorage.getItem(constants_1.STORAGE_KEY);
if (json) {
try {
const data = JSON.parse(json);
const { currentSession, expiresAt } = data;
const timeNow = Math.round(Date.now() / 1000);
if (expiresAt < timeNow) {
console.log('Saved session has expired.');
this._removeSession();
return __awaiter(this, void 0, void 0, function* () {
const json = helpers_1.isBrowser() && (yield this.localStorage.getItem(constants_1.STORAGE_KEY));
if (json) {
try {
const data = JSON.parse(json);
const { currentSession, expiresAt } = data;
const timeNow = Math.round(Date.now() / 1000);
if (expiresAt < timeNow) {
console.log('Saved session has expired.');
this._removeSession();
}
else if (!currentSession || !currentSession.user) {
console.log('Current session is missing data.');
this._removeSession();
}
else {
this.currentSession = currentSession;
this.currentUser = currentSession.user;
// schedule a refresh 60 seconds before token due to expire
setTimeout(this._callRefreshToken, (expiresAt - timeNow - 60) * 1000);
}
}
else if (!currentSession || !currentSession.user) {
console.log('Current session is missing data.');
this._removeSession();
catch (err) {
console.error(err);
return null;
}
else {
this.currentSession = currentSession;
this.currentUser = currentSession.user;
// schedule a refresh 60 seconds before token due to expire
setTimeout(this._callRefreshToken, (expiresAt - timeNow - 60) * 1000);
}
}
catch (err) {
console.error(err);
return null;
}
}
return null;
return null;
});
}

@@ -318,0 +325,0 @@ _callRefreshToken() {

export declare function uuid(): string;
export declare const isBrowser: () => boolean;
export declare function getParameterByName(name: string, url?: string): string | null;
export declare class LocalStorage implements Storage {
localStorage: Storage;
[name: string]: any;
length: number;
constructor(localStorage: Storage);
clear(): void;
key(index: number): string | null;
setItem(key: string, value: any): void;
getItem(key: string): string | null;
removeItem(key: string): void;
}
//# sourceMappingURL=helpers.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getParameterByName = exports.isBrowser = exports.uuid = void 0;
exports.LocalStorage = exports.getParameterByName = exports.isBrowser = exports.uuid = void 0;
function uuid() {

@@ -24,2 +24,23 @@ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {

exports.getParameterByName = getParameterByName;
class LocalStorage {
constructor(localStorage) {
this.localStorage = localStorage || global.localStorage;
}
clear() {
return this.localStorage.clear();
}
key(index) {
return this.localStorage.key(index);
}
setItem(key, value) {
return this.localStorage.setItem(key, value);
}
getItem(key) {
return this.localStorage.getItem(key);
}
removeItem(key) {
return this.localStorage.removeItem(key);
}
}
exports.LocalStorage = LocalStorage;
//# sourceMappingURL=helpers.js.map

@@ -9,2 +9,3 @@ import Api from './Api';

persistSession: boolean;
localStorage: Storage;
stateChangeEmmitters: Map<string, Subscription>;

@@ -18,2 +19,3 @@ /**

* @param options.persistSession Set to "true" if you want to automatically save the user session into local storage.
* @param options.localStorage
*/

@@ -28,2 +30,3 @@ constructor(options: {

persistSession?: boolean;
localStorage?: Storage;
});

@@ -30,0 +33,0 @@ /**

@@ -11,3 +11,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

import Api from './Api';
import { isBrowser, getParameterByName, uuid } from './lib/helpers';
import { isBrowser, getParameterByName, uuid, LocalStorage } from './lib/helpers';
import { GOTRUE_URL, DEFAULT_HEADERS, STORAGE_KEY } from './lib/constants';

@@ -19,2 +19,3 @@ import { AuthChangeEvent } from './lib/types';

persistSession: true,
localStorage: global.localStorage,
detectSessionInUrl: true,

@@ -31,2 +32,3 @@ headers: DEFAULT_HEADERS,

* @param options.persistSession Set to "true" if you want to automatically save the user session into local storage.
* @param options.localStorage
*/

@@ -40,2 +42,3 @@ constructor(options) {

this.persistSession = settings.persistSession;
this.localStorage = new LocalStorage(settings.localStorage);
this.api = new Api({ url: settings.url, headers: settings.headers });

@@ -277,37 +280,41 @@ this._recoverSession();

const data = { currentSession, expiresAt };
isBrowser() && localStorage.setItem(STORAGE_KEY, JSON.stringify(data));
isBrowser() && this.localStorage.setItem(STORAGE_KEY, JSON.stringify(data));
}
_removeSession() {
this.currentSession = null;
this.currentUser = null;
isBrowser() && localStorage.removeItem(STORAGE_KEY);
return __awaiter(this, void 0, void 0, function* () {
this.currentSession = null;
this.currentUser = null;
isBrowser() && (yield this.localStorage.removeItem(STORAGE_KEY));
});
}
_recoverSession() {
const json = isBrowser() && localStorage.getItem(STORAGE_KEY);
if (json) {
try {
const data = JSON.parse(json);
const { currentSession, expiresAt } = data;
const timeNow = Math.round(Date.now() / 1000);
if (expiresAt < timeNow) {
console.log('Saved session has expired.');
this._removeSession();
return __awaiter(this, void 0, void 0, function* () {
const json = isBrowser() && (yield this.localStorage.getItem(STORAGE_KEY));
if (json) {
try {
const data = JSON.parse(json);
const { currentSession, expiresAt } = data;
const timeNow = Math.round(Date.now() / 1000);
if (expiresAt < timeNow) {
console.log('Saved session has expired.');
this._removeSession();
}
else if (!currentSession || !currentSession.user) {
console.log('Current session is missing data.');
this._removeSession();
}
else {
this.currentSession = currentSession;
this.currentUser = currentSession.user;
// schedule a refresh 60 seconds before token due to expire
setTimeout(this._callRefreshToken, (expiresAt - timeNow - 60) * 1000);
}
}
else if (!currentSession || !currentSession.user) {
console.log('Current session is missing data.');
this._removeSession();
catch (err) {
console.error(err);
return null;
}
else {
this.currentSession = currentSession;
this.currentUser = currentSession.user;
// schedule a refresh 60 seconds before token due to expire
setTimeout(this._callRefreshToken, (expiresAt - timeNow - 60) * 1000);
}
}
catch (err) {
console.error(err);
return null;
}
}
return null;
return null;
});
}

@@ -314,0 +321,0 @@ _callRefreshToken() {

export declare function uuid(): string;
export declare const isBrowser: () => boolean;
export declare function getParameterByName(name: string, url?: string): string | null;
export declare class LocalStorage implements Storage {
localStorage: Storage;
[name: string]: any;
length: number;
constructor(localStorage: Storage);
clear(): void;
key(index: number): string | null;
setItem(key: string, value: any): void;
getItem(key: string): string | null;
removeItem(key: string): void;
}
//# sourceMappingURL=helpers.d.ts.map

@@ -19,2 +19,22 @@ export function uuid() {

}
export class LocalStorage {
constructor(localStorage) {
this.localStorage = localStorage || global.localStorage;
}
clear() {
return this.localStorage.clear();
}
key(index) {
return this.localStorage.key(index);
}
setItem(key, value) {
return this.localStorage.setItem(key, value);
}
getItem(key) {
return this.localStorage.getItem(key);
}
removeItem(key) {
return this.localStorage.removeItem(key);
}
}
//# sourceMappingURL=helpers.js.map
{
"name": "@supabase/gotrue-js",
"version": "1.5.4",
"version": "1.5.5",
"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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc