@extrahorizon/javascript-sdk 8.14.1 → 8.14.2-dev-208-aa6da5c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/build/index.cjs.js +16 -3
- package/build/index.mjs +16 -3
- package/build/types/version.d.ts +1 -1
- package/build/version.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [8.14.2]
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- OAuth2 token refreshes are now shared between parallel requests
|
|
12
|
+
|
|
8
13
|
## [8.14.1]
|
|
9
14
|
|
|
10
15
|
### Fixed
|
package/build/index.cjs.js
CHANGED
|
@@ -2390,6 +2390,7 @@ function btoa(input) {
|
|
|
2390
2390
|
const TOKEN_ENDPOINT = `${AUTH_BASE}/oauth2/tokens`;
|
|
2391
2391
|
function createOAuth2HttpClient(http, options) {
|
|
2392
2392
|
let tokenData;
|
|
2393
|
+
let refreshingTokensPromise = null;
|
|
2393
2394
|
if ('refreshToken' in options && 'accessToken' in options) {
|
|
2394
2395
|
tokenData = {
|
|
2395
2396
|
refreshToken: options.refreshToken,
|
|
@@ -2443,7 +2444,7 @@ function createOAuth2HttpClient(http, options) {
|
|
|
2443
2444
|
// Refresh 10 seconds before the token is about to expire.
|
|
2444
2445
|
// This is to prevent being just too late with a refresh of the token due to latencies
|
|
2445
2446
|
if (Date.now() > expireTime - 10 * 1000) {
|
|
2446
|
-
await
|
|
2447
|
+
await refreshTokens();
|
|
2447
2448
|
}
|
|
2448
2449
|
}
|
|
2449
2450
|
return {
|
|
@@ -2467,7 +2468,7 @@ function createOAuth2HttpClient(http, options) {
|
|
|
2467
2468
|
[118, 117].includes((_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.code) &&
|
|
2468
2469
|
!originalRequest.isRetryWithRefreshedTokens) {
|
|
2469
2470
|
originalRequest.isRetryWithRefreshedTokens = true;
|
|
2470
|
-
await
|
|
2471
|
+
await refreshTokens();
|
|
2471
2472
|
return httpWithAuth(originalRequest);
|
|
2472
2473
|
}
|
|
2473
2474
|
throw error;
|
|
@@ -2508,6 +2509,18 @@ function createOAuth2HttpClient(http, options) {
|
|
|
2508
2509
|
{});
|
|
2509
2510
|
return await dateAndSetTokenData(tokenResult.data);
|
|
2510
2511
|
}
|
|
2512
|
+
async function refreshTokens() {
|
|
2513
|
+
if (refreshingTokensPromise) {
|
|
2514
|
+
return refreshingTokensPromise;
|
|
2515
|
+
}
|
|
2516
|
+
refreshingTokensPromise = authenticate({ refreshToken: tokenData.refreshToken });
|
|
2517
|
+
try {
|
|
2518
|
+
return await refreshingTokensPromise;
|
|
2519
|
+
}
|
|
2520
|
+
finally {
|
|
2521
|
+
refreshingTokensPromise = null;
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2511
2524
|
async function confirmMfa({ token, methodId, code, }) {
|
|
2512
2525
|
const tokenResult = await http.post(TOKEN_ENDPOINT, {
|
|
2513
2526
|
...clientCredentials,
|
|
@@ -5768,7 +5781,7 @@ const templatesV2Service = (httpWithAuth) => {
|
|
|
5768
5781
|
};
|
|
5769
5782
|
};
|
|
5770
5783
|
|
|
5771
|
-
const version = '8.14.
|
|
5784
|
+
const version = '8.14.2-dev-208-aa6da5c';
|
|
5772
5785
|
|
|
5773
5786
|
/**
|
|
5774
5787
|
* Create ExtraHorizon client.
|
package/build/index.mjs
CHANGED
|
@@ -2360,6 +2360,7 @@ function btoa(input) {
|
|
|
2360
2360
|
const TOKEN_ENDPOINT = `${AUTH_BASE}/oauth2/tokens`;
|
|
2361
2361
|
function createOAuth2HttpClient(http, options) {
|
|
2362
2362
|
let tokenData;
|
|
2363
|
+
let refreshingTokensPromise = null;
|
|
2363
2364
|
if ('refreshToken' in options && 'accessToken' in options) {
|
|
2364
2365
|
tokenData = {
|
|
2365
2366
|
refreshToken: options.refreshToken,
|
|
@@ -2413,7 +2414,7 @@ function createOAuth2HttpClient(http, options) {
|
|
|
2413
2414
|
// Refresh 10 seconds before the token is about to expire.
|
|
2414
2415
|
// This is to prevent being just too late with a refresh of the token due to latencies
|
|
2415
2416
|
if (Date.now() > expireTime - 10 * 1000) {
|
|
2416
|
-
await
|
|
2417
|
+
await refreshTokens();
|
|
2417
2418
|
}
|
|
2418
2419
|
}
|
|
2419
2420
|
return {
|
|
@@ -2437,7 +2438,7 @@ function createOAuth2HttpClient(http, options) {
|
|
|
2437
2438
|
[118, 117].includes((_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.code) &&
|
|
2438
2439
|
!originalRequest.isRetryWithRefreshedTokens) {
|
|
2439
2440
|
originalRequest.isRetryWithRefreshedTokens = true;
|
|
2440
|
-
await
|
|
2441
|
+
await refreshTokens();
|
|
2441
2442
|
return httpWithAuth(originalRequest);
|
|
2442
2443
|
}
|
|
2443
2444
|
throw error;
|
|
@@ -2478,6 +2479,18 @@ function createOAuth2HttpClient(http, options) {
|
|
|
2478
2479
|
{});
|
|
2479
2480
|
return await dateAndSetTokenData(tokenResult.data);
|
|
2480
2481
|
}
|
|
2482
|
+
async function refreshTokens() {
|
|
2483
|
+
if (refreshingTokensPromise) {
|
|
2484
|
+
return refreshingTokensPromise;
|
|
2485
|
+
}
|
|
2486
|
+
refreshingTokensPromise = authenticate({ refreshToken: tokenData.refreshToken });
|
|
2487
|
+
try {
|
|
2488
|
+
return await refreshingTokensPromise;
|
|
2489
|
+
}
|
|
2490
|
+
finally {
|
|
2491
|
+
refreshingTokensPromise = null;
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2481
2494
|
async function confirmMfa({ token, methodId, code, }) {
|
|
2482
2495
|
const tokenResult = await http.post(TOKEN_ENDPOINT, {
|
|
2483
2496
|
...clientCredentials,
|
|
@@ -5738,7 +5751,7 @@ const templatesV2Service = (httpWithAuth) => {
|
|
|
5738
5751
|
};
|
|
5739
5752
|
};
|
|
5740
5753
|
|
|
5741
|
-
const version = '8.14.
|
|
5754
|
+
const version = '8.14.2-dev-208-aa6da5c';
|
|
5742
5755
|
|
|
5743
5756
|
/**
|
|
5744
5757
|
* Create ExtraHorizon client.
|
package/build/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "8.14.
|
|
1
|
+
export declare const version = "8.14.2-dev-208-aa6da5c";
|
package/build/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "8.14.
|
|
1
|
+
export declare const version = "8.14.2-dev-208-aa6da5c";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@extrahorizon/javascript-sdk",
|
|
3
|
-
"version": "8.14.
|
|
3
|
+
"version": "8.14.2-dev-208-aa6da5c",
|
|
4
4
|
"description": "This package serves as a JavaScript wrapper around all Extra Horizon cloud services.",
|
|
5
5
|
"main": "build/index.cjs.js",
|
|
6
6
|
"types": "build/types/index.d.ts",
|