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

@supabase/auth-js

Package Overview
Dependencies
Maintainers
12
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@supabase/auth-js - npm Package Compare versions

Comparing version 2.65.2-rc.2 to 2.66.0-rc.3

17

dist/main/lib/locks.d.ts

@@ -21,2 +21,4 @@ /**

}
export declare class ProcessLockAcquireTimeoutError extends LockAcquireTimeoutError {
}
/**

@@ -48,2 +50,17 @@ * Implements a global exclusive lock using the Navigator LockManager API. It

export declare function navigatorLock<R>(name: string, acquireTimeout: number, fn: () => Promise<R>): Promise<R>;
/**
* Implements a global exclusive lock that works only in the current process.
* Useful for environments like React Native or other non-browser
* single-process (i.e. no concept of "tabs") environments.
*
* Use {@link #navigatorLock} in browser environments.
*
* @param name Name of the lock to be acquired.
* @param acquireTimeout If negative, no timeout. If 0 an error is thrown if
* the lock can't be acquired without waiting. If positive, the lock acquire
* will time out after so many milliseconds. An error is
* a timeout if it has `isAcquireTimeout` set to true.
* @param fn The operation to run once the lock is acquired.
*/
export declare function processLock<R>(name: string, acquireTimeout: number, fn: () => Promise<R>): Promise<R>;
//# sourceMappingURL=locks.d.ts.map

61

dist/main/lib/locks.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.navigatorLock = exports.NavigatorLockAcquireTimeoutError = exports.LockAcquireTimeoutError = exports.internals = void 0;
exports.processLock = exports.navigatorLock = exports.ProcessLockAcquireTimeoutError = exports.NavigatorLockAcquireTimeoutError = exports.LockAcquireTimeoutError = exports.internals = void 0;
const helpers_1 = require("./helpers");

@@ -32,2 +32,5 @@ /**

exports.NavigatorLockAcquireTimeoutError = NavigatorLockAcquireTimeoutError;
class ProcessLockAcquireTimeoutError extends LockAcquireTimeoutError {
}
exports.ProcessLockAcquireTimeoutError = ProcessLockAcquireTimeoutError;
/**

@@ -122,2 +125,58 @@ * Implements a global exclusive lock using the Navigator LockManager API. It

exports.navigatorLock = navigatorLock;
const PROCESS_LOCKS = {};
/**
* Implements a global exclusive lock that works only in the current process.
* Useful for environments like React Native or other non-browser
* single-process (i.e. no concept of "tabs") environments.
*
* Use {@link #navigatorLock} in browser environments.
*
* @param name Name of the lock to be acquired.
* @param acquireTimeout If negative, no timeout. If 0 an error is thrown if
* the lock can't be acquired without waiting. If positive, the lock acquire
* will time out after so many milliseconds. An error is
* a timeout if it has `isAcquireTimeout` set to true.
* @param fn The operation to run once the lock is acquired.
*/
async function processLock(name, acquireTimeout, fn) {
var _a;
const previousOperation = (_a = PROCESS_LOCKS[name]) !== null && _a !== void 0 ? _a : Promise.resolve();
const currentOperation = Promise.race([
previousOperation.catch((e) => {
// ignore error of previous operation that we're waiting to finish
return null;
}),
acquireTimeout >= 0
? new Promise((_, reject) => {
setTimeout(() => {
reject(new ProcessLockAcquireTimeoutError(`Acquring process lock with name "${name}" timed out`));
}, acquireTimeout);
})
: null,
].filter((x) => x))
.catch((e) => {
if (e && e.isAcquireTimeout) {
throw e;
}
return null;
})
.then(async () => {
// previous operations finished and we didn't get a race on the acquire
// timeout, so the current operation can finally start
return await fn();
});
PROCESS_LOCKS[name] = currentOperation.catch(async (e) => {
if (e && e.isAcquireTimeout) {
// if the current operation timed out, it doesn't mean that the previous
// operation finished, so we need contnue waiting for it to finish
await previousOperation;
return null;
}
throw e;
});
// finally wait for the current operation to finish successfully, with an
// error or with an acquire timeout error
return await currentOperation;
}
exports.processLock = processLock;
//# sourceMappingURL=locks.js.map

2

dist/main/lib/version.d.ts

@@ -1,2 +0,2 @@

export declare const version = "2.65.2-rc.2";
export declare const version = "2.66.0-rc.3";
//# sourceMappingURL=version.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = void 0;
exports.version = '2.65.2-rc.2';
exports.version = '2.66.0-rc.3';
//# sourceMappingURL=version.js.map

@@ -21,2 +21,4 @@ /**

}
export declare class ProcessLockAcquireTimeoutError extends LockAcquireTimeoutError {
}
/**

@@ -48,2 +50,17 @@ * Implements a global exclusive lock using the Navigator LockManager API. It

export declare function navigatorLock<R>(name: string, acquireTimeout: number, fn: () => Promise<R>): Promise<R>;
/**
* Implements a global exclusive lock that works only in the current process.
* Useful for environments like React Native or other non-browser
* single-process (i.e. no concept of "tabs") environments.
*
* Use {@link #navigatorLock} in browser environments.
*
* @param name Name of the lock to be acquired.
* @param acquireTimeout If negative, no timeout. If 0 an error is thrown if
* the lock can't be acquired without waiting. If positive, the lock acquire
* will time out after so many milliseconds. An error is
* a timeout if it has `isAcquireTimeout` set to true.
* @param fn The operation to run once the lock is acquired.
*/
export declare function processLock<R>(name: string, acquireTimeout: number, fn: () => Promise<R>): Promise<R>;
//# sourceMappingURL=locks.d.ts.map

@@ -27,2 +27,4 @@ import { supportsLocalStorage } from './helpers';

}
export class ProcessLockAcquireTimeoutError extends LockAcquireTimeoutError {
}
/**

@@ -116,2 +118,57 @@ * Implements a global exclusive lock using the Navigator LockManager API. It

}
const PROCESS_LOCKS = {};
/**
* Implements a global exclusive lock that works only in the current process.
* Useful for environments like React Native or other non-browser
* single-process (i.e. no concept of "tabs") environments.
*
* Use {@link #navigatorLock} in browser environments.
*
* @param name Name of the lock to be acquired.
* @param acquireTimeout If negative, no timeout. If 0 an error is thrown if
* the lock can't be acquired without waiting. If positive, the lock acquire
* will time out after so many milliseconds. An error is
* a timeout if it has `isAcquireTimeout` set to true.
* @param fn The operation to run once the lock is acquired.
*/
export async function processLock(name, acquireTimeout, fn) {
var _a;
const previousOperation = (_a = PROCESS_LOCKS[name]) !== null && _a !== void 0 ? _a : Promise.resolve();
const currentOperation = Promise.race([
previousOperation.catch((e) => {
// ignore error of previous operation that we're waiting to finish
return null;
}),
acquireTimeout >= 0
? new Promise((_, reject) => {
setTimeout(() => {
reject(new ProcessLockAcquireTimeoutError(`Acquring process lock with name "${name}" timed out`));
}, acquireTimeout);
})
: null,
].filter((x) => x))
.catch((e) => {
if (e && e.isAcquireTimeout) {
throw e;
}
return null;
})
.then(async () => {
// previous operations finished and we didn't get a race on the acquire
// timeout, so the current operation can finally start
return await fn();
});
PROCESS_LOCKS[name] = currentOperation.catch(async (e) => {
if (e && e.isAcquireTimeout) {
// if the current operation timed out, it doesn't mean that the previous
// operation finished, so we need contnue waiting for it to finish
await previousOperation;
return null;
}
throw e;
});
// finally wait for the current operation to finish successfully, with an
// error or with an acquire timeout error
return await currentOperation;
}
//# sourceMappingURL=locks.js.map

@@ -1,2 +0,2 @@

export declare const version = "2.65.2-rc.2";
export declare const version = "2.66.0-rc.3";
//# sourceMappingURL=version.d.ts.map

@@ -1,2 +0,2 @@

export const version = '2.65.2-rc.2';
export const version = '2.66.0-rc.3';
//# sourceMappingURL=version.js.map
{
"name": "@supabase/auth-js",
"version": "2.65.2-rc.2",
"version": "2.66.0-rc.3",
"private": false,

@@ -5,0 +5,0 @@ "description": "Official client library for Supabase Auth",

@@ -32,2 +32,3 @@ import { supportsLocalStorage } from './helpers'

export class NavigatorLockAcquireTimeoutError extends LockAcquireTimeoutError {}
export class ProcessLockAcquireTimeoutError extends LockAcquireTimeoutError {}

@@ -145,1 +146,73 @@ /**

}
const PROCESS_LOCKS: { [name: string]: Promise<any> } = {}
/**
* Implements a global exclusive lock that works only in the current process.
* Useful for environments like React Native or other non-browser
* single-process (i.e. no concept of "tabs") environments.
*
* Use {@link #navigatorLock} in browser environments.
*
* @param name Name of the lock to be acquired.
* @param acquireTimeout If negative, no timeout. If 0 an error is thrown if
* the lock can't be acquired without waiting. If positive, the lock acquire
* will time out after so many milliseconds. An error is
* a timeout if it has `isAcquireTimeout` set to true.
* @param fn The operation to run once the lock is acquired.
*/
export async function processLock<R>(
name: string,
acquireTimeout: number,
fn: () => Promise<R>
): Promise<R> {
const previousOperation = PROCESS_LOCKS[name] ?? Promise.resolve()
const currentOperation = Promise.race(
[
previousOperation.catch((e: any) => {
// ignore error of previous operation that we're waiting to finish
return null
}),
acquireTimeout >= 0
? new Promise((_, reject) => {
setTimeout(() => {
reject(
new ProcessLockAcquireTimeoutError(
`Acquring process lock with name "${name}" timed out`
)
)
}, acquireTimeout)
})
: null,
].filter((x) => x)
)
.catch((e: any) => {
if (e && e.isAcquireTimeout) {
throw e
}
return null
})
.then(async () => {
// previous operations finished and we didn't get a race on the acquire
// timeout, so the current operation can finally start
return await fn()
})
PROCESS_LOCKS[name] = currentOperation.catch(async (e: any) => {
if (e && e.isAcquireTimeout) {
// if the current operation timed out, it doesn't mean that the previous
// operation finished, so we need contnue waiting for it to finish
await previousOperation
return null
}
throw e
})
// finally wait for the current operation to finish successfully, with an
// error or with an acquire timeout error
return await currentOperation
}

@@ -1,1 +0,1 @@

export const version = '2.65.2-rc.2'
export const version = '2.66.0-rc.3'

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