@leapdev/auth-agent 2.2.11 → 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/CHANGELOG.md +4 -0
- package/package.json +2 -2
- 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
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
## 2.2.*
|
|
4
4
|
|
|
5
|
+
### [2.2.12]
|
|
6
|
+
#### Bugfixes
|
|
7
|
+
* Update pubnub to v7.4.0 to fix Vulnerability warnings from Synopsis scan
|
|
8
|
+
|
|
5
9
|
### [2.2.11]
|
|
6
10
|
#### Features
|
|
7
11
|
* In function AuthAgent.getRefreshedAccessToken(force?: boolean) & AuthAgent.getDecodedRefreshedAccessToken(force?: boolean), now user can provide "force" with boolean value. AuthAgent will force to get a refreshed access token even the existing token is not expired
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leapdev/auth-agent",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.13-beta.0",
|
|
4
4
|
"description": "LEAP Auth Agent",
|
|
5
5
|
"license": "LEAP Legal Software, PTY LTD",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"lodash": "^4.17.21",
|
|
10
10
|
"uuid": "^8.3.2",
|
|
11
|
-
"pubnub": "7.
|
|
11
|
+
"pubnub": "7.4.0",
|
|
12
12
|
"tslib": "^2.3.0"
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {}
|
package/src/index.js
CHANGED
package/src/lib/auth-agent.js
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthAgent = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const authentication_1 = require("./authentication");
|
|
6
|
+
const idle_timer_1 = require("./idle-timer");
|
|
7
|
+
const types_1 = require("./types");
|
|
5
8
|
let auth;
|
|
6
|
-
const init = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
7
|
-
auth = new Authentication(options);
|
|
9
|
+
const init = (options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
10
|
+
auth = new authentication_1.Authentication(options);
|
|
8
11
|
if (!auth) {
|
|
9
12
|
return false;
|
|
10
13
|
}
|
|
11
14
|
const autoLogout = auth.autoLogout();
|
|
12
15
|
if (autoLogout) {
|
|
13
16
|
const timeoutInMinutes = auth.idleTimeoutInMinutes();
|
|
14
|
-
const idleTimer = new IdleTimer({ timeoutInMinutes, onTimeout: logout });
|
|
17
|
+
const idleTimer = new idle_timer_1.IdleTimer({ timeoutInMinutes, onTimeout: logout });
|
|
15
18
|
idleTimer.tracker();
|
|
16
19
|
}
|
|
17
20
|
const done = yield auth.checkAuthCode();
|
|
@@ -32,7 +35,7 @@ const init = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
32
35
|
}
|
|
33
36
|
return true;
|
|
34
37
|
});
|
|
35
|
-
const verifySession = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
+
const verifySession = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
36
39
|
if (!auth) {
|
|
37
40
|
throw Error('Not init yet');
|
|
38
41
|
}
|
|
@@ -41,10 +44,10 @@ const verifySession = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
41
44
|
const getAccessToken = () => {
|
|
42
45
|
return !auth ? '' : auth.getAccessToken();
|
|
43
46
|
};
|
|
44
|
-
const getRefreshedAccessToken = (force) => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
+
const getRefreshedAccessToken = (force) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
45
48
|
return !auth ? '' : yield auth.getRefreshedAccessToken(force);
|
|
46
49
|
});
|
|
47
|
-
const login = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
+
const login = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
48
51
|
if (!auth) {
|
|
49
52
|
throw Error('Not init yet');
|
|
50
53
|
}
|
|
@@ -52,11 +55,11 @@ const login = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
52
55
|
return token && auth ? auth.afterAuthenticated() : undefined;
|
|
53
56
|
});
|
|
54
57
|
});
|
|
55
|
-
const logout = (force = false, redirectUrl) => __awaiter(void 0, void 0, void 0, function* () {
|
|
58
|
+
const logout = (force = false, redirectUrl) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
56
59
|
if (!auth) {
|
|
57
60
|
throw Error('Not init yet');
|
|
58
61
|
}
|
|
59
|
-
return auth.triggerHooks(HookName.beforeLogout)
|
|
62
|
+
return auth.triggerHooks(types_1.HookName.beforeLogout)
|
|
60
63
|
.then(() => {
|
|
61
64
|
if (auth) {
|
|
62
65
|
auth.destroyNotification();
|
|
@@ -84,7 +87,7 @@ const getDecodedAccessToken = () => {
|
|
|
84
87
|
}
|
|
85
88
|
return auth.getDecodedAccessToken();
|
|
86
89
|
};
|
|
87
|
-
const getDecodedRefreshedAccessToken = (force) => __awaiter(void 0, void 0, void 0, function* () {
|
|
90
|
+
const getDecodedRefreshedAccessToken = (force) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
88
91
|
if (!auth) {
|
|
89
92
|
throw Error('Not init yet');
|
|
90
93
|
}
|
|
@@ -96,13 +99,13 @@ const userInfo = () => {
|
|
|
96
99
|
}
|
|
97
100
|
return auth.getUserInfo();
|
|
98
101
|
};
|
|
99
|
-
const linkUser = (redirectUrl, newWindow, callback) => __awaiter(void 0, void 0, void 0, function* () {
|
|
102
|
+
const linkUser = (redirectUrl, newWindow, callback) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
100
103
|
if (!auth) {
|
|
101
104
|
throw Error('Not init yet');
|
|
102
105
|
}
|
|
103
106
|
yield auth.linkUser({ redirectUrl, newWindow, callback });
|
|
104
107
|
});
|
|
105
|
-
const unlinkUser = (redirectUrl, newWindow, callback) => __awaiter(void 0, void 0, void 0, function* () {
|
|
108
|
+
const unlinkUser = (redirectUrl, newWindow, callback) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
106
109
|
if (!auth) {
|
|
107
110
|
throw Error('Not init yet');
|
|
108
111
|
}
|
|
@@ -188,13 +191,13 @@ const registerEventListener = (topic, messageType, callback) => {
|
|
|
188
191
|
}
|
|
189
192
|
auth.registerEventListenerForUserChannel({ topic, messageType, callback });
|
|
190
193
|
};
|
|
191
|
-
const passthrough = (url, newWindow = false, authHost) => __awaiter(void 0, void 0, void 0, function* () {
|
|
194
|
+
const passthrough = (url, newWindow = false, authHost) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
192
195
|
if (!auth) {
|
|
193
196
|
throw Error('Not init yet');
|
|
194
197
|
}
|
|
195
198
|
yield auth.passthrough({ url, newWindow, authHost });
|
|
196
199
|
});
|
|
197
|
-
|
|
200
|
+
exports.AuthAgent = {
|
|
198
201
|
init,
|
|
199
202
|
registerHook,
|
|
200
203
|
login,
|
|
@@ -220,4 +223,3 @@ export const AuthAgent = {
|
|
|
220
223
|
registerEventListener,
|
|
221
224
|
passthrough,
|
|
222
225
|
};
|
|
223
|
-
//# sourceMappingURL=auth-agent.js.map
|
package/src/lib/auth.service.js
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var _LeapAuthService_authHost, _LeapAuthService_clientId, _LeapAuthService_xhr, _LeapAuthService_redirectUrl;
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.LeapAuthService = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const lodash_1 = require("lodash");
|
|
4
7
|
const LEAP_AUTH_CLOSE_WINDOW_URL = '/oauth/close';
|
|
5
|
-
|
|
8
|
+
class LeapAuthService {
|
|
6
9
|
constructor(authHost, clientId) {
|
|
7
10
|
_LeapAuthService_authHost.set(this, void 0);
|
|
8
11
|
_LeapAuthService_clientId.set(this, void 0);
|
|
9
12
|
this.getAccessTokenByJti = (jti) => {
|
|
10
13
|
return new Promise((resolve, reject) => {
|
|
11
|
-
__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
14
|
+
tslib_1.__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
12
15
|
method: 'POST',
|
|
13
|
-
endpoint: `${__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/oauth/token`,
|
|
16
|
+
endpoint: `${tslib_1.__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/oauth/token`,
|
|
14
17
|
options: {
|
|
15
18
|
body: {
|
|
16
19
|
assertion: jti,
|
|
17
20
|
grant_type: "urn:ietf:params:oauth:grant-type:jti",
|
|
18
|
-
client_id: __classPrivateFieldGet(this, _LeapAuthService_clientId, "f"),
|
|
21
|
+
client_id: tslib_1.__classPrivateFieldGet(this, _LeapAuthService_clientId, "f"),
|
|
19
22
|
},
|
|
20
23
|
},
|
|
21
24
|
accessToken: undefined,
|
|
@@ -29,7 +32,7 @@ export class LeapAuthService {
|
|
|
29
32
|
};
|
|
30
33
|
this.getRedirections = () => {
|
|
31
34
|
return new Promise((resolve, reject) => {
|
|
32
|
-
__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
35
|
+
tslib_1.__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
33
36
|
method: 'GET',
|
|
34
37
|
endpoint: 'https://cdn.leap.com.au/leap_auth/auth_agent/redirections_v2.json',
|
|
35
38
|
options: null,
|
|
@@ -44,15 +47,15 @@ export class LeapAuthService {
|
|
|
44
47
|
};
|
|
45
48
|
this.exchangeAuthCodeForAccessToken = (params) => {
|
|
46
49
|
return new Promise((resolve, reject) => {
|
|
47
|
-
__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
50
|
+
tslib_1.__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
48
51
|
method: 'POST',
|
|
49
|
-
endpoint: `${__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/oauth/token`,
|
|
52
|
+
endpoint: `${tslib_1.__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/oauth/token`,
|
|
50
53
|
options: {
|
|
51
54
|
body: {
|
|
52
55
|
grant_type: 'authorization_code',
|
|
53
56
|
code: params.code,
|
|
54
57
|
code_verifier: params.verifier,
|
|
55
|
-
client_id: __classPrivateFieldGet(this, _LeapAuthService_clientId, "f"),
|
|
58
|
+
client_id: tslib_1.__classPrivateFieldGet(this, _LeapAuthService_clientId, "f"),
|
|
56
59
|
redirect_uri: params.redirectUri,
|
|
57
60
|
},
|
|
58
61
|
},
|
|
@@ -67,15 +70,15 @@ export class LeapAuthService {
|
|
|
67
70
|
};
|
|
68
71
|
this.renewAccessToken = (params) => {
|
|
69
72
|
return new Promise((resolve, reject) => {
|
|
70
|
-
__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
73
|
+
tslib_1.__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
71
74
|
method: 'POST',
|
|
72
|
-
endpoint: `${__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/oauth/token`,
|
|
75
|
+
endpoint: `${tslib_1.__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/oauth/token`,
|
|
73
76
|
options: {
|
|
74
77
|
body: {
|
|
75
78
|
grant_type: 'refresh_token',
|
|
76
79
|
refresh_token: params.refreshToken,
|
|
77
80
|
code_verifier: params.verifier,
|
|
78
|
-
client_id: __classPrivateFieldGet(this, _LeapAuthService_clientId, "f"),
|
|
81
|
+
client_id: tslib_1.__classPrivateFieldGet(this, _LeapAuthService_clientId, "f"),
|
|
79
82
|
},
|
|
80
83
|
},
|
|
81
84
|
accessToken: undefined,
|
|
@@ -89,9 +92,9 @@ export class LeapAuthService {
|
|
|
89
92
|
};
|
|
90
93
|
this.userInfo = (token) => {
|
|
91
94
|
return new Promise((resolve, reject) => {
|
|
92
|
-
__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
95
|
+
tslib_1.__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
93
96
|
method: 'GET',
|
|
94
|
-
endpoint: `${__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/api/userinfo`,
|
|
97
|
+
endpoint: `${tslib_1.__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/api/userinfo`,
|
|
95
98
|
options: null,
|
|
96
99
|
accessToken: token,
|
|
97
100
|
}, (response, status) => {
|
|
@@ -105,23 +108,23 @@ export class LeapAuthService {
|
|
|
105
108
|
this.linkUser = (params) => {
|
|
106
109
|
const { jti, newWindow, callback } = params;
|
|
107
110
|
const redirectUrl = newWindow
|
|
108
|
-
? __classPrivateFieldGet(this, _LeapAuthService_authHost, "f") + LEAP_AUTH_CLOSE_WINDOW_URL
|
|
111
|
+
? tslib_1.__classPrivateFieldGet(this, _LeapAuthService_authHost, "f") + LEAP_AUTH_CLOSE_WINDOW_URL
|
|
109
112
|
: params.redirectUrl;
|
|
110
|
-
const requestUrl = `/cloudprovider/link?client_id=${__classPrivateFieldGet(this, _LeapAuthService_clientId, "f")}&prompt=none&jti=${jti}&callback=${redirectUrl}`;
|
|
111
|
-
__classPrivateFieldGet(this, _LeapAuthService_redirectUrl, "f").call(this, { requestUrl, newWindow, callback });
|
|
113
|
+
const requestUrl = `/cloudprovider/link?client_id=${tslib_1.__classPrivateFieldGet(this, _LeapAuthService_clientId, "f")}&prompt=none&jti=${jti}&callback=${redirectUrl}`;
|
|
114
|
+
tslib_1.__classPrivateFieldGet(this, _LeapAuthService_redirectUrl, "f").call(this, { requestUrl, newWindow, callback });
|
|
112
115
|
};
|
|
113
116
|
this.unlinkUser = (params) => {
|
|
114
117
|
const { jti, newWindow, callback } = params;
|
|
115
118
|
const redirectUrl = newWindow
|
|
116
|
-
? __classPrivateFieldGet(this, _LeapAuthService_authHost, "f") + LEAP_AUTH_CLOSE_WINDOW_URL
|
|
119
|
+
? tslib_1.__classPrivateFieldGet(this, _LeapAuthService_authHost, "f") + LEAP_AUTH_CLOSE_WINDOW_URL
|
|
117
120
|
: params.redirectUrl;
|
|
118
|
-
const requestUrl = `/cloudprovider/unlink?client_id=${__classPrivateFieldGet(this, _LeapAuthService_clientId, "f")}&jti=${jti}&callback=${redirectUrl}`;
|
|
119
|
-
__classPrivateFieldGet(this, _LeapAuthService_redirectUrl, "f").call(this, { requestUrl, newWindow, callback });
|
|
121
|
+
const requestUrl = `/cloudprovider/unlink?client_id=${tslib_1.__classPrivateFieldGet(this, _LeapAuthService_clientId, "f")}&jti=${jti}&callback=${redirectUrl}`;
|
|
122
|
+
tslib_1.__classPrivateFieldGet(this, _LeapAuthService_redirectUrl, "f").call(this, { requestUrl, newWindow, callback });
|
|
120
123
|
};
|
|
121
124
|
this.getCloudProviderToken = (token, jti) => {
|
|
122
|
-
const url = `${__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/cloudprovider/accesstoken` + (jti ? '/' + jti : '');
|
|
125
|
+
const url = `${tslib_1.__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/cloudprovider/accesstoken` + (jti ? '/' + jti : '');
|
|
123
126
|
return new Promise((resolve, reject) => {
|
|
124
|
-
__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
127
|
+
tslib_1.__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
125
128
|
method: 'GET',
|
|
126
129
|
endpoint: url,
|
|
127
130
|
options: null,
|
|
@@ -136,9 +139,9 @@ export class LeapAuthService {
|
|
|
136
139
|
};
|
|
137
140
|
this.cloudProviderUserInfo = (token) => {
|
|
138
141
|
return new Promise((resolve, reject) => {
|
|
139
|
-
__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
142
|
+
tslib_1.__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
140
143
|
method: 'GET',
|
|
141
|
-
endpoint: `${__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/cloudprovider/userinfo`,
|
|
144
|
+
endpoint: `${tslib_1.__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/cloudprovider/userinfo`,
|
|
142
145
|
options: null,
|
|
143
146
|
accessToken: token,
|
|
144
147
|
}, (response, status) => {
|
|
@@ -152,16 +155,16 @@ export class LeapAuthService {
|
|
|
152
155
|
this.cloudProviderReauthenticate = (params) => {
|
|
153
156
|
const { nonce, newWindow, callback } = params;
|
|
154
157
|
const redirectUrl = newWindow
|
|
155
|
-
? __classPrivateFieldGet(this, _LeapAuthService_authHost, "f") + LEAP_AUTH_CLOSE_WINDOW_URL
|
|
158
|
+
? tslib_1.__classPrivateFieldGet(this, _LeapAuthService_authHost, "f") + LEAP_AUTH_CLOSE_WINDOW_URL
|
|
156
159
|
: params.redirectUrl;
|
|
157
160
|
const requestUrl = `/cloudprovider/reauthenticate?nonce=${nonce}&redirectUrl=${redirectUrl}`;
|
|
158
|
-
__classPrivateFieldGet(this, _LeapAuthService_redirectUrl, "f").call(this, { requestUrl, newWindow, callback });
|
|
161
|
+
tslib_1.__classPrivateFieldGet(this, _LeapAuthService_redirectUrl, "f").call(this, { requestUrl, newWindow, callback });
|
|
159
162
|
};
|
|
160
163
|
this.cloudProviderReauthenticateLink = (token) => {
|
|
161
164
|
return new Promise((resolve, reject) => {
|
|
162
|
-
__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
165
|
+
tslib_1.__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
163
166
|
method: 'GET',
|
|
164
|
-
endpoint: `${__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/cloudprovider/reauthenticate/link`,
|
|
167
|
+
endpoint: `${tslib_1.__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/cloudprovider/reauthenticate/link`,
|
|
165
168
|
options: null,
|
|
166
169
|
accessToken: token,
|
|
167
170
|
}, (response, status) => {
|
|
@@ -175,9 +178,9 @@ export class LeapAuthService {
|
|
|
175
178
|
this.cloudProviderUpdate = (params) => {
|
|
176
179
|
const { firmId, cloudProviderId, token } = params;
|
|
177
180
|
return new Promise((resolve, reject) => {
|
|
178
|
-
__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
181
|
+
tslib_1.__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
179
182
|
method: 'PUT',
|
|
180
|
-
endpoint: `${__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/api/firms/${firmId}`,
|
|
183
|
+
endpoint: `${tslib_1.__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/api/firms/${firmId}`,
|
|
181
184
|
options: {
|
|
182
185
|
body: { id: firmId, cloudProviderId: cloudProviderId }
|
|
183
186
|
},
|
|
@@ -192,9 +195,9 @@ export class LeapAuthService {
|
|
|
192
195
|
};
|
|
193
196
|
this.statusAdminConsent = (token) => {
|
|
194
197
|
return new Promise((resolve, reject) => {
|
|
195
|
-
__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
198
|
+
tslib_1.__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
196
199
|
method: 'GET',
|
|
197
|
-
endpoint: `${__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/cloudprovider/adminconsent/status?client_id=${__classPrivateFieldGet(this, _LeapAuthService_clientId, "f")}`,
|
|
200
|
+
endpoint: `${tslib_1.__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/cloudprovider/adminconsent/status?client_id=${tslib_1.__classPrivateFieldGet(this, _LeapAuthService_clientId, "f")}`,
|
|
198
201
|
options: null,
|
|
199
202
|
accessToken: token,
|
|
200
203
|
}, (response, status) => {
|
|
@@ -208,16 +211,16 @@ export class LeapAuthService {
|
|
|
208
211
|
this.getAdminConsent = (params) => {
|
|
209
212
|
const { domain, newWindow, callback } = params;
|
|
210
213
|
const redirectUrl = newWindow
|
|
211
|
-
? __classPrivateFieldGet(this, _LeapAuthService_authHost, "f") + LEAP_AUTH_CLOSE_WINDOW_URL
|
|
214
|
+
? tslib_1.__classPrivateFieldGet(this, _LeapAuthService_authHost, "f") + LEAP_AUTH_CLOSE_WINDOW_URL
|
|
212
215
|
: params.redirectUrl;
|
|
213
|
-
const requestUrl = `/cloudprovider/adminconsent?client_id=${__classPrivateFieldGet(this, _LeapAuthService_clientId, "f")}&redirectUrl=${redirectUrl}${domain ? '&domain=' + domain : ''}`;
|
|
214
|
-
__classPrivateFieldGet(this, _LeapAuthService_redirectUrl, "f").call(this, { requestUrl, newWindow, callback });
|
|
216
|
+
const requestUrl = `/cloudprovider/adminconsent?client_id=${tslib_1.__classPrivateFieldGet(this, _LeapAuthService_clientId, "f")}&redirectUrl=${redirectUrl}${domain ? '&domain=' + domain : ''}`;
|
|
217
|
+
tslib_1.__classPrivateFieldGet(this, _LeapAuthService_redirectUrl, "f").call(this, { requestUrl, newWindow, callback });
|
|
215
218
|
};
|
|
216
219
|
this.revokeAdminConsent = (token) => {
|
|
217
220
|
return new Promise((resolve, reject) => {
|
|
218
|
-
__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
221
|
+
tslib_1.__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
219
222
|
method: 'DELETE',
|
|
220
|
-
endpoint: `${__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/cloudprovider/adminconsent?client_id=${__classPrivateFieldGet(this, _LeapAuthService_clientId, "f")}`,
|
|
223
|
+
endpoint: `${tslib_1.__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/cloudprovider/adminconsent?client_id=${tslib_1.__classPrivateFieldGet(this, _LeapAuthService_clientId, "f")}`,
|
|
221
224
|
options: null,
|
|
222
225
|
accessToken: token,
|
|
223
226
|
}, (response, status) => {
|
|
@@ -230,9 +233,9 @@ export class LeapAuthService {
|
|
|
230
233
|
};
|
|
231
234
|
this.getLinkMap = (token, allUsers) => {
|
|
232
235
|
return new Promise((resolve, reject) => {
|
|
233
|
-
__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
236
|
+
tslib_1.__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
234
237
|
method: 'GET',
|
|
235
|
-
endpoint: `${__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/cloudprovider/linkmap?client_id=${__classPrivateFieldGet(this, _LeapAuthService_clientId, "f")}${allUsers ? '&allUsers=true' : ''}`,
|
|
238
|
+
endpoint: `${tslib_1.__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/cloudprovider/linkmap?client_id=${tslib_1.__classPrivateFieldGet(this, _LeapAuthService_clientId, "f")}${allUsers ? '&allUsers=true' : ''}`,
|
|
236
239
|
options: null,
|
|
237
240
|
accessToken: token,
|
|
238
241
|
}, (response, status) => {
|
|
@@ -245,9 +248,9 @@ export class LeapAuthService {
|
|
|
245
248
|
};
|
|
246
249
|
this.setLinkMap = (token, linkMap) => {
|
|
247
250
|
return new Promise((resolve, reject) => {
|
|
248
|
-
__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
251
|
+
tslib_1.__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
249
252
|
method: 'PUT',
|
|
250
|
-
endpoint: `${__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/cloudprovider/linkmap?client_id=${__classPrivateFieldGet(this, _LeapAuthService_clientId, "f")}`,
|
|
253
|
+
endpoint: `${tslib_1.__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/cloudprovider/linkmap?client_id=${tslib_1.__classPrivateFieldGet(this, _LeapAuthService_clientId, "f")}`,
|
|
251
254
|
options: { body: linkMap },
|
|
252
255
|
accessToken: token,
|
|
253
256
|
}, (response, status) => {
|
|
@@ -261,14 +264,14 @@ export class LeapAuthService {
|
|
|
261
264
|
this.authoriseSupport = (token, params) => {
|
|
262
265
|
const { code, duration } = params;
|
|
263
266
|
return new Promise((resolve, reject) => {
|
|
264
|
-
__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
267
|
+
tslib_1.__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
265
268
|
method: 'POST',
|
|
266
|
-
endpoint: `${__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/support/authorization`,
|
|
269
|
+
endpoint: `${tslib_1.__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/support/authorization`,
|
|
267
270
|
options: {
|
|
268
271
|
body: {
|
|
269
272
|
requestCode: code,
|
|
270
273
|
duration,
|
|
271
|
-
client_id: __classPrivateFieldGet(this, _LeapAuthService_clientId, "f"),
|
|
274
|
+
client_id: tslib_1.__classPrivateFieldGet(this, _LeapAuthService_clientId, "f"),
|
|
272
275
|
},
|
|
273
276
|
},
|
|
274
277
|
accessToken: token,
|
|
@@ -282,12 +285,12 @@ export class LeapAuthService {
|
|
|
282
285
|
};
|
|
283
286
|
this.changePassword = (params) => {
|
|
284
287
|
const { newWindow, callback, redirectUrl } = params;
|
|
285
|
-
let changePasswordUrl = `/oauth/changepassword?client_id=${__classPrivateFieldGet(this, _LeapAuthService_clientId, "f")}`;
|
|
288
|
+
let changePasswordUrl = `/oauth/changepassword?client_id=${tslib_1.__classPrivateFieldGet(this, _LeapAuthService_clientId, "f")}`;
|
|
286
289
|
let redirect_uri = '';
|
|
287
290
|
let noListener = false;
|
|
288
291
|
if (newWindow) {
|
|
289
292
|
if (!!callback && typeof callback === 'function') {
|
|
290
|
-
redirect_uri = __classPrivateFieldGet(this, _LeapAuthService_authHost, "f") + LEAP_AUTH_CLOSE_WINDOW_URL;
|
|
293
|
+
redirect_uri = tslib_1.__classPrivateFieldGet(this, _LeapAuthService_authHost, "f") + LEAP_AUTH_CLOSE_WINDOW_URL;
|
|
291
294
|
}
|
|
292
295
|
else {
|
|
293
296
|
redirect_uri = '';
|
|
@@ -296,7 +299,7 @@ export class LeapAuthService {
|
|
|
296
299
|
}
|
|
297
300
|
else {
|
|
298
301
|
redirect_uri =
|
|
299
|
-
__classPrivateFieldGet(this, _LeapAuthService_authHost, "f") +
|
|
302
|
+
tslib_1.__classPrivateFieldGet(this, _LeapAuthService_authHost, "f") +
|
|
300
303
|
'/oauth/logout?force=true' +
|
|
301
304
|
'&redirect_uri=' +
|
|
302
305
|
(redirectUrl || window.location.href);
|
|
@@ -304,7 +307,7 @@ export class LeapAuthService {
|
|
|
304
307
|
if (redirect_uri) {
|
|
305
308
|
changePasswordUrl += `&redirect_uri=${encodeURIComponent(redirect_uri)}`;
|
|
306
309
|
}
|
|
307
|
-
__classPrivateFieldGet(this, _LeapAuthService_redirectUrl, "f").call(this, {
|
|
310
|
+
tslib_1.__classPrivateFieldGet(this, _LeapAuthService_redirectUrl, "f").call(this, {
|
|
308
311
|
requestUrl: changePasswordUrl,
|
|
309
312
|
newWindow,
|
|
310
313
|
callback,
|
|
@@ -314,7 +317,7 @@ export class LeapAuthService {
|
|
|
314
317
|
_LeapAuthService_xhr.set(this, (params, onload) => {
|
|
315
318
|
const { method, endpoint, accessToken } = params;
|
|
316
319
|
let { options } = params;
|
|
317
|
-
options = merge({}, {
|
|
320
|
+
options = (0, lodash_1.merge)({}, {
|
|
318
321
|
contentType: 'application/json',
|
|
319
322
|
accessControlAllowOrigin: '*',
|
|
320
323
|
body: undefined,
|
|
@@ -342,13 +345,13 @@ export class LeapAuthService {
|
|
|
342
345
|
});
|
|
343
346
|
_LeapAuthService_redirectUrl.set(this, (params) => {
|
|
344
347
|
const { requestUrl, newWindow, callback, noListener } = params;
|
|
345
|
-
const fullUrl = __classPrivateFieldGet(this, _LeapAuthService_authHost, "f") + requestUrl;
|
|
348
|
+
const fullUrl = tslib_1.__classPrivateFieldGet(this, _LeapAuthService_authHost, "f") + requestUrl;
|
|
346
349
|
if (newWindow) {
|
|
347
350
|
const childWindow = window.open(fullUrl, '_blank');
|
|
348
351
|
const eventHandler = (event) => {
|
|
349
352
|
if (event && event.data === 'closeMe' && childWindow) {
|
|
350
353
|
childWindow.close();
|
|
351
|
-
if (isFunction(callback)) {
|
|
354
|
+
if ((0, lodash_1.isFunction)(callback)) {
|
|
352
355
|
callback();
|
|
353
356
|
window.removeEventListener('message', eventHandler, false);
|
|
354
357
|
}
|
|
@@ -362,9 +365,9 @@ export class LeapAuthService {
|
|
|
362
365
|
window.location.href = fullUrl;
|
|
363
366
|
}
|
|
364
367
|
});
|
|
365
|
-
__classPrivateFieldSet(this, _LeapAuthService_authHost, authHost, "f");
|
|
366
|
-
__classPrivateFieldSet(this, _LeapAuthService_clientId, clientId, "f");
|
|
368
|
+
tslib_1.__classPrivateFieldSet(this, _LeapAuthService_authHost, authHost, "f");
|
|
369
|
+
tslib_1.__classPrivateFieldSet(this, _LeapAuthService_clientId, clientId, "f");
|
|
367
370
|
}
|
|
368
371
|
}
|
|
372
|
+
exports.LeapAuthService = LeapAuthService;
|
|
369
373
|
_LeapAuthService_authHost = new WeakMap(), _LeapAuthService_clientId = new WeakMap(), _LeapAuthService_xhr = new WeakMap(), _LeapAuthService_redirectUrl = new WeakMap();
|
|
370
|
-
//# sourceMappingURL=auth.service.js.map
|