@leapdev/auth-agent 2.5.1-beta.0 → 2.5.2
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/package.json +1 -1
- package/src/index.umd.js +61 -27
- package/src/lib/authentication.js +42 -25
- package/src/lib/utils.d.ts +1 -0
- package/src/lib/utils.js +19 -0
package/package.json
CHANGED
package/src/index.umd.js
CHANGED
|
@@ -6310,6 +6310,23 @@
|
|
|
6310
6310
|
}
|
|
6311
6311
|
return result;
|
|
6312
6312
|
};
|
|
6313
|
+
function createInFlightDedupe() {
|
|
6314
|
+
let inFlight;
|
|
6315
|
+
return factory => __awaiter(this, void 0, void 0, function* () {
|
|
6316
|
+
if (inFlight) return inFlight;
|
|
6317
|
+
console.log('11111111111111');
|
|
6318
|
+
const promise = (() => __awaiter(this, void 0, void 0, function* () {
|
|
6319
|
+
try {
|
|
6320
|
+
return yield factory();
|
|
6321
|
+
} finally {
|
|
6322
|
+
console.log('inFlight-------------------- cleanup');
|
|
6323
|
+
inFlight = undefined;
|
|
6324
|
+
}
|
|
6325
|
+
}))();
|
|
6326
|
+
inFlight = promise;
|
|
6327
|
+
return promise;
|
|
6328
|
+
});
|
|
6329
|
+
}
|
|
6313
6330
|
|
|
6314
6331
|
var _Notification_pubnubKeys, _Notification_pubnub, _Notification_eventListeners, _Notification_userId, _Notification_uniqueSessionTriggerHook, _Notification_userPresenceTriggerHook, _Notification_currentUUIDString, _Notification_joinTimeToken, _Notification_initFirmChannel, _Notification_initUserChannel, _Notification_initUniqueSessionChannel;
|
|
6315
6332
|
const EMPTY_GUID = '00000000-0000-0000-0000-000000000000';
|
|
@@ -6773,7 +6790,7 @@
|
|
|
6773
6790
|
return list.find(appName => app.startsWith(`http://${appName}`) || app.startsWith(`https://${appName}`));
|
|
6774
6791
|
};
|
|
6775
6792
|
|
|
6776
|
-
var _Authentication_accessToken, _Authentication_config, _Authentication_leapAuthService, _Authentication_notification, _Authentication_refreshInfo, _Authentication_exchangeAuthCodeForAccessToken, _Authentication_verifyAndPerformRedirections, _Authentication_startRefreshAccessTokenProcess, _Authentication_destroyRefreshAccessTokenProcess, _Authentication_decodeAccessToken;
|
|
6793
|
+
var _Authentication_accessToken, _Authentication_config, _Authentication_leapAuthService, _Authentication_notification, _Authentication_refreshInfo, _Authentication_dedupeAccessTokenFetch, _Authentication_dedupeUserInfoFetch, _Authentication_exchangeAuthCodeForAccessToken, _Authentication_verifyAndPerformRedirections, _Authentication_startRefreshAccessTokenProcess, _Authentication_destroyRefreshAccessTokenProcess, _Authentication_decodeAccessToken, _Authentication_getRefreshedAccessTokenFactory, _Authentication_getUserInfoFactory;
|
|
6777
6794
|
const SECONDS_BEFORE_EXPIRE = 30;
|
|
6778
6795
|
const MAX_SETTIME_OUT = 2147483647;
|
|
6779
6796
|
const DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS = 60;
|
|
@@ -6786,6 +6803,8 @@
|
|
|
6786
6803
|
_Authentication_leapAuthService.set(this, void 0);
|
|
6787
6804
|
_Authentication_notification.set(this, void 0);
|
|
6788
6805
|
_Authentication_refreshInfo.set(this, void 0);
|
|
6806
|
+
_Authentication_dedupeAccessTokenFetch.set(this, void 0);
|
|
6807
|
+
_Authentication_dedupeUserInfoFetch.set(this, void 0);
|
|
6789
6808
|
this.registerEventListenerForUserChannel = params => {
|
|
6790
6809
|
const {
|
|
6791
6810
|
topic,
|
|
@@ -6863,27 +6882,10 @@
|
|
|
6863
6882
|
if (__classPrivateFieldGet(this, _Authentication_accessToken, "f") === undefined || !__classPrivateFieldGet(this, _Authentication_accessToken, "f")) {
|
|
6864
6883
|
return '';
|
|
6865
6884
|
} else {
|
|
6866
|
-
|
|
6867
|
-
const
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
refreshToken: __classPrivateFieldGet(this, _Authentication_refreshInfo, "f").refreshToken,
|
|
6871
|
-
verifier: __classPrivateFieldGet(this, _Authentication_refreshInfo, "f").verifier
|
|
6872
|
-
});
|
|
6873
|
-
if (data) {
|
|
6874
|
-
if (data.refresh_token && data.expires_in) {
|
|
6875
|
-
__classPrivateFieldSet(this, _Authentication_refreshInfo, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Authentication_refreshInfo, "f")), {
|
|
6876
|
-
refreshToken: data.refresh_token,
|
|
6877
|
-
accessTokenExpireIn: data.expires_in
|
|
6878
|
-
}), "f");
|
|
6879
|
-
}
|
|
6880
|
-
__classPrivateFieldSet(this, _Authentication_accessToken, data.access_token, "f");
|
|
6881
|
-
yield this.triggerHooks(HookName.afterRefreshToken);
|
|
6882
|
-
return __classPrivateFieldGet(this, _Authentication_accessToken, "f");
|
|
6883
|
-
}
|
|
6884
|
-
}
|
|
6885
|
-
}
|
|
6886
|
-
return __classPrivateFieldGet(this, _Authentication_accessToken, "f");
|
|
6885
|
+
return __classPrivateFieldGet(this, _Authentication_dedupeAccessTokenFetch, "f").call(this, () => __awaiter(this, void 0, void 0, function* () {
|
|
6886
|
+
const data = yield __classPrivateFieldGet(this, _Authentication_getRefreshedAccessTokenFactory, "f").call(this, force);
|
|
6887
|
+
return data;
|
|
6888
|
+
}));
|
|
6887
6889
|
}
|
|
6888
6890
|
});
|
|
6889
6891
|
this.getDecodedAccessToken = () => {
|
|
@@ -7032,8 +7034,10 @@
|
|
|
7032
7034
|
}
|
|
7033
7035
|
});
|
|
7034
7036
|
this.getUserInfo = () => __awaiter(this, void 0, void 0, function* () {
|
|
7035
|
-
|
|
7036
|
-
|
|
7037
|
+
return __classPrivateFieldGet(this, _Authentication_dedupeUserInfoFetch, "f").call(this, () => __awaiter(this, void 0, void 0, function* () {
|
|
7038
|
+
const data = yield __classPrivateFieldGet(this, _Authentication_getUserInfoFactory, "f").call(this);
|
|
7039
|
+
return data;
|
|
7040
|
+
}));
|
|
7037
7041
|
});
|
|
7038
7042
|
this.linkUser = params => __awaiter(this, void 0, void 0, function* () {
|
|
7039
7043
|
const decodeToken = yield this.getDecodedRefreshedAccessToken();
|
|
@@ -7192,8 +7196,7 @@
|
|
|
7192
7196
|
});
|
|
7193
7197
|
this.triggerHooks = hookName => __awaiter(this, void 0, void 0, function* () {
|
|
7194
7198
|
const hooks = this.getHooks();
|
|
7195
|
-
const
|
|
7196
|
-
const hookFn = hooks && !!hooks[hookName] && lodash.isFunction(hooks[hookName]) ? hooks[hookName](token) : false;
|
|
7199
|
+
const hookFn = hooks && !!hooks[hookName] && lodash.isFunction(hooks[hookName]) ? hooks[hookName]() : false;
|
|
7197
7200
|
return Promise.resolve(hookFn);
|
|
7198
7201
|
});
|
|
7199
7202
|
this.afterAuthenticated = () => {
|
|
@@ -7347,13 +7350,44 @@
|
|
|
7347
7350
|
}
|
|
7348
7351
|
return undefined;
|
|
7349
7352
|
});
|
|
7353
|
+
_Authentication_getRefreshedAccessTokenFactory.set(this, force => __awaiter(this, void 0, void 0, function* () {
|
|
7354
|
+
if (__classPrivateFieldGet(this, _Authentication_refreshInfo, "f") && __classPrivateFieldGet(this, _Authentication_refreshInfo, "f").accessTokenExpireIn) {
|
|
7355
|
+
const decoded = __classPrivateFieldGet(this, _Authentication_decodeAccessToken, "f").call(this, __classPrivateFieldGet(this, _Authentication_accessToken, "f"));
|
|
7356
|
+
if (force || !!decoded && (decoded.exp - SECONDS_BEFORE_EXPIRE) * 1000 < Date.now()) {
|
|
7357
|
+
const data = yield __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").renewAccessToken({
|
|
7358
|
+
refreshToken: __classPrivateFieldGet(this, _Authentication_refreshInfo, "f").refreshToken,
|
|
7359
|
+
verifier: __classPrivateFieldGet(this, _Authentication_refreshInfo, "f").verifier
|
|
7360
|
+
});
|
|
7361
|
+
if (data) {
|
|
7362
|
+
if (data.refresh_token && data.expires_in) {
|
|
7363
|
+
__classPrivateFieldSet(this, _Authentication_refreshInfo, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Authentication_refreshInfo, "f")), {
|
|
7364
|
+
refreshToken: data.refresh_token,
|
|
7365
|
+
accessTokenExpireIn: data.expires_in
|
|
7366
|
+
}), "f");
|
|
7367
|
+
}
|
|
7368
|
+
if (data) {
|
|
7369
|
+
yield this.triggerHooks(HookName.afterRefreshToken);
|
|
7370
|
+
}
|
|
7371
|
+
__classPrivateFieldSet(this, _Authentication_accessToken, data.access_token, "f");
|
|
7372
|
+
return __classPrivateFieldGet(this, _Authentication_accessToken, "f");
|
|
7373
|
+
}
|
|
7374
|
+
}
|
|
7375
|
+
}
|
|
7376
|
+
return __classPrivateFieldGet(this, _Authentication_accessToken, "f") || '';
|
|
7377
|
+
}));
|
|
7378
|
+
_Authentication_getUserInfoFactory.set(this, () => __awaiter(this, void 0, void 0, function* () {
|
|
7379
|
+
const token = yield this.getRefreshedAccessToken();
|
|
7380
|
+
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").userInfo(token);
|
|
7381
|
+
}));
|
|
7350
7382
|
__classPrivateFieldSet(this, _Authentication_accessToken, undefined, "f");
|
|
7351
7383
|
__classPrivateFieldSet(this, _Authentication_config, init$1(options), "f");
|
|
7352
7384
|
__classPrivateFieldSet(this, _Authentication_leapAuthService, new LeapAuthService(__classPrivateFieldGet(this, _Authentication_config, "f").authHost, __classPrivateFieldGet(this, _Authentication_config, "f").clientId), "f");
|
|
7353
7385
|
__classPrivateFieldSet(this, _Authentication_notification, new Notification(), "f");
|
|
7386
|
+
__classPrivateFieldSet(this, _Authentication_dedupeAccessTokenFetch, createInFlightDedupe(), "f");
|
|
7387
|
+
__classPrivateFieldSet(this, _Authentication_dedupeUserInfoFetch, createInFlightDedupe(), "f");
|
|
7354
7388
|
}
|
|
7355
7389
|
}
|
|
7356
|
-
_Authentication_accessToken = new WeakMap(), _Authentication_config = new WeakMap(), _Authentication_leapAuthService = new WeakMap(), _Authentication_notification = new WeakMap(), _Authentication_refreshInfo = new WeakMap(), _Authentication_exchangeAuthCodeForAccessToken = new WeakMap(), _Authentication_verifyAndPerformRedirections = new WeakMap(), _Authentication_startRefreshAccessTokenProcess = new WeakMap(), _Authentication_destroyRefreshAccessTokenProcess = new WeakMap(), _Authentication_decodeAccessToken = new WeakMap();
|
|
7390
|
+
_Authentication_accessToken = new WeakMap(), _Authentication_config = new WeakMap(), _Authentication_leapAuthService = new WeakMap(), _Authentication_notification = new WeakMap(), _Authentication_refreshInfo = new WeakMap(), _Authentication_dedupeAccessTokenFetch = new WeakMap(), _Authentication_dedupeUserInfoFetch = new WeakMap(), _Authentication_exchangeAuthCodeForAccessToken = new WeakMap(), _Authentication_verifyAndPerformRedirections = new WeakMap(), _Authentication_startRefreshAccessTokenProcess = new WeakMap(), _Authentication_destroyRefreshAccessTokenProcess = new WeakMap(), _Authentication_decodeAccessToken = new WeakMap(), _Authentication_getRefreshedAccessTokenFactory = new WeakMap(), _Authentication_getUserInfoFactory = new WeakMap();
|
|
7357
7391
|
|
|
7358
7392
|
var _IdleTimer_timeoutInMinutes, _IdleTimer_timer, _IdleTimer_onTimeout, _IdleTimer_cleanUpTracker, _IdleTimer_clearTimeout, _IdleTimer_resetTimer;
|
|
7359
7393
|
class IdleTimer {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var _Authentication_accessToken, _Authentication_config, _Authentication_leapAuthService, _Authentication_notification, _Authentication_refreshInfo, _Authentication_exchangeAuthCodeForAccessToken, _Authentication_verifyAndPerformRedirections, _Authentication_startRefreshAccessTokenProcess, _Authentication_destroyRefreshAccessTokenProcess, _Authentication_decodeAccessToken;
|
|
1
|
+
var _Authentication_accessToken, _Authentication_config, _Authentication_leapAuthService, _Authentication_notification, _Authentication_refreshInfo, _Authentication_dedupeAccessTokenFetch, _Authentication_dedupeUserInfoFetch, _Authentication_exchangeAuthCodeForAccessToken, _Authentication_verifyAndPerformRedirections, _Authentication_startRefreshAccessTokenProcess, _Authentication_destroyRefreshAccessTokenProcess, _Authentication_decodeAccessToken, _Authentication_getRefreshedAccessTokenFactory, _Authentication_getUserInfoFactory;
|
|
2
2
|
import { __awaiter, __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
3
3
|
import { isFunction } from 'lodash';
|
|
4
4
|
import { init } from './config';
|
|
5
5
|
import { LeapAuthService } from './auth.service';
|
|
6
6
|
import { HookName, } from './types';
|
|
7
7
|
import { Notification } from './notification';
|
|
8
|
-
import { createCodeChallenge, createLoginUrl, createRandomString, deleteQueryParameter, getQueryParameter } from './utils';
|
|
8
|
+
import { createCodeChallenge, createInFlightDedupe, createLoginUrl, createRandomString, deleteQueryParameter, getQueryParameter } from './utils';
|
|
9
9
|
import { getRedirectUri } from './redirections';
|
|
10
10
|
const SECONDS_BEFORE_EXPIRE = 30;
|
|
11
11
|
const MAX_SETTIME_OUT = 2147483647;
|
|
@@ -19,6 +19,8 @@ export class Authentication {
|
|
|
19
19
|
_Authentication_leapAuthService.set(this, void 0);
|
|
20
20
|
_Authentication_notification.set(this, void 0);
|
|
21
21
|
_Authentication_refreshInfo.set(this, void 0);
|
|
22
|
+
_Authentication_dedupeAccessTokenFetch.set(this, void 0);
|
|
23
|
+
_Authentication_dedupeUserInfoFetch.set(this, void 0);
|
|
22
24
|
this.registerEventListenerForUserChannel = (params) => {
|
|
23
25
|
const { topic, messageType, callback } = params;
|
|
24
26
|
__classPrivateFieldGet(this, _Authentication_notification, "f").registerEventListenerForUserChannel({
|
|
@@ -88,24 +90,10 @@ export class Authentication {
|
|
|
88
90
|
return '';
|
|
89
91
|
}
|
|
90
92
|
else {
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
refreshToken: __classPrivateFieldGet(this, _Authentication_refreshInfo, "f").refreshToken,
|
|
96
|
-
verifier: __classPrivateFieldGet(this, _Authentication_refreshInfo, "f").verifier,
|
|
97
|
-
});
|
|
98
|
-
if (data) {
|
|
99
|
-
if (data.refresh_token && data.expires_in) {
|
|
100
|
-
__classPrivateFieldSet(this, _Authentication_refreshInfo, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Authentication_refreshInfo, "f")), { refreshToken: data.refresh_token, accessTokenExpireIn: data.expires_in }), "f");
|
|
101
|
-
}
|
|
102
|
-
__classPrivateFieldSet(this, _Authentication_accessToken, data.access_token, "f");
|
|
103
|
-
yield this.triggerHooks(HookName.afterRefreshToken);
|
|
104
|
-
return __classPrivateFieldGet(this, _Authentication_accessToken, "f");
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return __classPrivateFieldGet(this, _Authentication_accessToken, "f");
|
|
93
|
+
return __classPrivateFieldGet(this, _Authentication_dedupeAccessTokenFetch, "f").call(this, () => __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
const data = yield __classPrivateFieldGet(this, _Authentication_getRefreshedAccessTokenFactory, "f").call(this, force);
|
|
95
|
+
return data;
|
|
96
|
+
}));
|
|
109
97
|
}
|
|
110
98
|
});
|
|
111
99
|
this.getDecodedAccessToken = () => {
|
|
@@ -242,8 +230,10 @@ export class Authentication {
|
|
|
242
230
|
}
|
|
243
231
|
});
|
|
244
232
|
this.getUserInfo = () => __awaiter(this, void 0, void 0, function* () {
|
|
245
|
-
|
|
246
|
-
|
|
233
|
+
return __classPrivateFieldGet(this, _Authentication_dedupeUserInfoFetch, "f").call(this, () => __awaiter(this, void 0, void 0, function* () {
|
|
234
|
+
const data = yield __classPrivateFieldGet(this, _Authentication_getUserInfoFactory, "f").call(this);
|
|
235
|
+
return data;
|
|
236
|
+
}));
|
|
247
237
|
});
|
|
248
238
|
this.linkUser = (params) => __awaiter(this, void 0, void 0, function* () {
|
|
249
239
|
const decodeToken = yield this.getDecodedRefreshedAccessToken();
|
|
@@ -385,8 +375,7 @@ export class Authentication {
|
|
|
385
375
|
});
|
|
386
376
|
this.triggerHooks = (hookName) => __awaiter(this, void 0, void 0, function* () {
|
|
387
377
|
const hooks = this.getHooks();
|
|
388
|
-
const
|
|
389
|
-
const hookFn = hooks && !!hooks[hookName] && isFunction(hooks[hookName]) ? hooks[hookName](token) : false;
|
|
378
|
+
const hookFn = hooks && !!hooks[hookName] && isFunction(hooks[hookName]) ? hooks[hookName]() : false;
|
|
390
379
|
return Promise.resolve(hookFn);
|
|
391
380
|
});
|
|
392
381
|
this.afterAuthenticated = () => {
|
|
@@ -530,10 +519,38 @@ export class Authentication {
|
|
|
530
519
|
}
|
|
531
520
|
return undefined;
|
|
532
521
|
});
|
|
522
|
+
_Authentication_getRefreshedAccessTokenFactory.set(this, (force) => __awaiter(this, void 0, void 0, function* () {
|
|
523
|
+
if (__classPrivateFieldGet(this, _Authentication_refreshInfo, "f") && __classPrivateFieldGet(this, _Authentication_refreshInfo, "f").accessTokenExpireIn) {
|
|
524
|
+
const decoded = __classPrivateFieldGet(this, _Authentication_decodeAccessToken, "f").call(this, __classPrivateFieldGet(this, _Authentication_accessToken, "f"));
|
|
525
|
+
if (force || (!!decoded && ((decoded.exp - SECONDS_BEFORE_EXPIRE) * 1000 < Date.now()))) {
|
|
526
|
+
const data = yield __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").renewAccessToken({
|
|
527
|
+
refreshToken: __classPrivateFieldGet(this, _Authentication_refreshInfo, "f").refreshToken,
|
|
528
|
+
verifier: __classPrivateFieldGet(this, _Authentication_refreshInfo, "f").verifier,
|
|
529
|
+
});
|
|
530
|
+
if (data) {
|
|
531
|
+
if (data.refresh_token && data.expires_in) {
|
|
532
|
+
__classPrivateFieldSet(this, _Authentication_refreshInfo, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Authentication_refreshInfo, "f")), { refreshToken: data.refresh_token, accessTokenExpireIn: data.expires_in }), "f");
|
|
533
|
+
}
|
|
534
|
+
if (data) {
|
|
535
|
+
yield this.triggerHooks(HookName.afterRefreshToken);
|
|
536
|
+
}
|
|
537
|
+
__classPrivateFieldSet(this, _Authentication_accessToken, data.access_token, "f");
|
|
538
|
+
return __classPrivateFieldGet(this, _Authentication_accessToken, "f");
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
return __classPrivateFieldGet(this, _Authentication_accessToken, "f") || '';
|
|
543
|
+
}));
|
|
544
|
+
_Authentication_getUserInfoFactory.set(this, () => __awaiter(this, void 0, void 0, function* () {
|
|
545
|
+
const token = yield this.getRefreshedAccessToken();
|
|
546
|
+
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").userInfo(token);
|
|
547
|
+
}));
|
|
533
548
|
__classPrivateFieldSet(this, _Authentication_accessToken, undefined, "f");
|
|
534
549
|
__classPrivateFieldSet(this, _Authentication_config, init(options), "f");
|
|
535
550
|
__classPrivateFieldSet(this, _Authentication_leapAuthService, new LeapAuthService(__classPrivateFieldGet(this, _Authentication_config, "f").authHost, __classPrivateFieldGet(this, _Authentication_config, "f").clientId), "f");
|
|
536
551
|
__classPrivateFieldSet(this, _Authentication_notification, new Notification(), "f");
|
|
552
|
+
__classPrivateFieldSet(this, _Authentication_dedupeAccessTokenFetch, createInFlightDedupe(), "f");
|
|
553
|
+
__classPrivateFieldSet(this, _Authentication_dedupeUserInfoFetch, createInFlightDedupe(), "f");
|
|
537
554
|
}
|
|
538
555
|
}
|
|
539
|
-
_Authentication_accessToken = new WeakMap(), _Authentication_config = new WeakMap(), _Authentication_leapAuthService = new WeakMap(), _Authentication_notification = new WeakMap(), _Authentication_refreshInfo = new WeakMap(), _Authentication_exchangeAuthCodeForAccessToken = new WeakMap(), _Authentication_verifyAndPerformRedirections = new WeakMap(), _Authentication_startRefreshAccessTokenProcess = new WeakMap(), _Authentication_destroyRefreshAccessTokenProcess = new WeakMap(), _Authentication_decodeAccessToken = new WeakMap();
|
|
556
|
+
_Authentication_accessToken = new WeakMap(), _Authentication_config = new WeakMap(), _Authentication_leapAuthService = new WeakMap(), _Authentication_notification = new WeakMap(), _Authentication_refreshInfo = new WeakMap(), _Authentication_dedupeAccessTokenFetch = new WeakMap(), _Authentication_dedupeUserInfoFetch = new WeakMap(), _Authentication_exchangeAuthCodeForAccessToken = new WeakMap(), _Authentication_verifyAndPerformRedirections = new WeakMap(), _Authentication_startRefreshAccessTokenProcess = new WeakMap(), _Authentication_destroyRefreshAccessTokenProcess = new WeakMap(), _Authentication_decodeAccessToken = new WeakMap(), _Authentication_getRefreshedAccessTokenFactory = new WeakMap(), _Authentication_getUserInfoFactory = new WeakMap();
|
package/src/lib/utils.d.ts
CHANGED
package/src/lib/utils.js
CHANGED
|
@@ -99,3 +99,22 @@ const parseParams = (url) => {
|
|
|
99
99
|
}
|
|
100
100
|
return result;
|
|
101
101
|
};
|
|
102
|
+
export function createInFlightDedupe() {
|
|
103
|
+
let inFlight;
|
|
104
|
+
return (factory) => __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
if (inFlight)
|
|
106
|
+
return inFlight;
|
|
107
|
+
console.log('11111111111111');
|
|
108
|
+
const promise = (() => __awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
try {
|
|
110
|
+
return yield factory();
|
|
111
|
+
}
|
|
112
|
+
finally {
|
|
113
|
+
console.log('inFlight-------------------- cleanup');
|
|
114
|
+
inFlight = undefined;
|
|
115
|
+
}
|
|
116
|
+
}))();
|
|
117
|
+
inFlight = promise;
|
|
118
|
+
return promise;
|
|
119
|
+
});
|
|
120
|
+
}
|