@leapdev/auth-agent 2.2.12 → 2.2.13-beta.0
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.js +4 -2
- package/src/lib/auth-agent.js +20 -18
- package/src/lib/auth.service.js +58 -55
- package/src/lib/authentication.js +151 -148
- package/src/lib/config.js +9 -6
- package/src/lib/idle-timer.js +26 -23
- package/src/lib/notification.js +44 -41
- package/src/lib/redirections.js +5 -2
- package/src/lib/types.js +5 -3
- package/src/lib/utils.js +17 -10
- package/src/index.js.map +0 -1
- package/src/lib/auth-agent.js.map +0 -1
- package/src/lib/auth.service.js.map +0 -1
- package/src/lib/authentication.js.map +0 -1
- package/src/lib/config.js.map +0 -1
- package/src/lib/idle-timer.js.map +0 -1
- package/src/lib/notification.js.map +0 -1
- package/src/lib/redirections.js.map +0 -1
- package/src/lib/types.js.map +0 -1
- package/src/lib/utils.js.map +0 -1
|
@@ -1,18 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var _Authentication_accessToken, _Authentication_config, _Authentication_leapAuthService, _Authentication_notification, _Authentication_refreshInfo, _Authentication_exchangeAuthCodeForAccessToken, _Authentication_verifyAndPerformRedirections, _Authentication_startRefreshAccessTokenProcess, _Authentication_destroyRefreshAccessTokenProcess, _Authentication_decodeAccessToken;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Authentication = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const lodash_1 = require("lodash");
|
|
7
|
+
const config_1 = require("./config");
|
|
8
|
+
const auth_service_1 = require("./auth.service");
|
|
9
|
+
const types_1 = require("./types");
|
|
10
|
+
const notification_1 = require("./notification");
|
|
11
|
+
const utils_1 = require("./utils");
|
|
12
|
+
const redirections_1 = require("./redirections");
|
|
10
13
|
const SECONDS_BEFORE_EXPIRE = 30;
|
|
11
14
|
const MAX_SETTIME_OUT = 2147483647;
|
|
12
15
|
const DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS = 60;
|
|
13
16
|
const CLEANUP_IFRAME_TIMEOUT_IN_SECONDS = 2;
|
|
14
17
|
const PASSTHROUGH_SESSION_KEY = 'leap-auth-agent-passthrough';
|
|
15
|
-
|
|
18
|
+
class Authentication {
|
|
16
19
|
constructor(options) {
|
|
17
20
|
_Authentication_accessToken.set(this, void 0);
|
|
18
21
|
_Authentication_config.set(this, void 0);
|
|
@@ -21,100 +24,100 @@ export class Authentication {
|
|
|
21
24
|
_Authentication_refreshInfo.set(this, void 0);
|
|
22
25
|
this.registerEventListenerForUserChannel = (params) => {
|
|
23
26
|
const { topic, messageType, callback } = params;
|
|
24
|
-
__classPrivateFieldGet(this, _Authentication_notification, "f").registerEventListenerForUserChannel({
|
|
27
|
+
tslib_1.__classPrivateFieldGet(this, _Authentication_notification, "f").registerEventListenerForUserChannel({
|
|
25
28
|
topic,
|
|
26
29
|
messageType,
|
|
27
30
|
callback,
|
|
28
31
|
});
|
|
29
32
|
};
|
|
30
|
-
this.initNotification = () => __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
this.initNotification = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
31
34
|
const decodedToken = yield this.getDecodedRefreshedAccessToken();
|
|
32
35
|
if (decodedToken) {
|
|
33
|
-
yield __classPrivateFieldGet(this, _Authentication_notification, "f").init({
|
|
34
|
-
authHost: __classPrivateFieldGet(this, _Authentication_config, "f").authHost,
|
|
35
|
-
clientId: __classPrivateFieldGet(this, _Authentication_config, "f").clientId,
|
|
36
|
+
yield tslib_1.__classPrivateFieldGet(this, _Authentication_notification, "f").init({
|
|
37
|
+
authHost: tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f").authHost,
|
|
38
|
+
clientId: tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f").clientId,
|
|
36
39
|
firmId: decodedToken.firmId,
|
|
37
40
|
userId: decodedToken.userId,
|
|
38
|
-
uniqueSession: !!__classPrivateFieldGet(this, _Authentication_config, "f").uniqueSession,
|
|
39
|
-
hooks: __classPrivateFieldGet(this, _Authentication_config, "f").hooks,
|
|
41
|
+
uniqueSession: !!tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f").uniqueSession,
|
|
42
|
+
hooks: tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f").hooks,
|
|
40
43
|
});
|
|
41
44
|
}
|
|
42
45
|
});
|
|
43
46
|
this.destroyNotification = () => {
|
|
44
|
-
__classPrivateFieldGet(this, _Authentication_notification, "f").destroy();
|
|
47
|
+
tslib_1.__classPrivateFieldGet(this, _Authentication_notification, "f").destroy();
|
|
45
48
|
};
|
|
46
|
-
this.login = (noPrompt) => __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
this.login = (noPrompt) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
47
50
|
const done = yield this.checkAuthCode();
|
|
48
|
-
if (done && !!__classPrivateFieldGet(this, _Authentication_accessToken, "f")) {
|
|
49
|
-
return __classPrivateFieldGet(this, _Authentication_accessToken, "f");
|
|
51
|
+
if (done && !!tslib_1.__classPrivateFieldGet(this, _Authentication_accessToken, "f")) {
|
|
52
|
+
return tslib_1.__classPrivateFieldGet(this, _Authentication_accessToken, "f");
|
|
50
53
|
}
|
|
51
54
|
else {
|
|
52
|
-
const code_verifier = createRandomString(64);
|
|
53
|
-
const state = createRandomString(6);
|
|
55
|
+
const code_verifier = (0, utils_1.createRandomString)(64);
|
|
56
|
+
const state = (0, utils_1.createRandomString)(6);
|
|
54
57
|
window.sessionStorage.setItem(state, code_verifier);
|
|
55
|
-
const { code_challenge, code_challenge_method } = yield createCodeChallenge(code_verifier);
|
|
56
|
-
const scope = __classPrivateFieldGet(this, _Authentication_config, "f").scopes.join(',');
|
|
58
|
+
const { code_challenge, code_challenge_method } = yield (0, utils_1.createCodeChallenge)(code_verifier);
|
|
59
|
+
const scope = tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f").scopes.join(',');
|
|
57
60
|
const prompt = noPrompt ? 'none' : '';
|
|
58
|
-
const url = `${__classPrivateFieldGet(this, _Authentication_config, "f").authHost}/oauth/authorize?response_type=code&scope=${scope}&client_id=${__classPrivateFieldGet(this, _Authentication_config, "f").clientId}&redirect_uri=${encodeURIComponent(window.location.href)}&code_challenge=${encodeURIComponent(code_challenge)}&code_challenge_method=${code_challenge_method}&state=${state}&prompt=${prompt}&remember_me=${__classPrivateFieldGet(this, _Authentication_config, "f").rememberMe}`;
|
|
61
|
+
const url = `${tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f").authHost}/oauth/authorize?response_type=code&scope=${scope}&client_id=${tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f").clientId}&redirect_uri=${encodeURIComponent(window.location.href)}&code_challenge=${encodeURIComponent(code_challenge)}&code_challenge_method=${code_challenge_method}&state=${state}&prompt=${prompt}&remember_me=${tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f").rememberMe}`;
|
|
59
62
|
window.location.assign(url);
|
|
60
63
|
return;
|
|
61
64
|
}
|
|
62
65
|
});
|
|
63
66
|
this.logout = (force = false, redirectUrl) => {
|
|
64
|
-
__classPrivateFieldSet(this, _Authentication_accessToken, undefined, "f");
|
|
67
|
+
tslib_1.__classPrivateFieldSet(this, _Authentication_accessToken, undefined, "f");
|
|
65
68
|
const redirectUri = encodeURIComponent(redirectUrl || window.location.href);
|
|
66
|
-
window.location.href = `${__classPrivateFieldGet(this, _Authentication_config, "f").authHost}/oauth/logout?force=${force}&redirect_uri=${redirectUri}`;
|
|
67
|
-
__classPrivateFieldGet(this, _Authentication_destroyRefreshAccessTokenProcess, "f").call(this);
|
|
69
|
+
window.location.href = `${tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f").authHost}/oauth/logout?force=${force}&redirect_uri=${redirectUri}`;
|
|
70
|
+
tslib_1.__classPrivateFieldGet(this, _Authentication_destroyRefreshAccessTokenProcess, "f").call(this);
|
|
68
71
|
};
|
|
69
72
|
this.getAccessToken = () => {
|
|
70
|
-
if (__classPrivateFieldGet(this, _Authentication_accessToken, "f") === undefined || !__classPrivateFieldGet(this, _Authentication_accessToken, "f")) {
|
|
73
|
+
if (tslib_1.__classPrivateFieldGet(this, _Authentication_accessToken, "f") === undefined || !tslib_1.__classPrivateFieldGet(this, _Authentication_accessToken, "f")) {
|
|
71
74
|
return '';
|
|
72
75
|
}
|
|
73
76
|
else {
|
|
74
|
-
return __classPrivateFieldGet(this, _Authentication_accessToken, "f");
|
|
77
|
+
return tslib_1.__classPrivateFieldGet(this, _Authentication_accessToken, "f");
|
|
75
78
|
}
|
|
76
79
|
};
|
|
77
|
-
this.getRefreshedAccessToken = (force) => __awaiter(this, void 0, void 0, function* () {
|
|
78
|
-
if (__classPrivateFieldGet(this, _Authentication_accessToken, "f") === undefined || !__classPrivateFieldGet(this, _Authentication_accessToken, "f")) {
|
|
80
|
+
this.getRefreshedAccessToken = (force) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
if (tslib_1.__classPrivateFieldGet(this, _Authentication_accessToken, "f") === undefined || !tslib_1.__classPrivateFieldGet(this, _Authentication_accessToken, "f")) {
|
|
79
82
|
return '';
|
|
80
83
|
}
|
|
81
84
|
else {
|
|
82
|
-
if (__classPrivateFieldGet(this, _Authentication_refreshInfo, "f") && __classPrivateFieldGet(this, _Authentication_refreshInfo, "f").accessTokenExpireIn) {
|
|
83
|
-
const decoded = __classPrivateFieldGet(this, _Authentication_decodeAccessToken, "f").call(this, __classPrivateFieldGet(this, _Authentication_accessToken, "f"));
|
|
85
|
+
if (tslib_1.__classPrivateFieldGet(this, _Authentication_refreshInfo, "f") && tslib_1.__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").accessTokenExpireIn) {
|
|
86
|
+
const decoded = tslib_1.__classPrivateFieldGet(this, _Authentication_decodeAccessToken, "f").call(this, tslib_1.__classPrivateFieldGet(this, _Authentication_accessToken, "f"));
|
|
84
87
|
if (force || (!!decoded && ((decoded.exp - SECONDS_BEFORE_EXPIRE) * 1000 < Date.now()))) {
|
|
85
|
-
const data = yield __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").renewAccessToken({
|
|
86
|
-
refreshToken: __classPrivateFieldGet(this, _Authentication_refreshInfo, "f").refreshToken,
|
|
87
|
-
verifier: __classPrivateFieldGet(this, _Authentication_refreshInfo, "f").verifier,
|
|
88
|
+
const data = yield tslib_1.__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").renewAccessToken({
|
|
89
|
+
refreshToken: tslib_1.__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").refreshToken,
|
|
90
|
+
verifier: tslib_1.__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").verifier,
|
|
88
91
|
});
|
|
89
92
|
if (data) {
|
|
90
93
|
if (data.refresh_token && data.expires_in) {
|
|
91
|
-
__classPrivateFieldSet(this, _Authentication_refreshInfo, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Authentication_refreshInfo, "f")), { refreshToken: data.refresh_token, accessTokenExpireIn: data.expires_in }), "f");
|
|
94
|
+
tslib_1.__classPrivateFieldSet(this, _Authentication_refreshInfo, Object.assign(Object.assign({}, tslib_1.__classPrivateFieldGet(this, _Authentication_refreshInfo, "f")), { refreshToken: data.refresh_token, accessTokenExpireIn: data.expires_in }), "f");
|
|
92
95
|
}
|
|
93
|
-
__classPrivateFieldSet(this, _Authentication_accessToken, data.access_token, "f");
|
|
94
|
-
yield this.triggerHooks(HookName.afterRefreshToken);
|
|
95
|
-
return __classPrivateFieldGet(this, _Authentication_accessToken, "f");
|
|
96
|
+
tslib_1.__classPrivateFieldSet(this, _Authentication_accessToken, data.access_token, "f");
|
|
97
|
+
yield this.triggerHooks(types_1.HookName.afterRefreshToken);
|
|
98
|
+
return tslib_1.__classPrivateFieldGet(this, _Authentication_accessToken, "f");
|
|
96
99
|
}
|
|
97
100
|
}
|
|
98
101
|
}
|
|
99
|
-
return __classPrivateFieldGet(this, _Authentication_accessToken, "f");
|
|
102
|
+
return tslib_1.__classPrivateFieldGet(this, _Authentication_accessToken, "f");
|
|
100
103
|
}
|
|
101
104
|
});
|
|
102
105
|
this.getDecodedAccessToken = () => {
|
|
103
|
-
if (!__classPrivateFieldGet(this, _Authentication_accessToken, "f")) {
|
|
106
|
+
if (!tslib_1.__classPrivateFieldGet(this, _Authentication_accessToken, "f")) {
|
|
104
107
|
return undefined;
|
|
105
108
|
}
|
|
106
|
-
return __classPrivateFieldGet(this, _Authentication_decodeAccessToken, "f").call(this, __classPrivateFieldGet(this, _Authentication_accessToken, "f"));
|
|
109
|
+
return tslib_1.__classPrivateFieldGet(this, _Authentication_decodeAccessToken, "f").call(this, tslib_1.__classPrivateFieldGet(this, _Authentication_accessToken, "f"));
|
|
107
110
|
};
|
|
108
|
-
this.getDecodedRefreshedAccessToken = (force) => __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
this.getDecodedRefreshedAccessToken = (force) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
109
112
|
const token = yield this.getRefreshedAccessToken(force);
|
|
110
113
|
if (!token) {
|
|
111
114
|
return undefined;
|
|
112
115
|
}
|
|
113
|
-
return __classPrivateFieldGet(this, _Authentication_decodeAccessToken, "f").call(this, token);
|
|
116
|
+
return tslib_1.__classPrivateFieldGet(this, _Authentication_decodeAccessToken, "f").call(this, token);
|
|
114
117
|
});
|
|
115
118
|
this.getHooks = () => {
|
|
116
|
-
if (__classPrivateFieldGet(this, _Authentication_config, "f")) {
|
|
117
|
-
return __classPrivateFieldGet(this, _Authentication_config, "f").hooks;
|
|
119
|
+
if (tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f")) {
|
|
120
|
+
return tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f").hooks;
|
|
118
121
|
}
|
|
119
122
|
else {
|
|
120
123
|
return undefined;
|
|
@@ -122,40 +125,40 @@ export class Authentication {
|
|
|
122
125
|
};
|
|
123
126
|
this.setHook = (params) => {
|
|
124
127
|
const { name, callback } = params;
|
|
125
|
-
if (!Object.values(HookName).find((h) => h === name)) {
|
|
128
|
+
if (!Object.values(types_1.HookName).find((h) => h === name)) {
|
|
126
129
|
throw Error('Unsupported hook: ' + name);
|
|
127
130
|
}
|
|
128
|
-
if (!isFunction(callback)) {
|
|
131
|
+
if (!(0, lodash_1.isFunction)(callback)) {
|
|
129
132
|
throw Error('hook must be a function: ' + name);
|
|
130
133
|
}
|
|
131
|
-
__classPrivateFieldSet(this, _Authentication_config, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Authentication_config, "f")), { hooks: Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Authentication_config, "f").hooks), { [name]: callback }) }), "f");
|
|
132
|
-
if (name === HookName.uniqueSessionTrigger) {
|
|
133
|
-
__classPrivateFieldGet(this, _Authentication_notification, "f").setUniqueSessionTriggerHook(callback);
|
|
134
|
+
tslib_1.__classPrivateFieldSet(this, _Authentication_config, Object.assign(Object.assign({}, tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f")), { hooks: Object.assign(Object.assign({}, tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f").hooks), { [name]: callback }) }), "f");
|
|
135
|
+
if (name === types_1.HookName.uniqueSessionTrigger) {
|
|
136
|
+
tslib_1.__classPrivateFieldGet(this, _Authentication_notification, "f").setUniqueSessionTriggerHook(callback);
|
|
134
137
|
}
|
|
135
138
|
return;
|
|
136
139
|
};
|
|
137
140
|
this.autoLogin = () => {
|
|
138
|
-
return __classPrivateFieldGet(this, _Authentication_config, "f") ? __classPrivateFieldGet(this, _Authentication_config, "f").autoLogin || false : false;
|
|
141
|
+
return tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f") ? tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f").autoLogin || false : false;
|
|
139
142
|
};
|
|
140
143
|
this.autoLogout = () => {
|
|
141
|
-
return __classPrivateFieldGet(this, _Authentication_config, "f") ? __classPrivateFieldGet(this, _Authentication_config, "f").autoLogout || false : false;
|
|
144
|
+
return tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f") ? tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f").autoLogout || false : false;
|
|
142
145
|
};
|
|
143
146
|
this.idleTimeoutInMinutes = () => {
|
|
144
|
-
return __classPrivateFieldGet(this, _Authentication_config, "f") ? __classPrivateFieldGet(this, _Authentication_config, "f").idleTimeoutInMinutes || 30 : 30;
|
|
147
|
+
return tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f") ? tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f").idleTimeoutInMinutes || 30 : 30;
|
|
145
148
|
};
|
|
146
149
|
this.checkTokenInUrl = () => {
|
|
147
|
-
const accessTokenQuery = getQueryParameter('access_token') || getQueryParameter('auth') || getQueryParameter('authToken') || getQueryParameter('token') || getQueryParameter('jwt');
|
|
150
|
+
const accessTokenQuery = (0, utils_1.getQueryParameter)('access_token') || (0, utils_1.getQueryParameter)('auth') || (0, utils_1.getQueryParameter)('authToken') || (0, utils_1.getQueryParameter)('token') || (0, utils_1.getQueryParameter)('jwt');
|
|
148
151
|
if (accessTokenQuery) {
|
|
149
|
-
const { aud, firmId, userId } = __classPrivateFieldGet(this, _Authentication_decodeAccessToken, "f").call(this, accessTokenQuery);
|
|
152
|
+
const { aud, firmId, userId } = tslib_1.__classPrivateFieldGet(this, _Authentication_decodeAccessToken, "f").call(this, accessTokenQuery);
|
|
150
153
|
if (!!firmId && !!userId && aud === '8MBJWOFS4RRRSZQC') {
|
|
151
154
|
const queryParameterValue = accessTokenQuery;
|
|
152
|
-
let myselfWithoutToken = deleteQueryParameter(window.location.href, 'access_token', queryParameterValue);
|
|
153
|
-
myselfWithoutToken = deleteQueryParameter(myselfWithoutToken, 'token', queryParameterValue);
|
|
154
|
-
myselfWithoutToken = deleteQueryParameter(myselfWithoutToken, 'auth', queryParameterValue);
|
|
155
|
-
myselfWithoutToken = deleteQueryParameter(myselfWithoutToken, 'authToken', queryParameterValue);
|
|
156
|
-
myselfWithoutToken = deleteQueryParameter(myselfWithoutToken, 'jwt', queryParameterValue);
|
|
155
|
+
let myselfWithoutToken = (0, utils_1.deleteQueryParameter)(window.location.href, 'access_token', queryParameterValue);
|
|
156
|
+
myselfWithoutToken = (0, utils_1.deleteQueryParameter)(myselfWithoutToken, 'token', queryParameterValue);
|
|
157
|
+
myselfWithoutToken = (0, utils_1.deleteQueryParameter)(myselfWithoutToken, 'auth', queryParameterValue);
|
|
158
|
+
myselfWithoutToken = (0, utils_1.deleteQueryParameter)(myselfWithoutToken, 'authToken', queryParameterValue);
|
|
159
|
+
myselfWithoutToken = (0, utils_1.deleteQueryParameter)(myselfWithoutToken, 'jwt', queryParameterValue);
|
|
157
160
|
const myselfEncoded = encodeURIComponent(myselfWithoutToken);
|
|
158
|
-
window.location.href = __classPrivateFieldGet(this, _Authentication_config, "f").authHost + '/oauth/passthrough?token=' + queryParameterValue + '&redirect=' + myselfEncoded;
|
|
161
|
+
window.location.href = tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f").authHost + '/oauth/passthrough?token=' + queryParameterValue + '&redirect=' + myselfEncoded;
|
|
159
162
|
return true;
|
|
160
163
|
}
|
|
161
164
|
return false;
|
|
@@ -163,8 +166,8 @@ export class Authentication {
|
|
|
163
166
|
return false;
|
|
164
167
|
};
|
|
165
168
|
this.checkTokenInInit = () => {
|
|
166
|
-
if (__classPrivateFieldGet(this, _Authentication_config, "f") && __classPrivateFieldGet(this, _Authentication_config, "f").initToken) {
|
|
167
|
-
const { jti } = __classPrivateFieldGet(this, _Authentication_decodeAccessToken, "f").call(this, __classPrivateFieldGet(this, _Authentication_config, "f").initToken);
|
|
169
|
+
if (tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f") && tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f").initToken) {
|
|
170
|
+
const { jti } = tslib_1.__classPrivateFieldGet(this, _Authentication_decodeAccessToken, "f").call(this, tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f").initToken);
|
|
168
171
|
if (jti) {
|
|
169
172
|
const windowPassthroughSession = window.sessionStorage.getItem(PASSTHROUGH_SESSION_KEY);
|
|
170
173
|
if (windowPassthroughSession) {
|
|
@@ -173,27 +176,27 @@ export class Authentication {
|
|
|
173
176
|
}
|
|
174
177
|
window.sessionStorage.setItem(PASSTHROUGH_SESSION_KEY, jti);
|
|
175
178
|
const myselfEncoded = encodeURIComponent(window.location.href);
|
|
176
|
-
window.location.href = __classPrivateFieldGet(this, _Authentication_config, "f").authHost + '/oauth/passthrough?jti=' + jti + '&redirect=' + myselfEncoded;
|
|
179
|
+
window.location.href = tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f").authHost + '/oauth/passthrough?jti=' + jti + '&redirect=' + myselfEncoded;
|
|
177
180
|
return true;
|
|
178
181
|
}
|
|
179
182
|
}
|
|
180
183
|
window.sessionStorage.removeItem(PASSTHROUGH_SESSION_KEY);
|
|
181
184
|
return false;
|
|
182
185
|
};
|
|
183
|
-
this.verifySession = () => __awaiter(this, void 0, void 0, function* () {
|
|
184
|
-
const code_verifier = createRandomString(64);
|
|
185
|
-
const state = createRandomString(6);
|
|
186
|
+
this.verifySession = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
187
|
+
const code_verifier = (0, utils_1.createRandomString)(64);
|
|
188
|
+
const state = (0, utils_1.createRandomString)(6);
|
|
186
189
|
window.sessionStorage.setItem(state, code_verifier);
|
|
187
|
-
const { code_challenge, code_challenge_method } = yield createCodeChallenge(code_verifier);
|
|
188
|
-
const scope = __classPrivateFieldGet(this, _Authentication_config, "f").scopes.join(',');
|
|
190
|
+
const { code_challenge, code_challenge_method } = yield (0, utils_1.createCodeChallenge)(code_verifier);
|
|
191
|
+
const scope = tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f").scopes.join(',');
|
|
189
192
|
const redirectUri = `${window.location.protocol}//${window.location.host}${window.location.pathname}`;
|
|
190
|
-
const url = `${__classPrivateFieldGet(this, _Authentication_config, "f").authHost}/oauth/authorize?response_type=code&response_mode=web_message&scope=${scope}&client_id=${__classPrivateFieldGet(this, _Authentication_config, "f").clientId}&redirect_uri=${encodeURIComponent(redirectUri)}&code_challenge=${encodeURIComponent(code_challenge)}&code_challenge_method=${code_challenge_method}&state=${state}&prompt=none`;
|
|
193
|
+
const url = `${tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f").authHost}/oauth/authorize?response_type=code&response_mode=web_message&scope=${scope}&client_id=${tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f").clientId}&redirect_uri=${encodeURIComponent(redirectUri)}&code_challenge=${encodeURIComponent(code_challenge)}&code_challenge_method=${code_challenge_method}&state=${state}&prompt=none`;
|
|
191
194
|
const resp = yield this.runIframe(url, state);
|
|
192
195
|
if (resp && resp.state) {
|
|
193
196
|
const verifier = window.sessionStorage.getItem(resp.state);
|
|
194
197
|
window.sessionStorage.removeItem(resp.state);
|
|
195
198
|
if (resp.code && verifier) {
|
|
196
|
-
return __classPrivateFieldGet(this, _Authentication_exchangeAuthCodeForAccessToken, "f").call(this, {
|
|
199
|
+
return tslib_1.__classPrivateFieldGet(this, _Authentication_exchangeAuthCodeForAccessToken, "f").call(this, {
|
|
197
200
|
code: resp.code,
|
|
198
201
|
verifier,
|
|
199
202
|
redirectUri
|
|
@@ -205,7 +208,7 @@ export class Authentication {
|
|
|
205
208
|
return false;
|
|
206
209
|
}
|
|
207
210
|
});
|
|
208
|
-
this.checkAuthCode = () => __awaiter(this, void 0, void 0, function* () {
|
|
211
|
+
this.checkAuthCode = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
209
212
|
const search = window.location.search;
|
|
210
213
|
const queryParams = new URLSearchParams(search);
|
|
211
214
|
const code = queryParams.get('code');
|
|
@@ -214,10 +217,10 @@ export class Authentication {
|
|
|
214
217
|
const verifier = window.sessionStorage.getItem(state);
|
|
215
218
|
window.sessionStorage.removeItem(state);
|
|
216
219
|
let newUrl = window.location.href;
|
|
217
|
-
newUrl = deleteQueryParameter(newUrl, 'code', code);
|
|
218
|
-
newUrl = deleteQueryParameter(newUrl, 'state', state);
|
|
220
|
+
newUrl = (0, utils_1.deleteQueryParameter)(newUrl, 'code', code);
|
|
221
|
+
newUrl = (0, utils_1.deleteQueryParameter)(newUrl, 'state', state);
|
|
219
222
|
window.history.pushState(null, '', newUrl);
|
|
220
|
-
return __classPrivateFieldGet(this, _Authentication_exchangeAuthCodeForAccessToken, "f").call(this, {
|
|
223
|
+
return tslib_1.__classPrivateFieldGet(this, _Authentication_exchangeAuthCodeForAccessToken, "f").call(this, {
|
|
221
224
|
code,
|
|
222
225
|
verifier,
|
|
223
226
|
redirectUri: newUrl
|
|
@@ -227,51 +230,51 @@ export class Authentication {
|
|
|
227
230
|
return false;
|
|
228
231
|
}
|
|
229
232
|
});
|
|
230
|
-
this.getUserInfo = () => __awaiter(this, void 0, void 0, function* () {
|
|
233
|
+
this.getUserInfo = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
231
234
|
const token = yield this.getRefreshedAccessToken();
|
|
232
|
-
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").userInfo(token);
|
|
235
|
+
return tslib_1.__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").userInfo(token);
|
|
233
236
|
});
|
|
234
|
-
this.linkUser = (params) => __awaiter(this, void 0, void 0, function* () {
|
|
237
|
+
this.linkUser = (params) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
235
238
|
const decodeToken = yield this.getDecodedRefreshedAccessToken();
|
|
236
239
|
if (!decodeToken) {
|
|
237
240
|
return;
|
|
238
241
|
}
|
|
239
242
|
const redirectUrl = params.redirectUrl || window.location.href;
|
|
240
|
-
__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").linkUser({
|
|
243
|
+
tslib_1.__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").linkUser({
|
|
241
244
|
redirectUrl,
|
|
242
245
|
jti: decodeToken.jti,
|
|
243
246
|
newWindow: params.newWindow,
|
|
244
247
|
callback: params.callback,
|
|
245
248
|
});
|
|
246
249
|
});
|
|
247
|
-
this.unlinkUser = (params) => __awaiter(this, void 0, void 0, function* () {
|
|
250
|
+
this.unlinkUser = (params) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
248
251
|
const decodeToken = yield this.getDecodedRefreshedAccessToken();
|
|
249
252
|
if (!decodeToken) {
|
|
250
253
|
return;
|
|
251
254
|
}
|
|
252
255
|
const redirectUrl = params.redirectUrl || window.location.href;
|
|
253
|
-
__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").unlinkUser({
|
|
256
|
+
tslib_1.__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").unlinkUser({
|
|
254
257
|
redirectUrl,
|
|
255
258
|
jti: decodeToken.jti,
|
|
256
259
|
newWindow: params.newWindow,
|
|
257
260
|
callback: params.callback,
|
|
258
261
|
});
|
|
259
262
|
});
|
|
260
|
-
this.getCloudProviderToken = (jti) => __awaiter(this, void 0, void 0, function* () {
|
|
263
|
+
this.getCloudProviderToken = (jti) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
261
264
|
const token = yield this.getRefreshedAccessToken();
|
|
262
265
|
if (!token) {
|
|
263
266
|
throw Error('Not authenticated yet');
|
|
264
267
|
}
|
|
265
|
-
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").getCloudProviderToken(token, jti);
|
|
268
|
+
return tslib_1.__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").getCloudProviderToken(token, jti);
|
|
266
269
|
});
|
|
267
|
-
this.cloudProviderUserInfo = () => __awaiter(this, void 0, void 0, function* () {
|
|
270
|
+
this.cloudProviderUserInfo = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
268
271
|
const token = yield this.getRefreshedAccessToken();
|
|
269
272
|
if (!token) {
|
|
270
273
|
throw Error('Not authenticated yet');
|
|
271
274
|
}
|
|
272
|
-
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").cloudProviderUserInfo(token);
|
|
275
|
+
return tslib_1.__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").cloudProviderUserInfo(token);
|
|
273
276
|
});
|
|
274
|
-
this.cloudProviderReauthenticate = (params) => __awaiter(this, void 0, void 0, function* () {
|
|
277
|
+
this.cloudProviderReauthenticate = (params) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
275
278
|
const token = yield this.getRefreshedAccessToken();
|
|
276
279
|
if (!token) {
|
|
277
280
|
throw Error('Not authenticated yet');
|
|
@@ -280,51 +283,51 @@ export class Authentication {
|
|
|
280
283
|
const { newWindow, callback } = params;
|
|
281
284
|
redirectUrl = redirectUrl || window.location.href;
|
|
282
285
|
if (!nonce) {
|
|
283
|
-
const reauthticateLink = yield __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").cloudProviderReauthenticateLink(token);
|
|
286
|
+
const reauthticateLink = yield tslib_1.__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").cloudProviderReauthenticateLink(token);
|
|
284
287
|
nonce = reauthticateLink.nonce;
|
|
285
288
|
}
|
|
286
|
-
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").cloudProviderReauthenticate({
|
|
289
|
+
return tslib_1.__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").cloudProviderReauthenticate({
|
|
287
290
|
redirectUrl,
|
|
288
291
|
nonce,
|
|
289
292
|
newWindow,
|
|
290
293
|
callback,
|
|
291
294
|
});
|
|
292
295
|
});
|
|
293
|
-
this.cloudProviderUpdate = (cloudProviderId) => __awaiter(this, void 0, void 0, function* () {
|
|
296
|
+
this.cloudProviderUpdate = (cloudProviderId) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
294
297
|
const token = yield this.getRefreshedAccessToken();
|
|
295
298
|
if (!token) {
|
|
296
299
|
throw Error('Not authenticated yet');
|
|
297
300
|
}
|
|
298
|
-
const decodedToken = __classPrivateFieldGet(this, _Authentication_decodeAccessToken, "f").call(this, token);
|
|
301
|
+
const decodedToken = tslib_1.__classPrivateFieldGet(this, _Authentication_decodeAccessToken, "f").call(this, token);
|
|
299
302
|
const { firmId } = decodedToken;
|
|
300
|
-
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").cloudProviderUpdate({ firmId, cloudProviderId, token: token });
|
|
303
|
+
return tslib_1.__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").cloudProviderUpdate({ firmId, cloudProviderId, token: token });
|
|
301
304
|
});
|
|
302
|
-
this.statusAdminConsent = () => __awaiter(this, void 0, void 0, function* () {
|
|
305
|
+
this.statusAdminConsent = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
303
306
|
const token = yield this.getRefreshedAccessToken();
|
|
304
307
|
if (!token) {
|
|
305
308
|
throw Error('Not authenticated yet');
|
|
306
309
|
}
|
|
307
|
-
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").statusAdminConsent(token);
|
|
310
|
+
return tslib_1.__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").statusAdminConsent(token);
|
|
308
311
|
});
|
|
309
312
|
this.getAdminConsent = (params) => {
|
|
310
313
|
const redirectUrl = params.redirectUrl || window.location.href;
|
|
311
|
-
__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").getAdminConsent(Object.assign(Object.assign({}, params), { redirectUrl }));
|
|
314
|
+
tslib_1.__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").getAdminConsent(Object.assign(Object.assign({}, params), { redirectUrl }));
|
|
312
315
|
};
|
|
313
|
-
this.revokeAdminConsent = () => __awaiter(this, void 0, void 0, function* () {
|
|
316
|
+
this.revokeAdminConsent = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
314
317
|
const token = yield this.getRefreshedAccessToken();
|
|
315
318
|
if (!token) {
|
|
316
319
|
throw Error('Not authenticated yet');
|
|
317
320
|
}
|
|
318
|
-
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").revokeAdminConsent(token);
|
|
321
|
+
return tslib_1.__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").revokeAdminConsent(token);
|
|
319
322
|
});
|
|
320
|
-
this.getLinkMap = (allUsers = false) => __awaiter(this, void 0, void 0, function* () {
|
|
323
|
+
this.getLinkMap = (allUsers = false) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
321
324
|
const token = yield this.getRefreshedAccessToken();
|
|
322
325
|
if (!token) {
|
|
323
326
|
throw Error('Not authenticated yet');
|
|
324
327
|
}
|
|
325
|
-
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").getLinkMap(token, allUsers);
|
|
328
|
+
return tslib_1.__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").getLinkMap(token, allUsers);
|
|
326
329
|
});
|
|
327
|
-
this.setLinkMap = (linkMap) => __awaiter(this, void 0, void 0, function* () {
|
|
330
|
+
this.setLinkMap = (linkMap) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
328
331
|
const token = yield this.getRefreshedAccessToken();
|
|
329
332
|
if (!token) {
|
|
330
333
|
throw Error('Not authenticated yet');
|
|
@@ -341,25 +344,25 @@ export class Authentication {
|
|
|
341
344
|
};
|
|
342
345
|
if (!verifyFormat())
|
|
343
346
|
throw Error('linkmap in wrong format');
|
|
344
|
-
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").setLinkMap(token, linkMap);
|
|
347
|
+
return tslib_1.__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").setLinkMap(token, linkMap);
|
|
345
348
|
});
|
|
346
|
-
this.authoriseSupport = (params) => __awaiter(this, void 0, void 0, function* () {
|
|
349
|
+
this.authoriseSupport = (params) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
347
350
|
const token = yield this.getRefreshedAccessToken();
|
|
348
351
|
if (!token) {
|
|
349
352
|
throw Error('Not authenticated yet');
|
|
350
353
|
}
|
|
351
|
-
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").authoriseSupport(token, params);
|
|
354
|
+
return tslib_1.__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").authoriseSupport(token, params);
|
|
352
355
|
});
|
|
353
356
|
this.changePassword = (params) => {
|
|
354
357
|
const redirectUrl = params.redirectUrl || window.location.href;
|
|
355
|
-
__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").changePassword(Object.assign(Object.assign({}, params), { redirectUrl }));
|
|
358
|
+
tslib_1.__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").changePassword(Object.assign(Object.assign({}, params), { redirectUrl }));
|
|
356
359
|
};
|
|
357
|
-
this.passthrough = (params) => __awaiter(this, void 0, void 0, function* () {
|
|
360
|
+
this.passthrough = (params) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
358
361
|
const decodedToken = yield this.getDecodedRefreshedAccessToken();
|
|
359
362
|
if (decodedToken && decodedToken.jti) {
|
|
360
363
|
const { url, newWindow, authHost } = params;
|
|
361
364
|
const encodedRedirectUrl = encodeURIComponent(url);
|
|
362
|
-
const passthroughUrl = `${authHost || __classPrivateFieldGet(this, _Authentication_config, "f").authHost}/oauth/passthrough?jti=${decodedToken.jti}&redirect=${encodedRedirectUrl}&output=embed`;
|
|
365
|
+
const passthroughUrl = `${authHost || tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f").authHost}/oauth/passthrough?jti=${decodedToken.jti}&redirect=${encodedRedirectUrl}&output=embed`;
|
|
363
366
|
if (newWindow) {
|
|
364
367
|
window.open(passthroughUrl, '_blank');
|
|
365
368
|
}
|
|
@@ -369,16 +372,16 @@ export class Authentication {
|
|
|
369
372
|
}
|
|
370
373
|
return;
|
|
371
374
|
});
|
|
372
|
-
this.triggerHooks = (hookName) => __awaiter(this, void 0, void 0, function* () {
|
|
375
|
+
this.triggerHooks = (hookName) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
373
376
|
const hooks = this.getHooks();
|
|
374
377
|
const token = yield this.getRefreshedAccessToken();
|
|
375
|
-
const hookFn = hooks && !!hooks[hookName] && isFunction(hooks[hookName]) ? hooks[hookName](token) : false;
|
|
378
|
+
const hookFn = hooks && !!hooks[hookName] && (0, lodash_1.isFunction)(hooks[hookName]) ? hooks[hookName](token) : false;
|
|
376
379
|
return Promise.resolve(hookFn);
|
|
377
380
|
});
|
|
378
381
|
this.afterAuthenticated = () => {
|
|
379
|
-
return this.triggerHooks(HookName.afterLogin).then(() => __awaiter(this, void 0, void 0, function* () {
|
|
382
|
+
return this.triggerHooks(types_1.HookName.afterLogin).then(() => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
380
383
|
yield this.initNotification();
|
|
381
|
-
return __classPrivateFieldGet(this, _Authentication_accessToken, "f");
|
|
384
|
+
return tslib_1.__classPrivateFieldGet(this, _Authentication_accessToken, "f");
|
|
382
385
|
}));
|
|
383
386
|
};
|
|
384
387
|
this.runIframe = (authorizeUrl, state, timeoutInSeconds = DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS) => {
|
|
@@ -401,7 +404,7 @@ export class Authentication {
|
|
|
401
404
|
}, timeoutInSeconds * 1000);
|
|
402
405
|
const iframeEventHandler = (e) => {
|
|
403
406
|
const { data, origin, source } = e;
|
|
404
|
-
if (origin !== __classPrivateFieldGet(this, _Authentication_config, "f").authHost)
|
|
407
|
+
if (origin !== tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f").authHost)
|
|
405
408
|
return;
|
|
406
409
|
if (!data || data.type !== 'authorization_response')
|
|
407
410
|
return;
|
|
@@ -418,42 +421,42 @@ export class Authentication {
|
|
|
418
421
|
iframe.setAttribute('src', authorizeUrl);
|
|
419
422
|
});
|
|
420
423
|
};
|
|
421
|
-
_Authentication_exchangeAuthCodeForAccessToken.set(this, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
424
|
+
_Authentication_exchangeAuthCodeForAccessToken.set(this, (params) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
422
425
|
const { verifier, code, redirectUri } = params;
|
|
423
426
|
if (verifier) {
|
|
424
|
-
const data = yield __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").exchangeAuthCodeForAccessToken({
|
|
427
|
+
const data = yield tslib_1.__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").exchangeAuthCodeForAccessToken({
|
|
425
428
|
code,
|
|
426
429
|
verifier,
|
|
427
430
|
redirectUri
|
|
428
431
|
});
|
|
429
|
-
const redirectTriggered = yield __classPrivateFieldGet(this, _Authentication_verifyAndPerformRedirections, "f").call(this, data.access_token);
|
|
432
|
+
const redirectTriggered = yield tslib_1.__classPrivateFieldGet(this, _Authentication_verifyAndPerformRedirections, "f").call(this, data.access_token);
|
|
430
433
|
if (redirectTriggered) {
|
|
431
434
|
return true;
|
|
432
435
|
}
|
|
433
436
|
if (data.refresh_token &&
|
|
434
437
|
data.expires_in) {
|
|
435
|
-
__classPrivateFieldSet(this, _Authentication_refreshInfo, {
|
|
438
|
+
tslib_1.__classPrivateFieldSet(this, _Authentication_refreshInfo, {
|
|
436
439
|
refreshToken: data.refresh_token,
|
|
437
440
|
accessTokenExpireIn: data.expires_in,
|
|
438
441
|
verifier: verifier,
|
|
439
442
|
timer: undefined,
|
|
440
443
|
}, "f");
|
|
441
|
-
if (__classPrivateFieldGet(this, _Authentication_config, "f").autoRefreshToken) {
|
|
442
|
-
__classPrivateFieldGet(this, _Authentication_startRefreshAccessTokenProcess, "f").call(this);
|
|
444
|
+
if (tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f").autoRefreshToken) {
|
|
445
|
+
tslib_1.__classPrivateFieldGet(this, _Authentication_startRefreshAccessTokenProcess, "f").call(this);
|
|
443
446
|
}
|
|
444
447
|
}
|
|
445
|
-
__classPrivateFieldSet(this, _Authentication_accessToken, data.access_token, "f");
|
|
448
|
+
tslib_1.__classPrivateFieldSet(this, _Authentication_accessToken, data.access_token, "f");
|
|
446
449
|
return true;
|
|
447
450
|
}
|
|
448
451
|
else {
|
|
449
452
|
return false;
|
|
450
453
|
}
|
|
451
454
|
}));
|
|
452
|
-
_Authentication_verifyAndPerformRedirections.set(this, (accessToken) => __awaiter(this, void 0, void 0, function* () {
|
|
453
|
-
const redirectionConfig = yield __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").getRedirections();
|
|
455
|
+
_Authentication_verifyAndPerformRedirections.set(this, (accessToken) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
456
|
+
const redirectionConfig = yield tslib_1.__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").getRedirections();
|
|
454
457
|
const origin = window.location.origin;
|
|
455
|
-
const decodedToken = __classPrivateFieldGet(this, _Authentication_decodeAccessToken, "f").call(this, accessToken);
|
|
456
|
-
const redirectUri = getRedirectUri(origin, decodedToken, redirectionConfig);
|
|
458
|
+
const decodedToken = tslib_1.__classPrivateFieldGet(this, _Authentication_decodeAccessToken, "f").call(this, accessToken);
|
|
459
|
+
const redirectUri = (0, redirections_1.getRedirectUri)(origin, decodedToken, redirectionConfig);
|
|
457
460
|
if (redirectUri) {
|
|
458
461
|
this.logout(false, redirectUri);
|
|
459
462
|
return true;
|
|
@@ -461,44 +464,44 @@ export class Authentication {
|
|
|
461
464
|
return false;
|
|
462
465
|
}));
|
|
463
466
|
_Authentication_startRefreshAccessTokenProcess.set(this, () => {
|
|
464
|
-
if (!__classPrivateFieldGet(this, _Authentication_refreshInfo, "f")) {
|
|
467
|
+
if (!tslib_1.__classPrivateFieldGet(this, _Authentication_refreshInfo, "f")) {
|
|
465
468
|
return;
|
|
466
469
|
}
|
|
467
|
-
if (__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").timer) {
|
|
468
|
-
clearTimeout(__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").timer);
|
|
469
|
-
__classPrivateFieldSet(this, _Authentication_refreshInfo, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Authentication_refreshInfo, "f")), { timer: undefined }), "f");
|
|
470
|
+
if (tslib_1.__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").timer) {
|
|
471
|
+
clearTimeout(tslib_1.__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").timer);
|
|
472
|
+
tslib_1.__classPrivateFieldSet(this, _Authentication_refreshInfo, Object.assign(Object.assign({}, tslib_1.__classPrivateFieldGet(this, _Authentication_refreshInfo, "f")), { timer: undefined }), "f");
|
|
470
473
|
}
|
|
471
|
-
const waitBeforeExecuting = (__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").accessTokenExpireIn - SECONDS_BEFORE_EXPIRE) * 1000;
|
|
474
|
+
const waitBeforeExecuting = (tslib_1.__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").accessTokenExpireIn - SECONDS_BEFORE_EXPIRE) * 1000;
|
|
472
475
|
if (waitBeforeExecuting > MAX_SETTIME_OUT) {
|
|
473
476
|
return;
|
|
474
477
|
}
|
|
475
|
-
const timer = setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
476
|
-
if (!__classPrivateFieldGet(this, _Authentication_refreshInfo, "f")) {
|
|
478
|
+
const timer = setTimeout(() => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
479
|
+
if (!tslib_1.__classPrivateFieldGet(this, _Authentication_refreshInfo, "f")) {
|
|
477
480
|
return;
|
|
478
481
|
}
|
|
479
|
-
const data = yield __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").renewAccessToken({
|
|
480
|
-
refreshToken: __classPrivateFieldGet(this, _Authentication_refreshInfo, "f").refreshToken,
|
|
481
|
-
verifier: __classPrivateFieldGet(this, _Authentication_refreshInfo, "f").verifier,
|
|
482
|
+
const data = yield tslib_1.__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").renewAccessToken({
|
|
483
|
+
refreshToken: tslib_1.__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").refreshToken,
|
|
484
|
+
verifier: tslib_1.__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").verifier,
|
|
482
485
|
});
|
|
483
486
|
if (data) {
|
|
484
487
|
if (data.refresh_token && data.expires_in) {
|
|
485
|
-
__classPrivateFieldSet(this, _Authentication_refreshInfo, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Authentication_refreshInfo, "f")), { refreshToken: data.refresh_token, accessTokenExpireIn: data.expires_in }), "f");
|
|
486
|
-
__classPrivateFieldGet(this, _Authentication_startRefreshAccessTokenProcess, "f").call(this);
|
|
488
|
+
tslib_1.__classPrivateFieldSet(this, _Authentication_refreshInfo, Object.assign(Object.assign({}, tslib_1.__classPrivateFieldGet(this, _Authentication_refreshInfo, "f")), { refreshToken: data.refresh_token, accessTokenExpireIn: data.expires_in }), "f");
|
|
489
|
+
tslib_1.__classPrivateFieldGet(this, _Authentication_startRefreshAccessTokenProcess, "f").call(this);
|
|
487
490
|
}
|
|
488
|
-
__classPrivateFieldSet(this, _Authentication_accessToken, data.access_token, "f");
|
|
489
|
-
yield this.triggerHooks(HookName.afterRefreshToken);
|
|
491
|
+
tslib_1.__classPrivateFieldSet(this, _Authentication_accessToken, data.access_token, "f");
|
|
492
|
+
yield this.triggerHooks(types_1.HookName.afterRefreshToken);
|
|
490
493
|
}
|
|
491
494
|
}), waitBeforeExecuting);
|
|
492
|
-
__classPrivateFieldSet(this, _Authentication_refreshInfo, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Authentication_refreshInfo, "f")), { timer }), "f");
|
|
495
|
+
tslib_1.__classPrivateFieldSet(this, _Authentication_refreshInfo, Object.assign(Object.assign({}, tslib_1.__classPrivateFieldGet(this, _Authentication_refreshInfo, "f")), { timer }), "f");
|
|
493
496
|
});
|
|
494
497
|
_Authentication_destroyRefreshAccessTokenProcess.set(this, () => {
|
|
495
|
-
if (!__classPrivateFieldGet(this, _Authentication_refreshInfo, "f")) {
|
|
498
|
+
if (!tslib_1.__classPrivateFieldGet(this, _Authentication_refreshInfo, "f")) {
|
|
496
499
|
return;
|
|
497
500
|
}
|
|
498
|
-
if (__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").timer) {
|
|
499
|
-
clearTimeout(__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").timer);
|
|
501
|
+
if (tslib_1.__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").timer) {
|
|
502
|
+
clearTimeout(tslib_1.__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").timer);
|
|
500
503
|
}
|
|
501
|
-
__classPrivateFieldSet(this, _Authentication_refreshInfo, undefined, "f");
|
|
504
|
+
tslib_1.__classPrivateFieldSet(this, _Authentication_refreshInfo, undefined, "f");
|
|
502
505
|
});
|
|
503
506
|
_Authentication_decodeAccessToken.set(this, (accessToken) => {
|
|
504
507
|
if (!accessToken) {
|
|
@@ -516,11 +519,11 @@ export class Authentication {
|
|
|
516
519
|
}
|
|
517
520
|
return undefined;
|
|
518
521
|
});
|
|
519
|
-
__classPrivateFieldSet(this, _Authentication_accessToken, undefined, "f");
|
|
520
|
-
__classPrivateFieldSet(this, _Authentication_config, init(options), "f");
|
|
521
|
-
__classPrivateFieldSet(this, _Authentication_leapAuthService, new LeapAuthService(__classPrivateFieldGet(this, _Authentication_config, "f").authHost, __classPrivateFieldGet(this, _Authentication_config, "f").clientId), "f");
|
|
522
|
-
__classPrivateFieldSet(this, _Authentication_notification, new Notification(), "f");
|
|
522
|
+
tslib_1.__classPrivateFieldSet(this, _Authentication_accessToken, undefined, "f");
|
|
523
|
+
tslib_1.__classPrivateFieldSet(this, _Authentication_config, (0, config_1.init)(options), "f");
|
|
524
|
+
tslib_1.__classPrivateFieldSet(this, _Authentication_leapAuthService, new auth_service_1.LeapAuthService(tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f").authHost, tslib_1.__classPrivateFieldGet(this, _Authentication_config, "f").clientId), "f");
|
|
525
|
+
tslib_1.__classPrivateFieldSet(this, _Authentication_notification, new notification_1.Notification(), "f");
|
|
523
526
|
}
|
|
524
527
|
}
|
|
528
|
+
exports.Authentication = Authentication;
|
|
525
529
|
_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();
|
|
526
|
-
//# sourceMappingURL=authentication.js.map
|