@leapdev/auth-agent 2.5.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 +73 -30
- package/src/lib/authentication.js +42 -25
- package/src/lib/redirections.js +13 -3
- package/src/lib/types.d.ts +12 -0
- 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';
|
|
@@ -6721,9 +6738,18 @@
|
|
|
6721
6738
|
let redirection;
|
|
6722
6739
|
let redirectUrl;
|
|
6723
6740
|
const topLevelDomains = redirectionConfig.topLevelDomains;
|
|
6724
|
-
const
|
|
6725
|
-
|
|
6726
|
-
|
|
6741
|
+
const topLevelDomainsV2 = redirectionConfig.topLevelDomains_v2;
|
|
6742
|
+
let suffix;
|
|
6743
|
+
let redirections = redirectionConfig.environments;
|
|
6744
|
+
let environmentVariables;
|
|
6745
|
+
suffix = topLevelDomainsV2.find(s => origin.endsWith(s));
|
|
6746
|
+
if (suffix) {
|
|
6747
|
+
redirections = redirectionConfig.environments_v2;
|
|
6748
|
+
environmentVariables = {};
|
|
6749
|
+
} else {
|
|
6750
|
+
suffix = topLevelDomains.find(s => origin.endsWith(s));
|
|
6751
|
+
environmentVariables = redirectionConfig.environmentVariables;
|
|
6752
|
+
}
|
|
6727
6753
|
if (suffix) {
|
|
6728
6754
|
for (let i = 0; i < redirections.length; i++) {
|
|
6729
6755
|
redirection = redirections[i];
|
|
@@ -6764,7 +6790,7 @@
|
|
|
6764
6790
|
return list.find(appName => app.startsWith(`http://${appName}`) || app.startsWith(`https://${appName}`));
|
|
6765
6791
|
};
|
|
6766
6792
|
|
|
6767
|
-
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;
|
|
6768
6794
|
const SECONDS_BEFORE_EXPIRE = 30;
|
|
6769
6795
|
const MAX_SETTIME_OUT = 2147483647;
|
|
6770
6796
|
const DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS = 60;
|
|
@@ -6777,6 +6803,8 @@
|
|
|
6777
6803
|
_Authentication_leapAuthService.set(this, void 0);
|
|
6778
6804
|
_Authentication_notification.set(this, void 0);
|
|
6779
6805
|
_Authentication_refreshInfo.set(this, void 0);
|
|
6806
|
+
_Authentication_dedupeAccessTokenFetch.set(this, void 0);
|
|
6807
|
+
_Authentication_dedupeUserInfoFetch.set(this, void 0);
|
|
6780
6808
|
this.registerEventListenerForUserChannel = params => {
|
|
6781
6809
|
const {
|
|
6782
6810
|
topic,
|
|
@@ -6854,27 +6882,10 @@
|
|
|
6854
6882
|
if (__classPrivateFieldGet(this, _Authentication_accessToken, "f") === undefined || !__classPrivateFieldGet(this, _Authentication_accessToken, "f")) {
|
|
6855
6883
|
return '';
|
|
6856
6884
|
} else {
|
|
6857
|
-
|
|
6858
|
-
const
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
refreshToken: __classPrivateFieldGet(this, _Authentication_refreshInfo, "f").refreshToken,
|
|
6862
|
-
verifier: __classPrivateFieldGet(this, _Authentication_refreshInfo, "f").verifier
|
|
6863
|
-
});
|
|
6864
|
-
if (data) {
|
|
6865
|
-
if (data.refresh_token && data.expires_in) {
|
|
6866
|
-
__classPrivateFieldSet(this, _Authentication_refreshInfo, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Authentication_refreshInfo, "f")), {
|
|
6867
|
-
refreshToken: data.refresh_token,
|
|
6868
|
-
accessTokenExpireIn: data.expires_in
|
|
6869
|
-
}), "f");
|
|
6870
|
-
}
|
|
6871
|
-
__classPrivateFieldSet(this, _Authentication_accessToken, data.access_token, "f");
|
|
6872
|
-
yield this.triggerHooks(HookName.afterRefreshToken);
|
|
6873
|
-
return __classPrivateFieldGet(this, _Authentication_accessToken, "f");
|
|
6874
|
-
}
|
|
6875
|
-
}
|
|
6876
|
-
}
|
|
6877
|
-
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
|
+
}));
|
|
6878
6889
|
}
|
|
6879
6890
|
});
|
|
6880
6891
|
this.getDecodedAccessToken = () => {
|
|
@@ -7023,8 +7034,10 @@
|
|
|
7023
7034
|
}
|
|
7024
7035
|
});
|
|
7025
7036
|
this.getUserInfo = () => __awaiter(this, void 0, void 0, function* () {
|
|
7026
|
-
|
|
7027
|
-
|
|
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
|
+
}));
|
|
7028
7041
|
});
|
|
7029
7042
|
this.linkUser = params => __awaiter(this, void 0, void 0, function* () {
|
|
7030
7043
|
const decodeToken = yield this.getDecodedRefreshedAccessToken();
|
|
@@ -7183,8 +7196,7 @@
|
|
|
7183
7196
|
});
|
|
7184
7197
|
this.triggerHooks = hookName => __awaiter(this, void 0, void 0, function* () {
|
|
7185
7198
|
const hooks = this.getHooks();
|
|
7186
|
-
const
|
|
7187
|
-
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;
|
|
7188
7200
|
return Promise.resolve(hookFn);
|
|
7189
7201
|
});
|
|
7190
7202
|
this.afterAuthenticated = () => {
|
|
@@ -7338,13 +7350,44 @@
|
|
|
7338
7350
|
}
|
|
7339
7351
|
return undefined;
|
|
7340
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
|
+
}));
|
|
7341
7382
|
__classPrivateFieldSet(this, _Authentication_accessToken, undefined, "f");
|
|
7342
7383
|
__classPrivateFieldSet(this, _Authentication_config, init$1(options), "f");
|
|
7343
7384
|
__classPrivateFieldSet(this, _Authentication_leapAuthService, new LeapAuthService(__classPrivateFieldGet(this, _Authentication_config, "f").authHost, __classPrivateFieldGet(this, _Authentication_config, "f").clientId), "f");
|
|
7344
7385
|
__classPrivateFieldSet(this, _Authentication_notification, new Notification(), "f");
|
|
7386
|
+
__classPrivateFieldSet(this, _Authentication_dedupeAccessTokenFetch, createInFlightDedupe(), "f");
|
|
7387
|
+
__classPrivateFieldSet(this, _Authentication_dedupeUserInfoFetch, createInFlightDedupe(), "f");
|
|
7345
7388
|
}
|
|
7346
7389
|
}
|
|
7347
|
-
_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();
|
|
7348
7391
|
|
|
7349
7392
|
var _IdleTimer_timeoutInMinutes, _IdleTimer_timer, _IdleTimer_onTimeout, _IdleTimer_cleanUpTracker, _IdleTimer_clearTimeout, _IdleTimer_resetTimer;
|
|
7350
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/redirections.js
CHANGED
|
@@ -3,9 +3,19 @@ export const getRedirectUri = (origin, decodedToken, redirectionConfig) => {
|
|
|
3
3
|
let redirection;
|
|
4
4
|
let redirectUrl;
|
|
5
5
|
const topLevelDomains = redirectionConfig.topLevelDomains;
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const topLevelDomainsV2 = redirectionConfig.topLevelDomains_v2;
|
|
7
|
+
let suffix;
|
|
8
|
+
let redirections = redirectionConfig.environments;
|
|
9
|
+
let environmentVariables;
|
|
10
|
+
suffix = topLevelDomainsV2.find((s) => origin.endsWith(s));
|
|
11
|
+
if (suffix) {
|
|
12
|
+
redirections = redirectionConfig.environments_v2;
|
|
13
|
+
environmentVariables = {};
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
suffix = topLevelDomains.find((s) => origin.endsWith(s));
|
|
17
|
+
environmentVariables = redirectionConfig.environmentVariables;
|
|
18
|
+
}
|
|
9
19
|
if (suffix) {
|
|
10
20
|
for (let i = 0; i < redirections.length; i++) {
|
|
11
21
|
redirection = redirections[i];
|
package/src/lib/types.d.ts
CHANGED
|
@@ -75,10 +75,22 @@ export declare type LeapToken = {
|
|
|
75
75
|
};
|
|
76
76
|
export declare type Redirections = {
|
|
77
77
|
topLevelDomains: Array<string>;
|
|
78
|
+
topLevelDomains_v2: Array<string>;
|
|
78
79
|
environments: Array<{
|
|
79
80
|
criteria: {
|
|
80
81
|
region: string;
|
|
81
82
|
environment: 'test' | 'live' | 'liveb';
|
|
83
|
+
countryCode: number;
|
|
84
|
+
};
|
|
85
|
+
topLevelDomain: string;
|
|
86
|
+
authHost: string;
|
|
87
|
+
applications: Array<string>;
|
|
88
|
+
}>;
|
|
89
|
+
environments_v2: Array<{
|
|
90
|
+
criteria: {
|
|
91
|
+
region: string;
|
|
92
|
+
environment: 'test' | 'live' | 'liveb';
|
|
93
|
+
countryCode: number;
|
|
82
94
|
};
|
|
83
95
|
topLevelDomain: string;
|
|
84
96
|
authHost: string;
|
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
|
+
}
|