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

@workos-inc/authkit-js

Package Overview
Dependencies
Maintainers
0
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@workos-inc/authkit-js - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

31

dist/index.js

@@ -640,14 +640,19 @@ "use strict";

let _authkitClientState = "INITIAL";
const _needsRefresh = () => {
if (_authkitClientState !== "AUTHENTICATED") {
return true;
const _shouldRefresh = () => {
switch (_authkitClientState) {
case "INITIAL":
case "AUTHENTICATING":
return true;
case "ERROR":
return false;
case "AUTHENTICATED":
const accessToken = memoryStorage.getItem(storageKeys.accessToken);
const expiresAt = memoryStorage.getItem(storageKeys.expiresAt);
if (!accessToken || !expiresAt) {
return true;
}
const LEEWAY = 10 * 1e3;
const refreshTime = expiresAt - LEEWAY;
return refreshTime < Date.now();
}
const accessToken = memoryStorage.getItem(storageKeys.accessToken);
const expiresAt = memoryStorage.getItem(storageKeys.expiresAt);
if (!accessToken || !expiresAt) {
return true;
}
const LEEWAY = 10 * 1e3;
const refreshTime = expiresAt - LEEWAY;
return refreshTime < Date.now();
};

@@ -688,3 +693,3 @@ async function signIn(opts = {}) {

async function getAccessToken() {
if (_needsRefresh()) {
if (_shouldRefresh()) {
try {

@@ -709,3 +714,3 @@ await refreshSession();

_refreshTimer = setTimeout(() => {
if (_needsRefresh() && onBeforeAutoRefresh()) {
if (_shouldRefresh() && onBeforeAutoRefresh()) {
refreshSession().catch((e) => {

@@ -712,0 +717,0 @@ console.error(e);

{
"name": "@workos-inc/authkit-js",
"version": "0.4.0",
"version": "0.4.1",
"description": "AuthKit SDK",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

@@ -65,22 +65,26 @@ import { CreateClientOptions, User } from "./interfaces";

const _needsRefresh = () => {
if (_authkitClientState !== "AUTHENTICATED") {
return true;
}
const _shouldRefresh = () => {
switch (_authkitClientState) {
case "INITIAL":
case "AUTHENTICATING":
return true;
case "ERROR":
return false;
case "AUTHENTICATED":
const accessToken = memoryStorage.getItem(storageKeys.accessToken) as
| string
| undefined;
const expiresAt = memoryStorage.getItem(storageKeys.expiresAt) as
| number
| undefined;
const accessToken = memoryStorage.getItem(storageKeys.accessToken) as
| string
| undefined;
const expiresAt = memoryStorage.getItem(storageKeys.expiresAt) as
| number
| undefined;
if (!accessToken || !expiresAt) {
return true;
}
if (!accessToken || !expiresAt) {
return true;
// TODO: should LEEWAY be configurable?
const LEEWAY = 10 * 1000; // 10 seconds
const refreshTime = expiresAt - LEEWAY;
return refreshTime < Date.now();
}
// TODO: should LEEWAY be configurable?
const LEEWAY = 10 * 1000; // 10 seconds
const refreshTime = expiresAt - LEEWAY;
return refreshTime < Date.now();
};

@@ -129,3 +133,3 @@

async function getAccessToken(): Promise<string> {
if (_needsRefresh()) {
if (_shouldRefresh()) {
try {

@@ -153,3 +157,3 @@ await refreshSession();

_refreshTimer = setTimeout(() => {
if (_needsRefresh() && onBeforeAutoRefresh()) {
if (_shouldRefresh() && onBeforeAutoRefresh()) {
refreshSession()

@@ -156,0 +160,0 @@ .catch((e) => {

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