@logto/client
Advanced tools
Comparing version 1.0.0-beta.13 to 1.0.0-beta.14
@@ -128,3 +128,2 @@ var $4R6L3$logtocorekit = require("@logto/core-kit"); | ||
accessTokenMap = new Map(); | ||
getAccessTokenPromiseMap = new Map(); | ||
constructor(logtoConfig, adapter){ | ||
@@ -148,3 +147,2 @@ this.logtoConfig = { | ||
} | ||
// eslint-disable-next-line complexity | ||
async getAccessToken(resource) { | ||
@@ -159,14 +157,3 @@ if (!await this.getIdToken()) throw new (0, $9166104b36889c59$export$877962ca249b8fc8)("not_authenticated"); | ||
* Need to fetch a new access token using refresh token. | ||
* Reuse the cached promise if exists. | ||
*/ const cachedPromise = this.getAccessTokenPromiseMap.get(accessTokenKey); | ||
if (cachedPromise) return cachedPromise; | ||
/** | ||
* Create a new promise and cache in map to avoid race condition. | ||
* Since we enable "refresh token rotation" by default, | ||
* it will be problematic when calling multiple `getAccessToken()` closely. | ||
*/ const promise = this.getAccessTokenByRefreshToken(resource); | ||
this.getAccessTokenPromiseMap.set(accessTokenKey, promise); | ||
const token = await promise; | ||
this.getAccessTokenPromiseMap.delete(accessTokenKey); | ||
return token; | ||
*/ return this.getAccessTokenByRefreshToken(resource); | ||
} | ||
@@ -367,3 +354,3 @@ async getIdTokenClaims() { | ||
} | ||
} /* eslint-enable max-lines */ | ||
} | ||
$parcel$exportWildcard(module.exports, $9166104b36889c59$exports); | ||
@@ -370,0 +357,0 @@ $parcel$exportWildcard(module.exports, $6d3989f7f53311af$exports); |
{ | ||
"name": "@logto/client", | ||
"version": "1.0.0-beta.13", | ||
"version": "1.0.0-beta.14", | ||
"source": "./src/index.ts", | ||
@@ -25,3 +25,3 @@ "main": "./lib/index.js", | ||
"check": "tsc --noEmit", | ||
"build": "rm -rf lib/ && pnpm check && parcel build", | ||
"build": "rm -rf lib/ && pnpm check && parcel build && cp lib/index.d.ts lib/module.d.mts", | ||
"lint": "eslint --ext .ts src", | ||
@@ -34,3 +34,3 @@ "test": "jest", | ||
"@logto/core-kit": "1.0.0-beta.20", | ||
"@logto/js": "^1.0.0-beta.13", | ||
"@logto/js": "^1.0.0-beta.14", | ||
"@silverhand/essentials": "^1.2.1", | ||
@@ -72,3 +72,3 @@ "camelcase-keys": "^7.0.1", | ||
}, | ||
"gitHead": "8c64e263617689191d60391021f5f1b0872ff276" | ||
"gitHead": "2b391f477b116a1adbf100696d7bf32c25f019e9" | ||
} |
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
10
110379
705
Updated@logto/js@^1.0.0-beta.14