@leapdev/auth-agent 2.2.13-beta.4 → 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 +358 -38
- package/src/lib/authentication.js +14 -30
- 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,15 +6458,18 @@
|
|
|
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
|
-
const isPopupLogin = window.
|
|
6469
|
+
const isPopupLogin = window.localStorage.getItem('leap-auth-popup-login');
|
|
6470
|
+
|
|
6313
6471
|
if (isPopupLogin === 'true' && window.opener) {
|
|
6314
|
-
window.
|
|
6472
|
+
window.localStorage.removeItem('leap-auth-popup-login');
|
|
6315
6473
|
window.opener.postMessage({
|
|
6316
6474
|
source: 'leap-auth-popup-login',
|
|
6317
6475
|
code,
|
|
@@ -6320,6 +6478,7 @@
|
|
|
6320
6478
|
window.close();
|
|
6321
6479
|
return false;
|
|
6322
6480
|
} else {
|
|
6481
|
+
window.localStorage.removeItem('leap-auth-popup-login');
|
|
6323
6482
|
const verifier = window.sessionStorage.getItem(state);
|
|
6324
6483
|
window.sessionStorage.removeItem(state);
|
|
6325
6484
|
let newUrl = window.location.href;
|
|
@@ -6336,16 +6495,21 @@
|
|
|
6336
6495
|
return false;
|
|
6337
6496
|
}
|
|
6338
6497
|
});
|
|
6498
|
+
|
|
6339
6499
|
this.getUserInfo = () => __awaiter(this, void 0, void 0, function* () {
|
|
6340
6500
|
const token = yield this.getRefreshedAccessToken();
|
|
6341
6501
|
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").userInfo(token);
|
|
6342
6502
|
});
|
|
6503
|
+
|
|
6343
6504
|
this.linkUser = params => __awaiter(this, void 0, void 0, function* () {
|
|
6344
6505
|
const decodeToken = yield this.getDecodedRefreshedAccessToken();
|
|
6506
|
+
|
|
6345
6507
|
if (!decodeToken) {
|
|
6346
6508
|
return;
|
|
6347
6509
|
}
|
|
6510
|
+
|
|
6348
6511
|
const redirectUrl = params.redirectUrl || window.location.href;
|
|
6512
|
+
|
|
6349
6513
|
__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").linkUser({
|
|
6350
6514
|
redirectUrl,
|
|
6351
6515
|
jti: decodeToken.jti,
|
|
@@ -6353,12 +6517,16 @@
|
|
|
6353
6517
|
callback: params.callback
|
|
6354
6518
|
});
|
|
6355
6519
|
});
|
|
6520
|
+
|
|
6356
6521
|
this.unlinkUser = params => __awaiter(this, void 0, void 0, function* () {
|
|
6357
6522
|
const decodeToken = yield this.getDecodedRefreshedAccessToken();
|
|
6523
|
+
|
|
6358
6524
|
if (!decodeToken) {
|
|
6359
6525
|
return;
|
|
6360
6526
|
}
|
|
6527
|
+
|
|
6361
6528
|
const redirectUrl = params.redirectUrl || window.location.href;
|
|
6529
|
+
|
|
6362
6530
|
__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").unlinkUser({
|
|
6363
6531
|
redirectUrl,
|
|
6364
6532
|
jti: decodeToken.jti,
|
|
@@ -6366,25 +6534,34 @@
|
|
|
6366
6534
|
callback: params.callback
|
|
6367
6535
|
});
|
|
6368
6536
|
});
|
|
6537
|
+
|
|
6369
6538
|
this.getCloudProviderToken = jti => __awaiter(this, void 0, void 0, function* () {
|
|
6370
6539
|
const token = yield this.getRefreshedAccessToken();
|
|
6540
|
+
|
|
6371
6541
|
if (!token) {
|
|
6372
6542
|
throw Error('Not authenticated yet');
|
|
6373
6543
|
}
|
|
6544
|
+
|
|
6374
6545
|
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").getCloudProviderToken(token, jti);
|
|
6375
6546
|
});
|
|
6547
|
+
|
|
6376
6548
|
this.cloudProviderUserInfo = () => __awaiter(this, void 0, void 0, function* () {
|
|
6377
6549
|
const token = yield this.getRefreshedAccessToken();
|
|
6550
|
+
|
|
6378
6551
|
if (!token) {
|
|
6379
6552
|
throw Error('Not authenticated yet');
|
|
6380
6553
|
}
|
|
6554
|
+
|
|
6381
6555
|
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").cloudProviderUserInfo(token);
|
|
6382
6556
|
});
|
|
6557
|
+
|
|
6383
6558
|
this.cloudProviderReauthenticate = params => __awaiter(this, void 0, void 0, function* () {
|
|
6384
6559
|
const token = yield this.getRefreshedAccessToken();
|
|
6560
|
+
|
|
6385
6561
|
if (!token) {
|
|
6386
6562
|
throw Error('Not authenticated yet');
|
|
6387
6563
|
}
|
|
6564
|
+
|
|
6388
6565
|
let {
|
|
6389
6566
|
nonce,
|
|
6390
6567
|
redirectUrl
|
|
@@ -6394,10 +6571,12 @@
|
|
|
6394
6571
|
callback
|
|
6395
6572
|
} = params;
|
|
6396
6573
|
redirectUrl = redirectUrl || window.location.href;
|
|
6574
|
+
|
|
6397
6575
|
if (!nonce) {
|
|
6398
6576
|
const reauthticateLink = yield __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").cloudProviderReauthenticateLink(token);
|
|
6399
6577
|
nonce = reauthticateLink.nonce;
|
|
6400
6578
|
}
|
|
6579
|
+
|
|
6401
6580
|
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").cloudProviderReauthenticate({
|
|
6402
6581
|
redirectUrl,
|
|
6403
6582
|
nonce,
|
|
@@ -6405,12 +6584,16 @@
|
|
|
6405
6584
|
callback
|
|
6406
6585
|
});
|
|
6407
6586
|
});
|
|
6587
|
+
|
|
6408
6588
|
this.cloudProviderUpdate = cloudProviderId => __awaiter(this, void 0, void 0, function* () {
|
|
6409
6589
|
const token = yield this.getRefreshedAccessToken();
|
|
6590
|
+
|
|
6410
6591
|
if (!token) {
|
|
6411
6592
|
throw Error('Not authenticated yet');
|
|
6412
6593
|
}
|
|
6594
|
+
|
|
6413
6595
|
const decodedToken = __classPrivateFieldGet(this, _Authentication_decodeAccessToken, "f").call(this, token);
|
|
6596
|
+
|
|
6414
6597
|
const {
|
|
6415
6598
|
firmId
|
|
6416
6599
|
} = decodedToken;
|
|
@@ -6420,65 +6603,89 @@
|
|
|
6420
6603
|
token: token
|
|
6421
6604
|
});
|
|
6422
6605
|
});
|
|
6606
|
+
|
|
6423
6607
|
this.statusAdminConsent = () => __awaiter(this, void 0, void 0, function* () {
|
|
6424
6608
|
const token = yield this.getRefreshedAccessToken();
|
|
6609
|
+
|
|
6425
6610
|
if (!token) {
|
|
6426
6611
|
throw Error('Not authenticated yet');
|
|
6427
6612
|
}
|
|
6613
|
+
|
|
6428
6614
|
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").statusAdminConsent(token);
|
|
6429
6615
|
});
|
|
6616
|
+
|
|
6430
6617
|
this.getAdminConsent = params => {
|
|
6431
6618
|
const redirectUrl = params.redirectUrl || window.location.href;
|
|
6619
|
+
|
|
6432
6620
|
__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").getAdminConsent(Object.assign(Object.assign({}, params), {
|
|
6433
6621
|
redirectUrl
|
|
6434
6622
|
}));
|
|
6435
6623
|
};
|
|
6624
|
+
|
|
6436
6625
|
this.revokeAdminConsent = () => __awaiter(this, void 0, void 0, function* () {
|
|
6437
6626
|
const token = yield this.getRefreshedAccessToken();
|
|
6627
|
+
|
|
6438
6628
|
if (!token) {
|
|
6439
6629
|
throw Error('Not authenticated yet');
|
|
6440
6630
|
}
|
|
6631
|
+
|
|
6441
6632
|
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").revokeAdminConsent(token);
|
|
6442
6633
|
});
|
|
6634
|
+
|
|
6443
6635
|
this.getLinkMap = (allUsers = false) => __awaiter(this, void 0, void 0, function* () {
|
|
6444
6636
|
const token = yield this.getRefreshedAccessToken();
|
|
6637
|
+
|
|
6445
6638
|
if (!token) {
|
|
6446
6639
|
throw Error('Not authenticated yet');
|
|
6447
6640
|
}
|
|
6641
|
+
|
|
6448
6642
|
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").getLinkMap(token, allUsers);
|
|
6449
6643
|
});
|
|
6644
|
+
|
|
6450
6645
|
this.setLinkMap = linkMap => __awaiter(this, void 0, void 0, function* () {
|
|
6451
6646
|
const token = yield this.getRefreshedAccessToken();
|
|
6647
|
+
|
|
6452
6648
|
if (!token) {
|
|
6453
6649
|
throw Error('Not authenticated yet');
|
|
6454
6650
|
}
|
|
6651
|
+
|
|
6455
6652
|
const verifyFormat = () => {
|
|
6456
6653
|
if (Array.isArray(linkMap)) {
|
|
6457
6654
|
for (const link of linkMap) {
|
|
6458
6655
|
if (!(link.internalUser && link.externalUser && link.externalUser.id)) return false;
|
|
6459
6656
|
}
|
|
6657
|
+
|
|
6460
6658
|
return true;
|
|
6461
6659
|
}
|
|
6660
|
+
|
|
6462
6661
|
return false;
|
|
6463
6662
|
};
|
|
6663
|
+
|
|
6464
6664
|
if (!verifyFormat()) throw Error('linkmap in wrong format');
|
|
6465
6665
|
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").setLinkMap(token, linkMap);
|
|
6466
6666
|
});
|
|
6667
|
+
|
|
6467
6668
|
this.authoriseSupport = params => __awaiter(this, void 0, void 0, function* () {
|
|
6468
6669
|
const token = yield this.getRefreshedAccessToken();
|
|
6670
|
+
|
|
6469
6671
|
if (!token) {
|
|
6470
6672
|
throw Error('Not authenticated yet');
|
|
6471
6673
|
}
|
|
6674
|
+
|
|
6472
6675
|
return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").authoriseSupport(token, params);
|
|
6473
6676
|
});
|
|
6677
|
+
|
|
6474
6678
|
this.changePassword = params => {
|
|
6475
6679
|
const redirectUrl = params.redirectUrl || window.location.href;
|
|
6680
|
+
|
|
6476
6681
|
__classPrivateFieldGet(this, _Authentication_leapAuthService, "f").changePassword(Object.assign(Object.assign({}, params), {
|
|
6477
6682
|
redirectUrl
|
|
6478
6683
|
}));
|
|
6479
6684
|
};
|
|
6685
|
+
|
|
6480
6686
|
this.passthrough = params => __awaiter(this, void 0, void 0, function* () {
|
|
6481
6687
|
const decodedToken = yield this.getDecodedRefreshedAccessToken();
|
|
6688
|
+
|
|
6482
6689
|
if (decodedToken && decodedToken.jti) {
|
|
6483
6690
|
const {
|
|
6484
6691
|
url,
|
|
@@ -6487,26 +6694,31 @@
|
|
|
6487
6694
|
} = params;
|
|
6488
6695
|
const encodedRedirectUrl = encodeURIComponent(url);
|
|
6489
6696
|
const passthroughUrl = `${authHost || __classPrivateFieldGet(this, _Authentication_config, "f").authHost}/oauth/passthrough?jti=${decodedToken.jti}&redirect=${encodedRedirectUrl}&output=embed`;
|
|
6697
|
+
|
|
6490
6698
|
if (newWindow) {
|
|
6491
6699
|
window.open(passthroughUrl, '_blank');
|
|
6492
6700
|
} else {
|
|
6493
6701
|
window.location.assign(passthroughUrl);
|
|
6494
6702
|
}
|
|
6495
6703
|
}
|
|
6704
|
+
|
|
6496
6705
|
return;
|
|
6497
6706
|
});
|
|
6707
|
+
|
|
6498
6708
|
this.triggerHooks = hookName => __awaiter(this, void 0, void 0, function* () {
|
|
6499
6709
|
const hooks = this.getHooks();
|
|
6500
6710
|
const token = yield this.getRefreshedAccessToken();
|
|
6501
6711
|
const hookFn = hooks && !!hooks[hookName] && lodash.isFunction(hooks[hookName]) ? hooks[hookName](token) : false;
|
|
6502
6712
|
return Promise.resolve(hookFn);
|
|
6503
6713
|
});
|
|
6714
|
+
|
|
6504
6715
|
this.afterAuthenticated = () => {
|
|
6505
6716
|
return this.triggerHooks(HookName.afterLogin).then(() => __awaiter(this, void 0, void 0, function* () {
|
|
6506
6717
|
yield this.initNotification();
|
|
6507
6718
|
return __classPrivateFieldGet(this, _Authentication_accessToken, "f");
|
|
6508
6719
|
}));
|
|
6509
6720
|
};
|
|
6721
|
+
|
|
6510
6722
|
this.runIframe = (authorizeUrl, state, timeoutInSeconds = DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS) => {
|
|
6511
6723
|
return new Promise((res, rej) => {
|
|
6512
6724
|
const iframe = window.document.createElement('iframe');
|
|
@@ -6514,17 +6726,20 @@
|
|
|
6514
6726
|
iframe.setAttribute('height', '0');
|
|
6515
6727
|
iframe.setAttribute('id', 'agent-iframe');
|
|
6516
6728
|
iframe.style.display = 'none';
|
|
6729
|
+
|
|
6517
6730
|
const removeIframe = () => {
|
|
6518
6731
|
if (window.document.body.contains(iframe)) {
|
|
6519
6732
|
window.document.body.removeChild(iframe);
|
|
6520
6733
|
window.removeEventListener('message', iframeEventHandler, false);
|
|
6521
6734
|
}
|
|
6522
6735
|
};
|
|
6736
|
+
|
|
6523
6737
|
const timeoutSetTimeoutId = setTimeout(() => {
|
|
6524
6738
|
rej('agent-iframe timeout');
|
|
6525
6739
|
removeIframe();
|
|
6526
6740
|
window.sessionStorage.removeItem(state);
|
|
6527
6741
|
}, timeoutInSeconds * 1000);
|
|
6742
|
+
|
|
6528
6743
|
const iframeEventHandler = e => {
|
|
6529
6744
|
const {
|
|
6530
6745
|
data,
|
|
@@ -6533,25 +6748,30 @@
|
|
|
6533
6748
|
} = e;
|
|
6534
6749
|
if (origin !== __classPrivateFieldGet(this, _Authentication_config, "f").authHost) return;
|
|
6535
6750
|
if (!data || data.type !== 'authorization_response') return;
|
|
6751
|
+
|
|
6536
6752
|
if (source) {
|
|
6537
6753
|
source.close();
|
|
6538
6754
|
}
|
|
6755
|
+
|
|
6539
6756
|
res(data.response);
|
|
6540
6757
|
clearTimeout(timeoutSetTimeoutId);
|
|
6541
6758
|
window.removeEventListener('message', iframeEventHandler, false);
|
|
6542
6759
|
setTimeout(removeIframe, CLEANUP_IFRAME_TIMEOUT_IN_SECONDS * 1000);
|
|
6543
6760
|
};
|
|
6761
|
+
|
|
6544
6762
|
window.addEventListener('message', iframeEventHandler, false);
|
|
6545
6763
|
window.document.body.appendChild(iframe);
|
|
6546
6764
|
iframe.setAttribute('src', authorizeUrl);
|
|
6547
6765
|
});
|
|
6548
6766
|
};
|
|
6767
|
+
|
|
6549
6768
|
_Authentication_exchangeAuthCodeForAccessToken.set(this, params => __awaiter(this, void 0, void 0, function* () {
|
|
6550
6769
|
const {
|
|
6551
6770
|
verifier,
|
|
6552
6771
|
code,
|
|
6553
6772
|
redirectUri
|
|
6554
6773
|
} = params;
|
|
6774
|
+
|
|
6555
6775
|
if (verifier) {
|
|
6556
6776
|
const data = yield __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").exchangeAuthCodeForAccessToken({
|
|
6557
6777
|
code,
|
|
@@ -6559,9 +6779,11 @@
|
|
|
6559
6779
|
redirectUri
|
|
6560
6780
|
});
|
|
6561
6781
|
const redirectTriggered = yield __classPrivateFieldGet(this, _Authentication_verifyAndPerformRedirections, "f").call(this, data.access_token);
|
|
6782
|
+
|
|
6562
6783
|
if (redirectTriggered) {
|
|
6563
6784
|
return true;
|
|
6564
6785
|
}
|
|
6786
|
+
|
|
6565
6787
|
if (data.refresh_token && data.expires_in) {
|
|
6566
6788
|
__classPrivateFieldSet(this, _Authentication_refreshInfo, {
|
|
6567
6789
|
refreshToken: data.refresh_token,
|
|
@@ -6569,79 +6791,105 @@
|
|
|
6569
6791
|
verifier: verifier,
|
|
6570
6792
|
timer: undefined
|
|
6571
6793
|
}, "f");
|
|
6794
|
+
|
|
6572
6795
|
if (__classPrivateFieldGet(this, _Authentication_config, "f").autoRefreshToken) {
|
|
6573
6796
|
__classPrivateFieldGet(this, _Authentication_startRefreshAccessTokenProcess, "f").call(this);
|
|
6574
6797
|
}
|
|
6575
6798
|
}
|
|
6799
|
+
|
|
6576
6800
|
__classPrivateFieldSet(this, _Authentication_accessToken, data.access_token, "f");
|
|
6801
|
+
|
|
6577
6802
|
return true;
|
|
6578
6803
|
} else {
|
|
6579
6804
|
return false;
|
|
6580
6805
|
}
|
|
6581
6806
|
}));
|
|
6807
|
+
|
|
6582
6808
|
_Authentication_verifyAndPerformRedirections.set(this, accessToken => __awaiter(this, void 0, void 0, function* () {
|
|
6583
6809
|
const redirectionConfig = yield __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").getRedirections();
|
|
6584
6810
|
const origin = window.location.origin;
|
|
6811
|
+
|
|
6585
6812
|
const decodedToken = __classPrivateFieldGet(this, _Authentication_decodeAccessToken, "f").call(this, accessToken);
|
|
6813
|
+
|
|
6586
6814
|
const redirectUri = getRedirectUri(origin, decodedToken, redirectionConfig);
|
|
6815
|
+
|
|
6587
6816
|
if (redirectUri) {
|
|
6588
6817
|
this.logout(false, redirectUri);
|
|
6589
6818
|
return true;
|
|
6590
6819
|
}
|
|
6820
|
+
|
|
6591
6821
|
return false;
|
|
6592
6822
|
}));
|
|
6823
|
+
|
|
6593
6824
|
_Authentication_startRefreshAccessTokenProcess.set(this, () => {
|
|
6594
6825
|
if (!__classPrivateFieldGet(this, _Authentication_refreshInfo, "f")) {
|
|
6595
6826
|
return;
|
|
6596
6827
|
}
|
|
6828
|
+
|
|
6597
6829
|
if (__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").timer) {
|
|
6598
6830
|
clearTimeout(__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").timer);
|
|
6831
|
+
|
|
6599
6832
|
__classPrivateFieldSet(this, _Authentication_refreshInfo, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Authentication_refreshInfo, "f")), {
|
|
6600
6833
|
timer: undefined
|
|
6601
6834
|
}), "f");
|
|
6602
6835
|
}
|
|
6836
|
+
|
|
6603
6837
|
const waitBeforeExecuting = (__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").accessTokenExpireIn - SECONDS_BEFORE_EXPIRE) * 1000;
|
|
6838
|
+
|
|
6604
6839
|
if (waitBeforeExecuting > MAX_SETTIME_OUT) {
|
|
6605
6840
|
return;
|
|
6606
6841
|
}
|
|
6842
|
+
|
|
6607
6843
|
const timer = setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
6608
6844
|
if (!__classPrivateFieldGet(this, _Authentication_refreshInfo, "f")) {
|
|
6609
6845
|
return;
|
|
6610
6846
|
}
|
|
6847
|
+
|
|
6611
6848
|
const data = yield __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").renewAccessToken({
|
|
6612
6849
|
refreshToken: __classPrivateFieldGet(this, _Authentication_refreshInfo, "f").refreshToken,
|
|
6613
6850
|
verifier: __classPrivateFieldGet(this, _Authentication_refreshInfo, "f").verifier
|
|
6614
6851
|
});
|
|
6852
|
+
|
|
6615
6853
|
if (data) {
|
|
6616
6854
|
if (data.refresh_token && data.expires_in) {
|
|
6617
6855
|
__classPrivateFieldSet(this, _Authentication_refreshInfo, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Authentication_refreshInfo, "f")), {
|
|
6618
6856
|
refreshToken: data.refresh_token,
|
|
6619
6857
|
accessTokenExpireIn: data.expires_in
|
|
6620
6858
|
}), "f");
|
|
6859
|
+
|
|
6621
6860
|
__classPrivateFieldGet(this, _Authentication_startRefreshAccessTokenProcess, "f").call(this);
|
|
6622
6861
|
}
|
|
6862
|
+
|
|
6623
6863
|
__classPrivateFieldSet(this, _Authentication_accessToken, data.access_token, "f");
|
|
6864
|
+
|
|
6624
6865
|
yield this.triggerHooks(HookName.afterRefreshToken);
|
|
6625
6866
|
}
|
|
6626
6867
|
}), waitBeforeExecuting);
|
|
6868
|
+
|
|
6627
6869
|
__classPrivateFieldSet(this, _Authentication_refreshInfo, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Authentication_refreshInfo, "f")), {
|
|
6628
6870
|
timer
|
|
6629
6871
|
}), "f");
|
|
6630
6872
|
});
|
|
6873
|
+
|
|
6631
6874
|
_Authentication_destroyRefreshAccessTokenProcess.set(this, () => {
|
|
6632
6875
|
if (!__classPrivateFieldGet(this, _Authentication_refreshInfo, "f")) {
|
|
6633
6876
|
return;
|
|
6634
6877
|
}
|
|
6878
|
+
|
|
6635
6879
|
if (__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").timer) {
|
|
6636
6880
|
clearTimeout(__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").timer);
|
|
6637
6881
|
}
|
|
6882
|
+
|
|
6638
6883
|
__classPrivateFieldSet(this, _Authentication_refreshInfo, undefined, "f");
|
|
6639
6884
|
});
|
|
6885
|
+
|
|
6640
6886
|
_Authentication_decodeAccessToken.set(this, accessToken => {
|
|
6641
6887
|
if (!accessToken) {
|
|
6642
6888
|
return undefined;
|
|
6643
6889
|
}
|
|
6890
|
+
|
|
6644
6891
|
const payload = accessToken.split('.')[1];
|
|
6892
|
+
|
|
6645
6893
|
if (payload) {
|
|
6646
6894
|
try {
|
|
6647
6895
|
const result = window.atob(payload);
|
|
@@ -6650,52 +6898,51 @@
|
|
|
6650
6898
|
throw Error('Fail to decode access token.');
|
|
6651
6899
|
}
|
|
6652
6900
|
}
|
|
6901
|
+
|
|
6653
6902
|
return undefined;
|
|
6654
6903
|
});
|
|
6904
|
+
|
|
6655
6905
|
_Authentication_handlePopupLogin.set(this, url => {
|
|
6656
6906
|
return new Promise(resolve => {
|
|
6657
6907
|
__classPrivateFieldSet(this, _Authentication_popupLogin, true, "f");
|
|
6658
|
-
|
|
6659
|
-
window.
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
newUrl = deleteQueryParameter(newUrl, 'code', code);
|
|
6668
|
-
newUrl = deleteQueryParameter(newUrl, 'state', state);
|
|
6669
|
-
window.history.pushState(null, '', newUrl);
|
|
6670
|
-
const done = yield __classPrivateFieldGet(this, _Authentication_exchangeAuthCodeForAccessToken, "f").call(this, {
|
|
6671
|
-
code,
|
|
6672
|
-
verifier,
|
|
6673
|
-
redirectUri: newUrl
|
|
6908
|
+
|
|
6909
|
+
window.localStorage.setItem('leap-auth-popup-login', 'true');
|
|
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');
|
|
6674
6917
|
});
|
|
6675
|
-
|
|
6676
|
-
|
|
6677
|
-
} else {
|
|
6678
|
-
resolve(undefined);
|
|
6679
|
-
}
|
|
6680
|
-
}
|
|
6681
|
-
}));
|
|
6918
|
+
});
|
|
6919
|
+
}
|
|
6682
6920
|
});
|
|
6683
6921
|
});
|
|
6922
|
+
|
|
6684
6923
|
__classPrivateFieldSet(this, _Authentication_accessToken, undefined, "f");
|
|
6924
|
+
|
|
6685
6925
|
__classPrivateFieldSet(this, _Authentication_config, init$1(options), "f");
|
|
6926
|
+
|
|
6686
6927
|
__classPrivateFieldSet(this, _Authentication_leapAuthService, new LeapAuthService(__classPrivateFieldGet(this, _Authentication_config, "f").authHost, __classPrivateFieldGet(this, _Authentication_config, "f").clientId), "f");
|
|
6928
|
+
|
|
6687
6929
|
__classPrivateFieldSet(this, _Authentication_notification, new Notification(), "f");
|
|
6930
|
+
|
|
6688
6931
|
__classPrivateFieldSet(this, _Authentication_popupLogin, false, "f");
|
|
6689
6932
|
}
|
|
6933
|
+
|
|
6690
6934
|
}
|
|
6691
|
-
_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();
|
|
6692
6936
|
|
|
6693
6937
|
var _IdleTimer_timeoutInMinutes, _IdleTimer_timer, _IdleTimer_onTimeout, _IdleTimer_cleanUpTracker, _IdleTimer_clearTimeout, _IdleTimer_resetTimer;
|
|
6694
6938
|
class IdleTimer {
|
|
6695
6939
|
constructor(params) {
|
|
6696
6940
|
_IdleTimer_timeoutInMinutes.set(this, void 0);
|
|
6941
|
+
|
|
6697
6942
|
_IdleTimer_timer.set(this, void 0);
|
|
6943
|
+
|
|
6698
6944
|
_IdleTimer_onTimeout.set(this, void 0);
|
|
6945
|
+
|
|
6699
6946
|
this.tracker = () => {
|
|
6700
6947
|
window.addEventListener('onload', __classPrivateFieldGet(this, _IdleTimer_resetTimer, "f"), true);
|
|
6701
6948
|
window.addEventListener('mousemove', __classPrivateFieldGet(this, _IdleTimer_resetTimer, "f"), true);
|
|
@@ -6703,6 +6950,7 @@
|
|
|
6703
6950
|
window.addEventListener('onscroll', __classPrivateFieldGet(this, _IdleTimer_resetTimer, "f"), true);
|
|
6704
6951
|
window.addEventListener('onkeypress', __classPrivateFieldGet(this, _IdleTimer_resetTimer, "f"), true);
|
|
6705
6952
|
};
|
|
6953
|
+
|
|
6706
6954
|
_IdleTimer_cleanUpTracker.set(this, () => {
|
|
6707
6955
|
window.removeEventListener('onload', __classPrivateFieldGet(this, _IdleTimer_resetTimer, "f"), true);
|
|
6708
6956
|
window.removeEventListener('mousemove', __classPrivateFieldGet(this, _IdleTimer_resetTimer, "f"), true);
|
|
@@ -6710,36 +6958,49 @@
|
|
|
6710
6958
|
window.removeEventListener('onscroll', __classPrivateFieldGet(this, _IdleTimer_resetTimer, "f"), true);
|
|
6711
6959
|
window.removeEventListener('onkeypress', __classPrivateFieldGet(this, _IdleTimer_resetTimer, "f"), true);
|
|
6712
6960
|
});
|
|
6961
|
+
|
|
6713
6962
|
_IdleTimer_clearTimeout.set(this, () => {
|
|
6714
6963
|
if (__classPrivateFieldGet(this, _IdleTimer_timer, "f")) {
|
|
6715
6964
|
clearTimeout(__classPrivateFieldGet(this, _IdleTimer_timer, "f"));
|
|
6716
6965
|
}
|
|
6717
6966
|
});
|
|
6967
|
+
|
|
6718
6968
|
_IdleTimer_resetTimer.set(this, () => {
|
|
6719
6969
|
__classPrivateFieldGet(this, _IdleTimer_clearTimeout, "f").call(this);
|
|
6970
|
+
|
|
6720
6971
|
__classPrivateFieldSet(this, _IdleTimer_timer, setTimeout(() => {
|
|
6721
6972
|
__classPrivateFieldGet(this, _IdleTimer_clearTimeout, "f").call(this);
|
|
6973
|
+
|
|
6722
6974
|
__classPrivateFieldGet(this, _IdleTimer_cleanUpTracker, "f").call(this);
|
|
6975
|
+
|
|
6723
6976
|
__classPrivateFieldGet(this, _IdleTimer_onTimeout, "f").call(this);
|
|
6724
6977
|
}, __classPrivateFieldGet(this, _IdleTimer_timeoutInMinutes, "f") * 60 * 1000), "f");
|
|
6725
6978
|
});
|
|
6979
|
+
|
|
6726
6980
|
const {
|
|
6727
6981
|
timeoutInMinutes,
|
|
6728
6982
|
onTimeout: onTimeout
|
|
6729
6983
|
} = params;
|
|
6984
|
+
|
|
6730
6985
|
__classPrivateFieldSet(this, _IdleTimer_timeoutInMinutes, timeoutInMinutes, "f");
|
|
6986
|
+
|
|
6731
6987
|
__classPrivateFieldSet(this, _IdleTimer_onTimeout, onTimeout, "f");
|
|
6732
6988
|
}
|
|
6989
|
+
|
|
6733
6990
|
}
|
|
6734
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();
|
|
6735
6992
|
|
|
6736
6993
|
let auth;
|
|
6994
|
+
|
|
6737
6995
|
const init = options => __awaiter(void 0, void 0, void 0, function* () {
|
|
6738
6996
|
auth = new Authentication(options);
|
|
6997
|
+
|
|
6739
6998
|
if (!auth) {
|
|
6740
6999
|
return false;
|
|
6741
7000
|
}
|
|
7001
|
+
|
|
6742
7002
|
const autoLogout = auth.autoLogout();
|
|
7003
|
+
|
|
6743
7004
|
if (autoLogout) {
|
|
6744
7005
|
const timeoutInMinutes = auth.idleTimeoutInMinutes();
|
|
6745
7006
|
const idleTimer = new IdleTimer({
|
|
@@ -6748,40 +7009,55 @@
|
|
|
6748
7009
|
});
|
|
6749
7010
|
idleTimer.tracker();
|
|
6750
7011
|
}
|
|
7012
|
+
|
|
6751
7013
|
const done = yield auth.checkAuthCode();
|
|
7014
|
+
|
|
6752
7015
|
if (done) {
|
|
6753
7016
|
return auth.afterAuthenticated();
|
|
6754
7017
|
}
|
|
7018
|
+
|
|
6755
7019
|
const hasAuthSession = yield verifySession();
|
|
7020
|
+
|
|
6756
7021
|
if (hasAuthSession) {
|
|
6757
7022
|
return auth.afterAuthenticated();
|
|
6758
7023
|
}
|
|
7024
|
+
|
|
6759
7025
|
const passthrough = auth.checkTokenInUrl() || auth.checkTokenInInit();
|
|
7026
|
+
|
|
6760
7027
|
if (passthrough) {
|
|
6761
7028
|
return false;
|
|
6762
7029
|
}
|
|
7030
|
+
|
|
6763
7031
|
const autoLogin = auth.autoLogin();
|
|
7032
|
+
|
|
6764
7033
|
if (autoLogin) {
|
|
6765
7034
|
yield login();
|
|
6766
7035
|
}
|
|
7036
|
+
|
|
6767
7037
|
return true;
|
|
6768
7038
|
});
|
|
7039
|
+
|
|
6769
7040
|
const verifySession = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
6770
7041
|
if (!auth) {
|
|
6771
7042
|
throw Error('Not init yet');
|
|
6772
7043
|
}
|
|
7044
|
+
|
|
6773
7045
|
return yield auth.verifySession();
|
|
6774
7046
|
});
|
|
7047
|
+
|
|
6775
7048
|
const getAccessToken = () => {
|
|
6776
7049
|
return !auth ? '' : auth.getAccessToken();
|
|
6777
7050
|
};
|
|
7051
|
+
|
|
6778
7052
|
const getRefreshedAccessToken = force => __awaiter(void 0, void 0, void 0, function* () {
|
|
6779
7053
|
return !auth ? '' : yield auth.getRefreshedAccessToken(force);
|
|
6780
7054
|
});
|
|
7055
|
+
|
|
6781
7056
|
const login = (params = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
6782
7057
|
if (!auth) {
|
|
6783
7058
|
throw Error('Not init yet');
|
|
6784
7059
|
}
|
|
7060
|
+
|
|
6785
7061
|
const {
|
|
6786
7062
|
force_2fa,
|
|
6787
7063
|
popup
|
|
@@ -6794,87 +7070,109 @@
|
|
|
6794
7070
|
return token && auth ? auth.afterAuthenticated() : undefined;
|
|
6795
7071
|
});
|
|
6796
7072
|
});
|
|
7073
|
+
|
|
6797
7074
|
const logout = (force = false, redirectUrl) => __awaiter(void 0, void 0, void 0, function* () {
|
|
6798
7075
|
if (!auth) {
|
|
6799
7076
|
throw Error('Not init yet');
|
|
6800
7077
|
}
|
|
7078
|
+
|
|
6801
7079
|
return auth.triggerHooks(HookName.beforeLogout).then(() => {
|
|
6802
7080
|
if (auth) {
|
|
6803
7081
|
auth.destroyNotification();
|
|
6804
7082
|
auth.logout(force, redirectUrl);
|
|
6805
7083
|
}
|
|
7084
|
+
|
|
6806
7085
|
return;
|
|
6807
7086
|
}).catch(function (err) {
|
|
6808
7087
|
console.error('Error while logging out : ', err);
|
|
6809
7088
|
throw Error(err);
|
|
6810
7089
|
});
|
|
6811
7090
|
});
|
|
7091
|
+
|
|
6812
7092
|
const registerHook = (hookName, callback) => {
|
|
6813
7093
|
if (!auth) {
|
|
6814
7094
|
throw Error('Not init yet');
|
|
6815
7095
|
}
|
|
7096
|
+
|
|
6816
7097
|
if (auth) {
|
|
6817
7098
|
auth.setHook({
|
|
6818
7099
|
name: hookName,
|
|
6819
7100
|
callback
|
|
6820
7101
|
});
|
|
6821
7102
|
}
|
|
7103
|
+
|
|
6822
7104
|
return;
|
|
6823
7105
|
};
|
|
7106
|
+
|
|
6824
7107
|
const getDecodedAccessToken = () => {
|
|
6825
7108
|
if (!auth) {
|
|
6826
7109
|
throw Error('Not init yet');
|
|
6827
7110
|
}
|
|
7111
|
+
|
|
6828
7112
|
return auth.getDecodedAccessToken();
|
|
6829
7113
|
};
|
|
7114
|
+
|
|
6830
7115
|
const getDecodedRefreshedAccessToken = force => __awaiter(void 0, void 0, void 0, function* () {
|
|
6831
7116
|
if (!auth) {
|
|
6832
7117
|
throw Error('Not init yet');
|
|
6833
7118
|
}
|
|
7119
|
+
|
|
6834
7120
|
return yield auth.getDecodedRefreshedAccessToken(force);
|
|
6835
7121
|
});
|
|
7122
|
+
|
|
6836
7123
|
const userInfo = () => {
|
|
6837
7124
|
if (!auth) {
|
|
6838
7125
|
throw Error('Not init yet');
|
|
6839
7126
|
}
|
|
7127
|
+
|
|
6840
7128
|
return auth.getUserInfo();
|
|
6841
7129
|
};
|
|
7130
|
+
|
|
6842
7131
|
const linkUser = (redirectUrl, newWindow, callback) => __awaiter(void 0, void 0, void 0, function* () {
|
|
6843
7132
|
if (!auth) {
|
|
6844
7133
|
throw Error('Not init yet');
|
|
6845
7134
|
}
|
|
7135
|
+
|
|
6846
7136
|
yield auth.linkUser({
|
|
6847
7137
|
redirectUrl,
|
|
6848
7138
|
newWindow,
|
|
6849
7139
|
callback
|
|
6850
7140
|
});
|
|
6851
7141
|
});
|
|
7142
|
+
|
|
6852
7143
|
const unlinkUser = (redirectUrl, newWindow, callback) => __awaiter(void 0, void 0, void 0, function* () {
|
|
6853
7144
|
if (!auth) {
|
|
6854
7145
|
throw Error('Not init yet');
|
|
6855
7146
|
}
|
|
7147
|
+
|
|
6856
7148
|
yield auth.unlinkUser({
|
|
6857
7149
|
redirectUrl,
|
|
6858
7150
|
newWindow,
|
|
6859
7151
|
callback
|
|
6860
7152
|
});
|
|
6861
7153
|
});
|
|
7154
|
+
|
|
6862
7155
|
const getCloudProviderToken = jti => {
|
|
6863
7156
|
if (!auth) {
|
|
6864
7157
|
throw Error('Not init yet');
|
|
6865
7158
|
}
|
|
7159
|
+
|
|
6866
7160
|
return auth.getCloudProviderToken(jti);
|
|
6867
7161
|
};
|
|
7162
|
+
|
|
6868
7163
|
const cloudProviderUserInfo = () => {
|
|
6869
7164
|
if (!auth) {
|
|
6870
7165
|
throw Error('Not init yet');
|
|
6871
7166
|
}
|
|
7167
|
+
|
|
6872
7168
|
return auth.cloudProviderUserInfo();
|
|
6873
7169
|
};
|
|
7170
|
+
|
|
6874
7171
|
const cloudProviderReauthenticate = (nonce, redirectUrl, newWindow, callback) => {
|
|
6875
7172
|
if (!auth) {
|
|
6876
7173
|
throw Error('Not init yet');
|
|
6877
7174
|
}
|
|
7175
|
+
|
|
6878
7176
|
return auth.cloudProviderReauthenticate({
|
|
6879
7177
|
redirectUrl,
|
|
6880
7178
|
nonce,
|
|
@@ -6882,25 +7180,32 @@
|
|
|
6882
7180
|
callback
|
|
6883
7181
|
});
|
|
6884
7182
|
};
|
|
7183
|
+
|
|
6885
7184
|
const cloudProviderUpdate = cloudProviderId => {
|
|
6886
7185
|
if (!auth) {
|
|
6887
7186
|
throw Error('Not init yet');
|
|
6888
7187
|
}
|
|
7188
|
+
|
|
6889
7189
|
if (!cloudProviderId) {
|
|
6890
7190
|
throw Error('cloudProviderId is required');
|
|
6891
7191
|
}
|
|
7192
|
+
|
|
6892
7193
|
return auth.cloudProviderUpdate(cloudProviderId);
|
|
6893
7194
|
};
|
|
7195
|
+
|
|
6894
7196
|
const statusAdminConsent = () => {
|
|
6895
7197
|
if (!auth) {
|
|
6896
7198
|
throw Error('Not init yet');
|
|
6897
7199
|
}
|
|
7200
|
+
|
|
6898
7201
|
return auth.statusAdminConsent();
|
|
6899
7202
|
};
|
|
7203
|
+
|
|
6900
7204
|
const getAdminConsent = (domain, redirectUrl, newWindow, callback) => {
|
|
6901
7205
|
if (!auth) {
|
|
6902
7206
|
throw Error('Not init yet');
|
|
6903
7207
|
}
|
|
7208
|
+
|
|
6904
7209
|
auth.getAdminConsent({
|
|
6905
7210
|
domain,
|
|
6906
7211
|
redirectUrl,
|
|
@@ -6908,63 +7213,78 @@
|
|
|
6908
7213
|
callback
|
|
6909
7214
|
});
|
|
6910
7215
|
};
|
|
7216
|
+
|
|
6911
7217
|
const revokeAdminConsent = () => {
|
|
6912
7218
|
if (!auth) {
|
|
6913
7219
|
throw Error('Not init yet');
|
|
6914
7220
|
}
|
|
7221
|
+
|
|
6915
7222
|
return auth.revokeAdminConsent();
|
|
6916
7223
|
};
|
|
7224
|
+
|
|
6917
7225
|
const getLinkMap = allUsers => {
|
|
6918
7226
|
if (!auth) {
|
|
6919
7227
|
throw Error('Not init yet');
|
|
6920
7228
|
}
|
|
7229
|
+
|
|
6921
7230
|
return auth.getLinkMap(allUsers);
|
|
6922
7231
|
};
|
|
7232
|
+
|
|
6923
7233
|
const setLinkMap = linkMap => {
|
|
6924
7234
|
if (!auth) {
|
|
6925
7235
|
throw Error('Not init yet');
|
|
6926
7236
|
}
|
|
7237
|
+
|
|
6927
7238
|
return auth.setLinkMap(linkMap);
|
|
6928
7239
|
};
|
|
7240
|
+
|
|
6929
7241
|
const authoriseSupport = (code, duration) => {
|
|
6930
7242
|
if (!auth) {
|
|
6931
7243
|
throw Error('Not init yet');
|
|
6932
7244
|
}
|
|
7245
|
+
|
|
6933
7246
|
return auth.authoriseSupport({
|
|
6934
7247
|
code,
|
|
6935
7248
|
duration
|
|
6936
7249
|
});
|
|
6937
7250
|
};
|
|
7251
|
+
|
|
6938
7252
|
const changePassword = (redirectUrl, newWindow, callback) => {
|
|
6939
7253
|
if (!auth) {
|
|
6940
7254
|
throw Error('Not init yet');
|
|
6941
7255
|
}
|
|
7256
|
+
|
|
6942
7257
|
auth.changePassword({
|
|
6943
7258
|
redirectUrl,
|
|
6944
7259
|
newWindow,
|
|
6945
7260
|
callback
|
|
6946
7261
|
});
|
|
6947
7262
|
};
|
|
7263
|
+
|
|
6948
7264
|
const registerEventListener = (topic, messageType, callback) => {
|
|
6949
7265
|
if (!auth) {
|
|
6950
7266
|
throw Error('Not init yet');
|
|
6951
7267
|
}
|
|
7268
|
+
|
|
6952
7269
|
auth.registerEventListenerForUserChannel({
|
|
6953
7270
|
topic,
|
|
6954
7271
|
messageType,
|
|
6955
7272
|
callback
|
|
6956
7273
|
});
|
|
6957
7274
|
};
|
|
7275
|
+
|
|
6958
7276
|
const passthrough = (url, newWindow = false, authHost) => __awaiter(void 0, void 0, void 0, function* () {
|
|
6959
7277
|
if (!auth) {
|
|
6960
7278
|
throw Error('Not init yet');
|
|
6961
7279
|
}
|
|
7280
|
+
|
|
6962
7281
|
yield auth.passthrough({
|
|
6963
7282
|
url,
|
|
6964
7283
|
newWindow,
|
|
6965
7284
|
authHost
|
|
6966
7285
|
});
|
|
6967
7286
|
});
|
|
7287
|
+
|
|
6968
7288
|
const AuthAgent = {
|
|
6969
7289
|
init,
|
|
6970
7290
|
registerHook,
|