@axa-fr/react-oidc 6.11.4-alpha2 → 6.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/OidcProvider.d.ts +1 -1
  2. package/dist/OidcProvider.d.ts.map +1 -1
  3. package/dist/OidcSecure.d.ts +1 -1
  4. package/dist/OidcSecure.d.ts.map +1 -1
  5. package/dist/OidcServiceWorker.js +16 -3
  6. package/dist/ReactOidc.d.ts +1 -1
  7. package/dist/ReactOidc.d.ts.map +1 -1
  8. package/dist/index.d.ts +1 -1
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js.map +1 -1
  11. package/dist/vanilla/initSession.d.ts +3 -3
  12. package/dist/vanilla/initSession.d.ts.map +1 -1
  13. package/dist/vanilla/initSession.js +20 -20
  14. package/dist/vanilla/initSession.js.map +1 -1
  15. package/dist/vanilla/initWorker.d.ts +4 -4
  16. package/dist/vanilla/initWorker.d.ts.map +1 -1
  17. package/dist/vanilla/initWorker.js +13 -13
  18. package/dist/vanilla/initWorker.js.map +1 -1
  19. package/dist/vanilla/oidc.d.ts +36 -7
  20. package/dist/vanilla/oidc.d.ts.map +1 -1
  21. package/dist/vanilla/oidc.js +357 -82
  22. package/dist/vanilla/oidc.js.map +1 -1
  23. package/dist/vanilla/requests.d.ts +0 -2
  24. package/dist/vanilla/requests.d.ts.map +1 -1
  25. package/dist/vanilla/requests.js +1 -20
  26. package/dist/vanilla/requests.js.map +1 -1
  27. package/dist/vanilla/route-utils.js +1 -1
  28. package/dist/vanilla/route-utils.js.map +1 -1
  29. package/dist/vanilla/vanillaOidc.d.ts +1 -2
  30. package/dist/vanilla/vanillaOidc.d.ts.map +1 -1
  31. package/dist/vanilla/vanillaOidc.js.map +1 -1
  32. package/package.json +1 -1
  33. package/src/oidc/OidcProvider.tsx +1 -1
  34. package/src/oidc/OidcSecure.tsx +1 -1
  35. package/src/oidc/ReactOidc.tsx +1 -1
  36. package/src/oidc/index.ts +1 -1
  37. package/src/oidc/vanilla/OidcServiceWorker.js +16 -3
  38. package/src/oidc/vanilla/index.ts +1 -1
  39. package/src/oidc/vanilla/initSession.ts +20 -20
  40. package/src/oidc/vanilla/initWorker.ts +14 -14
  41. package/src/oidc/vanilla/oidc.ts +380 -52
  42. package/src/oidc/vanilla/requests.ts +0 -24
  43. package/src/oidc/vanilla/route-utils.ts +1 -1
  44. package/src/oidc/vanilla/vanillaOidc.ts +1 -2
  45. package/dist/vanilla/checkSession.d.ts +0 -5
  46. package/dist/vanilla/checkSession.d.ts.map +0 -1
  47. package/dist/vanilla/checkSession.js +0 -68
  48. package/dist/vanilla/checkSession.js.map +0 -1
  49. package/dist/vanilla/events.d.ts +0 -29
  50. package/dist/vanilla/events.d.ts.map +0 -1
  51. package/dist/vanilla/events.js +0 -32
  52. package/dist/vanilla/events.js.map +0 -1
  53. package/dist/vanilla/login.d.ts +0 -4
  54. package/dist/vanilla/login.d.ts.map +0 -1
  55. package/dist/vanilla/login.js +0 -125
  56. package/dist/vanilla/login.js.map +0 -1
  57. package/dist/vanilla/silentLogin.d.ts +0 -8
  58. package/dist/vanilla/silentLogin.d.ts.map +0 -1
  59. package/dist/vanilla/silentLogin.js +0 -95
  60. package/dist/vanilla/silentLogin.js.map +0 -1
  61. package/dist/vanilla/types.d.ts +0 -33
  62. package/dist/vanilla/types.d.ts.map +0 -1
  63. package/dist/vanilla/types.js +0 -3
  64. package/dist/vanilla/types.js.map +0 -1
  65. package/dist/vanilla/user.d.ts +0 -2
  66. package/dist/vanilla/user.d.ts.map +0 -1
  67. package/dist/vanilla/user.js +0 -48
  68. package/dist/vanilla/user.js.map +0 -1
  69. package/src/oidc/vanilla/checkSession.ts +0 -55
  70. package/src/oidc/vanilla/events.ts +0 -29
  71. package/src/oidc/vanilla/login.ts +0 -118
  72. package/src/oidc/vanilla/silentLogin.ts +0 -102
  73. package/src/oidc/vanilla/types.ts +0 -35
  74. package/src/oidc/vanilla/user.ts +0 -39
@@ -14,19 +14,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.Oidc = exports.OidcAuthorizationServiceConfiguration = void 0;
16
16
  const appauth_1 = require("@openid/appauth");
17
- const checkSession_1 = require("./checkSession");
18
- const events_1 = require("./events");
17
+ const cache_1 = require("./cache");
18
+ const checkSessionIFrame_1 = require("./checkSessionIFrame");
19
19
  const initSession_1 = require("./initSession");
20
20
  const initWorker_1 = require("./initWorker");
21
- const login_1 = require("./login");
22
21
  const memoryStorageBackend_1 = require("./memoryStorageBackend");
23
22
  const noHashQueryStringUtils_1 = require("./noHashQueryStringUtils");
24
23
  const parseTokens_1 = require("./parseTokens");
25
24
  const requests_1 = require("./requests");
26
25
  const route_utils_1 = require("./route-utils");
27
- const silentLogin_1 = __importDefault(require("./silentLogin"));
28
26
  const timer_1 = __importDefault(require("./timer"));
29
- const user_1 = require("./user");
27
+ const randomString = function (length) {
28
+ let text = '';
29
+ const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
30
+ for (let i = 0; i < length; i++) {
31
+ text += possible.charAt(Math.floor(Math.random() * possible.length));
32
+ }
33
+ return text;
34
+ };
30
35
  class OidcAuthorizationServiceConfiguration extends appauth_1.AuthorizationServiceConfiguration {
31
36
  constructor(request) {
32
37
  super(request);
@@ -56,9 +61,9 @@ function renewTokensAndStartTimerAsync(oidc, refreshToken, forceRefresh = false,
56
61
  return __awaiter(this, void 0, void 0, function* () {
57
62
  const updateTokens = (tokens) => { oidc.tokens = tokens; };
58
63
  const { tokens, status } = yield oidc.synchroniseTokensAsync(refreshToken, 0, forceRefresh, extras, updateTokens);
59
- const serviceWorker = yield (0, initWorker_1.initWorkerAsync)(oidc.configuration.service_worker_relative_url, oidc.configurationName);
64
+ const serviceWorker = yield (0, initWorker_1.initWorkerAsync)(oidc.configuration.service_worker_relative_url, oidc.configurationName, oidc.configuration.redirect_uri);
60
65
  if (!serviceWorker) {
61
- const session = (0, initSession_1.initSession)(oidc.configurationName, oidc.configuration.storage);
66
+ const session = (0, initSession_1.initSession)(oidc.configurationName, oidc.configuration.redirect_uri, oidc.configuration.storage);
62
67
  yield session.setTokens(oidc.tokens);
63
68
  }
64
69
  if (!oidc.tokens) {
@@ -79,9 +84,85 @@ const autoRenewTokens = (oidc, refreshToken, expiresAt, extras = null) => {
79
84
  yield renewTokensAndStartTimerAsync(oidc, refreshToken, false, extras);
80
85
  }), 1000);
81
86
  };
87
+ const userInfoAsync = (oidc) => __awaiter(void 0, void 0, void 0, function* () {
88
+ if (oidc.userInfo != null) {
89
+ return oidc.userInfo;
90
+ }
91
+ if (!oidc.tokens) {
92
+ return null;
93
+ }
94
+ const accessToken = oidc.tokens.accessToken;
95
+ if (!accessToken) {
96
+ return null;
97
+ }
98
+ // We wait the synchronisation before making a request
99
+ while (oidc.tokens && !(0, parseTokens_1.isTokensValid)(oidc.tokens)) {
100
+ yield (0, initWorker_1.sleepAsync)(200);
101
+ }
102
+ const oidcServerConfiguration = yield oidc.initAsync(oidc.configuration.authority, oidc.configuration.authority_configuration);
103
+ const url = oidcServerConfiguration.userInfoEndpoint;
104
+ const fetchUserInfo = (accessToken) => __awaiter(void 0, void 0, void 0, function* () {
105
+ const res = yield fetch(url, {
106
+ headers: {
107
+ authorization: `Bearer ${accessToken}`,
108
+ },
109
+ });
110
+ if (res.status !== 200) {
111
+ return null;
112
+ }
113
+ return res.json();
114
+ });
115
+ const userInfo = yield fetchUserInfo(accessToken);
116
+ oidc.userInfo = userInfo;
117
+ return userInfo;
118
+ });
119
+ const eventNames = {
120
+ service_worker_not_supported_by_browser: 'service_worker_not_supported_by_browser',
121
+ token_aquired: 'token_aquired',
122
+ logout_from_another_tab: 'logout_from_another_tab',
123
+ logout_from_same_tab: 'logout_from_same_tab',
124
+ token_renewed: 'token_renewed',
125
+ token_timer: 'token_timer',
126
+ loginAsync_begin: 'loginAsync_begin',
127
+ loginAsync_error: 'loginAsync_error',
128
+ loginCallbackAsync_begin: 'loginCallbackAsync_begin',
129
+ loginCallbackAsync_end: 'loginCallbackAsync_end',
130
+ loginCallbackAsync_error: 'loginCallbackAsync_error',
131
+ refreshTokensAsync_begin: 'refreshTokensAsync_begin',
132
+ refreshTokensAsync: 'refreshTokensAsync',
133
+ refreshTokensAsync_end: 'refreshTokensAsync_end',
134
+ refreshTokensAsync_error: 'refreshTokensAsync_error',
135
+ refreshTokensAsync_silent_error: 'refreshTokensAsync_silent_error',
136
+ tryKeepExistingSessionAsync_begin: 'tryKeepExistingSessionAsync_begin',
137
+ tryKeepExistingSessionAsync_end: 'tryKeepExistingSessionAsync_end',
138
+ tryKeepExistingSessionAsync_error: 'tryKeepExistingSessionAsync_error',
139
+ silentLoginAsync_begin: 'silentLoginAsync_begin',
140
+ silentLoginAsync: 'silentLoginAsync',
141
+ silentLoginAsync_end: 'silentLoginAsync_end',
142
+ silentLoginAsync_error: 'silentLoginAsync_error',
143
+ syncTokensAsync_begin: 'syncTokensAsync_begin',
144
+ syncTokensAsync_end: 'syncTokensAsync_end',
145
+ syncTokensAsync_error: 'syncTokensAsync_error',
146
+ };
82
147
  const getRandomInt = (max) => {
83
148
  return Math.floor(Math.random() * max);
84
149
  };
150
+ const oneHourSecond = 60 * 60;
151
+ const fetchFromIssuer = (openIdIssuerUrl, timeCacheSecond = oneHourSecond, storage = window.sessionStorage) => __awaiter(void 0, void 0, void 0, function* () {
152
+ const fullUrl = `${openIdIssuerUrl}/.well-known/openid-configuration`;
153
+ const localStorageKey = `oidc.server:${openIdIssuerUrl}`;
154
+ const data = (0, cache_1.getFromCache)(localStorageKey, storage, timeCacheSecond);
155
+ if (data) {
156
+ return new OidcAuthorizationServiceConfiguration(data);
157
+ }
158
+ const response = yield fetch(fullUrl);
159
+ if (response.status !== 200) {
160
+ return null;
161
+ }
162
+ const result = yield response.json();
163
+ (0, cache_1.setCache)(localStorageKey, result, storage);
164
+ return new OidcAuthorizationServiceConfiguration(result);
165
+ });
85
166
  class Oidc {
86
167
  constructor(configuration, configurationName = 'default') {
87
168
  var _a, _b, _c, _d;
@@ -165,7 +246,94 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
165
246
  }
166
247
  silentLoginAsync(extras = null, state = null, scope = null) {
167
248
  return __awaiter(this, void 0, void 0, function* () {
168
- return (0, silentLogin_1.default)(this.configurationName, this.configuration, this.publishEvent.bind(this))(extras, state, scope);
249
+ if (!this.configuration.silent_redirect_uri || !this.configuration.silent_login_uri) {
250
+ return Promise.resolve(null);
251
+ }
252
+ try {
253
+ this.publishEvent(eventNames.silentLoginAsync_begin, {});
254
+ const configuration = this.configuration;
255
+ let queries = '';
256
+ if (state) {
257
+ if (extras == null) {
258
+ extras = {};
259
+ }
260
+ extras.state = state;
261
+ }
262
+ if (scope) {
263
+ if (extras == null) {
264
+ extras = {};
265
+ }
266
+ extras.scope = scope;
267
+ }
268
+ if (extras != null) {
269
+ for (const [key, value] of Object.entries(extras)) {
270
+ if (queries === '') {
271
+ queries = `?${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
272
+ }
273
+ else {
274
+ queries += `&${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
275
+ }
276
+ }
277
+ }
278
+ const link = configuration.silent_login_uri + queries;
279
+ const idx = link.indexOf('/', link.indexOf('//') + 2);
280
+ const iFrameOrigin = link.substr(0, idx);
281
+ const iframe = document.createElement('iframe');
282
+ iframe.width = '0px';
283
+ iframe.height = '0px';
284
+ iframe.id = `${this.configurationName}_oidc_iframe`;
285
+ iframe.setAttribute('src', link);
286
+ document.body.appendChild(iframe);
287
+ return new Promise((resolve, reject) => {
288
+ try {
289
+ let isResolved = false;
290
+ window.onmessage = (e) => {
291
+ if (e.origin === iFrameOrigin &&
292
+ e.source === iframe.contentWindow) {
293
+ const key = `${this.configurationName}_oidc_tokens:`;
294
+ const key_error = `${this.configurationName}_oidc_error:`;
295
+ const data = e.data;
296
+ if (data && typeof (data) === 'string') {
297
+ if (!isResolved) {
298
+ if (data.startsWith(key)) {
299
+ const result = JSON.parse(e.data.replace(key, ''));
300
+ this.publishEvent(eventNames.silentLoginAsync_end, {});
301
+ iframe.remove();
302
+ isResolved = true;
303
+ resolve(result);
304
+ }
305
+ else if (data.startsWith(key_error)) {
306
+ const result = JSON.parse(e.data.replace(key_error, ''));
307
+ this.publishEvent(eventNames.silentLoginAsync_error, result);
308
+ iframe.remove();
309
+ isResolved = true;
310
+ reject(new Error('oidc_' + result.error));
311
+ }
312
+ }
313
+ }
314
+ }
315
+ };
316
+ const silentSigninTimeout = configuration.silent_login_timeout;
317
+ setTimeout(() => {
318
+ if (!isResolved) {
319
+ this.publishEvent(eventNames.silentLoginAsync_error, { reason: 'timeout' });
320
+ iframe.remove();
321
+ isResolved = true;
322
+ reject(new Error('timeout'));
323
+ }
324
+ }, silentSigninTimeout);
325
+ }
326
+ catch (e) {
327
+ iframe.remove();
328
+ this.publishEvent(eventNames.silentLoginAsync_error, e);
329
+ reject(e);
330
+ }
331
+ });
332
+ }
333
+ catch (e) {
334
+ this.publishEvent(eventNames.silentLoginAsync_error, e);
335
+ throw e;
336
+ }
169
337
  });
170
338
  }
171
339
  initAsync(authority, authorityConfiguration) {
@@ -186,9 +354,9 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
186
354
  issuer: authorityConfiguration.issuer,
187
355
  });
188
356
  }
189
- const serviceWorker = yield (0, initWorker_1.initWorkerAsync)(this.configuration.service_worker_relative_url, this.configurationName);
357
+ const serviceWorker = yield (0, initWorker_1.initWorkerAsync)(this.configuration.service_worker_relative_url, this.configurationName, this.configuration.redirect_uri);
190
358
  const storage = serviceWorker ? window.localStorage : null;
191
- return yield (0, requests_1.fetchFromIssuer)(authority, (_a = this.configuration.authority_time_cache_wellknowurl_in_second) !== null && _a !== void 0 ? _a : 60 * 60, storage);
359
+ return yield fetchFromIssuer(authority, (_a = this.configuration.authority_time_cache_wellknowurl_in_second) !== null && _a !== void 0 ? _a : 60 * 60, storage);
192
360
  });
193
361
  this.initPromise = localFuncAsync();
194
362
  return this.initPromise.then((result) => {
@@ -208,11 +376,11 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
208
376
  if (this.tokens != null) {
209
377
  return false;
210
378
  }
211
- this.publishEvent(events_1.eventNames.tryKeepExistingSessionAsync_begin, {});
379
+ this.publishEvent(eventNames.tryKeepExistingSessionAsync_begin, {});
212
380
  try {
213
381
  const configuration = this.configuration;
214
382
  const oidcServerConfiguration = yield this.initAsync(configuration.authority, configuration.authority_configuration);
215
- serviceWorker = yield (0, initWorker_1.initWorkerAsync)(configuration.service_worker_relative_url, this.configurationName);
383
+ serviceWorker = yield (0, initWorker_1.initWorkerAsync)(configuration.service_worker_relative_url, this.configurationName, configuration.redirect_uri);
216
384
  if (serviceWorker) {
217
385
  const { tokens } = yield serviceWorker.initAsync(oidcServerConfiguration, 'tryKeepExistingSessionAsync', configuration);
218
386
  if (tokens) {
@@ -224,24 +392,24 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
224
392
  const sessionState = yield serviceWorker.getSessionStateAsync();
225
393
  // @ts-ignore
226
394
  yield this.startCheckSessionAsync(oidcServerConfiguration.check_session_iframe, configuration.client_id, sessionState);
227
- this.publishEvent(events_1.eventNames.tryKeepExistingSessionAsync_end, {
395
+ this.publishEvent(eventNames.tryKeepExistingSessionAsync_end, {
228
396
  success: true,
229
397
  message: 'tokens inside ServiceWorker are valid',
230
398
  });
231
399
  return true;
232
400
  }
233
- this.publishEvent(events_1.eventNames.tryKeepExistingSessionAsync_end, {
401
+ this.publishEvent(eventNames.tryKeepExistingSessionAsync_end, {
234
402
  success: false,
235
403
  message: 'no exiting session found',
236
404
  });
237
405
  }
238
406
  else {
239
407
  if (configuration.service_worker_relative_url) {
240
- this.publishEvent(events_1.eventNames.service_worker_not_supported_by_browser, {
408
+ this.publishEvent(eventNames.service_worker_not_supported_by_browser, {
241
409
  message: 'service worker is not supported by this browser',
242
410
  });
243
411
  }
244
- const session = (0, initSession_1.initSession)(this.configurationName, (_a = configuration.storage) !== null && _a !== void 0 ? _a : sessionStorage);
412
+ const session = (0, initSession_1.initSession)(this.configurationName, configuration.redirect_uri, (_a = configuration.storage) !== null && _a !== void 0 ? _a : sessionStorage);
245
413
  const { tokens } = yield session.initAsync();
246
414
  if (tokens) {
247
415
  // @ts-ignore
@@ -251,14 +419,14 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
251
419
  const sessionState = session.getSessionState();
252
420
  // @ts-ignore
253
421
  yield this.startCheckSessionAsync(oidcServerConfiguration.check_session_iframe, configuration.client_id, sessionState);
254
- this.publishEvent(events_1.eventNames.tryKeepExistingSessionAsync_end, {
422
+ this.publishEvent(eventNames.tryKeepExistingSessionAsync_end, {
255
423
  success: true,
256
424
  message: 'tokens inside storage are valid',
257
425
  });
258
426
  return true;
259
427
  }
260
428
  }
261
- this.publishEvent(events_1.eventNames.tryKeepExistingSessionAsync_end, {
429
+ this.publishEvent(eventNames.tryKeepExistingSessionAsync_end, {
262
430
  success: false,
263
431
  message: serviceWorker ? 'service worker sessions not retrieved' : 'session storage sessions not retrieved',
264
432
  });
@@ -269,7 +437,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
269
437
  if (serviceWorker) {
270
438
  yield serviceWorker.clearAsync();
271
439
  }
272
- this.publishEvent(events_1.eventNames.tryKeepExistingSessionAsync_error, 'tokens inside ServiceWorker are invalid');
440
+ this.publishEvent(eventNames.tryKeepExistingSessionAsync_error, 'tokens inside ServiceWorker are invalid');
273
441
  return false;
274
442
  }
275
443
  });
@@ -280,27 +448,145 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
280
448
  });
281
449
  });
282
450
  }
283
- startCheckSessionAsync(checkSessionIFrameUri, clientId, sessionState, isSilentSignin = false) {
284
- return __awaiter(this, void 0, void 0, function* () {
285
- const getCurrentTokens = () => this.tokens;
286
- this.checkSessionIFrame = yield (0, checkSession_1.startCheckSessionAsync)(oidcDatabase, this.configuration, this.checkSessionIFrame, this.silentLoginAsync.bind(this), getCurrentTokens)(checkSessionIFrameUri, clientId, sessionState, isSilentSignin);
287
- });
288
- }
289
451
  loginAsync(callbackPath = undefined, extras = null, isSilentSignin = false, scope = undefined, silentLoginOnly = false) {
290
452
  return __awaiter(this, void 0, void 0, function* () {
291
453
  if (this.loginPromise !== null) {
292
454
  return this.loginPromise;
293
455
  }
294
- if (silentLoginOnly) {
295
- return (0, login_1.defaultSilentLoginAsync2)(window, this.configurationName, this.configuration, this.publishEvent.bind(this), this)(extras, scope);
296
- }
297
- this.loginPromise = (0, login_1.defaultLoginAsync)(window, this.configurationName, this.configuration, this.silentLoginAsync.bind(this), this.publishEvent.bind(this), this.initAsync.bind(this))(callbackPath, extras, isSilentSignin, scope);
456
+ const loginLocalAsync = () => __awaiter(this, void 0, void 0, function* () {
457
+ var _a, _b;
458
+ const location = window.location;
459
+ const url = callbackPath || location.pathname + (location.search || '') + (location.hash || '');
460
+ const configuration = this.configuration;
461
+ let state;
462
+ if (extras && 'state' in extras) {
463
+ state = extras.state;
464
+ delete extras.state;
465
+ }
466
+ if (silentLoginOnly) {
467
+ try {
468
+ const extraFinal = (_a = extras !== null && extras !== void 0 ? extras : configuration.extras) !== null && _a !== void 0 ? _a : {};
469
+ const silentResult = yield this.silentLoginAsync(Object.assign(Object.assign({}, extraFinal), { prompt: 'none' }), state, scope);
470
+ if (silentResult) {
471
+ this.tokens = silentResult.tokens;
472
+ this.publishEvent(eventNames.token_aquired, {});
473
+ // @ts-ignore
474
+ this.timeoutId = autoRenewTokens(this, this.tokens.refreshToken, this.tokens.expiresAt, extras);
475
+ return {};
476
+ }
477
+ }
478
+ catch (e) {
479
+ return e;
480
+ }
481
+ }
482
+ this.publishEvent(eventNames.loginAsync_begin, {});
483
+ try {
484
+ const redirectUri = isSilentSignin ? configuration.silent_redirect_uri : configuration.redirect_uri;
485
+ if (!scope) {
486
+ scope = configuration.scope;
487
+ }
488
+ const extraFinal = (_b = extras !== null && extras !== void 0 ? extras : configuration.extras) !== null && _b !== void 0 ? _b : {};
489
+ if (!extraFinal.nonce) {
490
+ extraFinal.nonce = randomString(12);
491
+ }
492
+ const nonce = { nonce: extraFinal.nonce };
493
+ const serviceWorker = yield (0, initWorker_1.initWorkerAsync)(configuration.service_worker_relative_url, this.configurationName, this.configuration.redirect_uri);
494
+ const oidcServerConfiguration = yield this.initAsync(configuration.authority, configuration.authority_configuration);
495
+ let storage;
496
+ if (serviceWorker) {
497
+ serviceWorker.setLoginParams(this.configurationName, redirectUri, { callbackPath: url, extras, state });
498
+ serviceWorker.startKeepAliveServiceWorker();
499
+ yield serviceWorker.initAsync(oidcServerConfiguration, 'loginAsync', configuration);
500
+ yield serviceWorker.setNonceAsync(nonce);
501
+ storage = new memoryStorageBackend_1.MemoryStorageBackend(serviceWorker.saveItemsAsync, {});
502
+ yield storage.setItem('dummy', {});
503
+ }
504
+ else {
505
+ const session = (0, initSession_1.initSession)(this.configurationName, redirectUri);
506
+ session.setLoginParams(this.configurationName, redirectUri, { callbackPath: url, extras, state });
507
+ yield session.setNonceAsync(nonce);
508
+ storage = new memoryStorageBackend_1.MemoryStorageBackend(session.saveItemsAsync, {});
509
+ }
510
+ // @ts-ignore
511
+ const queryStringUtil = redirectUri.includes('#') ? new noHashQueryStringUtils_1.HashQueryStringUtils() : new noHashQueryStringUtils_1.NoHashQueryStringUtils();
512
+ const authorizationHandler = new appauth_1.RedirectRequestHandler(storage, queryStringUtil, window.location, new appauth_1.DefaultCrypto());
513
+ const authRequest = new appauth_1.AuthorizationRequest({
514
+ client_id: configuration.client_id,
515
+ redirect_uri: redirectUri,
516
+ scope,
517
+ response_type: appauth_1.AuthorizationRequest.RESPONSE_TYPE_CODE,
518
+ state,
519
+ extras: extraFinal,
520
+ });
521
+ authorizationHandler.performAuthorizationRequest(oidcServerConfiguration, authRequest);
522
+ }
523
+ catch (exception) {
524
+ this.publishEvent(eventNames.loginAsync_error, exception);
525
+ throw exception;
526
+ }
527
+ });
528
+ this.loginPromise = loginLocalAsync();
298
529
  return this.loginPromise.then(result => {
299
530
  this.loginPromise = null;
300
531
  return result;
301
532
  });
302
533
  });
303
534
  }
535
+ startCheckSessionAsync(checkSessionIFrameUri, clientId, sessionState, isSilentSignin = false) {
536
+ return __awaiter(this, void 0, void 0, function* () {
537
+ return new Promise((resolve, reject) => {
538
+ if (this.configuration.silent_login_uri && this.configuration.silent_redirect_uri && this.configuration.monitor_session && checkSessionIFrameUri && sessionState && !isSilentSignin) {
539
+ const checkSessionCallback = () => {
540
+ this.checkSessionIFrame.stop();
541
+ if (this.tokens === null) {
542
+ return;
543
+ }
544
+ // @ts-ignore
545
+ const idToken = this.tokens.idToken;
546
+ // @ts-ignore
547
+ const idTokenPayload = this.tokens.idTokenPayload;
548
+ this.silentLoginAsync({
549
+ prompt: 'none',
550
+ id_token_hint: idToken,
551
+ scope: 'openid',
552
+ }).then((silentSigninResponse) => {
553
+ const iFrameIdTokenPayload = silentSigninResponse.tokens.idTokenPayload;
554
+ if (idTokenPayload.sub === iFrameIdTokenPayload.sub) {
555
+ const sessionState = silentSigninResponse.sessionState;
556
+ this.checkSessionIFrame.start(silentSigninResponse.sessionState);
557
+ if (idTokenPayload.sid === iFrameIdTokenPayload.sid) {
558
+ console.debug('SessionMonitor._callback: Same sub still logged in at OP, restarting check session iframe; session_state:', sessionState);
559
+ }
560
+ else {
561
+ console.debug('SessionMonitor._callback: Same sub still logged in at OP, session state has changed, restarting check session iframe; session_state:', sessionState);
562
+ }
563
+ }
564
+ else {
565
+ console.debug('SessionMonitor._callback: Different subject signed into OP:', iFrameIdTokenPayload.sub);
566
+ }
567
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
568
+ }).catch((e) => __awaiter(this, void 0, void 0, function* () {
569
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
570
+ for (const [key, oidc] of Object.entries(oidcDatabase)) {
571
+ // @ts-ignore
572
+ yield oidc.logoutOtherTabAsync(this.configuration.client_id, idTokenPayload.sub);
573
+ }
574
+ }));
575
+ };
576
+ this.checkSessionIFrame = new checkSessionIFrame_1.CheckSessionIFrame(checkSessionCallback, clientId, checkSessionIFrameUri);
577
+ this.checkSessionIFrame.load().then(() => {
578
+ this.checkSessionIFrame.start(sessionState);
579
+ resolve();
580
+ }).catch((e) => {
581
+ reject(e);
582
+ });
583
+ }
584
+ else {
585
+ resolve();
586
+ }
587
+ });
588
+ });
589
+ }
304
590
  loginCallbackAsync(isSilenSignin = false) {
305
591
  return __awaiter(this, void 0, void 0, function* () {
306
592
  if (this.loginCallbackPromise !== null) {
@@ -312,9 +598,9 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
312
598
  const parsedTokens = response.tokens;
313
599
  // @ts-ignore
314
600
  this.tokens = response.tokens;
315
- const serviceWorker = yield (0, initWorker_1.initWorkerAsync)(this.configuration.service_worker_relative_url, this.configurationName);
601
+ const serviceWorker = yield (0, initWorker_1.initWorkerAsync)(this.configuration.service_worker_relative_url, this.configurationName, this.configuration.redirect_uri);
316
602
  if (!serviceWorker) {
317
- const session = (0, initSession_1.initSession)(this.configurationName, this.configuration.storage);
603
+ const session = (0, initSession_1.initSession)(this.configurationName, this.configuration.redirect_uri, this.configuration.storage);
318
604
  session.setTokens(parsedTokens);
319
605
  }
320
606
  this.publishEvent(Oidc.eventNames.token_aquired, parsedTokens);
@@ -331,7 +617,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
331
617
  _loginCallbackAsync(isSilentSignin = false) {
332
618
  return __awaiter(this, void 0, void 0, function* () {
333
619
  try {
334
- this.publishEvent(events_1.eventNames.loginCallbackAsync_begin, {});
620
+ this.publishEvent(eventNames.loginCallbackAsync_begin, {});
335
621
  const configuration = this.configuration;
336
622
  const clientId = configuration.client_id;
337
623
  const redirectUri = isSilentSignin ? configuration.silent_redirect_uri : configuration.redirect_uri;
@@ -340,10 +626,9 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
340
626
  const oidcServerConfiguration = yield this.initAsync(authority, configuration.authority_configuration);
341
627
  const queryParams = (0, route_utils_1.getParseQueryStringFromLocation)(window.location.href);
342
628
  const sessionState = queryParams.session_state;
343
- const serviceWorker = yield (0, initWorker_1.initWorkerAsync)(configuration.service_worker_relative_url, this.configurationName);
629
+ const serviceWorker = yield (0, initWorker_1.initWorkerAsync)(configuration.service_worker_relative_url, this.configurationName, configuration.redirect_uri);
344
630
  let storage = null;
345
631
  let nonceData = null;
346
- let getLoginParams = null;
347
632
  if (serviceWorker) {
348
633
  serviceWorker.startKeepAliveServiceWorker();
349
634
  yield serviceWorker.initAsync(oidcServerConfiguration, 'loginCallbackAsync', configuration);
@@ -356,15 +641,13 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
356
641
  yield storage.removeItem('dummy');
357
642
  yield serviceWorker.setSessionStateAsync(sessionState);
358
643
  nonceData = yield serviceWorker.getNonceAsync();
359
- getLoginParams = serviceWorker.getLoginParams(this.configurationName);
360
644
  }
361
645
  else {
362
- const session = (0, initSession_1.initSession)(this.configurationName);
646
+ const session = (0, initSession_1.initSession)(this.configurationName, redirectUri);
363
647
  session.setSessionState(sessionState);
364
648
  const items = yield session.loadItemsAsync();
365
649
  storage = new memoryStorageBackend_1.MemoryStorageBackend(session.saveItemsAsync, items);
366
650
  nonceData = yield session.getNonceAsync();
367
- getLoginParams = session.getLoginParams(this.configurationName);
368
651
  }
369
652
  return new Promise((resolve, reject) => {
370
653
  let queryStringUtil = new noHashQueryStringUtils_1.NoHashQueryStringUtils();
@@ -378,7 +661,6 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
378
661
  const notifier = new appauth_1.AuthorizationNotifier();
379
662
  authorizationHandler.setAuthorizationNotifier(notifier);
380
663
  notifier.setAuthorizationListener((request, response, error) => {
381
- var _a;
382
664
  if (error) {
383
665
  reject(error);
384
666
  return;
@@ -387,27 +669,20 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
387
669
  reject(new Error('no response'));
388
670
  return;
389
671
  }
390
- const extras = {};
672
+ let extras = null;
391
673
  if (request && request.internal) {
392
- // @ts-ignore
674
+ extras = {};
393
675
  extras.code_verifier = request.internal.code_verifier;
394
676
  if (configuration.token_request_extras) {
395
677
  for (const [key, value] of Object.entries(configuration.token_request_extras)) {
396
678
  extras[key] = value;
397
679
  }
398
680
  }
399
- if (getLoginParams && getLoginParams.extras) {
400
- for (const [key, value] of Object.entries(getLoginParams.extras)) {
401
- if (key.endsWith(':token_request')) {
402
- extras[key.replace(':token_request', '')] = value;
403
- }
404
- }
405
- }
406
681
  }
407
682
  const tokenRequest = new appauth_1.TokenRequest({
408
683
  client_id: clientId,
409
684
  redirect_uri: redirectUri,
410
- grant_type: (_a = extras.grant_type) !== null && _a !== void 0 ? _a : appauth_1.GRANT_TYPE_AUTHORIZATION_CODE,
685
+ grant_type: appauth_1.GRANT_TYPE_AUTHORIZATION_CODE,
411
686
  code: response.code,
412
687
  refresh_token: undefined,
413
688
  extras,
@@ -426,12 +701,12 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
426
701
  let formattedTokens = null;
427
702
  if (serviceWorker) {
428
703
  const { tokens } = yield serviceWorker.initAsync(oidcServerConfiguration, 'syncTokensAsync', configuration);
429
- loginParams = serviceWorker.getLoginParams(this.configurationName);
704
+ loginParams = serviceWorker.getLoginParams(this.configurationName, redirectUri);
430
705
  formattedTokens = tokens;
431
706
  }
432
707
  else {
433
- const session = (0, initSession_1.initSession)(this.configurationName, configuration.storage);
434
- loginParams = session.getLoginParams(this.configurationName);
708
+ const session = (0, initSession_1.initSession)(this.configurationName, redirectUri, configuration.storage);
709
+ loginParams = session.getLoginParams(this.configurationName, redirectUri);
435
710
  formattedTokens = (0, parseTokens_1.setTokens)(tokenResponse, null, configuration.token_renew_mode);
436
711
  }
437
712
  if (!(0, parseTokens_1.isTokensOidcValid)(formattedTokens, nonceData.nonce, oidcServerConfiguration)) {
@@ -439,13 +714,13 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
439
714
  if (timeoutId) {
440
715
  clearTimeout(timeoutId);
441
716
  this.timeoutId = null;
442
- this.publishEvent(events_1.eventNames.loginCallbackAsync_error, exception);
717
+ this.publishEvent(eventNames.loginCallbackAsync_error, exception);
443
718
  console.error(exception);
444
719
  reject(exception);
445
720
  }
446
721
  }
447
722
  this.startCheckSessionAsync(oidcServerConfiguration.check_session_iframe, clientId, sessionState, isSilentSignin).then(() => {
448
- this.publishEvent(events_1.eventNames.loginCallbackAsync_end, {});
723
+ this.publishEvent(eventNames.loginCallbackAsync_end, {});
449
724
  resolve({
450
725
  tokens: formattedTokens,
451
726
  state: request.state,
@@ -459,7 +734,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
459
734
  if (timeoutId) {
460
735
  clearTimeout(timeoutId);
461
736
  this.timeoutId = null;
462
- this.publishEvent(events_1.eventNames.loginCallbackAsync_error, exception);
737
+ this.publishEvent(eventNames.loginCallbackAsync_error, exception);
463
738
  console.error(exception);
464
739
  reject(exception);
465
740
  }
@@ -470,7 +745,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
470
745
  }
471
746
  catch (exception) {
472
747
  console.error(exception);
473
- this.publishEvent(events_1.eventNames.loginCallbackAsync_error, exception);
748
+ this.publishEvent(eventNames.loginCallbackAsync_error, exception);
474
749
  throw exception;
475
750
  }
476
751
  });
@@ -479,19 +754,19 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
479
754
  return __awaiter(this, void 0, void 0, function* () {
480
755
  while (!navigator.onLine && document.hidden) {
481
756
  yield (0, initWorker_1.sleepAsync)(1000);
482
- this.publishEvent(events_1.eventNames.refreshTokensAsync, { message: 'wait because navigator is offline and hidden' });
757
+ this.publishEvent(eventNames.refreshTokensAsync, { message: 'wait because navigator is offline and hidden' });
483
758
  }
484
759
  let numberTryOnline = 6;
485
760
  while (!navigator.onLine && numberTryOnline > 0) {
486
761
  yield (0, initWorker_1.sleepAsync)(1000);
487
762
  numberTryOnline--;
488
- this.publishEvent(events_1.eventNames.refreshTokensAsync, { message: `wait because navigator is offline try ${numberTryOnline}` });
763
+ this.publishEvent(eventNames.refreshTokensAsync, { message: `wait because navigator is offline try ${numberTryOnline}` });
489
764
  }
490
765
  let numberTryHidden = Math.floor(Math.random() * 15) + 10;
491
766
  while (document.hidden && numberTryHidden > 0) {
492
767
  yield (0, initWorker_1.sleepAsync)(1000);
493
768
  numberTryHidden--;
494
- this.publishEvent(events_1.eventNames.refreshTokensAsync, { message: `wait because navigator is hidden try ${numberTryHidden}` });
769
+ this.publishEvent(eventNames.refreshTokensAsync, { message: `wait because navigator is hidden try ${numberTryHidden}` });
495
770
  }
496
771
  const isDocumentHidden = document.hidden;
497
772
  const nextIndex = isDocumentHidden ? index : index + 1;
@@ -502,13 +777,13 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
502
777
  const localsilentLoginAsync = () => __awaiter(this, void 0, void 0, function* () {
503
778
  try {
504
779
  let loginParams = null;
505
- const serviceWorker = yield (0, initWorker_1.initWorkerAsync)(configuration.service_worker_relative_url, this.configurationName);
780
+ const serviceWorker = yield (0, initWorker_1.initWorkerAsync)(configuration.service_worker_relative_url, this.configurationName, configuration.redirect_uri);
506
781
  if (serviceWorker) {
507
- loginParams = serviceWorker.getLoginParams(this.configurationName);
782
+ loginParams = serviceWorker.getLoginParams(this.configurationName, configuration.redirect_uri);
508
783
  }
509
784
  else {
510
- const session = (0, initSession_1.initSession)(this.configurationName, configuration.storage);
511
- loginParams = session.getLoginParams(this.configurationName);
785
+ const session = (0, initSession_1.initSession)(this.configurationName, configuration.redirect_uri, configuration.storage);
786
+ loginParams = session.getLoginParams(this.configurationName, configuration.redirect_uri);
512
787
  }
513
788
  const silent_token_response = yield this.silentLoginAsync(Object.assign(Object.assign(Object.assign({}, loginParams.extras), extras), { prompt: 'none' }), loginParams.state);
514
789
  if (silent_token_response) {
@@ -519,18 +794,18 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
519
794
  }
520
795
  catch (exceptionSilent) {
521
796
  console.error(exceptionSilent);
522
- this.publishEvent(events_1.eventNames.refreshTokensAsync_silent_error, { message: 'exceptionSilent', exception: exceptionSilent.message });
797
+ this.publishEvent(eventNames.refreshTokensAsync_silent_error, { message: 'exceptionSilent', exception: exceptionSilent.message });
523
798
  if (exceptionSilent && exceptionSilent.message && exceptionSilent.message.startsWith('oidc')) {
524
799
  updateTokens(null);
525
- this.publishEvent(events_1.eventNames.refreshTokensAsync_error, { message: 'refresh token silent' });
800
+ this.publishEvent(eventNames.refreshTokensAsync_error, { message: 'refresh token silent' });
526
801
  return { tokens: null, status: 'SESSION_LOST' };
527
802
  }
528
803
  }
529
- this.publishEvent(events_1.eventNames.refreshTokensAsync_error, { message: 'refresh token silent return' });
804
+ this.publishEvent(eventNames.refreshTokensAsync_error, { message: 'refresh token silent return' });
530
805
  return yield this.synchroniseTokensAsync(null, nextIndex, forceRefresh, extras, updateTokens);
531
806
  });
532
807
  if (index > 4) {
533
- this.publishEvent(events_1.eventNames.refreshTokensAsync_error, { message: 'refresh token' });
808
+ this.publishEvent(eventNames.refreshTokensAsync_error, { message: 'refresh token' });
534
809
  return { tokens: null, status: 'SESSION_LOST' };
535
810
  }
536
811
  try {
@@ -538,7 +813,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
538
813
  switch (status) {
539
814
  case 'SESSION_LOST':
540
815
  updateTokens(null);
541
- this.publishEvent(events_1.eventNames.refreshTokensAsync_error, { message: 'refresh token session lost' });
816
+ this.publishEvent(eventNames.refreshTokensAsync_error, { message: 'refresh token session lost' });
542
817
  return { tokens: null, status: 'SESSION_LOST' };
543
818
  case 'NOT_CONNECTED':
544
819
  updateTokens(null);
@@ -552,13 +827,13 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
552
827
  return { tokens, status: 'LOGGED_IN' };
553
828
  case 'LOGOUT_FROM_ANOTHER_TAB':
554
829
  updateTokens(null);
555
- this.publishEvent(events_1.eventNames.logout_from_another_tab, { status: 'session syncTokensAsync' });
830
+ this.publishEvent(eventNames.logout_from_another_tab, { status: 'session syncTokensAsync' });
556
831
  return { tokens: null, status: 'LOGGED_OUT' };
557
832
  case 'REQUIRE_SYNC_TOKENS':
558
- this.publishEvent(events_1.eventNames.refreshTokensAsync_begin, { refreshToken, status, tryNumber: index });
833
+ this.publishEvent(eventNames.refreshTokensAsync_begin, { refreshToken, status, tryNumber: index });
559
834
  return yield localsilentLoginAsync();
560
835
  default: {
561
- this.publishEvent(events_1.eventNames.refreshTokensAsync_begin, { refreshToken, status, tryNumber: index });
836
+ this.publishEvent(eventNames.refreshTokensAsync_begin, { refreshToken, status, tryNumber: index });
562
837
  if (!refreshToken) {
563
838
  return yield localsilentLoginAsync();
564
839
  }
@@ -580,16 +855,16 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
580
855
  if (tokenResponse.success) {
581
856
  if (!(0, parseTokens_1.isTokensOidcValid)(tokenResponse.data, nonce.nonce, oidcServerConfiguration)) {
582
857
  updateTokens(null);
583
- this.publishEvent(events_1.eventNames.refreshTokensAsync_error, { message: 'refresh token return not valid tokens' });
858
+ this.publishEvent(eventNames.refreshTokensAsync_error, { message: 'refresh token return not valid tokens' });
584
859
  return { tokens: null, status: 'SESSION_LOST' };
585
860
  }
586
861
  updateTokens(tokenResponse.data);
587
- this.publishEvent(events_1.eventNames.refreshTokensAsync_end, { success: tokenResponse.success });
862
+ this.publishEvent(eventNames.refreshTokensAsync_end, { success: tokenResponse.success });
588
863
  this.publishEvent(Oidc.eventNames.token_renewed, { reason: 'REFRESH_TOKEN' });
589
864
  return { tokens: tokenResponse.data, status: 'LOGGED_IN' };
590
865
  }
591
866
  else {
592
- this.publishEvent(events_1.eventNames.refreshTokensAsync_silent_error, {
867
+ this.publishEvent(eventNames.refreshTokensAsync_silent_error, {
593
868
  message: 'bad request',
594
869
  tokenResponse,
595
870
  });
@@ -603,7 +878,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
603
878
  }
604
879
  catch (exception) {
605
880
  console.error(exception);
606
- this.publishEvent(events_1.eventNames.refreshTokensAsync_silent_error, { message: 'exception', exception: exception.message });
881
+ this.publishEvent(eventNames.refreshTokensAsync_silent_error, { message: 'exception', exception: exception.message });
607
882
  return this.synchroniseTokensAsync(refreshToken, nextIndex, forceRefresh, extras, updateTokens);
608
883
  }
609
884
  });
@@ -619,7 +894,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
619
894
  }
620
895
  let nonce = nullNonce;
621
896
  const oidcServerConfiguration = yield this.initAsync(configuration.authority, configuration.authority_configuration);
622
- const serviceWorker = yield (0, initWorker_1.initWorkerAsync)(configuration.service_worker_relative_url, configurationName);
897
+ const serviceWorker = yield (0, initWorker_1.initWorkerAsync)(configuration.service_worker_relative_url, configurationName, configuration.redirect_uri);
623
898
  if (serviceWorker) {
624
899
  const { status, tokens } = yield serviceWorker.initAsync(oidcServerConfiguration, 'syncTokensAsync', configuration);
625
900
  if (status === 'LOGGED_OUT') {
@@ -640,7 +915,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
640
915
  nonce = yield serviceWorker.getNonceAsync();
641
916
  }
642
917
  else {
643
- const session = (0, initSession_1.initSession)(configurationName, (_a = configuration.storage) !== null && _a !== void 0 ? _a : sessionStorage);
918
+ const session = (0, initSession_1.initSession)(configurationName, configuration.redirect_uri, (_a = configuration.storage) !== null && _a !== void 0 ? _a : sessionStorage);
644
919
  const { tokens, status } = yield session.initAsync();
645
920
  if (!tokens) {
646
921
  return { tokens: null, status: 'LOGOUT_FROM_ANOTHER_TAB', nonce: nullNonce };
@@ -678,7 +953,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
678
953
  if (this.userInfoPromise !== null) {
679
954
  return this.userInfoPromise;
680
955
  }
681
- this.userInfoPromise = (0, user_1.userInfoAsync)(this);
956
+ this.userInfoPromise = userInfoAsync(this);
682
957
  return this.userInfoPromise.then(result => {
683
958
  this.userInfoPromise = null;
684
959
  return result;
@@ -701,9 +976,9 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
701
976
  if (this.checkSessionIFrame) {
702
977
  this.checkSessionIFrame.stop();
703
978
  }
704
- const serviceWorker = yield (0, initWorker_1.initWorkerAsync)(this.configuration.service_worker_relative_url, this.configurationName);
979
+ const serviceWorker = yield (0, initWorker_1.initWorkerAsync)(this.configuration.service_worker_relative_url, this.configurationName, this.configuration.redirect_uri);
705
980
  if (!serviceWorker) {
706
- const session = (0, initSession_1.initSession)(this.configurationName, this.configuration.storage);
981
+ const session = (0, initSession_1.initSession)(this.configurationName, this.configuration.redirect_uri, this.configuration.storage);
707
982
  yield session.clearAsync(status);
708
983
  }
709
984
  else {
@@ -718,7 +993,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
718
993
  return __awaiter(this, void 0, void 0, function* () {
719
994
  // @ts-ignore
720
995
  if (this.configuration.monitor_session && this.configuration.client_id === clientId && sub && this.tokens && this.tokens.idTokenPayload && this.tokens.idTokenPayload.sub === sub) {
721
- this.publishEvent(events_1.eventNames.logout_from_same_tab, { message: sub });
996
+ this.publishEvent(eventNames.logout_from_same_tab, { message: sub });
722
997
  yield this.destroyAsync('LOGGED_OUT');
723
998
  }
724
999
  });
@@ -728,7 +1003,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
728
1003
  // @ts-ignore
729
1004
  if (this.configuration.monitor_session && this.configuration.client_id === clientId && sub && this.tokens && this.tokens.idTokenPayload && this.tokens.idTokenPayload.sub === sub) {
730
1005
  yield this.destroyAsync('LOGGED_OUT');
731
- this.publishEvent(events_1.eventNames.logout_from_another_tab, { message: 'SessionMonitor', sub });
1006
+ this.publishEvent(eventNames.logout_from_another_tab, { message: 'SessionMonitor', sub });
732
1007
  }
733
1008
  });
734
1009
  }
@@ -808,6 +1083,6 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
808
1083
  }
809
1084
  }
810
1085
  exports.Oidc = Oidc;
811
- Oidc.eventNames = events_1.eventNames;
1086
+ Oidc.eventNames = eventNames;
812
1087
  exports.default = Oidc;
813
1088
  //# sourceMappingURL=oidc.js.map