@leapdev/auth-agent 2.2.13-beta.5 → 2.2.13-beta.6
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 +354 -35
- package/src/lib/authentication.js +10 -27
- package/src/lib/authentication.js.map +1 -1
package/src/index.umd.js
CHANGED
|
@@ -44,12 +44,7 @@
|
|
|
44
44
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
45
45
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
46
46
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
-
var e = new Error(message);
|
|
51
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
-
};
|
|
47
|
+
}
|
|
53
48
|
|
|
54
49
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
55
50
|
|
|
@@ -3829,9 +3824,11 @@
|
|
|
3829
3824
|
throw Error('Missing config parameter : ' + p);
|
|
3830
3825
|
}
|
|
3831
3826
|
});
|
|
3827
|
+
|
|
3832
3828
|
if (!lodash.isArray(options.scopes)) {
|
|
3833
3829
|
throw Error('Scopes must be an array with string values');
|
|
3834
3830
|
}
|
|
3831
|
+
|
|
3835
3832
|
const config = Object.assign(Object.assign({}, DEFAULT_CONFIG), options);
|
|
3836
3833
|
return config;
|
|
3837
3834
|
};
|
|
@@ -3841,7 +3838,9 @@
|
|
|
3841
3838
|
class LeapAuthService {
|
|
3842
3839
|
constructor(authHost, clientId) {
|
|
3843
3840
|
_LeapAuthService_authHost.set(this, void 0);
|
|
3841
|
+
|
|
3844
3842
|
_LeapAuthService_clientId.set(this, void 0);
|
|
3843
|
+
|
|
3845
3844
|
this.getAccessTokenByJti = jti => {
|
|
3846
3845
|
return new Promise((resolve, reject) => {
|
|
3847
3846
|
__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
@@ -3860,6 +3859,7 @@
|
|
|
3860
3859
|
});
|
|
3861
3860
|
});
|
|
3862
3861
|
};
|
|
3862
|
+
|
|
3863
3863
|
this.getRedirections = () => {
|
|
3864
3864
|
return new Promise((resolve, reject) => {
|
|
3865
3865
|
__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
@@ -3872,6 +3872,7 @@
|
|
|
3872
3872
|
});
|
|
3873
3873
|
});
|
|
3874
3874
|
};
|
|
3875
|
+
|
|
3875
3876
|
this.exchangeAuthCodeForAccessToken = params => {
|
|
3876
3877
|
return new Promise((resolve, reject) => {
|
|
3877
3878
|
__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
@@ -3892,6 +3893,7 @@
|
|
|
3892
3893
|
});
|
|
3893
3894
|
});
|
|
3894
3895
|
};
|
|
3896
|
+
|
|
3895
3897
|
this.renewAccessToken = params => {
|
|
3896
3898
|
return new Promise((resolve, reject) => {
|
|
3897
3899
|
__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
@@ -3911,6 +3913,7 @@
|
|
|
3911
3913
|
});
|
|
3912
3914
|
});
|
|
3913
3915
|
};
|
|
3916
|
+
|
|
3914
3917
|
this.userInfo = token => {
|
|
3915
3918
|
return new Promise((resolve, reject) => {
|
|
3916
3919
|
__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
@@ -3923,6 +3926,7 @@
|
|
|
3923
3926
|
});
|
|
3924
3927
|
});
|
|
3925
3928
|
};
|
|
3929
|
+
|
|
3926
3930
|
this.linkUser = params => {
|
|
3927
3931
|
const {
|
|
3928
3932
|
jti,
|
|
@@ -3931,12 +3935,14 @@
|
|
|
3931
3935
|
} = params;
|
|
3932
3936
|
const redirectUrl = newWindow ? __classPrivateFieldGet(this, _LeapAuthService_authHost, "f") + LEAP_AUTH_CLOSE_WINDOW_URL : params.redirectUrl;
|
|
3933
3937
|
const requestUrl = `/cloudprovider/link?client_id=${__classPrivateFieldGet(this, _LeapAuthService_clientId, "f")}&prompt=none&jti=${jti}&callback=${redirectUrl}`;
|
|
3938
|
+
|
|
3934
3939
|
__classPrivateFieldGet(this, _LeapAuthService_redirectUrl, "f").call(this, {
|
|
3935
3940
|
requestUrl,
|
|
3936
3941
|
newWindow,
|
|
3937
3942
|
callback
|
|
3938
3943
|
});
|
|
3939
3944
|
};
|
|
3945
|
+
|
|
3940
3946
|
this.unlinkUser = params => {
|
|
3941
3947
|
const {
|
|
3942
3948
|
jti,
|
|
@@ -3945,12 +3951,14 @@
|
|
|
3945
3951
|
} = params;
|
|
3946
3952
|
const redirectUrl = newWindow ? __classPrivateFieldGet(this, _LeapAuthService_authHost, "f") + LEAP_AUTH_CLOSE_WINDOW_URL : params.redirectUrl;
|
|
3947
3953
|
const requestUrl = `/cloudprovider/unlink?client_id=${__classPrivateFieldGet(this, _LeapAuthService_clientId, "f")}&jti=${jti}&callback=${redirectUrl}`;
|
|
3954
|
+
|
|
3948
3955
|
__classPrivateFieldGet(this, _LeapAuthService_redirectUrl, "f").call(this, {
|
|
3949
3956
|
requestUrl,
|
|
3950
3957
|
newWindow,
|
|
3951
3958
|
callback
|
|
3952
3959
|
});
|
|
3953
3960
|
};
|
|
3961
|
+
|
|
3954
3962
|
this.getCloudProviderToken = (token, jti) => {
|
|
3955
3963
|
const url = `${__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/cloudprovider/accesstoken` + (jti ? '/' + jti : '');
|
|
3956
3964
|
return new Promise((resolve, reject) => {
|
|
@@ -3964,6 +3972,7 @@
|
|
|
3964
3972
|
});
|
|
3965
3973
|
});
|
|
3966
3974
|
};
|
|
3975
|
+
|
|
3967
3976
|
this.cloudProviderUserInfo = token => {
|
|
3968
3977
|
return new Promise((resolve, reject) => {
|
|
3969
3978
|
__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
@@ -3976,6 +3985,7 @@
|
|
|
3976
3985
|
});
|
|
3977
3986
|
});
|
|
3978
3987
|
};
|
|
3988
|
+
|
|
3979
3989
|
this.cloudProviderReauthenticate = params => {
|
|
3980
3990
|
const {
|
|
3981
3991
|
nonce,
|
|
@@ -3984,12 +3994,14 @@
|
|
|
3984
3994
|
} = params;
|
|
3985
3995
|
const redirectUrl = newWindow ? __classPrivateFieldGet(this, _LeapAuthService_authHost, "f") + LEAP_AUTH_CLOSE_WINDOW_URL : params.redirectUrl;
|
|
3986
3996
|
const requestUrl = `/cloudprovider/reauthenticate?nonce=${nonce}&redirectUrl=${redirectUrl}`;
|
|
3997
|
+
|
|
3987
3998
|
__classPrivateFieldGet(this, _LeapAuthService_redirectUrl, "f").call(this, {
|
|
3988
3999
|
requestUrl,
|
|
3989
4000
|
newWindow,
|
|
3990
4001
|
callback
|
|
3991
4002
|
});
|
|
3992
4003
|
};
|
|
4004
|
+
|
|
3993
4005
|
this.cloudProviderReauthenticateLink = token => {
|
|
3994
4006
|
return new Promise((resolve, reject) => {
|
|
3995
4007
|
__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
@@ -4002,6 +4014,7 @@
|
|
|
4002
4014
|
});
|
|
4003
4015
|
});
|
|
4004
4016
|
};
|
|
4017
|
+
|
|
4005
4018
|
this.cloudProviderUpdate = params => {
|
|
4006
4019
|
const {
|
|
4007
4020
|
firmId,
|
|
@@ -4024,6 +4037,7 @@
|
|
|
4024
4037
|
});
|
|
4025
4038
|
});
|
|
4026
4039
|
};
|
|
4040
|
+
|
|
4027
4041
|
this.statusAdminConsent = token => {
|
|
4028
4042
|
return new Promise((resolve, reject) => {
|
|
4029
4043
|
__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
@@ -4036,6 +4050,7 @@
|
|
|
4036
4050
|
});
|
|
4037
4051
|
});
|
|
4038
4052
|
};
|
|
4053
|
+
|
|
4039
4054
|
this.getAdminConsent = params => {
|
|
4040
4055
|
const {
|
|
4041
4056
|
domain,
|
|
@@ -4044,12 +4059,14 @@
|
|
|
4044
4059
|
} = params;
|
|
4045
4060
|
const redirectUrl = newWindow ? __classPrivateFieldGet(this, _LeapAuthService_authHost, "f") + LEAP_AUTH_CLOSE_WINDOW_URL : params.redirectUrl;
|
|
4046
4061
|
const requestUrl = `/cloudprovider/adminconsent?client_id=${__classPrivateFieldGet(this, _LeapAuthService_clientId, "f")}&redirectUrl=${redirectUrl}${domain ? '&domain=' + domain : ''}`;
|
|
4062
|
+
|
|
4047
4063
|
__classPrivateFieldGet(this, _LeapAuthService_redirectUrl, "f").call(this, {
|
|
4048
4064
|
requestUrl,
|
|
4049
4065
|
newWindow,
|
|
4050
4066
|
callback
|
|
4051
4067
|
});
|
|
4052
4068
|
};
|
|
4069
|
+
|
|
4053
4070
|
this.revokeAdminConsent = token => {
|
|
4054
4071
|
return new Promise((resolve, reject) => {
|
|
4055
4072
|
__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
@@ -4062,6 +4079,7 @@
|
|
|
4062
4079
|
});
|
|
4063
4080
|
});
|
|
4064
4081
|
};
|
|
4082
|
+
|
|
4065
4083
|
this.getLinkMap = (token, allUsers) => {
|
|
4066
4084
|
return new Promise((resolve, reject) => {
|
|
4067
4085
|
__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
@@ -4074,6 +4092,7 @@
|
|
|
4074
4092
|
});
|
|
4075
4093
|
});
|
|
4076
4094
|
};
|
|
4095
|
+
|
|
4077
4096
|
this.setLinkMap = (token, linkMap) => {
|
|
4078
4097
|
return new Promise((resolve, reject) => {
|
|
4079
4098
|
__classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
|
|
@@ -4088,6 +4107,7 @@
|
|
|
4088
4107
|
});
|
|
4089
4108
|
});
|
|
4090
4109
|
};
|
|
4110
|
+
|
|
4091
4111
|
this.authoriseSupport = (token, params) => {
|
|
4092
4112
|
const {
|
|
4093
4113
|
code,
|
|
@@ -4110,6 +4130,7 @@
|
|
|
4110
4130
|
});
|
|
4111
4131
|
});
|
|
4112
4132
|
};
|
|
4133
|
+
|
|
4113
4134
|
this.changePassword = params => {
|
|
4114
4135
|
const {
|
|
4115
4136
|
newWindow,
|
|
@@ -4119,6 +4140,7 @@
|
|
|
4119
4140
|
let changePasswordUrl = `/oauth/changepassword?client_id=${__classPrivateFieldGet(this, _LeapAuthService_clientId, "f")}`;
|
|
4120
4141
|
let redirect_uri = '';
|
|
4121
4142
|
let noListener = false;
|
|
4143
|
+
|
|
4122
4144
|
if (newWindow) {
|
|
4123
4145
|
if (!!callback && typeof callback === 'function') {
|
|
4124
4146
|
redirect_uri = __classPrivateFieldGet(this, _LeapAuthService_authHost, "f") + LEAP_AUTH_CLOSE_WINDOW_URL;
|
|
@@ -4129,9 +4151,11 @@
|
|
|
4129
4151
|
} else {
|
|
4130
4152
|
redirect_uri = __classPrivateFieldGet(this, _LeapAuthService_authHost, "f") + '/oauth/logout?force=true' + '&redirect_uri=' + (redirectUrl || window.location.href);
|
|
4131
4153
|
}
|
|
4154
|
+
|
|
4132
4155
|
if (redirect_uri) {
|
|
4133
4156
|
changePasswordUrl += `&redirect_uri=${encodeURIComponent(redirect_uri)}`;
|
|
4134
4157
|
}
|
|
4158
|
+
|
|
4135
4159
|
__classPrivateFieldGet(this, _LeapAuthService_redirectUrl, "f").call(this, {
|
|
4136
4160
|
requestUrl: changePasswordUrl,
|
|
4137
4161
|
newWindow,
|
|
@@ -4139,6 +4163,7 @@
|
|
|
4139
4163
|
noListener
|
|
4140
4164
|
});
|
|
4141
4165
|
};
|
|
4166
|
+
|
|
4142
4167
|
_LeapAuthService_xhr.set(this, (params, onload) => {
|
|
4143
4168
|
const {
|
|
4144
4169
|
method,
|
|
@@ -4158,6 +4183,7 @@
|
|
|
4158
4183
|
xhr.setRequestHeader('Content-type', options.contentType);
|
|
4159
4184
|
xhr.setRequestHeader('Access-Control-Allow-Origin', options.accessControlAllowOrigin);
|
|
4160
4185
|
if (accessToken) xhr.setRequestHeader('Authorization', 'Bearer ' + accessToken);
|
|
4186
|
+
|
|
4161
4187
|
xhr.onload = () => {
|
|
4162
4188
|
try {
|
|
4163
4189
|
let resp;
|
|
@@ -4167,9 +4193,11 @@
|
|
|
4167
4193
|
onload(xhr.response, xhr.status);
|
|
4168
4194
|
}
|
|
4169
4195
|
};
|
|
4196
|
+
|
|
4170
4197
|
if (options.body) options.body = JSON.stringify(options.body);
|
|
4171
4198
|
xhr.send(options.body);
|
|
4172
4199
|
});
|
|
4200
|
+
|
|
4173
4201
|
_LeapAuthService_redirectUrl.set(this, params => {
|
|
4174
4202
|
const {
|
|
4175
4203
|
requestUrl,
|
|
@@ -4178,17 +4206,21 @@
|
|
|
4178
4206
|
noListener
|
|
4179
4207
|
} = params;
|
|
4180
4208
|
const fullUrl = __classPrivateFieldGet(this, _LeapAuthService_authHost, "f") + requestUrl;
|
|
4209
|
+
|
|
4181
4210
|
if (newWindow) {
|
|
4182
4211
|
const childWindow = window.open(fullUrl, '_blank');
|
|
4212
|
+
|
|
4183
4213
|
const eventHandler = event => {
|
|
4184
4214
|
if (event && event.data === 'closeMe' && childWindow) {
|
|
4185
4215
|
childWindow.close();
|
|
4216
|
+
|
|
4186
4217
|
if (lodash.isFunction(callback)) {
|
|
4187
4218
|
callback();
|
|
4188
4219
|
window.removeEventListener('message', eventHandler, false);
|
|
4189
4220
|
}
|
|
4190
4221
|
}
|
|
4191
4222
|
};
|
|
4223
|
+
|
|
4192
4224
|
if (!noListener) {
|
|
4193
4225
|
window.addEventListener('message', eventHandler, false);
|
|
4194
4226
|
}
|
|
@@ -4196,13 +4228,17 @@
|
|
|
4196
4228
|
window.location.href = fullUrl;
|
|
4197
4229
|
}
|
|
4198
4230
|
});
|
|
4231
|
+
|
|
4199
4232
|
__classPrivateFieldSet(this, _LeapAuthService_authHost, authHost, "f");
|
|
4233
|
+
|
|
4200
4234
|
__classPrivateFieldSet(this, _LeapAuthService_clientId, clientId, "f");
|
|
4201
4235
|
}
|
|
4236
|
+
|
|
4202
4237
|
}
|
|
4203
4238
|
_LeapAuthService_authHost = new WeakMap(), _LeapAuthService_clientId = new WeakMap(), _LeapAuthService_xhr = new WeakMap(), _LeapAuthService_redirectUrl = new WeakMap();
|
|
4204
4239
|
|
|
4205
4240
|
var HookName;
|
|
4241
|
+
|
|
4206
4242
|
(function (HookName) {
|
|
4207
4243
|
HookName["afterLogin"] = "afterLogin";
|
|
4208
4244
|
HookName["beforeLogout"] = "beforeLogout";
|
|
@@ -4220,9 +4256,13 @@
|
|
|
4220
4256
|
class Notification {
|
|
4221
4257
|
constructor() {
|
|
4222
4258
|
_Notification_pubnubKeys.set(this, void 0);
|
|
4259
|
+
|
|
4223
4260
|
_Notification_pubnub.set(this, void 0);
|
|
4261
|
+
|
|
4224
4262
|
_Notification_eventListeners.set(this, []);
|
|
4263
|
+
|
|
4225
4264
|
_Notification_uniqueSessionTriggerHook.set(this, undefined);
|
|
4265
|
+
|
|
4226
4266
|
this.init = params => __awaiter(this, void 0, void 0, function* () {
|
|
4227
4267
|
const {
|
|
4228
4268
|
authHost,
|
|
@@ -4232,11 +4272,15 @@
|
|
|
4232
4272
|
uniqueSession,
|
|
4233
4273
|
hooks
|
|
4234
4274
|
} = params;
|
|
4275
|
+
|
|
4235
4276
|
if (!!hooks && hooks.uniqueSessionTrigger) {
|
|
4236
4277
|
__classPrivateFieldSet(this, _Notification_uniqueSessionTriggerHook, hooks.uniqueSessionTrigger, "f");
|
|
4237
4278
|
}
|
|
4279
|
+
|
|
4238
4280
|
__classPrivateFieldGet(this, _Notification_initFirmChannel, "f").call(this, firmId, userId);
|
|
4281
|
+
|
|
4239
4282
|
__classPrivateFieldGet(this, _Notification_initUserChannel, "f").call(this, userId);
|
|
4283
|
+
|
|
4240
4284
|
if (uniqueSession) {
|
|
4241
4285
|
yield __classPrivateFieldGet(this, _Notification_initUniqueSessionChannel, "f").call(this, {
|
|
4242
4286
|
authHost,
|
|
@@ -4244,30 +4288,37 @@
|
|
|
4244
4288
|
});
|
|
4245
4289
|
}
|
|
4246
4290
|
});
|
|
4291
|
+
|
|
4247
4292
|
this.destroy = () => {
|
|
4248
4293
|
if (__classPrivateFieldGet(this, _Notification_pubnub, "f")) {
|
|
4249
4294
|
__classPrivateFieldGet(this, _Notification_pubnub, "f").unsubscribeAll();
|
|
4295
|
+
|
|
4250
4296
|
__classPrivateFieldSet(this, _Notification_eventListeners, [], "f");
|
|
4251
4297
|
}
|
|
4252
4298
|
};
|
|
4299
|
+
|
|
4253
4300
|
this.registerEventListenerForUserChannel = params => {
|
|
4254
4301
|
const {
|
|
4255
4302
|
topic,
|
|
4256
4303
|
messageType,
|
|
4257
4304
|
callback
|
|
4258
4305
|
} = params;
|
|
4306
|
+
|
|
4259
4307
|
if (!lodash.isFunction(callback)) {
|
|
4260
4308
|
throw Error(`Registering Event Listener ${topic} ${messageType}: callback needs to be a function`);
|
|
4261
4309
|
}
|
|
4310
|
+
|
|
4262
4311
|
__classPrivateFieldGet(this, _Notification_eventListeners, "f").push({
|
|
4263
4312
|
topic,
|
|
4264
4313
|
messageType,
|
|
4265
4314
|
callback
|
|
4266
4315
|
});
|
|
4267
4316
|
};
|
|
4317
|
+
|
|
4268
4318
|
this.setUniqueSessionTriggerHook = hook => {
|
|
4269
4319
|
__classPrivateFieldSet(this, _Notification_uniqueSessionTriggerHook, hook, "f");
|
|
4270
4320
|
};
|
|
4321
|
+
|
|
4271
4322
|
_Notification_initFirmChannel.set(this, (firmId, userId) => {
|
|
4272
4323
|
__classPrivateFieldGet(this, _Notification_pubnub, "f").addListener({
|
|
4273
4324
|
presence: presenceEvent => {
|
|
@@ -4275,32 +4326,38 @@
|
|
|
4275
4326
|
action,
|
|
4276
4327
|
uuid
|
|
4277
4328
|
} = presenceEvent;
|
|
4329
|
+
|
|
4278
4330
|
if (uuid === __classPrivateFieldGet(this, _Notification_pubnubKeys, "f").uuid) {
|
|
4279
4331
|
return;
|
|
4280
4332
|
}
|
|
4333
|
+
|
|
4281
4334
|
if (action === 'leave' || action === 'timeout') {
|
|
4282
4335
|
const valuesUUID = uuid.split('~');
|
|
4283
4336
|
const userIdFromPresence = valuesUUID[0] || '';
|
|
4284
4337
|
const instanceGuidFromPresence = valuesUUID[1] || '';
|
|
4285
4338
|
const userActionFromPresence = valuesUUID[2] || '';
|
|
4286
4339
|
const isUserActionRequiredLogout = userActionFromPresence === USER_ACTION.USERNAME_CHANGED || userActionFromPresence === USER_ACTION.PASSWORD_CHANGED || userActionFromPresence === USER_ACTION.USER_DISABLED;
|
|
4340
|
+
|
|
4287
4341
|
if (userIdFromPresence === userId && instanceGuidFromPresence === EMPTY_GUID && isUserActionRequiredLogout) {
|
|
4288
4342
|
AuthAgent.logout(true);
|
|
4289
4343
|
}
|
|
4290
4344
|
}
|
|
4291
4345
|
}
|
|
4292
4346
|
});
|
|
4347
|
+
|
|
4293
4348
|
__classPrivateFieldGet(this, _Notification_pubnub, "f").subscribe({
|
|
4294
4349
|
channels: [firmId],
|
|
4295
4350
|
withPresence: true
|
|
4296
4351
|
});
|
|
4297
4352
|
});
|
|
4353
|
+
|
|
4298
4354
|
_Notification_initUserChannel.set(this, userId => {
|
|
4299
4355
|
__classPrivateFieldGet(this, _Notification_pubnub, "f").addListener({
|
|
4300
4356
|
message: data => {
|
|
4301
4357
|
const {
|
|
4302
4358
|
content
|
|
4303
4359
|
} = data.message;
|
|
4360
|
+
|
|
4304
4361
|
if (content && content.topic && content.messageType && content.data) {
|
|
4305
4362
|
for (const eventListener of __classPrivateFieldGet(this, _Notification_eventListeners, "f")) {
|
|
4306
4363
|
if (eventListener.topic === content.topic && eventListener.messageType === content.messageType && eventListener.callback && lodash.isFunction(eventListener.callback)) {
|
|
@@ -4310,11 +4367,13 @@
|
|
|
4310
4367
|
}
|
|
4311
4368
|
}
|
|
4312
4369
|
});
|
|
4370
|
+
|
|
4313
4371
|
__classPrivateFieldGet(this, _Notification_pubnub, "f").subscribe({
|
|
4314
4372
|
channels: [`user_${userId}`],
|
|
4315
4373
|
withPresence: false
|
|
4316
4374
|
});
|
|
4317
4375
|
});
|
|
4376
|
+
|
|
4318
4377
|
_Notification_initUniqueSessionChannel.set(this, params => __awaiter(this, void 0, void 0, function* () {
|
|
4319
4378
|
const decodedToken = yield AuthAgent.getDecodedAccessToken();
|
|
4320
4379
|
const {
|
|
@@ -4326,29 +4385,36 @@
|
|
|
4326
4385
|
sessionId: mySessionId,
|
|
4327
4386
|
impersonatorId: myImpersonatorId
|
|
4328
4387
|
} = decodedToken;
|
|
4388
|
+
|
|
4329
4389
|
if (!decodedToken) {
|
|
4330
4390
|
return;
|
|
4331
4391
|
}
|
|
4392
|
+
|
|
4332
4393
|
const channel = `auth-session-${myUserId}`;
|
|
4394
|
+
|
|
4333
4395
|
__classPrivateFieldGet(this, _Notification_pubnub, "f").addListener({
|
|
4334
4396
|
message: data => __awaiter(this, void 0, void 0, function* () {
|
|
4335
4397
|
const decodedToken = yield AuthAgent.getDecodedAccessToken();
|
|
4398
|
+
|
|
4336
4399
|
if (!decodedToken) {
|
|
4337
4400
|
AuthAgent.logout(true);
|
|
4338
4401
|
}
|
|
4402
|
+
|
|
4339
4403
|
const {
|
|
4340
4404
|
sessionId: mySessionId,
|
|
4341
4405
|
impersonatorId: myImpersonatorId,
|
|
4342
4406
|
userId: myUserId
|
|
4343
4407
|
} = decodedToken;
|
|
4344
4408
|
const myAgentId = localStorage.getItem('leap-auth-agent-id');
|
|
4409
|
+
|
|
4345
4410
|
if (myAgentId && data && data.message) {
|
|
4346
4411
|
const sessionId = data.message.sessionId,
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4412
|
+
authHost = data.message.authHost,
|
|
4413
|
+
clientId = data.message.clientId,
|
|
4414
|
+
logout = data.message.logout;
|
|
4415
|
+
data.message.agentId;
|
|
4416
|
+
const impersonatorId = myImpersonatorId ? myImpersonatorId : data.message.impersonatorId;
|
|
4417
|
+
|
|
4352
4418
|
if (authHost === myAuthHost) {
|
|
4353
4419
|
if (clientId === myClientId && sessionId !== mySessionId || clientId !== myClientId && sessionId === mySessionId && logout) {
|
|
4354
4420
|
if (impersonatorId !== undefined && impersonatorId !== '') {
|
|
@@ -4365,15 +4431,19 @@
|
|
|
4365
4431
|
}
|
|
4366
4432
|
})
|
|
4367
4433
|
});
|
|
4434
|
+
|
|
4368
4435
|
__classPrivateFieldGet(this, _Notification_pubnub, "f").subscribe({
|
|
4369
4436
|
channels: [channel],
|
|
4370
4437
|
withPresence: true
|
|
4371
4438
|
});
|
|
4439
|
+
|
|
4372
4440
|
let agentId = localStorage.getItem('leap-auth-agent-id');
|
|
4441
|
+
|
|
4373
4442
|
if (!agentId) {
|
|
4374
4443
|
agentId = uuid.v4();
|
|
4375
4444
|
localStorage.setItem('leap-auth-agent-id', agentId);
|
|
4376
4445
|
}
|
|
4446
|
+
|
|
4377
4447
|
__classPrivateFieldGet(this, _Notification_pubnub, "f").publish({
|
|
4378
4448
|
message: {
|
|
4379
4449
|
authHost: myAuthHost,
|
|
@@ -4389,13 +4459,16 @@
|
|
|
4389
4459
|
}
|
|
4390
4460
|
});
|
|
4391
4461
|
}));
|
|
4462
|
+
|
|
4392
4463
|
__classPrivateFieldSet(this, _Notification_pubnubKeys, {
|
|
4393
4464
|
publishKey: 'pub-13f5288e-cd88-4ef9-9e68-0c11cd03ddb8',
|
|
4394
4465
|
subscribeKey: 'sub-a456f002-0095-11e2-9638-9581afc33ebf',
|
|
4395
4466
|
uuid: uuid.v4()
|
|
4396
4467
|
}, "f");
|
|
4468
|
+
|
|
4397
4469
|
__classPrivateFieldSet(this, _Notification_pubnub, new Pubnub__default["default"](__classPrivateFieldGet(this, _Notification_pubnubKeys, "f")), "f");
|
|
4398
4470
|
}
|
|
4471
|
+
|
|
4399
4472
|
}
|
|
4400
4473
|
_Notification_pubnubKeys = new WeakMap(), _Notification_pubnub = new WeakMap(), _Notification_eventListeners = new WeakMap(), _Notification_uniqueSessionTriggerHook = new WeakMap(), _Notification_initFirmChannel = new WeakMap(), _Notification_initUserChannel = new WeakMap(), _Notification_initUniqueSessionChannel = new WeakMap();
|
|
4401
4474
|
|
|
@@ -5835,6 +5908,7 @@
|
|
|
5835
5908
|
const deleteQueryParameter = (windowLocation, name, value) => {
|
|
5836
5909
|
const nameValue = name + '=' + value;
|
|
5837
5910
|
let toReplace = nameValue;
|
|
5911
|
+
|
|
5838
5912
|
if (windowLocation.indexOf('?' + nameValue) >= 0) {
|
|
5839
5913
|
if (windowLocation.indexOf('?' + nameValue + '&') >= 0) {
|
|
5840
5914
|
toReplace += '&';
|
|
@@ -5844,13 +5918,16 @@
|
|
|
5844
5918
|
} else if (windowLocation.indexOf('&' + nameValue) >= 0) {
|
|
5845
5919
|
toReplace = '&' + toReplace;
|
|
5846
5920
|
}
|
|
5921
|
+
|
|
5847
5922
|
return windowLocation.replace(toReplace, '');
|
|
5848
5923
|
};
|
|
5849
5924
|
const getQueryParameter = name => {
|
|
5850
5925
|
const paramsForSearch = parseParams(window.location.search.substring(1));
|
|
5926
|
+
|
|
5851
5927
|
if (paramsForSearch[name]) {
|
|
5852
5928
|
return paramsForSearch[name];
|
|
5853
5929
|
}
|
|
5930
|
+
|
|
5854
5931
|
return undefined;
|
|
5855
5932
|
};
|
|
5856
5933
|
const createCodeChallenge = verifier => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -5878,33 +5955,41 @@
|
|
|
5878
5955
|
randomValues.forEach(v => random += charset[v % charset.length]);
|
|
5879
5956
|
return random;
|
|
5880
5957
|
};
|
|
5958
|
+
|
|
5881
5959
|
const sha256 = s => __awaiter(void 0, void 0, void 0, function* () {
|
|
5882
5960
|
const digestOp = getCryptoSubtle().digest({
|
|
5883
5961
|
name: 'SHA-256'
|
|
5884
5962
|
}, new TextEncoder().encode(s));
|
|
5963
|
+
|
|
5885
5964
|
if (window.msCrypto) {
|
|
5886
5965
|
return new Promise((res, rej) => {
|
|
5887
5966
|
digestOp.oncomplete = e => {
|
|
5888
5967
|
res(e.target.result);
|
|
5889
5968
|
};
|
|
5969
|
+
|
|
5890
5970
|
digestOp.onerror = e => {
|
|
5891
5971
|
rej(e.error);
|
|
5892
5972
|
};
|
|
5973
|
+
|
|
5893
5974
|
digestOp.onabort = () => {
|
|
5894
5975
|
rej('The digest operation was aborted');
|
|
5895
5976
|
};
|
|
5896
5977
|
});
|
|
5897
5978
|
}
|
|
5979
|
+
|
|
5898
5980
|
return yield digestOp;
|
|
5899
5981
|
});
|
|
5982
|
+
|
|
5900
5983
|
const getCryptoSubtle = () => {
|
|
5901
5984
|
const crypto = getCrypto();
|
|
5902
5985
|
return crypto.subtle || crypto.webkitSubtle;
|
|
5903
5986
|
};
|
|
5987
|
+
|
|
5904
5988
|
const bufferToBase64UrlEncoded = input => {
|
|
5905
5989
|
const ie11SafeInput = new Uint8Array(input);
|
|
5906
5990
|
return urlEncodeB64(window.btoa(String.fromCharCode(...Array.from(ie11SafeInput))));
|
|
5907
5991
|
};
|
|
5992
|
+
|
|
5908
5993
|
const urlEncodeB64 = input => {
|
|
5909
5994
|
const b64Chars = {
|
|
5910
5995
|
'+': '-',
|
|
@@ -5913,14 +5998,17 @@
|
|
|
5913
5998
|
};
|
|
5914
5999
|
return input.replace(/[+/=]/g, m => b64Chars[m]);
|
|
5915
6000
|
};
|
|
6001
|
+
|
|
5916
6002
|
const parseParams = url => {
|
|
5917
6003
|
const result = {};
|
|
5918
6004
|
const params = url.split('&');
|
|
6005
|
+
|
|
5919
6006
|
for (let i = 0; i < params.length; i++) {
|
|
5920
6007
|
const param = params[i].split('=', 2);
|
|
5921
6008
|
if (param.length !== 2) continue;
|
|
5922
6009
|
result[param[0]] = decodeURIComponent(param[1].replace(/\+/g, " "));
|
|
5923
6010
|
}
|
|
6011
|
+
|
|
5924
6012
|
return result;
|
|
5925
6013
|
};
|
|
5926
6014
|
|
|
@@ -6031,33 +6119,42 @@
|
|
|
6031
6119
|
const redirections = redirectionConfig.environments;
|
|
6032
6120
|
const suffix = topLevelDomains.find(suffix => origin.endsWith(suffix));
|
|
6033
6121
|
const environmentVariables = redirectionConfig.environmentVariables;
|
|
6122
|
+
|
|
6034
6123
|
if (suffix) {
|
|
6035
6124
|
for (let i = 0; i < redirections.length; i++) {
|
|
6036
6125
|
redirection = redirections[i];
|
|
6037
6126
|
const tokenCriteriaMatched = containsKeys(decodedToken, redirection.criteria);
|
|
6127
|
+
|
|
6038
6128
|
if (tokenCriteriaMatched && !!containsApplication(redirection.applications, origin)) {
|
|
6039
6129
|
if (redirection.topLevelDomain !== suffix) {
|
|
6040
6130
|
redirectUrl = origin.replace(suffix, redirection.topLevelDomain);
|
|
6041
6131
|
}
|
|
6132
|
+
|
|
6042
6133
|
const envVariables = environmentVariables[redirection.criteria.environment];
|
|
6134
|
+
|
|
6043
6135
|
if (envVariables) {
|
|
6044
6136
|
const prefixMappings = envVariables['prefixMappings'];
|
|
6045
6137
|
const keys = Object.keys(prefixMappings);
|
|
6046
6138
|
const needToUpdatePrefixKey = containsApplication(keys, origin);
|
|
6139
|
+
|
|
6047
6140
|
if (needToUpdatePrefixKey) {
|
|
6048
6141
|
const prefixValue = prefixMappings[needToUpdatePrefixKey];
|
|
6049
6142
|
redirectUrl = redirectUrl ? redirectUrl.replace(needToUpdatePrefixKey, prefixValue) : origin.replace(needToUpdatePrefixKey, prefixValue);
|
|
6050
6143
|
}
|
|
6051
6144
|
}
|
|
6145
|
+
|
|
6052
6146
|
break;
|
|
6053
6147
|
}
|
|
6054
6148
|
}
|
|
6149
|
+
|
|
6055
6150
|
if (!!redirection && !!redirectUrl) {
|
|
6056
6151
|
result = `${redirection.authHost}/oauth/passthrough?jti=${decodedToken.jti}&redirect=${encodeURIComponent(redirectUrl)}`;
|
|
6057
6152
|
}
|
|
6058
6153
|
}
|
|
6154
|
+
|
|
6059
6155
|
return result;
|
|
6060
6156
|
};
|
|
6157
|
+
|
|
6061
6158
|
const containsKeys = (obj1, obj2) => {
|
|
6062
6159
|
let result = true;
|
|
6063
6160
|
Object.keys(obj2).forEach(key => {
|
|
@@ -6067,11 +6164,12 @@
|
|
|
6067
6164
|
});
|
|
6068
6165
|
return result;
|
|
6069
6166
|
};
|
|
6167
|
+
|
|
6070
6168
|
const containsApplication = (list, app) => {
|
|
6071
6169
|
return list.find(appName => app.startsWith(`http://${appName}`) || app.startsWith(`https://${appName}`));
|
|
6072
6170
|
};
|
|
6073
6171
|
|
|
6074
|
-
var _Authentication_accessToken, _Authentication_config, _Authentication_leapAuthService, _Authentication_notification, _Authentication_popupLogin, _Authentication_refreshInfo, _Authentication_exchangeAuthCodeForAccessToken, _Authentication_verifyAndPerformRedirections, _Authentication_startRefreshAccessTokenProcess, _Authentication_destroyRefreshAccessTokenProcess, _Authentication_decodeAccessToken, _Authentication_handlePopupLogin;
|
|
6172
|
+
var _Authentication_accessToken, _Authentication_config, _Authentication_leapAuthService, _Authentication_notification, _Authentication_popupLogin, _Authentication_officeDialog, _Authentication_refreshInfo, _Authentication_exchangeAuthCodeForAccessToken, _Authentication_verifyAndPerformRedirections, _Authentication_startRefreshAccessTokenProcess, _Authentication_destroyRefreshAccessTokenProcess, _Authentication_decodeAccessToken, _Authentication_handlePopupLogin;
|
|
6075
6173
|
const SECONDS_BEFORE_EXPIRE = 30;
|
|
6076
6174
|
const MAX_SETTIME_OUT = 2147483647;
|
|
6077
6175
|
const DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS = 60;
|
|
@@ -6080,25 +6178,36 @@
|
|
|
6080
6178
|
class Authentication {
|
|
6081
6179
|
constructor(options) {
|
|
6082
6180
|
_Authentication_accessToken.set(this, void 0);
|
|
6181
|
+
|
|
6083
6182
|
_Authentication_config.set(this, void 0);
|
|
6183
|
+
|
|
6084
6184
|
_Authentication_leapAuthService.set(this, void 0);
|
|
6185
|
+
|
|
6085
6186
|
_Authentication_notification.set(this, void 0);
|
|
6187
|
+
|
|
6086
6188
|
_Authentication_popupLogin.set(this, void 0);
|
|
6189
|
+
|
|
6190
|
+
_Authentication_officeDialog.set(this, void 0);
|
|
6191
|
+
|
|
6087
6192
|
_Authentication_refreshInfo.set(this, void 0);
|
|
6193
|
+
|
|
6088
6194
|
this.registerEventListenerForUserChannel = params => {
|
|
6089
6195
|
const {
|
|
6090
6196
|
topic,
|
|
6091
6197
|
messageType,
|
|
6092
6198
|
callback
|
|
6093
6199
|
} = params;
|
|
6200
|
+
|
|
6094
6201
|
__classPrivateFieldGet(this, _Authentication_notification, "f").registerEventListenerForUserChannel({
|
|
6095
6202
|
topic,
|
|
6096
6203
|
messageType,
|
|
6097
6204
|
callback
|
|
6098
6205
|
});
|
|
6099
6206
|
};
|
|
6207
|
+
|
|
6100
6208
|
this.initNotification = () => __awaiter(this, void 0, void 0, function* () {
|
|
6101
6209
|
const decodedToken = yield this.getDecodedRefreshedAccessToken();
|
|
6210
|
+
|
|
6102
6211
|
if (decodedToken) {
|
|
6103
6212
|
yield __classPrivateFieldGet(this, _Authentication_notification, "f").init({
|
|
6104
6213
|
authHost: __classPrivateFieldGet(this, _Authentication_config, "f").authHost,
|
|
@@ -6110,11 +6219,14 @@
|
|
|
6110
6219
|
});
|
|
6111
6220
|
}
|
|
6112
6221
|
});
|
|
6222
|
+
|
|
6113
6223
|
this.destroyNotification = () => {
|
|
6114
6224
|
__classPrivateFieldGet(this, _Authentication_notification, "f").destroy();
|
|
6115
6225
|
};
|
|
6226
|
+
|
|
6116
6227
|
this.login = params => __awaiter(this, void 0, void 0, function* () {
|
|
6117
6228
|
const done = yield this.checkAuthCode();
|
|
6229
|
+
|
|
6118
6230
|
if (done && !!__classPrivateFieldGet(this, _Authentication_accessToken, "f")) {
|
|
6119
6231
|
return __classPrivateFieldGet(this, _Authentication_accessToken, "f");
|
|
6120
6232
|
} else {
|
|
@@ -6131,9 +6243,12 @@
|
|
|
6131
6243
|
code_challenge,
|
|
6132
6244
|
code_challenge_method
|
|
6133
6245
|
} = yield createCodeChallenge(code_verifier);
|
|
6246
|
+
|
|
6134
6247
|
const scope = __classPrivateFieldGet(this, _Authentication_config, "f").scopes.join(',');
|
|
6248
|
+
|
|
6135
6249
|
const prompt = noPrompt ? 'none' : '';
|
|
6136
6250
|
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}&force_2fa=${force_2fa}&nonce=${nonce}&state=${state}&prompt=${prompt}&remember_me=${__classPrivateFieldGet(this, _Authentication_config, "f").rememberMe}`;
|
|
6251
|
+
|
|
6137
6252
|
if (popup) {
|
|
6138
6253
|
return __classPrivateFieldGet(this, _Authentication_handlePopupLogin, "f").call(this, url);
|
|
6139
6254
|
} else {
|
|
@@ -6142,12 +6257,16 @@
|
|
|
6142
6257
|
}
|
|
6143
6258
|
}
|
|
6144
6259
|
});
|
|
6260
|
+
|
|
6145
6261
|
this.logout = (force = false, redirectUrl) => {
|
|
6146
6262
|
__classPrivateFieldSet(this, _Authentication_accessToken, undefined, "f");
|
|
6263
|
+
|
|
6147
6264
|
const redirectUri = encodeURIComponent(redirectUrl || window.location.href);
|
|
6148
6265
|
window.location.href = `${__classPrivateFieldGet(this, _Authentication_config, "f").authHost}/oauth/logout?force=${force}&redirect_uri=${redirectUri}`;
|
|
6266
|
+
|
|
6149
6267
|
__classPrivateFieldGet(this, _Authentication_destroyRefreshAccessTokenProcess, "f").call(this);
|
|
6150
6268
|
};
|
|
6269
|
+
|
|
6151
6270
|
this.getAccessToken = () => {
|
|
6152
6271
|
if (__classPrivateFieldGet(this, _Authentication_accessToken, "f") === undefined || !__classPrivateFieldGet(this, _Authentication_accessToken, "f")) {
|
|
6153
6272
|
return '';
|
|
@@ -6155,17 +6274,20 @@
|
|
|
6155
6274
|
return __classPrivateFieldGet(this, _Authentication_accessToken, "f");
|
|
6156
6275
|
}
|
|
6157
6276
|
};
|
|
6277
|
+
|
|
6158
6278
|
this.getRefreshedAccessToken = force => __awaiter(this, void 0, void 0, function* () {
|
|
6159
6279
|
if (__classPrivateFieldGet(this, _Authentication_accessToken, "f") === undefined || !__classPrivateFieldGet(this, _Authentication_accessToken, "f")) {
|
|
6160
6280
|
return '';
|
|
6161
6281
|
} else {
|
|
6162
6282
|
if (__classPrivateFieldGet(this, _Authentication_refreshInfo, "f") && __classPrivateFieldGet(this, _Authentication_refreshInfo, "f").accessTokenExpireIn) {
|
|
6163
6283
|
const decoded = __classPrivateFieldGet(this, _Authentication_decodeAccessToken, "f").call(this, __classPrivateFieldGet(this, _Authentication_accessToken, "f"));
|
|
6284
|
+
|
|
6164
6285
|
if (force || !!decoded && (decoded.exp - SECONDS_BEFORE_EXPIRE) * 1000 < Date.now()) {
|
|
6165
6286
|
const data = yield __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").renewAccessToken({
|
|
6166
6287
|
refreshToken: __classPrivateFieldGet(this, _Authentication_refreshInfo, "f").refreshToken,
|
|
6167
6288
|
verifier: __classPrivateFieldGet(this, _Authentication_refreshInfo, "f").verifier
|
|
6168
6289
|
});
|
|
6290
|
+
|
|
6169
6291
|
if (data) {
|
|
6170
6292
|
if (data.refresh_token && data.expires_in) {
|
|
6171
6293
|
__classPrivateFieldSet(this, _Authentication_refreshInfo, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Authentication_refreshInfo, "f")), {
|
|
@@ -6173,28 +6295,37 @@
|
|
|
6173
6295
|
accessTokenExpireIn: data.expires_in
|
|
6174
6296
|
}), "f");
|
|
6175
6297
|
}
|
|
6298
|
+
|
|
6176
6299
|
__classPrivateFieldSet(this, _Authentication_accessToken, data.access_token, "f");
|
|
6300
|
+
|
|
6177
6301
|
yield this.triggerHooks(HookName.afterRefreshToken);
|
|
6178
6302
|
return __classPrivateFieldGet(this, _Authentication_accessToken, "f");
|
|
6179
6303
|
}
|
|
6180
6304
|
}
|
|
6181
6305
|
}
|
|
6306
|
+
|
|
6182
6307
|
return __classPrivateFieldGet(this, _Authentication_accessToken, "f");
|
|
6183
6308
|
}
|
|
6184
6309
|
});
|
|
6310
|
+
|
|
6185
6311
|
this.getDecodedAccessToken = () => {
|
|
6186
6312
|
if (!__classPrivateFieldGet(this, _Authentication_accessToken, "f")) {
|
|
6187
6313
|
return undefined;
|
|
6188
6314
|
}
|
|
6315
|
+
|
|
6189
6316
|
return __classPrivateFieldGet(this, _Authentication_decodeAccessToken, "f").call(this, __classPrivateFieldGet(this, _Authentication_accessToken, "f"));
|
|
6190
6317
|
};
|
|
6318
|
+
|
|
6191
6319
|
this.getDecodedRefreshedAccessToken = force => __awaiter(this, void 0, void 0, function* () {
|
|
6192
6320
|
const token = yield this.getRefreshedAccessToken(force);
|
|
6321
|
+
|
|
6193
6322
|
if (!token) {
|
|
6194
6323
|
return undefined;
|
|
6195
6324
|
}
|
|
6325
|
+
|
|
6196
6326
|
return __classPrivateFieldGet(this, _Authentication_decodeAccessToken, "f").call(this, token);
|
|
6197
6327
|
});
|
|
6328
|
+
|
|
6198
6329
|
this.getHooks = () => {
|
|
6199
6330
|
if (__classPrivateFieldGet(this, _Authentication_config, "f")) {
|
|
6200
6331
|
return __classPrivateFieldGet(this, _Authentication_config, "f").hooks;
|
|
@@ -6202,44 +6333,56 @@
|
|
|
6202
6333
|
return undefined;
|
|
6203
6334
|
}
|
|
6204
6335
|
};
|
|
6336
|
+
|
|
6205
6337
|
this.setHook = params => {
|
|
6206
6338
|
const {
|
|
6207
6339
|
name,
|
|
6208
6340
|
callback
|
|
6209
6341
|
} = params;
|
|
6342
|
+
|
|
6210
6343
|
if (!Object.values(HookName).find(h => h === name)) {
|
|
6211
6344
|
throw Error('Unsupported hook: ' + name);
|
|
6212
6345
|
}
|
|
6346
|
+
|
|
6213
6347
|
if (!lodash.isFunction(callback)) {
|
|
6214
6348
|
throw Error('hook must be a function: ' + name);
|
|
6215
6349
|
}
|
|
6350
|
+
|
|
6216
6351
|
__classPrivateFieldSet(this, _Authentication_config, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Authentication_config, "f")), {
|
|
6217
6352
|
hooks: Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Authentication_config, "f").hooks), {
|
|
6218
6353
|
[name]: callback
|
|
6219
6354
|
})
|
|
6220
6355
|
}), "f");
|
|
6356
|
+
|
|
6221
6357
|
if (name === HookName.uniqueSessionTrigger) {
|
|
6222
6358
|
__classPrivateFieldGet(this, _Authentication_notification, "f").setUniqueSessionTriggerHook(callback);
|
|
6223
6359
|
}
|
|
6360
|
+
|
|
6224
6361
|
return;
|
|
6225
6362
|
};
|
|
6363
|
+
|
|
6226
6364
|
this.autoLogin = () => {
|
|
6227
6365
|
return __classPrivateFieldGet(this, _Authentication_config, "f") ? __classPrivateFieldGet(this, _Authentication_config, "f").autoLogin || false : false;
|
|
6228
6366
|
};
|
|
6367
|
+
|
|
6229
6368
|
this.autoLogout = () => {
|
|
6230
6369
|
return __classPrivateFieldGet(this, _Authentication_config, "f") ? __classPrivateFieldGet(this, _Authentication_config, "f").autoLogout || false : false;
|
|
6231
6370
|
};
|
|
6371
|
+
|
|
6232
6372
|
this.idleTimeoutInMinutes = () => {
|
|
6233
6373
|
return __classPrivateFieldGet(this, _Authentication_config, "f") ? __classPrivateFieldGet(this, _Authentication_config, "f").idleTimeoutInMinutes || 30 : 30;
|
|
6234
6374
|
};
|
|
6375
|
+
|
|
6235
6376
|
this.checkTokenInUrl = () => {
|
|
6236
6377
|
const accessTokenQuery = getQueryParameter('access_token') || getQueryParameter('auth') || getQueryParameter('authToken') || getQueryParameter('token') || getQueryParameter('jwt');
|
|
6378
|
+
|
|
6237
6379
|
if (accessTokenQuery) {
|
|
6238
6380
|
const {
|
|
6239
6381
|
aud,
|
|
6240
6382
|
firmId,
|
|
6241
6383
|
userId
|
|
6242
6384
|
} = __classPrivateFieldGet(this, _Authentication_decodeAccessToken, "f").call(this, accessTokenQuery);
|
|
6385
|
+
|
|
6243
6386
|
if (!!firmId && !!userId && aud === '8MBJWOFS4RRRSZQC') {
|
|
6244
6387
|
const queryParameterValue = accessTokenQuery;
|
|
6245
6388
|
let myselfWithoutToken = deleteQueryParameter(window.location.href, 'access_token', queryParameterValue);
|
|
@@ -6251,30 +6394,38 @@
|
|
|
6251
6394
|
window.location.href = __classPrivateFieldGet(this, _Authentication_config, "f").authHost + '/oauth/passthrough?token=' + queryParameterValue + '&redirect=' + myselfEncoded;
|
|
6252
6395
|
return true;
|
|
6253
6396
|
}
|
|
6397
|
+
|
|
6254
6398
|
return false;
|
|
6255
6399
|
}
|
|
6400
|
+
|
|
6256
6401
|
return false;
|
|
6257
6402
|
};
|
|
6403
|
+
|
|
6258
6404
|
this.checkTokenInInit = () => {
|
|
6259
6405
|
if (__classPrivateFieldGet(this, _Authentication_config, "f") && __classPrivateFieldGet(this, _Authentication_config, "f").initToken) {
|
|
6260
6406
|
const {
|
|
6261
6407
|
jti
|
|
6262
6408
|
} = __classPrivateFieldGet(this, _Authentication_decodeAccessToken, "f").call(this, __classPrivateFieldGet(this, _Authentication_config, "f").initToken);
|
|
6409
|
+
|
|
6263
6410
|
if (jti) {
|
|
6264
6411
|
const windowPassthroughSession = window.sessionStorage.getItem(PASSTHROUGH_SESSION_KEY);
|
|
6412
|
+
|
|
6265
6413
|
if (windowPassthroughSession) {
|
|
6266
6414
|
window.sessionStorage.removeItem(PASSTHROUGH_SESSION_KEY);
|
|
6267
6415
|
return false;
|
|
6268
6416
|
}
|
|
6417
|
+
|
|
6269
6418
|
window.sessionStorage.setItem(PASSTHROUGH_SESSION_KEY, jti);
|
|
6270
6419
|
const myselfEncoded = encodeURIComponent(window.location.href);
|
|
6271
6420
|
window.location.href = __classPrivateFieldGet(this, _Authentication_config, "f").authHost + '/oauth/passthrough?jti=' + jti + '&redirect=' + myselfEncoded;
|
|
6272
6421
|
return true;
|
|
6273
6422
|
}
|
|
6274
6423
|
}
|
|
6424
|
+
|
|
6275
6425
|
window.sessionStorage.removeItem(PASSTHROUGH_SESSION_KEY);
|
|
6276
6426
|
return false;
|
|
6277
6427
|
};
|
|
6428
|
+
|
|
6278
6429
|
this.verifySession = () => __awaiter(this, void 0, void 0, function* () {
|
|
6279
6430
|
const code_verifier = createRandomString(64);
|
|
6280
6431
|
const state = createRandomString(6);
|
|
@@ -6283,13 +6434,17 @@
|
|
|
6283
6434
|
code_challenge,
|
|
6284
6435
|
code_challenge_method
|
|
6285
6436
|
} = yield createCodeChallenge(code_verifier);
|
|
6437
|
+
|
|
6286
6438
|
const scope = __classPrivateFieldGet(this, _Authentication_config, "f").scopes.join(',');
|
|
6439
|
+
|
|
6287
6440
|
const redirectUri = `${window.location.protocol}//${window.location.host}${window.location.pathname}`;
|
|
6288
6441
|
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`;
|
|
6289
6442
|
const resp = yield this.runIframe(url, state);
|
|
6443
|
+
|
|
6290
6444
|
if (resp && resp.state) {
|
|
6291
6445
|
const verifier = window.sessionStorage.getItem(resp.state);
|
|
6292
6446
|
window.sessionStorage.removeItem(resp.state);
|
|
6447
|
+
|
|
6293
6448
|
if (resp.code && verifier) {
|
|
6294
6449
|
return __classPrivateFieldGet(this, _Authentication_exchangeAuthCodeForAccessToken, "f").call(this, {
|
|
6295
6450
|
code: resp.code,
|
|
@@ -6303,13 +6458,16 @@
|
|
|
6303
6458
|
return false;
|
|
6304
6459
|
}
|
|
6305
6460
|
});
|
|
6461
|
+
|
|
6306
6462
|
this.checkAuthCode = () => __awaiter(this, void 0, void 0, function* () {
|
|
6307
6463
|
const search = window.location.search;
|
|
6308
6464
|
const queryParams = new URLSearchParams(search);
|
|
6309
6465
|
const code = queryParams.get('code');
|
|
6310
6466
|
const state = queryParams.get('state');
|
|
6467
|
+
|
|
6311
6468
|
if (!!code && !!state) {
|
|
6312
6469
|
const isPopupLogin = window.localStorage.getItem('leap-auth-popup-login');
|
|
6470
|
+
|
|
6313
6471
|
if (isPopupLogin === 'true' && window.opener) {
|
|
6314
6472
|
window.localStorage.removeItem('leap-auth-popup-login');
|
|
6315
6473
|
window.opener.postMessage({
|
|
@@ -6337,16 +6495,21 @@
|
|
|
6337
6495
|
return false;
|
|
6338
6496
|
}
|
|
6339
6497
|
});
|
|
6498
|
+
|
|
6340
6499
|
this.getUserInfo = () => __awaiter(this, void 0, void 0, function* () {
|
|
6341
6500
|
const token = yield this.getRefreshedAccessToken();
|
|
6342
6501
|
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").userInfo(token);
|
|
6343
6502
|
});
|
|
6503
|
+
|
|
6344
6504
|
this.linkUser = params => __awaiter(this, void 0, void 0, function* () {
|
|
6345
6505
|
const decodeToken = yield this.getDecodedRefreshedAccessToken();
|
|
6506
|
+
|
|
6346
6507
|
if (!decodeToken) {
|
|
6347
6508
|
return;
|
|
6348
6509
|
}
|
|
6510
|
+
|
|
6349
6511
|
const redirectUrl = params.redirectUrl || window.location.href;
|
|
6512
|
+
|
|
6350
6513
|
__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").linkUser({
|
|
6351
6514
|
redirectUrl,
|
|
6352
6515
|
jti: decodeToken.jti,
|
|
@@ -6354,12 +6517,16 @@
|
|
|
6354
6517
|
callback: params.callback
|
|
6355
6518
|
});
|
|
6356
6519
|
});
|
|
6520
|
+
|
|
6357
6521
|
this.unlinkUser = params => __awaiter(this, void 0, void 0, function* () {
|
|
6358
6522
|
const decodeToken = yield this.getDecodedRefreshedAccessToken();
|
|
6523
|
+
|
|
6359
6524
|
if (!decodeToken) {
|
|
6360
6525
|
return;
|
|
6361
6526
|
}
|
|
6527
|
+
|
|
6362
6528
|
const redirectUrl = params.redirectUrl || window.location.href;
|
|
6529
|
+
|
|
6363
6530
|
__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").unlinkUser({
|
|
6364
6531
|
redirectUrl,
|
|
6365
6532
|
jti: decodeToken.jti,
|
|
@@ -6367,25 +6534,34 @@
|
|
|
6367
6534
|
callback: params.callback
|
|
6368
6535
|
});
|
|
6369
6536
|
});
|
|
6537
|
+
|
|
6370
6538
|
this.getCloudProviderToken = jti => __awaiter(this, void 0, void 0, function* () {
|
|
6371
6539
|
const token = yield this.getRefreshedAccessToken();
|
|
6540
|
+
|
|
6372
6541
|
if (!token) {
|
|
6373
6542
|
throw Error('Not authenticated yet');
|
|
6374
6543
|
}
|
|
6544
|
+
|
|
6375
6545
|
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").getCloudProviderToken(token, jti);
|
|
6376
6546
|
});
|
|
6547
|
+
|
|
6377
6548
|
this.cloudProviderUserInfo = () => __awaiter(this, void 0, void 0, function* () {
|
|
6378
6549
|
const token = yield this.getRefreshedAccessToken();
|
|
6550
|
+
|
|
6379
6551
|
if (!token) {
|
|
6380
6552
|
throw Error('Not authenticated yet');
|
|
6381
6553
|
}
|
|
6554
|
+
|
|
6382
6555
|
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").cloudProviderUserInfo(token);
|
|
6383
6556
|
});
|
|
6557
|
+
|
|
6384
6558
|
this.cloudProviderReauthenticate = params => __awaiter(this, void 0, void 0, function* () {
|
|
6385
6559
|
const token = yield this.getRefreshedAccessToken();
|
|
6560
|
+
|
|
6386
6561
|
if (!token) {
|
|
6387
6562
|
throw Error('Not authenticated yet');
|
|
6388
6563
|
}
|
|
6564
|
+
|
|
6389
6565
|
let {
|
|
6390
6566
|
nonce,
|
|
6391
6567
|
redirectUrl
|
|
@@ -6395,10 +6571,12 @@
|
|
|
6395
6571
|
callback
|
|
6396
6572
|
} = params;
|
|
6397
6573
|
redirectUrl = redirectUrl || window.location.href;
|
|
6574
|
+
|
|
6398
6575
|
if (!nonce) {
|
|
6399
6576
|
const reauthticateLink = yield __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").cloudProviderReauthenticateLink(token);
|
|
6400
6577
|
nonce = reauthticateLink.nonce;
|
|
6401
6578
|
}
|
|
6579
|
+
|
|
6402
6580
|
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").cloudProviderReauthenticate({
|
|
6403
6581
|
redirectUrl,
|
|
6404
6582
|
nonce,
|
|
@@ -6406,12 +6584,16 @@
|
|
|
6406
6584
|
callback
|
|
6407
6585
|
});
|
|
6408
6586
|
});
|
|
6587
|
+
|
|
6409
6588
|
this.cloudProviderUpdate = cloudProviderId => __awaiter(this, void 0, void 0, function* () {
|
|
6410
6589
|
const token = yield this.getRefreshedAccessToken();
|
|
6590
|
+
|
|
6411
6591
|
if (!token) {
|
|
6412
6592
|
throw Error('Not authenticated yet');
|
|
6413
6593
|
}
|
|
6594
|
+
|
|
6414
6595
|
const decodedToken = __classPrivateFieldGet(this, _Authentication_decodeAccessToken, "f").call(this, token);
|
|
6596
|
+
|
|
6415
6597
|
const {
|
|
6416
6598
|
firmId
|
|
6417
6599
|
} = decodedToken;
|
|
@@ -6421,65 +6603,89 @@
|
|
|
6421
6603
|
token: token
|
|
6422
6604
|
});
|
|
6423
6605
|
});
|
|
6606
|
+
|
|
6424
6607
|
this.statusAdminConsent = () => __awaiter(this, void 0, void 0, function* () {
|
|
6425
6608
|
const token = yield this.getRefreshedAccessToken();
|
|
6609
|
+
|
|
6426
6610
|
if (!token) {
|
|
6427
6611
|
throw Error('Not authenticated yet');
|
|
6428
6612
|
}
|
|
6613
|
+
|
|
6429
6614
|
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").statusAdminConsent(token);
|
|
6430
6615
|
});
|
|
6616
|
+
|
|
6431
6617
|
this.getAdminConsent = params => {
|
|
6432
6618
|
const redirectUrl = params.redirectUrl || window.location.href;
|
|
6619
|
+
|
|
6433
6620
|
__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").getAdminConsent(Object.assign(Object.assign({}, params), {
|
|
6434
6621
|
redirectUrl
|
|
6435
6622
|
}));
|
|
6436
6623
|
};
|
|
6624
|
+
|
|
6437
6625
|
this.revokeAdminConsent = () => __awaiter(this, void 0, void 0, function* () {
|
|
6438
6626
|
const token = yield this.getRefreshedAccessToken();
|
|
6627
|
+
|
|
6439
6628
|
if (!token) {
|
|
6440
6629
|
throw Error('Not authenticated yet');
|
|
6441
6630
|
}
|
|
6631
|
+
|
|
6442
6632
|
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").revokeAdminConsent(token);
|
|
6443
6633
|
});
|
|
6634
|
+
|
|
6444
6635
|
this.getLinkMap = (allUsers = false) => __awaiter(this, void 0, void 0, function* () {
|
|
6445
6636
|
const token = yield this.getRefreshedAccessToken();
|
|
6637
|
+
|
|
6446
6638
|
if (!token) {
|
|
6447
6639
|
throw Error('Not authenticated yet');
|
|
6448
6640
|
}
|
|
6641
|
+
|
|
6449
6642
|
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").getLinkMap(token, allUsers);
|
|
6450
6643
|
});
|
|
6644
|
+
|
|
6451
6645
|
this.setLinkMap = linkMap => __awaiter(this, void 0, void 0, function* () {
|
|
6452
6646
|
const token = yield this.getRefreshedAccessToken();
|
|
6647
|
+
|
|
6453
6648
|
if (!token) {
|
|
6454
6649
|
throw Error('Not authenticated yet');
|
|
6455
6650
|
}
|
|
6651
|
+
|
|
6456
6652
|
const verifyFormat = () => {
|
|
6457
6653
|
if (Array.isArray(linkMap)) {
|
|
6458
6654
|
for (const link of linkMap) {
|
|
6459
6655
|
if (!(link.internalUser && link.externalUser && link.externalUser.id)) return false;
|
|
6460
6656
|
}
|
|
6657
|
+
|
|
6461
6658
|
return true;
|
|
6462
6659
|
}
|
|
6660
|
+
|
|
6463
6661
|
return false;
|
|
6464
6662
|
};
|
|
6663
|
+
|
|
6465
6664
|
if (!verifyFormat()) throw Error('linkmap in wrong format');
|
|
6466
6665
|
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").setLinkMap(token, linkMap);
|
|
6467
6666
|
});
|
|
6667
|
+
|
|
6468
6668
|
this.authoriseSupport = params => __awaiter(this, void 0, void 0, function* () {
|
|
6469
6669
|
const token = yield this.getRefreshedAccessToken();
|
|
6670
|
+
|
|
6470
6671
|
if (!token) {
|
|
6471
6672
|
throw Error('Not authenticated yet');
|
|
6472
6673
|
}
|
|
6674
|
+
|
|
6473
6675
|
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").authoriseSupport(token, params);
|
|
6474
6676
|
});
|
|
6677
|
+
|
|
6475
6678
|
this.changePassword = params => {
|
|
6476
6679
|
const redirectUrl = params.redirectUrl || window.location.href;
|
|
6680
|
+
|
|
6477
6681
|
__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").changePassword(Object.assign(Object.assign({}, params), {
|
|
6478
6682
|
redirectUrl
|
|
6479
6683
|
}));
|
|
6480
6684
|
};
|
|
6685
|
+
|
|
6481
6686
|
this.passthrough = params => __awaiter(this, void 0, void 0, function* () {
|
|
6482
6687
|
const decodedToken = yield this.getDecodedRefreshedAccessToken();
|
|
6688
|
+
|
|
6483
6689
|
if (decodedToken && decodedToken.jti) {
|
|
6484
6690
|
const {
|
|
6485
6691
|
url,
|
|
@@ -6488,26 +6694,31 @@
|
|
|
6488
6694
|
} = params;
|
|
6489
6695
|
const encodedRedirectUrl = encodeURIComponent(url);
|
|
6490
6696
|
const passthroughUrl = `${authHost || __classPrivateFieldGet(this, _Authentication_config, "f").authHost}/oauth/passthrough?jti=${decodedToken.jti}&redirect=${encodedRedirectUrl}&output=embed`;
|
|
6697
|
+
|
|
6491
6698
|
if (newWindow) {
|
|
6492
6699
|
window.open(passthroughUrl, '_blank');
|
|
6493
6700
|
} else {
|
|
6494
6701
|
window.location.assign(passthroughUrl);
|
|
6495
6702
|
}
|
|
6496
6703
|
}
|
|
6704
|
+
|
|
6497
6705
|
return;
|
|
6498
6706
|
});
|
|
6707
|
+
|
|
6499
6708
|
this.triggerHooks = hookName => __awaiter(this, void 0, void 0, function* () {
|
|
6500
6709
|
const hooks = this.getHooks();
|
|
6501
6710
|
const token = yield this.getRefreshedAccessToken();
|
|
6502
6711
|
const hookFn = hooks && !!hooks[hookName] && lodash.isFunction(hooks[hookName]) ? hooks[hookName](token) : false;
|
|
6503
6712
|
return Promise.resolve(hookFn);
|
|
6504
6713
|
});
|
|
6714
|
+
|
|
6505
6715
|
this.afterAuthenticated = () => {
|
|
6506
6716
|
return this.triggerHooks(HookName.afterLogin).then(() => __awaiter(this, void 0, void 0, function* () {
|
|
6507
6717
|
yield this.initNotification();
|
|
6508
6718
|
return __classPrivateFieldGet(this, _Authentication_accessToken, "f");
|
|
6509
6719
|
}));
|
|
6510
6720
|
};
|
|
6721
|
+
|
|
6511
6722
|
this.runIframe = (authorizeUrl, state, timeoutInSeconds = DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS) => {
|
|
6512
6723
|
return new Promise((res, rej) => {
|
|
6513
6724
|
const iframe = window.document.createElement('iframe');
|
|
@@ -6515,17 +6726,20 @@
|
|
|
6515
6726
|
iframe.setAttribute('height', '0');
|
|
6516
6727
|
iframe.setAttribute('id', 'agent-iframe');
|
|
6517
6728
|
iframe.style.display = 'none';
|
|
6729
|
+
|
|
6518
6730
|
const removeIframe = () => {
|
|
6519
6731
|
if (window.document.body.contains(iframe)) {
|
|
6520
6732
|
window.document.body.removeChild(iframe);
|
|
6521
6733
|
window.removeEventListener('message', iframeEventHandler, false);
|
|
6522
6734
|
}
|
|
6523
6735
|
};
|
|
6736
|
+
|
|
6524
6737
|
const timeoutSetTimeoutId = setTimeout(() => {
|
|
6525
6738
|
rej('agent-iframe timeout');
|
|
6526
6739
|
removeIframe();
|
|
6527
6740
|
window.sessionStorage.removeItem(state);
|
|
6528
6741
|
}, timeoutInSeconds * 1000);
|
|
6742
|
+
|
|
6529
6743
|
const iframeEventHandler = e => {
|
|
6530
6744
|
const {
|
|
6531
6745
|
data,
|
|
@@ -6534,25 +6748,30 @@
|
|
|
6534
6748
|
} = e;
|
|
6535
6749
|
if (origin !== __classPrivateFieldGet(this, _Authentication_config, "f").authHost) return;
|
|
6536
6750
|
if (!data || data.type !== 'authorization_response') return;
|
|
6751
|
+
|
|
6537
6752
|
if (source) {
|
|
6538
6753
|
source.close();
|
|
6539
6754
|
}
|
|
6755
|
+
|
|
6540
6756
|
res(data.response);
|
|
6541
6757
|
clearTimeout(timeoutSetTimeoutId);
|
|
6542
6758
|
window.removeEventListener('message', iframeEventHandler, false);
|
|
6543
6759
|
setTimeout(removeIframe, CLEANUP_IFRAME_TIMEOUT_IN_SECONDS * 1000);
|
|
6544
6760
|
};
|
|
6761
|
+
|
|
6545
6762
|
window.addEventListener('message', iframeEventHandler, false);
|
|
6546
6763
|
window.document.body.appendChild(iframe);
|
|
6547
6764
|
iframe.setAttribute('src', authorizeUrl);
|
|
6548
6765
|
});
|
|
6549
6766
|
};
|
|
6767
|
+
|
|
6550
6768
|
_Authentication_exchangeAuthCodeForAccessToken.set(this, params => __awaiter(this, void 0, void 0, function* () {
|
|
6551
6769
|
const {
|
|
6552
6770
|
verifier,
|
|
6553
6771
|
code,
|
|
6554
6772
|
redirectUri
|
|
6555
6773
|
} = params;
|
|
6774
|
+
|
|
6556
6775
|
if (verifier) {
|
|
6557
6776
|
const data = yield __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").exchangeAuthCodeForAccessToken({
|
|
6558
6777
|
code,
|
|
@@ -6560,9 +6779,11 @@
|
|
|
6560
6779
|
redirectUri
|
|
6561
6780
|
});
|
|
6562
6781
|
const redirectTriggered = yield __classPrivateFieldGet(this, _Authentication_verifyAndPerformRedirections, "f").call(this, data.access_token);
|
|
6782
|
+
|
|
6563
6783
|
if (redirectTriggered) {
|
|
6564
6784
|
return true;
|
|
6565
6785
|
}
|
|
6786
|
+
|
|
6566
6787
|
if (data.refresh_token && data.expires_in) {
|
|
6567
6788
|
__classPrivateFieldSet(this, _Authentication_refreshInfo, {
|
|
6568
6789
|
refreshToken: data.refresh_token,
|
|
@@ -6570,79 +6791,105 @@
|
|
|
6570
6791
|
verifier: verifier,
|
|
6571
6792
|
timer: undefined
|
|
6572
6793
|
}, "f");
|
|
6794
|
+
|
|
6573
6795
|
if (__classPrivateFieldGet(this, _Authentication_config, "f").autoRefreshToken) {
|
|
6574
6796
|
__classPrivateFieldGet(this, _Authentication_startRefreshAccessTokenProcess, "f").call(this);
|
|
6575
6797
|
}
|
|
6576
6798
|
}
|
|
6799
|
+
|
|
6577
6800
|
__classPrivateFieldSet(this, _Authentication_accessToken, data.access_token, "f");
|
|
6801
|
+
|
|
6578
6802
|
return true;
|
|
6579
6803
|
} else {
|
|
6580
6804
|
return false;
|
|
6581
6805
|
}
|
|
6582
6806
|
}));
|
|
6807
|
+
|
|
6583
6808
|
_Authentication_verifyAndPerformRedirections.set(this, accessToken => __awaiter(this, void 0, void 0, function* () {
|
|
6584
6809
|
const redirectionConfig = yield __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").getRedirections();
|
|
6585
6810
|
const origin = window.location.origin;
|
|
6811
|
+
|
|
6586
6812
|
const decodedToken = __classPrivateFieldGet(this, _Authentication_decodeAccessToken, "f").call(this, accessToken);
|
|
6813
|
+
|
|
6587
6814
|
const redirectUri = getRedirectUri(origin, decodedToken, redirectionConfig);
|
|
6815
|
+
|
|
6588
6816
|
if (redirectUri) {
|
|
6589
6817
|
this.logout(false, redirectUri);
|
|
6590
6818
|
return true;
|
|
6591
6819
|
}
|
|
6820
|
+
|
|
6592
6821
|
return false;
|
|
6593
6822
|
}));
|
|
6823
|
+
|
|
6594
6824
|
_Authentication_startRefreshAccessTokenProcess.set(this, () => {
|
|
6595
6825
|
if (!__classPrivateFieldGet(this, _Authentication_refreshInfo, "f")) {
|
|
6596
6826
|
return;
|
|
6597
6827
|
}
|
|
6828
|
+
|
|
6598
6829
|
if (__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").timer) {
|
|
6599
6830
|
clearTimeout(__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").timer);
|
|
6831
|
+
|
|
6600
6832
|
__classPrivateFieldSet(this, _Authentication_refreshInfo, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Authentication_refreshInfo, "f")), {
|
|
6601
6833
|
timer: undefined
|
|
6602
6834
|
}), "f");
|
|
6603
6835
|
}
|
|
6836
|
+
|
|
6604
6837
|
const waitBeforeExecuting = (__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").accessTokenExpireIn - SECONDS_BEFORE_EXPIRE) * 1000;
|
|
6838
|
+
|
|
6605
6839
|
if (waitBeforeExecuting > MAX_SETTIME_OUT) {
|
|
6606
6840
|
return;
|
|
6607
6841
|
}
|
|
6842
|
+
|
|
6608
6843
|
const timer = setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
6609
6844
|
if (!__classPrivateFieldGet(this, _Authentication_refreshInfo, "f")) {
|
|
6610
6845
|
return;
|
|
6611
6846
|
}
|
|
6847
|
+
|
|
6612
6848
|
const data = yield __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").renewAccessToken({
|
|
6613
6849
|
refreshToken: __classPrivateFieldGet(this, _Authentication_refreshInfo, "f").refreshToken,
|
|
6614
6850
|
verifier: __classPrivateFieldGet(this, _Authentication_refreshInfo, "f").verifier
|
|
6615
6851
|
});
|
|
6852
|
+
|
|
6616
6853
|
if (data) {
|
|
6617
6854
|
if (data.refresh_token && data.expires_in) {
|
|
6618
6855
|
__classPrivateFieldSet(this, _Authentication_refreshInfo, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Authentication_refreshInfo, "f")), {
|
|
6619
6856
|
refreshToken: data.refresh_token,
|
|
6620
6857
|
accessTokenExpireIn: data.expires_in
|
|
6621
6858
|
}), "f");
|
|
6859
|
+
|
|
6622
6860
|
__classPrivateFieldGet(this, _Authentication_startRefreshAccessTokenProcess, "f").call(this);
|
|
6623
6861
|
}
|
|
6862
|
+
|
|
6624
6863
|
__classPrivateFieldSet(this, _Authentication_accessToken, data.access_token, "f");
|
|
6864
|
+
|
|
6625
6865
|
yield this.triggerHooks(HookName.afterRefreshToken);
|
|
6626
6866
|
}
|
|
6627
6867
|
}), waitBeforeExecuting);
|
|
6868
|
+
|
|
6628
6869
|
__classPrivateFieldSet(this, _Authentication_refreshInfo, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Authentication_refreshInfo, "f")), {
|
|
6629
6870
|
timer
|
|
6630
6871
|
}), "f");
|
|
6631
6872
|
});
|
|
6873
|
+
|
|
6632
6874
|
_Authentication_destroyRefreshAccessTokenProcess.set(this, () => {
|
|
6633
6875
|
if (!__classPrivateFieldGet(this, _Authentication_refreshInfo, "f")) {
|
|
6634
6876
|
return;
|
|
6635
6877
|
}
|
|
6878
|
+
|
|
6636
6879
|
if (__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").timer) {
|
|
6637
6880
|
clearTimeout(__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").timer);
|
|
6638
6881
|
}
|
|
6882
|
+
|
|
6639
6883
|
__classPrivateFieldSet(this, _Authentication_refreshInfo, undefined, "f");
|
|
6640
6884
|
});
|
|
6885
|
+
|
|
6641
6886
|
_Authentication_decodeAccessToken.set(this, accessToken => {
|
|
6642
6887
|
if (!accessToken) {
|
|
6643
6888
|
return undefined;
|
|
6644
6889
|
}
|
|
6890
|
+
|
|
6645
6891
|
const payload = accessToken.split('.')[1];
|
|
6892
|
+
|
|
6646
6893
|
if (payload) {
|
|
6647
6894
|
try {
|
|
6648
6895
|
const result = window.atob(payload);
|
|
@@ -6651,52 +6898,51 @@
|
|
|
6651
6898
|
throw Error('Fail to decode access token.');
|
|
6652
6899
|
}
|
|
6653
6900
|
}
|
|
6901
|
+
|
|
6654
6902
|
return undefined;
|
|
6655
6903
|
});
|
|
6904
|
+
|
|
6656
6905
|
_Authentication_handlePopupLogin.set(this, url => {
|
|
6657
6906
|
return new Promise(resolve => {
|
|
6658
6907
|
__classPrivateFieldSet(this, _Authentication_popupLogin, true, "f");
|
|
6908
|
+
|
|
6659
6909
|
window.localStorage.setItem('leap-auth-popup-login', 'true');
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
let newUrl = window.location.href;
|
|
6668
|
-
newUrl = deleteQueryParameter(newUrl, 'code', code);
|
|
6669
|
-
newUrl = deleteQueryParameter(newUrl, 'state', state);
|
|
6670
|
-
window.history.pushState(null, '', newUrl);
|
|
6671
|
-
const done = yield __classPrivateFieldGet(this, _Authentication_exchangeAuthCodeForAccessToken, "f").call(this, {
|
|
6672
|
-
code,
|
|
6673
|
-
verifier,
|
|
6674
|
-
redirectUri: newUrl
|
|
6910
|
+
|
|
6911
|
+
if (Office) {
|
|
6912
|
+
Office.context.ui.displayDialogAsync(url, asyncResult => {
|
|
6913
|
+
__classPrivateFieldSet(this, _Authentication_officeDialog, asyncResult.value, "f");
|
|
6914
|
+
|
|
6915
|
+
__classPrivateFieldGet(this, _Authentication_officeDialog, "f").addEventHandler(Office.EventType.DialogMessageReceived, arg => {
|
|
6916
|
+
console.log('---------good');
|
|
6675
6917
|
});
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
} else {
|
|
6679
|
-
resolve(undefined);
|
|
6680
|
-
}
|
|
6681
|
-
}
|
|
6682
|
-
}));
|
|
6918
|
+
});
|
|
6919
|
+
}
|
|
6683
6920
|
});
|
|
6684
6921
|
});
|
|
6922
|
+
|
|
6685
6923
|
__classPrivateFieldSet(this, _Authentication_accessToken, undefined, "f");
|
|
6924
|
+
|
|
6686
6925
|
__classPrivateFieldSet(this, _Authentication_config, init$1(options), "f");
|
|
6926
|
+
|
|
6687
6927
|
__classPrivateFieldSet(this, _Authentication_leapAuthService, new LeapAuthService(__classPrivateFieldGet(this, _Authentication_config, "f").authHost, __classPrivateFieldGet(this, _Authentication_config, "f").clientId), "f");
|
|
6928
|
+
|
|
6688
6929
|
__classPrivateFieldSet(this, _Authentication_notification, new Notification(), "f");
|
|
6930
|
+
|
|
6689
6931
|
__classPrivateFieldSet(this, _Authentication_popupLogin, false, "f");
|
|
6690
6932
|
}
|
|
6933
|
+
|
|
6691
6934
|
}
|
|
6692
|
-
_Authentication_accessToken = new WeakMap(), _Authentication_config = new WeakMap(), _Authentication_leapAuthService = new WeakMap(), _Authentication_notification = new WeakMap(), _Authentication_popupLogin = 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(), _Authentication_handlePopupLogin = new WeakMap();
|
|
6935
|
+
_Authentication_accessToken = new WeakMap(), _Authentication_config = new WeakMap(), _Authentication_leapAuthService = new WeakMap(), _Authentication_notification = new WeakMap(), _Authentication_popupLogin = new WeakMap(), _Authentication_officeDialog = 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(), _Authentication_handlePopupLogin = new WeakMap();
|
|
6693
6936
|
|
|
6694
6937
|
var _IdleTimer_timeoutInMinutes, _IdleTimer_timer, _IdleTimer_onTimeout, _IdleTimer_cleanUpTracker, _IdleTimer_clearTimeout, _IdleTimer_resetTimer;
|
|
6695
6938
|
class IdleTimer {
|
|
6696
6939
|
constructor(params) {
|
|
6697
6940
|
_IdleTimer_timeoutInMinutes.set(this, void 0);
|
|
6941
|
+
|
|
6698
6942
|
_IdleTimer_timer.set(this, void 0);
|
|
6943
|
+
|
|
6699
6944
|
_IdleTimer_onTimeout.set(this, void 0);
|
|
6945
|
+
|
|
6700
6946
|
this.tracker = () => {
|
|
6701
6947
|
window.addEventListener('onload', __classPrivateFieldGet(this, _IdleTimer_resetTimer, "f"), true);
|
|
6702
6948
|
window.addEventListener('mousemove', __classPrivateFieldGet(this, _IdleTimer_resetTimer, "f"), true);
|
|
@@ -6704,6 +6950,7 @@
|
|
|
6704
6950
|
window.addEventListener('onscroll', __classPrivateFieldGet(this, _IdleTimer_resetTimer, "f"), true);
|
|
6705
6951
|
window.addEventListener('onkeypress', __classPrivateFieldGet(this, _IdleTimer_resetTimer, "f"), true);
|
|
6706
6952
|
};
|
|
6953
|
+
|
|
6707
6954
|
_IdleTimer_cleanUpTracker.set(this, () => {
|
|
6708
6955
|
window.removeEventListener('onload', __classPrivateFieldGet(this, _IdleTimer_resetTimer, "f"), true);
|
|
6709
6956
|
window.removeEventListener('mousemove', __classPrivateFieldGet(this, _IdleTimer_resetTimer, "f"), true);
|
|
@@ -6711,36 +6958,49 @@
|
|
|
6711
6958
|
window.removeEventListener('onscroll', __classPrivateFieldGet(this, _IdleTimer_resetTimer, "f"), true);
|
|
6712
6959
|
window.removeEventListener('onkeypress', __classPrivateFieldGet(this, _IdleTimer_resetTimer, "f"), true);
|
|
6713
6960
|
});
|
|
6961
|
+
|
|
6714
6962
|
_IdleTimer_clearTimeout.set(this, () => {
|
|
6715
6963
|
if (__classPrivateFieldGet(this, _IdleTimer_timer, "f")) {
|
|
6716
6964
|
clearTimeout(__classPrivateFieldGet(this, _IdleTimer_timer, "f"));
|
|
6717
6965
|
}
|
|
6718
6966
|
});
|
|
6967
|
+
|
|
6719
6968
|
_IdleTimer_resetTimer.set(this, () => {
|
|
6720
6969
|
__classPrivateFieldGet(this, _IdleTimer_clearTimeout, "f").call(this);
|
|
6970
|
+
|
|
6721
6971
|
__classPrivateFieldSet(this, _IdleTimer_timer, setTimeout(() => {
|
|
6722
6972
|
__classPrivateFieldGet(this, _IdleTimer_clearTimeout, "f").call(this);
|
|
6973
|
+
|
|
6723
6974
|
__classPrivateFieldGet(this, _IdleTimer_cleanUpTracker, "f").call(this);
|
|
6975
|
+
|
|
6724
6976
|
__classPrivateFieldGet(this, _IdleTimer_onTimeout, "f").call(this);
|
|
6725
6977
|
}, __classPrivateFieldGet(this, _IdleTimer_timeoutInMinutes, "f") * 60 * 1000), "f");
|
|
6726
6978
|
});
|
|
6979
|
+
|
|
6727
6980
|
const {
|
|
6728
6981
|
timeoutInMinutes,
|
|
6729
6982
|
onTimeout: onTimeout
|
|
6730
6983
|
} = params;
|
|
6984
|
+
|
|
6731
6985
|
__classPrivateFieldSet(this, _IdleTimer_timeoutInMinutes, timeoutInMinutes, "f");
|
|
6986
|
+
|
|
6732
6987
|
__classPrivateFieldSet(this, _IdleTimer_onTimeout, onTimeout, "f");
|
|
6733
6988
|
}
|
|
6989
|
+
|
|
6734
6990
|
}
|
|
6735
6991
|
_IdleTimer_timeoutInMinutes = new WeakMap(), _IdleTimer_timer = new WeakMap(), _IdleTimer_onTimeout = new WeakMap(), _IdleTimer_cleanUpTracker = new WeakMap(), _IdleTimer_clearTimeout = new WeakMap(), _IdleTimer_resetTimer = new WeakMap();
|
|
6736
6992
|
|
|
6737
6993
|
let auth;
|
|
6994
|
+
|
|
6738
6995
|
const init = options => __awaiter(void 0, void 0, void 0, function* () {
|
|
6739
6996
|
auth = new Authentication(options);
|
|
6997
|
+
|
|
6740
6998
|
if (!auth) {
|
|
6741
6999
|
return false;
|
|
6742
7000
|
}
|
|
7001
|
+
|
|
6743
7002
|
const autoLogout = auth.autoLogout();
|
|
7003
|
+
|
|
6744
7004
|
if (autoLogout) {
|
|
6745
7005
|
const timeoutInMinutes = auth.idleTimeoutInMinutes();
|
|
6746
7006
|
const idleTimer = new IdleTimer({
|
|
@@ -6749,40 +7009,55 @@
|
|
|
6749
7009
|
});
|
|
6750
7010
|
idleTimer.tracker();
|
|
6751
7011
|
}
|
|
7012
|
+
|
|
6752
7013
|
const done = yield auth.checkAuthCode();
|
|
7014
|
+
|
|
6753
7015
|
if (done) {
|
|
6754
7016
|
return auth.afterAuthenticated();
|
|
6755
7017
|
}
|
|
7018
|
+
|
|
6756
7019
|
const hasAuthSession = yield verifySession();
|
|
7020
|
+
|
|
6757
7021
|
if (hasAuthSession) {
|
|
6758
7022
|
return auth.afterAuthenticated();
|
|
6759
7023
|
}
|
|
7024
|
+
|
|
6760
7025
|
const passthrough = auth.checkTokenInUrl() || auth.checkTokenInInit();
|
|
7026
|
+
|
|
6761
7027
|
if (passthrough) {
|
|
6762
7028
|
return false;
|
|
6763
7029
|
}
|
|
7030
|
+
|
|
6764
7031
|
const autoLogin = auth.autoLogin();
|
|
7032
|
+
|
|
6765
7033
|
if (autoLogin) {
|
|
6766
7034
|
yield login();
|
|
6767
7035
|
}
|
|
7036
|
+
|
|
6768
7037
|
return true;
|
|
6769
7038
|
});
|
|
7039
|
+
|
|
6770
7040
|
const verifySession = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
6771
7041
|
if (!auth) {
|
|
6772
7042
|
throw Error('Not init yet');
|
|
6773
7043
|
}
|
|
7044
|
+
|
|
6774
7045
|
return yield auth.verifySession();
|
|
6775
7046
|
});
|
|
7047
|
+
|
|
6776
7048
|
const getAccessToken = () => {
|
|
6777
7049
|
return !auth ? '' : auth.getAccessToken();
|
|
6778
7050
|
};
|
|
7051
|
+
|
|
6779
7052
|
const getRefreshedAccessToken = force => __awaiter(void 0, void 0, void 0, function* () {
|
|
6780
7053
|
return !auth ? '' : yield auth.getRefreshedAccessToken(force);
|
|
6781
7054
|
});
|
|
7055
|
+
|
|
6782
7056
|
const login = (params = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
6783
7057
|
if (!auth) {
|
|
6784
7058
|
throw Error('Not init yet');
|
|
6785
7059
|
}
|
|
7060
|
+
|
|
6786
7061
|
const {
|
|
6787
7062
|
force_2fa,
|
|
6788
7063
|
popup
|
|
@@ -6795,87 +7070,109 @@
|
|
|
6795
7070
|
return token && auth ? auth.afterAuthenticated() : undefined;
|
|
6796
7071
|
});
|
|
6797
7072
|
});
|
|
7073
|
+
|
|
6798
7074
|
const logout = (force = false, redirectUrl) => __awaiter(void 0, void 0, void 0, function* () {
|
|
6799
7075
|
if (!auth) {
|
|
6800
7076
|
throw Error('Not init yet');
|
|
6801
7077
|
}
|
|
7078
|
+
|
|
6802
7079
|
return auth.triggerHooks(HookName.beforeLogout).then(() => {
|
|
6803
7080
|
if (auth) {
|
|
6804
7081
|
auth.destroyNotification();
|
|
6805
7082
|
auth.logout(force, redirectUrl);
|
|
6806
7083
|
}
|
|
7084
|
+
|
|
6807
7085
|
return;
|
|
6808
7086
|
}).catch(function (err) {
|
|
6809
7087
|
console.error('Error while logging out : ', err);
|
|
6810
7088
|
throw Error(err);
|
|
6811
7089
|
});
|
|
6812
7090
|
});
|
|
7091
|
+
|
|
6813
7092
|
const registerHook = (hookName, callback) => {
|
|
6814
7093
|
if (!auth) {
|
|
6815
7094
|
throw Error('Not init yet');
|
|
6816
7095
|
}
|
|
7096
|
+
|
|
6817
7097
|
if (auth) {
|
|
6818
7098
|
auth.setHook({
|
|
6819
7099
|
name: hookName,
|
|
6820
7100
|
callback
|
|
6821
7101
|
});
|
|
6822
7102
|
}
|
|
7103
|
+
|
|
6823
7104
|
return;
|
|
6824
7105
|
};
|
|
7106
|
+
|
|
6825
7107
|
const getDecodedAccessToken = () => {
|
|
6826
7108
|
if (!auth) {
|
|
6827
7109
|
throw Error('Not init yet');
|
|
6828
7110
|
}
|
|
7111
|
+
|
|
6829
7112
|
return auth.getDecodedAccessToken();
|
|
6830
7113
|
};
|
|
7114
|
+
|
|
6831
7115
|
const getDecodedRefreshedAccessToken = force => __awaiter(void 0, void 0, void 0, function* () {
|
|
6832
7116
|
if (!auth) {
|
|
6833
7117
|
throw Error('Not init yet');
|
|
6834
7118
|
}
|
|
7119
|
+
|
|
6835
7120
|
return yield auth.getDecodedRefreshedAccessToken(force);
|
|
6836
7121
|
});
|
|
7122
|
+
|
|
6837
7123
|
const userInfo = () => {
|
|
6838
7124
|
if (!auth) {
|
|
6839
7125
|
throw Error('Not init yet');
|
|
6840
7126
|
}
|
|
7127
|
+
|
|
6841
7128
|
return auth.getUserInfo();
|
|
6842
7129
|
};
|
|
7130
|
+
|
|
6843
7131
|
const linkUser = (redirectUrl, newWindow, callback) => __awaiter(void 0, void 0, void 0, function* () {
|
|
6844
7132
|
if (!auth) {
|
|
6845
7133
|
throw Error('Not init yet');
|
|
6846
7134
|
}
|
|
7135
|
+
|
|
6847
7136
|
yield auth.linkUser({
|
|
6848
7137
|
redirectUrl,
|
|
6849
7138
|
newWindow,
|
|
6850
7139
|
callback
|
|
6851
7140
|
});
|
|
6852
7141
|
});
|
|
7142
|
+
|
|
6853
7143
|
const unlinkUser = (redirectUrl, newWindow, callback) => __awaiter(void 0, void 0, void 0, function* () {
|
|
6854
7144
|
if (!auth) {
|
|
6855
7145
|
throw Error('Not init yet');
|
|
6856
7146
|
}
|
|
7147
|
+
|
|
6857
7148
|
yield auth.unlinkUser({
|
|
6858
7149
|
redirectUrl,
|
|
6859
7150
|
newWindow,
|
|
6860
7151
|
callback
|
|
6861
7152
|
});
|
|
6862
7153
|
});
|
|
7154
|
+
|
|
6863
7155
|
const getCloudProviderToken = jti => {
|
|
6864
7156
|
if (!auth) {
|
|
6865
7157
|
throw Error('Not init yet');
|
|
6866
7158
|
}
|
|
7159
|
+
|
|
6867
7160
|
return auth.getCloudProviderToken(jti);
|
|
6868
7161
|
};
|
|
7162
|
+
|
|
6869
7163
|
const cloudProviderUserInfo = () => {
|
|
6870
7164
|
if (!auth) {
|
|
6871
7165
|
throw Error('Not init yet');
|
|
6872
7166
|
}
|
|
7167
|
+
|
|
6873
7168
|
return auth.cloudProviderUserInfo();
|
|
6874
7169
|
};
|
|
7170
|
+
|
|
6875
7171
|
const cloudProviderReauthenticate = (nonce, redirectUrl, newWindow, callback) => {
|
|
6876
7172
|
if (!auth) {
|
|
6877
7173
|
throw Error('Not init yet');
|
|
6878
7174
|
}
|
|
7175
|
+
|
|
6879
7176
|
return auth.cloudProviderReauthenticate({
|
|
6880
7177
|
redirectUrl,
|
|
6881
7178
|
nonce,
|
|
@@ -6883,25 +7180,32 @@
|
|
|
6883
7180
|
callback
|
|
6884
7181
|
});
|
|
6885
7182
|
};
|
|
7183
|
+
|
|
6886
7184
|
const cloudProviderUpdate = cloudProviderId => {
|
|
6887
7185
|
if (!auth) {
|
|
6888
7186
|
throw Error('Not init yet');
|
|
6889
7187
|
}
|
|
7188
|
+
|
|
6890
7189
|
if (!cloudProviderId) {
|
|
6891
7190
|
throw Error('cloudProviderId is required');
|
|
6892
7191
|
}
|
|
7192
|
+
|
|
6893
7193
|
return auth.cloudProviderUpdate(cloudProviderId);
|
|
6894
7194
|
};
|
|
7195
|
+
|
|
6895
7196
|
const statusAdminConsent = () => {
|
|
6896
7197
|
if (!auth) {
|
|
6897
7198
|
throw Error('Not init yet');
|
|
6898
7199
|
}
|
|
7200
|
+
|
|
6899
7201
|
return auth.statusAdminConsent();
|
|
6900
7202
|
};
|
|
7203
|
+
|
|
6901
7204
|
const getAdminConsent = (domain, redirectUrl, newWindow, callback) => {
|
|
6902
7205
|
if (!auth) {
|
|
6903
7206
|
throw Error('Not init yet');
|
|
6904
7207
|
}
|
|
7208
|
+
|
|
6905
7209
|
auth.getAdminConsent({
|
|
6906
7210
|
domain,
|
|
6907
7211
|
redirectUrl,
|
|
@@ -6909,63 +7213,78 @@
|
|
|
6909
7213
|
callback
|
|
6910
7214
|
});
|
|
6911
7215
|
};
|
|
7216
|
+
|
|
6912
7217
|
const revokeAdminConsent = () => {
|
|
6913
7218
|
if (!auth) {
|
|
6914
7219
|
throw Error('Not init yet');
|
|
6915
7220
|
}
|
|
7221
|
+
|
|
6916
7222
|
return auth.revokeAdminConsent();
|
|
6917
7223
|
};
|
|
7224
|
+
|
|
6918
7225
|
const getLinkMap = allUsers => {
|
|
6919
7226
|
if (!auth) {
|
|
6920
7227
|
throw Error('Not init yet');
|
|
6921
7228
|
}
|
|
7229
|
+
|
|
6922
7230
|
return auth.getLinkMap(allUsers);
|
|
6923
7231
|
};
|
|
7232
|
+
|
|
6924
7233
|
const setLinkMap = linkMap => {
|
|
6925
7234
|
if (!auth) {
|
|
6926
7235
|
throw Error('Not init yet');
|
|
6927
7236
|
}
|
|
7237
|
+
|
|
6928
7238
|
return auth.setLinkMap(linkMap);
|
|
6929
7239
|
};
|
|
7240
|
+
|
|
6930
7241
|
const authoriseSupport = (code, duration) => {
|
|
6931
7242
|
if (!auth) {
|
|
6932
7243
|
throw Error('Not init yet');
|
|
6933
7244
|
}
|
|
7245
|
+
|
|
6934
7246
|
return auth.authoriseSupport({
|
|
6935
7247
|
code,
|
|
6936
7248
|
duration
|
|
6937
7249
|
});
|
|
6938
7250
|
};
|
|
7251
|
+
|
|
6939
7252
|
const changePassword = (redirectUrl, newWindow, callback) => {
|
|
6940
7253
|
if (!auth) {
|
|
6941
7254
|
throw Error('Not init yet');
|
|
6942
7255
|
}
|
|
7256
|
+
|
|
6943
7257
|
auth.changePassword({
|
|
6944
7258
|
redirectUrl,
|
|
6945
7259
|
newWindow,
|
|
6946
7260
|
callback
|
|
6947
7261
|
});
|
|
6948
7262
|
};
|
|
7263
|
+
|
|
6949
7264
|
const registerEventListener = (topic, messageType, callback) => {
|
|
6950
7265
|
if (!auth) {
|
|
6951
7266
|
throw Error('Not init yet');
|
|
6952
7267
|
}
|
|
7268
|
+
|
|
6953
7269
|
auth.registerEventListenerForUserChannel({
|
|
6954
7270
|
topic,
|
|
6955
7271
|
messageType,
|
|
6956
7272
|
callback
|
|
6957
7273
|
});
|
|
6958
7274
|
};
|
|
7275
|
+
|
|
6959
7276
|
const passthrough = (url, newWindow = false, authHost) => __awaiter(void 0, void 0, void 0, function* () {
|
|
6960
7277
|
if (!auth) {
|
|
6961
7278
|
throw Error('Not init yet');
|
|
6962
7279
|
}
|
|
7280
|
+
|
|
6963
7281
|
yield auth.passthrough({
|
|
6964
7282
|
url,
|
|
6965
7283
|
newWindow,
|
|
6966
7284
|
authHost
|
|
6967
7285
|
});
|
|
6968
7286
|
});
|
|
7287
|
+
|
|
6969
7288
|
const AuthAgent = {
|
|
6970
7289
|
init,
|
|
6971
7290
|
registerHook,
|