@leapdev/auth-agent 2.0.7-beta.1 → 2.0.7-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/index.umd.js CHANGED
@@ -1,7 +1,12 @@
1
- (function (factory) {
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('lodash'), require('uuid'), require('pubnub')) :
2
3
  typeof define === 'function' && define.amd ? define(['lodash', 'uuid', 'pubnub'], factory) :
3
- factory();
4
- })((function () { 'use strict';
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.AuthAgent = factory(global.lodash, global.uuid, global.Pubnub));
5
+ })(this, (function (lodash, uuid, Pubnub) { 'use strict';
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
+
9
+ var Pubnub__default = /*#__PURE__*/_interopDefaultLegacy(Pubnub);
5
10
 
6
11
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
7
12
 
@@ -587,9 +592,9 @@
587
592
  var isCallable$i = isCallable$p;
588
593
  var inspectSource$3 = inspectSource$4;
589
594
 
590
- var WeakMap$1 = global$E.WeakMap;
595
+ var WeakMap$2 = global$E.WeakMap;
591
596
 
592
- var nativeWeakMap = isCallable$i(WeakMap$1) && /native code/.test(inspectSource$3(WeakMap$1));
597
+ var nativeWeakMap = isCallable$i(WeakMap$2) && /native code/.test(inspectSource$3(WeakMap$2));
593
598
 
594
599
  var shared$2 = shared$4.exports;
595
600
  var uid$1 = uid$3;
@@ -614,7 +619,7 @@
614
619
 
615
620
  var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
616
621
  var TypeError$c = global$D.TypeError;
617
- var WeakMap = global$D.WeakMap;
622
+ var WeakMap$1 = global$D.WeakMap;
618
623
  var set$2, get$1, has;
619
624
 
620
625
  var enforce = function (it) {
@@ -631,7 +636,7 @@
631
636
  };
632
637
 
633
638
  if (NATIVE_WEAK_MAP || shared$1.state) {
634
- var store = shared$1.state || (shared$1.state = new WeakMap());
639
+ var store = shared$1.state || (shared$1.state = new WeakMap$1());
635
640
  var wmget = uncurryThis$k(store.get);
636
641
  var wmhas = uncurryThis$k(store.has);
637
642
  var wmset = uncurryThis$k(store.set);
@@ -2162,6 +2167,44 @@
2162
2167
  }
2163
2168
  });
2164
2169
 
2170
+ /******************************************************************************
2171
+ Copyright (c) Microsoft Corporation.
2172
+
2173
+ Permission to use, copy, modify, and/or distribute this software for any
2174
+ purpose with or without fee is hereby granted.
2175
+
2176
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
2177
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
2178
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
2179
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
2180
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
2181
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2182
+ PERFORMANCE OF THIS SOFTWARE.
2183
+ ***************************************************************************** */
2184
+
2185
+ function __awaiter(thisArg, _arguments, P, generator) {
2186
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
2187
+ return new (P || (P = Promise))(function (resolve, reject) {
2188
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
2189
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
2190
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
2191
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
2192
+ });
2193
+ }
2194
+
2195
+ function __classPrivateFieldGet(receiver, state, kind, f) {
2196
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
2197
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
2198
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2199
+ }
2200
+
2201
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
2202
+ if (kind === "m") throw new TypeError("Private method is not writable");
2203
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
2204
+ 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");
2205
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
2206
+ }
2207
+
2165
2208
  var internalObjectKeys = objectKeysInternal;
2166
2209
  var enumBugKeys$1 = enumBugKeys$3;
2167
2210
 
@@ -3216,7 +3259,7 @@
3216
3259
  var RegExp$1 = global$e.RegExp;
3217
3260
  var TypeError$3 = global$e.TypeError;
3218
3261
  var decodeURIComponent = global$e.decodeURIComponent;
3219
- var encodeURIComponent = global$e.encodeURIComponent;
3262
+ var encodeURIComponent$1 = global$e.encodeURIComponent;
3220
3263
  var charAt$3 = uncurryThis$a(''.charAt);
3221
3264
  var join = uncurryThis$a([].join);
3222
3265
  var push$3 = uncurryThis$a([].push);
@@ -3270,7 +3313,7 @@
3270
3313
  };
3271
3314
 
3272
3315
  var serialize = function (it) {
3273
- return replace$1(encodeURIComponent(it), find, replacer);
3316
+ return replace$1(encodeURIComponent$1(it), find, replacer);
3274
3317
  };
3275
3318
 
3276
3319
  var URLSearchParamsIterator = createIteratorConstructor(function Iterator(params, kind) {
@@ -3803,6 +3846,602 @@
3803
3846
  ];
3804
3847
  }, !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC, UNSUPPORTED_Y);
3805
3848
 
3849
+ const DEFAULT_CONFIG = {
3850
+ autoLogin: true,
3851
+ autoLogout: true,
3852
+ autoRefreshToken: false,
3853
+ idleTimeoutInMinutes: 30,
3854
+ uniqueSession: true,
3855
+ hooks: {}
3856
+ };
3857
+ const requiredParams = ['authHost', 'clientId', 'scopes'];
3858
+ const init$1 = options => {
3859
+ lodash.forEach(requiredParams, p => {
3860
+ if (!lodash.has(options, p)) {
3861
+ throw Error('Missing config parameter : ' + p);
3862
+ }
3863
+ });
3864
+
3865
+ if (!lodash.isArray(options.scopes)) {
3866
+ throw Error('Scopes must be an array with string values');
3867
+ }
3868
+
3869
+ const config = Object.assign(Object.assign({}, DEFAULT_CONFIG), options);
3870
+ return config;
3871
+ };
3872
+
3873
+ var _LeapAuthService_authHost, _LeapAuthService_clientId, _LeapAuthService_xhr, _LeapAuthService_redirectUrl;
3874
+ const LEAP_AUTH_CLOSE_WINDOW_URL = '/oauth/close';
3875
+ class LeapAuthService {
3876
+ constructor(authHost, clientId) {
3877
+ _LeapAuthService_authHost.set(this, void 0);
3878
+
3879
+ _LeapAuthService_clientId.set(this, void 0);
3880
+
3881
+ this.getRedirections = () => {
3882
+ //* local development
3883
+ //return import('../../config/redirections_v2.json');
3884
+ return new Promise((resolve, reject) => {
3885
+ __classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
3886
+ method: 'GET',
3887
+ endpoint: 'https://cdn.leap.com.au/leap_auth/auth_agent/redirections_v2.json',
3888
+ options: null,
3889
+ accessToken: undefined
3890
+ }, (response, status) => {
3891
+ if (status === 200) return resolve(response);else return reject(response);
3892
+ });
3893
+ });
3894
+ };
3895
+
3896
+ this.exchangeAuthCodeForAccessToken = params => {
3897
+ return new Promise((resolve, reject) => {
3898
+ __classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
3899
+ method: 'POST',
3900
+ endpoint: `${__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/oauth/token`,
3901
+ options: {
3902
+ body: {
3903
+ grant_type: 'authorization_code',
3904
+ code: params.code,
3905
+ code_verifier: params.verifier,
3906
+ client_id: __classPrivateFieldGet(this, _LeapAuthService_clientId, "f"),
3907
+ redirect_uri: params.redirectUri
3908
+ }
3909
+ },
3910
+ accessToken: undefined
3911
+ }, (response, status) => {
3912
+ if (status === 200) return resolve(response);else return reject(response);
3913
+ });
3914
+ });
3915
+ };
3916
+
3917
+ this.renewAccessToken = params => {
3918
+ return new Promise((resolve, reject) => {
3919
+ __classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
3920
+ method: 'POST',
3921
+ endpoint: `${__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/oauth/token`,
3922
+ options: {
3923
+ body: {
3924
+ grant_type: 'refresh_token',
3925
+ refresh_token: params.refreshToken,
3926
+ code_verifier: params.verifier,
3927
+ client_id: __classPrivateFieldGet(this, _LeapAuthService_clientId, "f")
3928
+ }
3929
+ },
3930
+ accessToken: undefined
3931
+ }, (response, status) => {
3932
+ if (status === 200) return resolve(response);else return reject(response);
3933
+ });
3934
+ });
3935
+ };
3936
+
3937
+ this.userInfo = token => {
3938
+ return new Promise((resolve, reject) => {
3939
+ __classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
3940
+ method: 'GET',
3941
+ endpoint: `${__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/api/userinfo`,
3942
+ options: null,
3943
+ accessToken: token
3944
+ }, (response, status) => {
3945
+ if (status === 200) return resolve(response);else return reject(response);
3946
+ });
3947
+ });
3948
+ };
3949
+
3950
+ this.linkUser = params => {
3951
+ const {
3952
+ jti,
3953
+ newWindow,
3954
+ callback
3955
+ } = params;
3956
+ const redirectUrl = newWindow ? __classPrivateFieldGet(this, _LeapAuthService_authHost, "f") + LEAP_AUTH_CLOSE_WINDOW_URL : params.redirectUrl;
3957
+ const requestUrl = `/cloudprovider/link?client_id=${__classPrivateFieldGet(this, _LeapAuthService_clientId, "f")}&prompt=none&jti=${jti}&callback=${redirectUrl}`;
3958
+
3959
+ __classPrivateFieldGet(this, _LeapAuthService_redirectUrl, "f").call(this, {
3960
+ requestUrl,
3961
+ newWindow,
3962
+ callback
3963
+ });
3964
+ };
3965
+
3966
+ this.unlinkUser = params => {
3967
+ const {
3968
+ jti,
3969
+ newWindow,
3970
+ callback
3971
+ } = params;
3972
+ const redirectUrl = newWindow ? __classPrivateFieldGet(this, _LeapAuthService_authHost, "f") + LEAP_AUTH_CLOSE_WINDOW_URL : params.redirectUrl;
3973
+ const requestUrl = `/cloudprovider/unlink?client_id=${__classPrivateFieldGet(this, _LeapAuthService_clientId, "f")}&jti=${jti}&callback=${redirectUrl}`;
3974
+
3975
+ __classPrivateFieldGet(this, _LeapAuthService_redirectUrl, "f").call(this, {
3976
+ requestUrl,
3977
+ newWindow,
3978
+ callback
3979
+ });
3980
+ };
3981
+
3982
+ this.getCloudProviderToken = (token, jti) => {
3983
+ const url = `${__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/cloudprovider/accesstoken` + (jti ? '/' + jti : '');
3984
+ return new Promise((resolve, reject) => {
3985
+ __classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
3986
+ method: 'GET',
3987
+ endpoint: url,
3988
+ options: null,
3989
+ accessToken: token
3990
+ }, (response, status) => {
3991
+ if (status === 200) return resolve(response);else return reject(response);
3992
+ });
3993
+ });
3994
+ };
3995
+
3996
+ this.cloudProviderUserInfo = token => {
3997
+ return new Promise((resolve, reject) => {
3998
+ __classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
3999
+ method: 'GET',
4000
+ endpoint: `${__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/cloudprovider/userinfo`,
4001
+ options: null,
4002
+ accessToken: token
4003
+ }, (response, status) => {
4004
+ if (status === 200) return resolve(response);else return reject(response);
4005
+ });
4006
+ });
4007
+ };
4008
+
4009
+ this.cloudProviderReauthenticate = params => {
4010
+ const {
4011
+ nonce,
4012
+ newWindow,
4013
+ callback
4014
+ } = params;
4015
+ const redirectUrl = newWindow ? __classPrivateFieldGet(this, _LeapAuthService_authHost, "f") + LEAP_AUTH_CLOSE_WINDOW_URL : params.redirectUrl;
4016
+ const requestUrl = `/cloudprovider/reauthenticate?nonce=${nonce}&redirectUrl=${redirectUrl}`;
4017
+
4018
+ __classPrivateFieldGet(this, _LeapAuthService_redirectUrl, "f").call(this, {
4019
+ requestUrl,
4020
+ newWindow,
4021
+ callback
4022
+ });
4023
+ };
4024
+
4025
+ this.cloudProviderReauthenticateLink = token => {
4026
+ return new Promise((resolve, reject) => {
4027
+ __classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
4028
+ method: 'GET',
4029
+ endpoint: `${__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/cloudprovider/reauthenticate/link`,
4030
+ options: null,
4031
+ accessToken: token
4032
+ }, (response, status) => {
4033
+ if (status === 200) return resolve(response);else return reject(response);
4034
+ });
4035
+ });
4036
+ };
4037
+
4038
+ this.statusAdminConsent = token => {
4039
+ return new Promise((resolve, reject) => {
4040
+ __classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
4041
+ method: 'GET',
4042
+ endpoint: `${__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/cloudprovider/adminconsent/status?client_id=${__classPrivateFieldGet(this, _LeapAuthService_clientId, "f")}`,
4043
+ options: null,
4044
+ accessToken: token
4045
+ }, (response, status) => {
4046
+ if (status === 200) return resolve(response);else return reject(response);
4047
+ });
4048
+ });
4049
+ };
4050
+
4051
+ this.getAdminConsent = params => {
4052
+ const {
4053
+ domain,
4054
+ newWindow,
4055
+ callback
4056
+ } = params;
4057
+ const redirectUrl = newWindow ? __classPrivateFieldGet(this, _LeapAuthService_authHost, "f") + LEAP_AUTH_CLOSE_WINDOW_URL : params.redirectUrl;
4058
+ const requestUrl = `/cloudprovider/adminconsent?client_id=${__classPrivateFieldGet(this, _LeapAuthService_clientId, "f")}&redirectUrl=${redirectUrl}${domain ? '&domain=' + domain : ''}`;
4059
+
4060
+ __classPrivateFieldGet(this, _LeapAuthService_redirectUrl, "f").call(this, {
4061
+ requestUrl,
4062
+ newWindow,
4063
+ callback
4064
+ });
4065
+ };
4066
+
4067
+ this.revokeAdminConsent = token => {
4068
+ return new Promise((resolve, reject) => {
4069
+ __classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
4070
+ method: 'DELETE',
4071
+ endpoint: `${__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/cloudprovider/adminconsent?client_id=${__classPrivateFieldGet(this, _LeapAuthService_clientId, "f")}`,
4072
+ options: null,
4073
+ accessToken: token
4074
+ }, (response, status) => {
4075
+ if (status === 200) return resolve(response);else return reject(response);
4076
+ });
4077
+ });
4078
+ };
4079
+
4080
+ this.getLinkMap = (token, allUsers) => {
4081
+ return new Promise((resolve, reject) => {
4082
+ __classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
4083
+ method: 'GET',
4084
+ endpoint: `${__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/cloudprovider/linkmap?client_id=${__classPrivateFieldGet(this, _LeapAuthService_clientId, "f")}${allUsers ? '&allUsers=true' : ''}`,
4085
+ options: null,
4086
+ accessToken: token
4087
+ }, (response, status) => {
4088
+ if (status === 200) return resolve(response);else return reject(response);
4089
+ });
4090
+ });
4091
+ };
4092
+
4093
+ this.setLinkMap = (token, linkMap) => {
4094
+ return new Promise((resolve, reject) => {
4095
+ __classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
4096
+ method: 'PUT',
4097
+ endpoint: `${__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/cloudprovider/linkmap?client_id=${__classPrivateFieldGet(this, _LeapAuthService_clientId, "f")}`,
4098
+ options: {
4099
+ body: linkMap
4100
+ },
4101
+ accessToken: token
4102
+ }, (response, status) => {
4103
+ if (status === 200) return resolve(response);else return reject(response);
4104
+ });
4105
+ });
4106
+ };
4107
+
4108
+ this.authoriseSupport = (token, params) => {
4109
+ const {
4110
+ code,
4111
+ duration
4112
+ } = params;
4113
+ return new Promise((resolve, reject) => {
4114
+ __classPrivateFieldGet(this, _LeapAuthService_xhr, "f").call(this, {
4115
+ method: 'POST',
4116
+ endpoint: `${__classPrivateFieldGet(this, _LeapAuthService_authHost, "f")}/support/authorization`,
4117
+ options: {
4118
+ body: {
4119
+ requestCode: code,
4120
+ duration,
4121
+ client_id: __classPrivateFieldGet(this, _LeapAuthService_clientId, "f")
4122
+ }
4123
+ },
4124
+ accessToken: token
4125
+ }, (response, status) => {
4126
+ if (status === 200) return resolve(response);else return reject(response);
4127
+ });
4128
+ });
4129
+ };
4130
+
4131
+ this.changePassword = params => {
4132
+ const {
4133
+ newWindow,
4134
+ callback,
4135
+ redirectUrl
4136
+ } = params;
4137
+ let changePasswordUrl = `/oauth/changepassword?client_id=${__classPrivateFieldGet(this, _LeapAuthService_clientId, "f")}`;
4138
+ let redirect_uri = '';
4139
+ let noListener = false;
4140
+
4141
+ if (newWindow) {
4142
+ if (!!callback && typeof callback === 'function') {
4143
+ redirect_uri = __classPrivateFieldGet(this, _LeapAuthService_authHost, "f") + LEAP_AUTH_CLOSE_WINDOW_URL;
4144
+ } else {
4145
+ redirect_uri = '';
4146
+ noListener = true; // open a new tab for changing password without adding an message event listener in this window
4147
+ }
4148
+ } else {
4149
+ redirect_uri = __classPrivateFieldGet(this, _LeapAuthService_authHost, "f") + '/oauth/logout?force=true' + '&redirect_uri=' + (redirectUrl || window.location.href);
4150
+ }
4151
+
4152
+ if (redirect_uri) {
4153
+ changePasswordUrl += `&redirect_uri=${encodeURIComponent(redirect_uri)}`;
4154
+ }
4155
+
4156
+ __classPrivateFieldGet(this, _LeapAuthService_redirectUrl, "f").call(this, {
4157
+ requestUrl: changePasswordUrl,
4158
+ newWindow,
4159
+ callback,
4160
+ noListener
4161
+ });
4162
+ };
4163
+
4164
+ _LeapAuthService_xhr.set(this, (params, onload) => {
4165
+ const {
4166
+ method,
4167
+ endpoint,
4168
+ accessToken
4169
+ } = params;
4170
+ let {
4171
+ options
4172
+ } = params;
4173
+ options = lodash.merge({}, {
4174
+ contentType: 'application/json',
4175
+ accessControlAllowOrigin: '*',
4176
+ body: undefined
4177
+ }, options || {});
4178
+ const xhr = new XMLHttpRequest();
4179
+ xhr.open(method, endpoint, true);
4180
+ xhr.setRequestHeader('Content-type', options.contentType);
4181
+ xhr.setRequestHeader('Access-Control-Allow-Origin', options.accessControlAllowOrigin);
4182
+ if (accessToken) xhr.setRequestHeader('Authorization', 'Bearer ' + accessToken);
4183
+
4184
+ xhr.onload = () => {
4185
+ try {
4186
+ let resp;
4187
+ if (xhr.response) resp = JSON.parse(xhr.response);
4188
+ onload(resp, xhr.status);
4189
+ } catch (e) {
4190
+ onload(xhr.response, xhr.status);
4191
+ }
4192
+ };
4193
+
4194
+ if (options.body) options.body = JSON.stringify(options.body);
4195
+ xhr.send(options.body);
4196
+ });
4197
+
4198
+ _LeapAuthService_redirectUrl.set(this, params => {
4199
+ const {
4200
+ requestUrl,
4201
+ newWindow,
4202
+ callback,
4203
+ noListener
4204
+ } = params;
4205
+ const fullUrl = __classPrivateFieldGet(this, _LeapAuthService_authHost, "f") + requestUrl;
4206
+
4207
+ if (newWindow) {
4208
+ const childWindow = window.open(fullUrl, '_blank');
4209
+
4210
+ const eventHandler = event => {
4211
+ if (event && event.data === 'closeMe' && childWindow) {
4212
+ childWindow.close();
4213
+
4214
+ if (lodash.isFunction(callback)) {
4215
+ callback();
4216
+ window.removeEventListener('message', eventHandler, false);
4217
+ }
4218
+ }
4219
+ };
4220
+
4221
+ if (!noListener) {
4222
+ window.addEventListener('message', eventHandler, false);
4223
+ }
4224
+ } else {
4225
+ window.location.href = fullUrl;
4226
+ }
4227
+ });
4228
+
4229
+ __classPrivateFieldSet(this, _LeapAuthService_authHost, authHost, "f");
4230
+
4231
+ __classPrivateFieldSet(this, _LeapAuthService_clientId, clientId, "f");
4232
+ }
4233
+
4234
+ }
4235
+ _LeapAuthService_authHost = new WeakMap(), _LeapAuthService_clientId = new WeakMap(), _LeapAuthService_xhr = new WeakMap(), _LeapAuthService_redirectUrl = new WeakMap();
4236
+
4237
+ var _Notification_pubnubKeys, _Notification_pubnub, _Notification_eventListeners, _Notification_initFirmChannel, _Notification_initUserChannel, _Notification_initUniqueSessionChannel;
4238
+ const EMPTY_GUID = '00000000-0000-0000-0000-000000000000';
4239
+ const USER_ACTION = {
4240
+ USERNAME_CHANGED: '1',
4241
+ PASSWORD_CHANGED: '2',
4242
+ USER_DISABLED: '3' // 3 - User has been disabled
4243
+
4244
+ };
4245
+ class Notification {
4246
+ constructor() {
4247
+ _Notification_pubnubKeys.set(this, void 0);
4248
+
4249
+ _Notification_pubnub.set(this, void 0);
4250
+
4251
+ _Notification_eventListeners.set(this, []);
4252
+
4253
+ this.init = params => {
4254
+ const {
4255
+ authHost,
4256
+ clientId,
4257
+ firmId,
4258
+ userId,
4259
+ uniqueSession
4260
+ } = params;
4261
+
4262
+ __classPrivateFieldGet(this, _Notification_initFirmChannel, "f").call(this, firmId, userId);
4263
+
4264
+ __classPrivateFieldGet(this, _Notification_initUserChannel, "f").call(this, userId);
4265
+
4266
+ if (uniqueSession) {
4267
+ __classPrivateFieldGet(this, _Notification_initUniqueSessionChannel, "f").call(this, {
4268
+ authHost,
4269
+ clientId
4270
+ });
4271
+ }
4272
+ };
4273
+
4274
+ this.destroy = () => {
4275
+ if (__classPrivateFieldGet(this, _Notification_pubnub, "f")) {
4276
+ __classPrivateFieldGet(this, _Notification_pubnub, "f").unsubscribeAll();
4277
+
4278
+ __classPrivateFieldSet(this, _Notification_eventListeners, [], "f");
4279
+ }
4280
+ };
4281
+
4282
+ this.registerEventListenerForUserChannel = params => {
4283
+ const {
4284
+ topic,
4285
+ messageType,
4286
+ callback
4287
+ } = params;
4288
+
4289
+ if (!lodash.isFunction(callback)) {
4290
+ throw Error(`Registering Event Listener ${topic} ${messageType}: callback needs to be a function`);
4291
+ }
4292
+
4293
+ __classPrivateFieldGet(this, _Notification_eventListeners, "f").push({
4294
+ topic,
4295
+ messageType,
4296
+ callback
4297
+ });
4298
+ };
4299
+
4300
+ _Notification_initFirmChannel.set(this, (firmId, userId) => {
4301
+ __classPrivateFieldGet(this, _Notification_pubnub, "f").addListener({
4302
+ presence: presenceEvent => {
4303
+ //* handle presence
4304
+ const {
4305
+ action,
4306
+ uuid
4307
+ } = presenceEvent; //* the message was sent from the current pubnub instance
4308
+
4309
+ if (uuid === __classPrivateFieldGet(this, _Notification_pubnubKeys, "f").uuid) {
4310
+ return;
4311
+ } //* handle action 'leave' and 'timeout'
4312
+
4313
+
4314
+ if (action === 'leave' || action === 'timeout') {
4315
+ const valuesUUID = uuid.split('~');
4316
+ const userIdFromPresence = valuesUUID[0] || '';
4317
+ const instanceGuidFromPresence = valuesUUID[1] || '';
4318
+ const userActionFromPresence = valuesUUID[2] || '';
4319
+ const isUserActionRequiredLogout = userActionFromPresence === USER_ACTION.USERNAME_CHANGED || userActionFromPresence === USER_ACTION.PASSWORD_CHANGED || userActionFromPresence === USER_ACTION.USER_DISABLED;
4320
+
4321
+ if (userIdFromPresence === userId && instanceGuidFromPresence === EMPTY_GUID && isUserActionRequiredLogout) {
4322
+ //* User Information has been changed, force user to logout
4323
+ AuthAgent.logout(true); // call logout with force=true (because the logout is forced)
4324
+ }
4325
+ }
4326
+ }
4327
+ });
4328
+
4329
+ __classPrivateFieldGet(this, _Notification_pubnub, "f").subscribe({
4330
+ channels: [firmId],
4331
+ withPresence: true
4332
+ });
4333
+ });
4334
+
4335
+ _Notification_initUserChannel.set(this, userId => {
4336
+ __classPrivateFieldGet(this, _Notification_pubnub, "f").addListener({
4337
+ message: data => {
4338
+ const {
4339
+ content
4340
+ } = data.message;
4341
+
4342
+ if (content && content.topic && content.messageType && content.data) {
4343
+ for (const eventListener of __classPrivateFieldGet(this, _Notification_eventListeners, "f")) {
4344
+ if (eventListener.topic === content.topic && eventListener.messageType === content.messageType && eventListener.callback && lodash.isFunction(eventListener.callback)) {
4345
+ return eventListener.callback(content.data);
4346
+ }
4347
+ }
4348
+ }
4349
+ }
4350
+ });
4351
+
4352
+ __classPrivateFieldGet(this, _Notification_pubnub, "f").subscribe({
4353
+ channels: [`user_${userId}`],
4354
+ withPresence: false
4355
+ });
4356
+ });
4357
+
4358
+ _Notification_initUniqueSessionChannel.set(this, params => {
4359
+ const decodedToken = AuthAgent.getDecodedAccessToken();
4360
+ const {
4361
+ authHost: myAuthHost,
4362
+ clientId: myClientId
4363
+ } = params;
4364
+ const {
4365
+ userId: myUserId,
4366
+ sessionId: mySessionId,
4367
+ impersonatorId: myImpersonatorId
4368
+ } = decodedToken;
4369
+
4370
+ if (!decodedToken) {
4371
+ return;
4372
+ }
4373
+
4374
+ const channel = `auth-session-${myUserId}`;
4375
+
4376
+ __classPrivateFieldGet(this, _Notification_pubnub, "f").addListener({
4377
+ message: data => {
4378
+ const decodedToken = AuthAgent.getDecodedAccessToken();
4379
+
4380
+ if (!decodedToken) {
4381
+ AuthAgent.logout(true); // call logout with force=true (because the logout is forced)
4382
+ }
4383
+
4384
+ const {
4385
+ sessionId: mySessionId,
4386
+ impersonatorId: myImpersonatorId,
4387
+ userId: myUserId
4388
+ } = decodedToken;
4389
+
4390
+ if (mySessionId && data && data.message) {
4391
+ const sessionId = data.message.sessionId,
4392
+ authHost = data.message.authHost,
4393
+ clientId = data.message.clientId,
4394
+ logout = data.message.logout,
4395
+ impersonatorId = myImpersonatorId ? myImpersonatorId : data.message.impersonatorId;
4396
+
4397
+ if (authHost === myAuthHost) {
4398
+ if (clientId === myClientId && sessionId !== mySessionId || // same application, different browser => logout (unique session feature)
4399
+ clientId !== myClientId && sessionId === mySessionId && logout // different application, same browser, logout asked by user => logout (unique logout feature)
4400
+ ) {
4401
+ if (impersonatorId !== undefined && impersonatorId !== '') {
4402
+ // I'm impersonating someone who is being logged in or out so I don't want to be logged out
4403
+ console.log('user ' + impersonatorId + ' impersonating user ' + myUserId);
4404
+ } else {
4405
+ AuthAgent.logout(true); // call logout with force=true (because the logout is forced)
4406
+ }
4407
+ }
4408
+ }
4409
+ }
4410
+ }
4411
+ });
4412
+
4413
+ __classPrivateFieldGet(this, _Notification_pubnub, "f").subscribe({
4414
+ channels: [channel],
4415
+ withPresence: true
4416
+ });
4417
+
4418
+ __classPrivateFieldGet(this, _Notification_pubnub, "f").publish({
4419
+ message: {
4420
+ authHost: myAuthHost,
4421
+ clientId: myClientId,
4422
+ sessionId: mySessionId,
4423
+ impersonatorId: myImpersonatorId
4424
+ },
4425
+ channel: channel
4426
+ }, status => {
4427
+ if (status.error) {
4428
+ console.log('pubnub error');
4429
+ }
4430
+ });
4431
+ });
4432
+
4433
+ __classPrivateFieldSet(this, _Notification_pubnubKeys, {
4434
+ publishKey: 'pub-13f5288e-cd88-4ef9-9e68-0c11cd03ddb8',
4435
+ subscribeKey: 'sub-a456f002-0095-11e2-9638-9581afc33ebf',
4436
+ uuid: uuid.v4()
4437
+ }, "f");
4438
+
4439
+ __classPrivateFieldSet(this, _Notification_pubnub, new Pubnub__default["default"](__classPrivateFieldGet(this, _Notification_pubnubKeys, "f")), "f");
4440
+ }
4441
+
4442
+ }
4443
+ _Notification_pubnubKeys = new WeakMap(), _Notification_pubnub = new WeakMap(), _Notification_eventListeners = new WeakMap(), _Notification_initFirmChannel = new WeakMap(), _Notification_initUserChannel = new WeakMap(), _Notification_initUniqueSessionChannel = new WeakMap();
4444
+
3806
4445
  var uncurryThis$7 = functionUncurryThis;
3807
4446
  var toObject$3 = toObject$7;
3808
4447
 
@@ -5236,6 +5875,73 @@
5236
5875
  );
5237
5876
  }, FORCED);
5238
5877
 
5878
+ const createCodeChallenge = verifier => __awaiter(void 0, void 0, void 0, function* () {
5879
+ const code_challengeBuffer = yield sha256(verifier);
5880
+ const code_challenge = bufferToBase64UrlEncoded(code_challengeBuffer);
5881
+ return code_challenge;
5882
+ });
5883
+ const getCrypto = () => {
5884
+ //ie 11.x uses msCrypto
5885
+ return window.crypto || window.msCrypto;
5886
+ };
5887
+ const createRandomString = size => {
5888
+ const charset = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
5889
+ let random = '';
5890
+ const randomValues = Array.from(getCrypto().getRandomValues(new Uint8Array(size)));
5891
+ randomValues.forEach(v => random += charset[v % charset.length]);
5892
+ return random;
5893
+ };
5894
+
5895
+ const sha256 = s => __awaiter(void 0, void 0, void 0, function* () {
5896
+ const digestOp = getCryptoSubtle().digest({
5897
+ name: 'SHA-256'
5898
+ }, new TextEncoder().encode(s)); // msCrypto (IE11) uses the old spec, which is not Promise based
5899
+ // https://msdn.microsoft.com/en-us/expression/dn904640(v=vs.71)
5900
+ // Instead of returning a promise, it returns a CryptoOperation
5901
+ // with a result property in it.
5902
+ // As a result, the various events need to be handled in the event that we're
5903
+ // working in IE11 (hence the msCrypto check). These events just call resolve
5904
+ // or reject depending on their intention.
5905
+
5906
+ if (window.msCrypto) {
5907
+ return new Promise((res, rej) => {
5908
+ digestOp.oncomplete = e => {
5909
+ res(e.target.result);
5910
+ };
5911
+
5912
+ digestOp.onerror = e => {
5913
+ rej(e.error);
5914
+ };
5915
+
5916
+ digestOp.onabort = () => {
5917
+ rej('The digest operation was aborted');
5918
+ };
5919
+ });
5920
+ }
5921
+
5922
+ return yield digestOp;
5923
+ });
5924
+
5925
+ const getCryptoSubtle = () => {
5926
+ const crypto = getCrypto(); //safari 10.x uses webkitSubtle
5927
+
5928
+ return crypto.subtle || crypto.webkitSubtle;
5929
+ };
5930
+
5931
+ const bufferToBase64UrlEncoded = input => {
5932
+ const ie11SafeInput = new Uint8Array(input);
5933
+ return urlEncodeB64(window.btoa(String.fromCharCode(...Array.from(ie11SafeInput))));
5934
+ };
5935
+
5936
+ const urlEncodeB64 = input => {
5937
+ const b64Chars = {
5938
+ '+': '-',
5939
+ '/': '_',
5940
+ '=': ''
5941
+ };
5942
+ return input.replace(/[+/=]/g, m => b64Chars[m]);
5943
+ };
5944
+
5239
5945
  var global$1 = global$V;
5240
5946
  var isRegExp = isRegexp;
5241
5947
 
@@ -5335,4 +6041,880 @@
5335
6041
  }
5336
6042
  });
5337
6043
 
6044
+ const getRedirectUri = (origin, decodedToken, redirectionConfig) => {
6045
+ let result;
6046
+ let redirection;
6047
+ let redirectUrl;
6048
+ const topLevelDomains = redirectionConfig.topLevelDomains;
6049
+ const redirections = redirectionConfig.environments;
6050
+ const suffix = topLevelDomains.find(suffix => origin.endsWith(suffix));
6051
+ const environmentVariables = redirectionConfig.environmentVariables;
6052
+
6053
+ if (suffix) {
6054
+ for (let i = 0; i < redirections.length; i++) {
6055
+ redirection = redirections[i];
6056
+ const tokenCriteriaMatched = containsKeys(decodedToken, redirection.criteria);
6057
+
6058
+ if (tokenCriteriaMatched && !!containsApplication(redirection.applications, origin)) {
6059
+ //* check whether suffix needed to change
6060
+ if (redirection.topLevelDomain !== suffix) {
6061
+ //* we need to change the suffix of the origin
6062
+ //* we gonna use `redirection.topLevelDomain` to replace the origin's suffix
6063
+ redirectUrl = origin.replace(suffix, redirection.topLevelDomain);
6064
+ } //* check whether prefix needed to change
6065
+
6066
+
6067
+ const envVariables = environmentVariables[redirection.criteria.environment];
6068
+
6069
+ if (envVariables) {
6070
+ const prefixMappings = envVariables['prefixMappings'];
6071
+ const keys = Object.keys(prefixMappings); //* check whether the current origin with anything inside the prefixMappings
6072
+
6073
+ const needToUpdatePrefixKey = containsApplication(keys, origin);
6074
+
6075
+ if (needToUpdatePrefixKey) {
6076
+ const prefixValue = prefixMappings[needToUpdatePrefixKey];
6077
+ redirectUrl = redirectUrl ? redirectUrl.replace(needToUpdatePrefixKey, prefixValue) : origin.replace(needToUpdatePrefixKey, prefixValue);
6078
+ }
6079
+ }
6080
+
6081
+ break;
6082
+ }
6083
+ }
6084
+
6085
+ if (!!redirection && !!redirectUrl) {
6086
+ result = `${redirection.authHost}/oauth/passthrough?jti=${decodedToken.jti}&redirect=${encodeURIComponent(redirectUrl)}`;
6087
+ }
6088
+ }
6089
+
6090
+ return result;
6091
+ };
6092
+
6093
+ const containsKeys = (obj1, obj2) => {
6094
+ let result = true;
6095
+ Object.keys(obj2).forEach(key => {
6096
+ if (obj1[key] !== obj2[key]) {
6097
+ result = false;
6098
+ }
6099
+ });
6100
+ return result;
6101
+ };
6102
+
6103
+ const containsApplication = (list, app) => {
6104
+ return list.find(appName => app.startsWith(`http://${appName}`) || app.startsWith(`https://${appName}`));
6105
+ };
6106
+
6107
+ var _Authentication_accessToken, _Authentication_config, _Authentication_leapAuthService, _Authentication_notification, _Authentication_refreshInfo, _Authentication_exchangeAuthCodeForAccessToken, _Authentication_verifyAndPerformRedirections, _Authentication_startRefreshAccessTokenProcess, _Authentication_destroyRefreshAccessTokenProcess, _Authentication_decodeAccessToken;
6108
+ const hookNames = ['afterLogin', 'beforeLogout'];
6109
+ const SECONDS_BEFORE_EXPIRE = 10;
6110
+ class Authentication {
6111
+ constructor(options) {
6112
+ _Authentication_accessToken.set(this, void 0);
6113
+
6114
+ _Authentication_config.set(this, void 0);
6115
+
6116
+ _Authentication_leapAuthService.set(this, void 0);
6117
+
6118
+ _Authentication_notification.set(this, void 0);
6119
+
6120
+ _Authentication_refreshInfo.set(this, void 0);
6121
+
6122
+ this.registerEventListenerForUserChannel = params => {
6123
+ const {
6124
+ topic,
6125
+ messageType,
6126
+ callback
6127
+ } = params;
6128
+
6129
+ __classPrivateFieldGet(this, _Authentication_notification, "f").registerEventListenerForUserChannel({
6130
+ topic,
6131
+ messageType,
6132
+ callback
6133
+ });
6134
+ };
6135
+
6136
+ this.initNotification = () => {
6137
+ const decodedToken = this.getDecodedAccessToken();
6138
+
6139
+ if (decodedToken) {
6140
+ __classPrivateFieldGet(this, _Authentication_notification, "f").init({
6141
+ authHost: __classPrivateFieldGet(this, _Authentication_config, "f").authHost,
6142
+ clientId: __classPrivateFieldGet(this, _Authentication_config, "f").clientId,
6143
+ firmId: decodedToken.firmId,
6144
+ userId: decodedToken.userId,
6145
+ uniqueSession: !!__classPrivateFieldGet(this, _Authentication_config, "f").uniqueSession
6146
+ });
6147
+ }
6148
+ };
6149
+
6150
+ this.destroyNotification = () => {
6151
+ __classPrivateFieldGet(this, _Authentication_notification, "f").destroy();
6152
+ };
6153
+
6154
+ this.login = () => __awaiter(this, void 0, void 0, function* () {
6155
+ const done = yield this.checkAuthCode();
6156
+
6157
+ if (done && !!__classPrivateFieldGet(this, _Authentication_accessToken, "f")) {
6158
+ return __classPrivateFieldGet(this, _Authentication_accessToken, "f");
6159
+ } else {
6160
+ const code_verifier = createRandomString(64);
6161
+ const state = createRandomString(6); //* store verifier into browser session for later auth-code exchange
6162
+
6163
+ window.sessionStorage.setItem(state, code_verifier);
6164
+ const code_challenge = yield createCodeChallenge(code_verifier);
6165
+
6166
+ const scope = __classPrivateFieldGet(this, _Authentication_config, "f").scopes.join(',');
6167
+
6168
+ 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=S256&state=${state}`;
6169
+ window.location.assign(url);
6170
+ return;
6171
+ }
6172
+ });
6173
+
6174
+ this.logout = (force = false, redirectUrl) => {
6175
+ __classPrivateFieldSet(this, _Authentication_accessToken, undefined, "f");
6176
+
6177
+ const redirectUri = encodeURIComponent(redirectUrl || window.location.href);
6178
+ window.location.href = `${__classPrivateFieldGet(this, _Authentication_config, "f").authHost}/oauth/logout?force=${force}&redirect_uri=${redirectUri}`;
6179
+
6180
+ __classPrivateFieldGet(this, _Authentication_destroyRefreshAccessTokenProcess, "f").call(this);
6181
+ };
6182
+
6183
+ this.getAccessToken = () => {
6184
+ if (__classPrivateFieldGet(this, _Authentication_accessToken, "f") === undefined || !__classPrivateFieldGet(this, _Authentication_accessToken, "f")) {
6185
+ return '';
6186
+ } else {
6187
+ return __classPrivateFieldGet(this, _Authentication_accessToken, "f");
6188
+ }
6189
+ }; //todo: need to replace the return type "any"
6190
+
6191
+
6192
+ this.getDecodedAccessToken = () => {
6193
+ if (!__classPrivateFieldGet(this, _Authentication_accessToken, "f")) {
6194
+ return undefined;
6195
+ }
6196
+
6197
+ return __classPrivateFieldGet(this, _Authentication_decodeAccessToken, "f").call(this, __classPrivateFieldGet(this, _Authentication_accessToken, "f"));
6198
+ };
6199
+
6200
+ this.getHooks = () => {
6201
+ if (__classPrivateFieldGet(this, _Authentication_config, "f")) {
6202
+ return __classPrivateFieldGet(this, _Authentication_config, "f").hooks;
6203
+ } else {
6204
+ return undefined;
6205
+ }
6206
+ };
6207
+
6208
+ this.setHook = params => {
6209
+ const {
6210
+ name,
6211
+ callback
6212
+ } = params;
6213
+
6214
+ if (hookNames.indexOf(name) < 0) {
6215
+ throw Error('Unimplemented hook : ' + name);
6216
+ }
6217
+
6218
+ if (lodash.isFunction(callback)) {
6219
+ throw Error('hook must be a function: ' + name);
6220
+ }
6221
+
6222
+ __classPrivateFieldSet(this, _Authentication_config, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Authentication_config, "f")), {
6223
+ hooks: Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Authentication_config, "f").hooks), {
6224
+ [name]: callback
6225
+ })
6226
+ }), "f");
6227
+
6228
+ return;
6229
+ };
6230
+
6231
+ this.autoLogin = () => {
6232
+ return __classPrivateFieldGet(this, _Authentication_config, "f") ? __classPrivateFieldGet(this, _Authentication_config, "f").autoLogin || false : false;
6233
+ };
6234
+
6235
+ this.autoLogout = () => {
6236
+ return __classPrivateFieldGet(this, _Authentication_config, "f") ? __classPrivateFieldGet(this, _Authentication_config, "f").autoLogin || false : false;
6237
+ };
6238
+
6239
+ this.idleTimeoutInMinutes = () => {
6240
+ return __classPrivateFieldGet(this, _Authentication_config, "f") ? __classPrivateFieldGet(this, _Authentication_config, "f").idleTimeoutInMinutes || 30 : 30;
6241
+ };
6242
+
6243
+ this.checkAuthCode = () => __awaiter(this, void 0, void 0, function* () {
6244
+ const search = window.location.search;
6245
+ const queryParams = new URLSearchParams(search);
6246
+ const code = queryParams.get('code');
6247
+ const state = queryParams.get('state'); //* check if "AuthCode" comes back from AuthServer
6248
+
6249
+ if (!!code && !!state) {
6250
+ const verifier = window.sessionStorage.getItem(state);
6251
+ window.sessionStorage.removeItem(state);
6252
+ queryParams.delete('code');
6253
+ queryParams.delete('state');
6254
+ const newQueryParams = queryParams.toString();
6255
+ const newUrl = window.location.origin + window.location.pathname + (newQueryParams ? '?' + newQueryParams : '');
6256
+ window.history.pushState(null, '', newUrl); //* use the Verifier and AuthCode to exchange for AccessToken
6257
+
6258
+ if (verifier) {
6259
+ const data = yield __classPrivateFieldGet(this, _Authentication_exchangeAuthCodeForAccessToken, "f").call(this, {
6260
+ code,
6261
+ verifier,
6262
+ redirectUri: newUrl
6263
+ });
6264
+ const redirectTriggered = yield __classPrivateFieldGet(this, _Authentication_verifyAndPerformRedirections, "f").call(this, data.access_token);
6265
+
6266
+ if (redirectTriggered) {
6267
+ return true;
6268
+ }
6269
+
6270
+ if (__classPrivateFieldGet(this, _Authentication_config, "f").autoRefreshToken && data.refresh_token && data.expires_in) {
6271
+ __classPrivateFieldSet(this, _Authentication_refreshInfo, {
6272
+ refreshToken: data.refresh_token,
6273
+ accessTokenExpireIn: data.expires_in,
6274
+ verifier: verifier,
6275
+ timer: undefined
6276
+ }, "f");
6277
+
6278
+ __classPrivateFieldGet(this, _Authentication_startRefreshAccessTokenProcess, "f").call(this);
6279
+ } //* store access token in memory
6280
+
6281
+
6282
+ __classPrivateFieldSet(this, _Authentication_accessToken, data.access_token, "f");
6283
+
6284
+ return true;
6285
+ }
6286
+
6287
+ return false;
6288
+ } else {
6289
+ return false;
6290
+ }
6291
+ });
6292
+
6293
+ this.getUserInfo = () => {
6294
+ return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").userInfo(__classPrivateFieldGet(this, _Authentication_accessToken, "f"));
6295
+ };
6296
+
6297
+ this.linkUser = params => {
6298
+ const decodeToken = this.getDecodedAccessToken();
6299
+
6300
+ if (!decodeToken) {
6301
+ return;
6302
+ }
6303
+
6304
+ const redirectUrl = params.redirectUrl || window.location.href;
6305
+
6306
+ __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").linkUser({
6307
+ redirectUrl,
6308
+ jti: decodeToken.jti,
6309
+ newWindow: params.newWindow,
6310
+ callback: params.callback
6311
+ });
6312
+ };
6313
+
6314
+ this.unlinkUser = params => {
6315
+ const decodeToken = this.getDecodedAccessToken();
6316
+
6317
+ if (!decodeToken) {
6318
+ return;
6319
+ }
6320
+
6321
+ const redirectUrl = params.redirectUrl || window.location.href;
6322
+
6323
+ __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").unlinkUser({
6324
+ redirectUrl,
6325
+ jti: decodeToken.jti,
6326
+ newWindow: params.newWindow,
6327
+ callback: params.callback
6328
+ });
6329
+ };
6330
+
6331
+ this.getCloudProviderToken = jti => {
6332
+ if (!__classPrivateFieldGet(this, _Authentication_accessToken, "f")) {
6333
+ throw Error('Not authenticated yet');
6334
+ }
6335
+
6336
+ return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").getCloudProviderToken(__classPrivateFieldGet(this, _Authentication_accessToken, "f"), jti);
6337
+ };
6338
+
6339
+ this.cloudProviderUserInfo = () => {
6340
+ if (!__classPrivateFieldGet(this, _Authentication_accessToken, "f")) {
6341
+ throw Error('Not authenticated yet');
6342
+ }
6343
+
6344
+ return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").cloudProviderUserInfo(__classPrivateFieldGet(this, _Authentication_accessToken, "f"));
6345
+ };
6346
+
6347
+ this.cloudProviderReauthenticate = params => __awaiter(this, void 0, void 0, function* () {
6348
+ if (!__classPrivateFieldGet(this, _Authentication_accessToken, "f")) {
6349
+ throw Error('Not authenticated yet');
6350
+ }
6351
+
6352
+ let {
6353
+ nonce,
6354
+ redirectUrl
6355
+ } = params;
6356
+ const {
6357
+ newWindow,
6358
+ callback
6359
+ } = params;
6360
+ redirectUrl = redirectUrl || window.location.href;
6361
+
6362
+ if (!nonce) {
6363
+ const reauthticateLink = yield __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").cloudProviderReauthenticateLink(__classPrivateFieldGet(this, _Authentication_accessToken, "f"));
6364
+ nonce = reauthticateLink.nonce;
6365
+ }
6366
+
6367
+ return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").cloudProviderReauthenticate({
6368
+ redirectUrl,
6369
+ nonce,
6370
+ newWindow,
6371
+ callback
6372
+ });
6373
+ });
6374
+
6375
+ this.statusAdminConsent = () => {
6376
+ if (!__classPrivateFieldGet(this, _Authentication_accessToken, "f")) {
6377
+ throw Error('Not authenticated yet');
6378
+ }
6379
+
6380
+ return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").statusAdminConsent(__classPrivateFieldGet(this, _Authentication_accessToken, "f"));
6381
+ };
6382
+
6383
+ this.getAdminConsent = params => {
6384
+ const redirectUrl = params.redirectUrl || window.location.href;
6385
+
6386
+ __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").getAdminConsent(Object.assign(Object.assign({}, params), {
6387
+ redirectUrl
6388
+ }));
6389
+ };
6390
+
6391
+ this.revokeAdminConsent = () => {
6392
+ if (!__classPrivateFieldGet(this, _Authentication_accessToken, "f")) {
6393
+ throw Error('Not authenticated yet');
6394
+ }
6395
+
6396
+ return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").revokeAdminConsent(__classPrivateFieldGet(this, _Authentication_accessToken, "f"));
6397
+ };
6398
+
6399
+ this.getLinkMap = (allUsers = false) => {
6400
+ if (!__classPrivateFieldGet(this, _Authentication_accessToken, "f")) {
6401
+ throw Error('Not authenticated yet');
6402
+ }
6403
+
6404
+ return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").getLinkMap(__classPrivateFieldGet(this, _Authentication_accessToken, "f"), allUsers);
6405
+ };
6406
+
6407
+ this.setLinkMap = linkMap => {
6408
+ if (!__classPrivateFieldGet(this, _Authentication_accessToken, "f")) {
6409
+ throw Error('Not authenticated yet');
6410
+ }
6411
+
6412
+ const verifyFormat = () => {
6413
+ if (Array.isArray(linkMap)) {
6414
+ for (const link of linkMap) {
6415
+ if (!(link.internalUser && link.externalUser && link.externalUser.id)) return false;
6416
+ }
6417
+
6418
+ return true;
6419
+ }
6420
+
6421
+ return false;
6422
+ };
6423
+
6424
+ if (!verifyFormat()) throw Error('linkmap in wrong format');
6425
+ return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").setLinkMap(__classPrivateFieldGet(this, _Authentication_accessToken, "f"), linkMap);
6426
+ };
6427
+
6428
+ this.authoriseSupport = params => {
6429
+ if (!__classPrivateFieldGet(this, _Authentication_accessToken, "f")) {
6430
+ throw Error('Not authenticated yet');
6431
+ }
6432
+
6433
+ return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").authoriseSupport(__classPrivateFieldGet(this, _Authentication_accessToken, "f"), params);
6434
+ };
6435
+
6436
+ this.changePassword = params => {
6437
+ const redirectUrl = params.redirectUrl || window.location.href;
6438
+
6439
+ __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").changePassword(Object.assign(Object.assign({}, params), {
6440
+ redirectUrl
6441
+ }));
6442
+ };
6443
+
6444
+ this.passthrough = params => {
6445
+ const decodedToken = this.getDecodedAccessToken();
6446
+
6447
+ if (decodedToken && decodedToken.jti) {
6448
+ const {
6449
+ url,
6450
+ newWindow,
6451
+ authHost
6452
+ } = params;
6453
+ const encodedRedirectUrl = encodeURIComponent(url);
6454
+ const passthroughUrl = `${authHost || __classPrivateFieldGet(this, _Authentication_config, "f").authHost}/oauth/passthrough?jti=${decodedToken.jti}&redirect=${encodedRedirectUrl}&output=embed`;
6455
+
6456
+ if (newWindow) {
6457
+ window.open(passthroughUrl, '_blank');
6458
+ } else {
6459
+ window.location.assign(passthroughUrl);
6460
+ }
6461
+ }
6462
+
6463
+ return;
6464
+ };
6465
+
6466
+ this.triggerHooks = hookName => {
6467
+ const hooks = this.getHooks();
6468
+ const token = this.getAccessToken();
6469
+ const hookFn = hooks && !!hooks[hookName] && lodash.isFunction(hooks[hookName]) ? hooks[hookName](token) : false;
6470
+ return Promise.resolve(hookFn);
6471
+ };
6472
+
6473
+ _Authentication_exchangeAuthCodeForAccessToken.set(this, params => __awaiter(this, void 0, void 0, function* () {
6474
+ const {
6475
+ code,
6476
+ verifier,
6477
+ redirectUri
6478
+ } = params;
6479
+ return __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").exchangeAuthCodeForAccessToken({
6480
+ code,
6481
+ verifier,
6482
+ redirectUri
6483
+ });
6484
+ }));
6485
+
6486
+ _Authentication_verifyAndPerformRedirections.set(this, accessToken => __awaiter(this, void 0, void 0, function* () {
6487
+ const redirectionConfig = yield __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").getRedirections();
6488
+ const origin = window.location.origin;
6489
+
6490
+ const decodedToken = __classPrivateFieldGet(this, _Authentication_decodeAccessToken, "f").call(this, accessToken);
6491
+
6492
+ const redirectUri = getRedirectUri(origin, decodedToken, redirectionConfig);
6493
+
6494
+ if (redirectUri) {
6495
+ this.logout(false, redirectUri);
6496
+ return true;
6497
+ }
6498
+
6499
+ return false;
6500
+ }));
6501
+
6502
+ _Authentication_startRefreshAccessTokenProcess.set(this, () => {
6503
+ if (!__classPrivateFieldGet(this, _Authentication_refreshInfo, "f")) {
6504
+ return;
6505
+ }
6506
+
6507
+ if (__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").timer) {
6508
+ clearTimeout(__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").timer);
6509
+
6510
+ __classPrivateFieldSet(this, _Authentication_refreshInfo, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Authentication_refreshInfo, "f")), {
6511
+ timer: undefined
6512
+ }), "f");
6513
+ }
6514
+
6515
+ const waitBeforeExecuting = (__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").accessTokenExpireIn - SECONDS_BEFORE_EXPIRE) * 1000;
6516
+ const timer = setTimeout(() => __awaiter(this, void 0, void 0, function* () {
6517
+ if (!__classPrivateFieldGet(this, _Authentication_refreshInfo, "f")) {
6518
+ return;
6519
+ }
6520
+
6521
+ const data = yield __classPrivateFieldGet(this, _Authentication_leapAuthService, "f").renewAccessToken({
6522
+ refreshToken: __classPrivateFieldGet(this, _Authentication_refreshInfo, "f").refreshToken,
6523
+ verifier: __classPrivateFieldGet(this, _Authentication_refreshInfo, "f").verifier
6524
+ });
6525
+
6526
+ if (data) {
6527
+ if (data.refresh_token && data.expires_in) {
6528
+ __classPrivateFieldSet(this, _Authentication_refreshInfo, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Authentication_refreshInfo, "f")), {
6529
+ refreshToken: data.refresh_token,
6530
+ accessTokenExpireIn: data.expires_in
6531
+ }), "f");
6532
+
6533
+ __classPrivateFieldGet(this, _Authentication_startRefreshAccessTokenProcess, "f").call(this);
6534
+ }
6535
+
6536
+ __classPrivateFieldSet(this, _Authentication_accessToken, data.access_token, "f");
6537
+ }
6538
+ }), waitBeforeExecuting);
6539
+
6540
+ __classPrivateFieldSet(this, _Authentication_refreshInfo, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Authentication_refreshInfo, "f")), {
6541
+ timer
6542
+ }), "f");
6543
+ });
6544
+
6545
+ _Authentication_destroyRefreshAccessTokenProcess.set(this, () => {
6546
+ if (!__classPrivateFieldGet(this, _Authentication_refreshInfo, "f")) {
6547
+ return;
6548
+ }
6549
+
6550
+ if (__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").timer) {
6551
+ clearTimeout(__classPrivateFieldGet(this, _Authentication_refreshInfo, "f").timer);
6552
+ }
6553
+
6554
+ __classPrivateFieldSet(this, _Authentication_refreshInfo, undefined, "f");
6555
+ });
6556
+
6557
+ _Authentication_decodeAccessToken.set(this, accessToken => {
6558
+ const payload = accessToken.split('.')[1];
6559
+
6560
+ if (payload) {
6561
+ try {
6562
+ const result = window.atob(payload);
6563
+ return JSON.parse(result);
6564
+ } catch (e) {
6565
+ throw Error('Fail to decode access token.');
6566
+ }
6567
+ }
6568
+
6569
+ return undefined;
6570
+ });
6571
+
6572
+ __classPrivateFieldSet(this, _Authentication_accessToken, undefined, "f");
6573
+
6574
+ __classPrivateFieldSet(this, _Authentication_config, init$1(options), "f");
6575
+
6576
+ __classPrivateFieldSet(this, _Authentication_leapAuthService, new LeapAuthService(__classPrivateFieldGet(this, _Authentication_config, "f").authHost, __classPrivateFieldGet(this, _Authentication_config, "f").clientId), "f");
6577
+
6578
+ __classPrivateFieldSet(this, _Authentication_notification, new Notification(), "f");
6579
+ }
6580
+
6581
+ }
6582
+ _Authentication_accessToken = new WeakMap(), _Authentication_config = new WeakMap(), _Authentication_leapAuthService = new WeakMap(), _Authentication_notification = new WeakMap(), _Authentication_refreshInfo = new WeakMap(), _Authentication_exchangeAuthCodeForAccessToken = new WeakMap(), _Authentication_verifyAndPerformRedirections = new WeakMap(), _Authentication_startRefreshAccessTokenProcess = new WeakMap(), _Authentication_destroyRefreshAccessTokenProcess = new WeakMap(), _Authentication_decodeAccessToken = new WeakMap();
6583
+
6584
+ var _IdleTimer_timeoutInMinutes, _IdleTimer_timer, _IdleTimer_onTimeout, _IdleTimer_cleanUpTracker, _IdleTimer_clearTimeout, _IdleTimer_resetTimer;
6585
+ class IdleTimer {
6586
+ constructor(params) {
6587
+ _IdleTimer_timeoutInMinutes.set(this, void 0);
6588
+
6589
+ _IdleTimer_timer.set(this, void 0);
6590
+
6591
+ _IdleTimer_onTimeout.set(this, void 0);
6592
+
6593
+ this.tracker = () => {
6594
+ window.addEventListener('onload', __classPrivateFieldGet(this, _IdleTimer_resetTimer, "f"), true);
6595
+ window.addEventListener('mousemove', __classPrivateFieldGet(this, _IdleTimer_resetTimer, "f"), true);
6596
+ window.addEventListener('onmousedown', __classPrivateFieldGet(this, _IdleTimer_resetTimer, "f"), true);
6597
+ window.addEventListener('onscroll', __classPrivateFieldGet(this, _IdleTimer_resetTimer, "f"), true);
6598
+ window.addEventListener('onkeypress', __classPrivateFieldGet(this, _IdleTimer_resetTimer, "f"), true);
6599
+ };
6600
+
6601
+ _IdleTimer_cleanUpTracker.set(this, () => {
6602
+ window.removeEventListener('onload', __classPrivateFieldGet(this, _IdleTimer_resetTimer, "f"), true);
6603
+ window.removeEventListener('mousemove', __classPrivateFieldGet(this, _IdleTimer_resetTimer, "f"), true);
6604
+ window.removeEventListener('onmousedown', __classPrivateFieldGet(this, _IdleTimer_resetTimer, "f"), true);
6605
+ window.removeEventListener('onscroll', __classPrivateFieldGet(this, _IdleTimer_resetTimer, "f"), true);
6606
+ window.removeEventListener('onkeypress', __classPrivateFieldGet(this, _IdleTimer_resetTimer, "f"), true);
6607
+ });
6608
+
6609
+ _IdleTimer_clearTimeout.set(this, () => {
6610
+ if (__classPrivateFieldGet(this, _IdleTimer_timer, "f")) {
6611
+ clearTimeout(__classPrivateFieldGet(this, _IdleTimer_timer, "f"));
6612
+ }
6613
+ });
6614
+
6615
+ _IdleTimer_resetTimer.set(this, () => {
6616
+ __classPrivateFieldGet(this, _IdleTimer_clearTimeout, "f").call(this);
6617
+
6618
+ __classPrivateFieldSet(this, _IdleTimer_timer, setTimeout(() => {
6619
+ __classPrivateFieldGet(this, _IdleTimer_clearTimeout, "f").call(this);
6620
+
6621
+ __classPrivateFieldGet(this, _IdleTimer_cleanUpTracker, "f").call(this);
6622
+
6623
+ __classPrivateFieldGet(this, _IdleTimer_onTimeout, "f").call(this);
6624
+ }, __classPrivateFieldGet(this, _IdleTimer_timeoutInMinutes, "f") * 60 * 1000), "f");
6625
+ });
6626
+
6627
+ const {
6628
+ timeoutInMinutes,
6629
+ onTimeout: onTimeout
6630
+ } = params;
6631
+
6632
+ __classPrivateFieldSet(this, _IdleTimer_timeoutInMinutes, timeoutInMinutes, "f");
6633
+
6634
+ __classPrivateFieldSet(this, _IdleTimer_onTimeout, onTimeout, "f");
6635
+ }
6636
+
6637
+ }
6638
+ _IdleTimer_timeoutInMinutes = new WeakMap(), _IdleTimer_timer = new WeakMap(), _IdleTimer_onTimeout = new WeakMap(), _IdleTimer_cleanUpTracker = new WeakMap(), _IdleTimer_clearTimeout = new WeakMap(), _IdleTimer_resetTimer = new WeakMap();
6639
+
6640
+ let auth;
6641
+
6642
+ const init = options => __awaiter(void 0, void 0, void 0, function* () {
6643
+ auth = new Authentication(options);
6644
+
6645
+ if (!auth) {
6646
+ return false;
6647
+ }
6648
+
6649
+ if (auth.autoLogout()) {
6650
+ const timeoutInMinutes = auth.idleTimeoutInMinutes();
6651
+ const idleTimer = new IdleTimer({
6652
+ timeoutInMinutes,
6653
+ onTimeout: logout
6654
+ });
6655
+ idleTimer.tracker();
6656
+ } //* check if authCode in URL
6657
+
6658
+
6659
+ const done = yield auth.checkAuthCode();
6660
+
6661
+ if (done) {
6662
+ return auth.triggerHooks('afterLogin').then(() => {
6663
+ return getAccessToken();
6664
+ });
6665
+ }
6666
+
6667
+ const autoLogin = auth.autoLogin();
6668
+
6669
+ if (autoLogin) {
6670
+ login();
6671
+ }
6672
+
6673
+ return true;
6674
+ });
6675
+
6676
+ const getAccessToken = () => {
6677
+ return !auth ? '' : auth.getAccessToken();
6678
+ };
6679
+
6680
+ const login = () => __awaiter(void 0, void 0, void 0, function* () {
6681
+ if (!auth) {
6682
+ throw Error('Not init yet');
6683
+ }
6684
+
6685
+ return auth.login().then(token => {
6686
+ const hooks = auth === null || auth === void 0 ? void 0 : auth.getHooks();
6687
+ const afterLogin = token && hooks && lodash.isFunction(hooks.afterLogin) ? hooks.afterLogin(token) : false;
6688
+ return Promise.resolve(afterLogin).then(() => {
6689
+ if (token && auth) {
6690
+ auth.initNotification();
6691
+ }
6692
+
6693
+ return token;
6694
+ });
6695
+ });
6696
+ });
6697
+
6698
+ const logout = (force = false, redirectUrl) => __awaiter(void 0, void 0, void 0, function* () {
6699
+ if (!auth) {
6700
+ throw Error('Not init yet');
6701
+ }
6702
+
6703
+ const hooks = auth === null || auth === void 0 ? void 0 : auth.getHooks();
6704
+ const beforeLogout = hooks && lodash.isFunction(hooks.beforeLogout) ? hooks.beforeLogout() : false;
6705
+ return Promise.resolve(beforeLogout).then(() => {
6706
+ if (auth) {
6707
+ auth.destroyNotification();
6708
+ auth.logout(force, redirectUrl);
6709
+ }
6710
+
6711
+ return;
6712
+ }).catch(function (err) {
6713
+ console.error('Error while logging out : ', err);
6714
+ throw Error(err);
6715
+ });
6716
+ });
6717
+
6718
+ const registerHook = (hookName, callback) => {
6719
+ if (!auth) {
6720
+ throw Error('Not init yet');
6721
+ }
6722
+
6723
+ if (auth) {
6724
+ auth.setHook({
6725
+ name: hookName,
6726
+ callback
6727
+ });
6728
+ }
6729
+
6730
+ return;
6731
+ };
6732
+
6733
+ const getDecodedAccessToken = () => {
6734
+ if (!auth) {
6735
+ throw Error('Not init yet');
6736
+ }
6737
+
6738
+ return auth.getDecodedAccessToken();
6739
+ };
6740
+
6741
+ const userInfo = () => {
6742
+ if (!auth) {
6743
+ throw Error('Not init yet');
6744
+ }
6745
+
6746
+ return auth.getUserInfo();
6747
+ };
6748
+
6749
+ const linkUser = (redirectUrl, newWindow, callback) => {
6750
+ if (!auth) {
6751
+ throw Error('Not init yet');
6752
+ }
6753
+
6754
+ auth.linkUser({
6755
+ redirectUrl,
6756
+ newWindow,
6757
+ callback
6758
+ });
6759
+ };
6760
+
6761
+ const unlinkUser = (redirectUrl, newWindow, callback) => {
6762
+ if (!auth) {
6763
+ throw Error('Not init yet');
6764
+ }
6765
+
6766
+ auth.unlinkUser({
6767
+ redirectUrl,
6768
+ newWindow,
6769
+ callback
6770
+ });
6771
+ };
6772
+
6773
+ const getCloudProviderToken = jti => {
6774
+ if (!auth) {
6775
+ throw Error('Not init yet');
6776
+ }
6777
+
6778
+ return auth.getCloudProviderToken(jti);
6779
+ };
6780
+
6781
+ const cloudProviderUserInfo = () => {
6782
+ if (!auth) {
6783
+ throw Error('Not init yet');
6784
+ }
6785
+
6786
+ return auth.cloudProviderUserInfo();
6787
+ };
6788
+
6789
+ const cloudProviderReauthenticate = (nonce, redirectUrl, newWindow, callback) => {
6790
+ if (!auth) {
6791
+ throw Error('Not init yet');
6792
+ }
6793
+
6794
+ return auth.cloudProviderReauthenticate({
6795
+ redirectUrl,
6796
+ nonce,
6797
+ newWindow,
6798
+ callback
6799
+ });
6800
+ };
6801
+
6802
+ const statusAdminConsent = () => {
6803
+ if (!auth) {
6804
+ throw Error('Not init yet');
6805
+ }
6806
+
6807
+ return auth.statusAdminConsent();
6808
+ };
6809
+
6810
+ const getAdminConsent = (domain, redirectUrl, newWindow, callback) => {
6811
+ if (!auth) {
6812
+ throw Error('Not init yet');
6813
+ }
6814
+
6815
+ auth.getAdminConsent({
6816
+ domain,
6817
+ redirectUrl,
6818
+ newWindow,
6819
+ callback
6820
+ });
6821
+ };
6822
+
6823
+ const revokeAdminConsent = () => {
6824
+ if (!auth) {
6825
+ throw Error('Not init yet');
6826
+ }
6827
+
6828
+ return auth.revokeAdminConsent();
6829
+ };
6830
+
6831
+ const getLinkMap = allUsers => {
6832
+ if (!auth) {
6833
+ throw Error('Not init yet');
6834
+ }
6835
+
6836
+ return auth.getLinkMap(allUsers);
6837
+ };
6838
+
6839
+ const setLinkMap = linkMap => {
6840
+ if (!auth) {
6841
+ throw Error('Not init yet');
6842
+ }
6843
+
6844
+ return auth.setLinkMap(linkMap);
6845
+ };
6846
+
6847
+ const authoriseSupport = (code, duration) => {
6848
+ if (!auth) {
6849
+ throw Error('Not init yet');
6850
+ }
6851
+
6852
+ return auth.authoriseSupport({
6853
+ code,
6854
+ duration
6855
+ });
6856
+ };
6857
+
6858
+ const changePassword = (redirectUrl, newWindow, callback) => {
6859
+ if (!auth) {
6860
+ throw Error('Not init yet');
6861
+ }
6862
+
6863
+ auth.changePassword({
6864
+ redirectUrl,
6865
+ newWindow,
6866
+ callback
6867
+ });
6868
+ };
6869
+
6870
+ const registerEventListener = (topic, messageType, callback) => {
6871
+ if (!auth) {
6872
+ throw Error('Not init yet');
6873
+ }
6874
+
6875
+ auth.registerEventListenerForUserChannel({
6876
+ topic,
6877
+ messageType,
6878
+ callback
6879
+ });
6880
+ };
6881
+
6882
+ const passthrough = (url, newWindow = false, authHost) => {
6883
+ if (!auth) {
6884
+ throw Error('Not init yet');
6885
+ }
6886
+
6887
+ auth.passthrough({
6888
+ url,
6889
+ newWindow,
6890
+ authHost
6891
+ });
6892
+ };
6893
+
6894
+ var AuthAgent = {
6895
+ init,
6896
+ registerHook,
6897
+ login,
6898
+ logout,
6899
+ getAccessToken,
6900
+ getDecodedAccessToken,
6901
+ userInfo,
6902
+ linkUser,
6903
+ unlinkUser,
6904
+ getCloudProviderToken,
6905
+ cloudProviderUserInfo,
6906
+ cloudProviderReauthenticate,
6907
+ statusAdminConsent,
6908
+ getAdminConsent,
6909
+ revokeAdminConsent,
6910
+ getLinkMap,
6911
+ setLinkMap,
6912
+ authoriseSupport,
6913
+ changePassword,
6914
+ registerEventListener,
6915
+ passthrough
6916
+ };
6917
+
6918
+ return AuthAgent;
6919
+
5338
6920
  }));