@axa-fr/react-oidc 5.12.0 → 5.13.1

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.
@@ -103,82 +103,74 @@ var oidcFactory = function (configuration, name) {
103
103
  return oidcDatabase[name];
104
104
  };
105
105
  var loginCallbackWithAutoTokensRenewAsync = function (oidc) { return __awaiter(void 0, void 0, void 0, function () {
106
- var response, tokens, _a, _b;
107
- return __generator(this, function (_c) {
108
- switch (_c.label) {
106
+ var response, tokens, _a;
107
+ return __generator(this, function (_b) {
108
+ switch (_b.label) {
109
109
  case 0: return [4 /*yield*/, oidc.loginCallbackAsync()];
110
110
  case 1:
111
- response = _c.sent();
111
+ response = _b.sent();
112
112
  tokens = response.tokens;
113
113
  _a = oidc;
114
114
  return [4 /*yield*/, setTokensAsync(oidc.serviceWorker, tokens)];
115
115
  case 2:
116
- _a.tokens = _c.sent();
116
+ _a.tokens = _b.sent();
117
117
  if (!!oidc.serviceWorker) return [3 /*break*/, 4];
118
118
  return [4 /*yield*/, oidc.session.setTokens(oidc.tokens)];
119
119
  case 3:
120
- _c.sent();
121
- _c.label = 4;
120
+ _b.sent();
121
+ _b.label = 4;
122
122
  case 4:
123
123
  oidc.publishEvent(Oidc.eventNames.token_aquired, oidc.tokens);
124
- _b = oidc;
125
- return [4 /*yield*/, autoRenewTokensAsync(oidc, tokens.refreshToken, oidc.tokens.expiresAt)];
126
- case 5:
127
- _b.timeoutId = _c.sent();
124
+ oidc.timeoutId = autoRenewTokens(oidc, tokens.refreshToken, oidc.tokens.expiresAt);
128
125
  return [2 /*return*/, { state: response.state, callbackPath: response.callbackPath }];
129
126
  }
130
127
  });
131
128
  }); };
132
- var autoRenewTokensAsync = function (oidc, refreshToken, expiresAt) { return __awaiter(void 0, void 0, void 0, function () {
133
- var refreshTimeBeforeTokensExpirationInSecond;
129
+ var autoRenewTokens = function (oidc, refreshToken, expiresAt) {
134
130
  var _a;
135
- return __generator(this, function (_b) {
136
- refreshTimeBeforeTokensExpirationInSecond = (_a = oidc.configuration.refresh_time_before_tokens_expiration_in_second) !== null && _a !== void 0 ? _a : 60;
137
- return [2 /*return*/, timer_1.default.setTimeout(function () { return __awaiter(void 0, void 0, void 0, function () {
138
- var currentTimeUnixSecond, timeInfo, tokens, _a, _b, _c;
139
- return __generator(this, function (_d) {
140
- switch (_d.label) {
141
- case 0:
142
- currentTimeUnixSecond = new Date().getTime() / 1000;
143
- timeInfo = { timeLeft: ((expiresAt - refreshTimeBeforeTokensExpirationInSecond) - currentTimeUnixSecond) };
144
- oidc.publishEvent(Oidc.eventNames.token_timer, timeInfo);
145
- if (!(currentTimeUnixSecond > (expiresAt - refreshTimeBeforeTokensExpirationInSecond))) return [3 /*break*/, 6];
146
- return [4 /*yield*/, oidc.refreshTokensAsync(refreshToken)];
147
- case 1:
148
- tokens = _d.sent();
149
- _a = oidc;
150
- return [4 /*yield*/, setTokensAsync(oidc.serviceWorker, tokens)];
151
- case 2:
152
- _a.tokens = _d.sent();
153
- if (!!oidc.serviceWorker) return [3 /*break*/, 4];
154
- return [4 /*yield*/, oidc.session.setTokens(oidc.tokens)];
155
- case 3:
156
- _d.sent();
157
- _d.label = 4;
158
- case 4:
159
- if (!oidc.tokens) {
160
- return [2 /*return*/];
161
- }
162
- oidc.publishEvent(Oidc.eventNames.token_renewed, oidc.tokens);
163
- _b = oidc;
164
- return [4 /*yield*/, autoRenewTokensAsync(oidc, tokens.refreshToken, oidc.tokens.expiresAt)];
165
- case 5:
166
- _b.timeoutId = _d.sent();
167
- return [3 /*break*/, 9];
168
- case 6: return [4 /*yield*/, oidc.syncTokensAsync()];
169
- case 7:
170
- _d.sent();
171
- _c = oidc;
172
- return [4 /*yield*/, autoRenewTokensAsync(oidc, refreshToken, expiresAt)];
173
- case 8:
174
- _c.timeoutId = _d.sent();
175
- _d.label = 9;
176
- case 9: return [2 /*return*/];
131
+ var refreshTimeBeforeTokensExpirationInSecond = (_a = oidc.configuration.refresh_time_before_tokens_expiration_in_second) !== null && _a !== void 0 ? _a : 60;
132
+ return timer_1.default.setTimeout(function () { return __awaiter(void 0, void 0, void 0, function () {
133
+ var currentTimeUnixSecond, timeInfo, tokens, _a;
134
+ return __generator(this, function (_b) {
135
+ switch (_b.label) {
136
+ case 0:
137
+ currentTimeUnixSecond = new Date().getTime() / 1000;
138
+ timeInfo = { timeLeft: Math.round(((expiresAt - refreshTimeBeforeTokensExpirationInSecond) - currentTimeUnixSecond)) };
139
+ oidc.publishEvent(Oidc.eventNames.token_timer, timeInfo);
140
+ if (!(currentTimeUnixSecond > (expiresAt - refreshTimeBeforeTokensExpirationInSecond))) return [3 /*break*/, 5];
141
+ return [4 /*yield*/, oidc.refreshTokensAsync(refreshToken)];
142
+ case 1:
143
+ tokens = _b.sent();
144
+ _a = oidc;
145
+ return [4 /*yield*/, setTokensAsync(oidc.serviceWorker, tokens)];
146
+ case 2:
147
+ _a.tokens = _b.sent();
148
+ if (!!oidc.serviceWorker) return [3 /*break*/, 4];
149
+ return [4 /*yield*/, oidc.session.setTokens(oidc.tokens)];
150
+ case 3:
151
+ _b.sent();
152
+ _b.label = 4;
153
+ case 4:
154
+ if (!oidc.tokens) {
155
+ return [2 /*return*/];
177
156
  }
178
- });
179
- }); }, 1000)];
180
- });
181
- }); };
157
+ oidc.publishEvent(Oidc.eventNames.token_renewed, oidc.tokens);
158
+ if (oidc.timeoutId) {
159
+ oidc.timeoutId = autoRenewTokens(oidc, tokens.refreshToken, oidc.tokens.expiresAt);
160
+ }
161
+ return [3 /*break*/, 7];
162
+ case 5: return [4 /*yield*/, oidc.syncTokensAsync()];
163
+ case 6:
164
+ _b.sent();
165
+ if (oidc.timeoutId) {
166
+ oidc.timeoutId = autoRenewTokens(oidc, refreshToken, expiresAt);
167
+ }
168
+ _b.label = 7;
169
+ case 7: return [2 /*return*/];
170
+ }
171
+ });
172
+ }); }, 1000);
173
+ };
182
174
  var getLoginParams = function (configurationName) {
183
175
  return JSON.parse(sessionStorage["oidc_login.".concat(configurationName)]);
184
176
  };
@@ -280,6 +272,9 @@ var eventNames = {
280
272
  silentSigninAsync_begin: "silentSigninAsync_begin",
281
273
  silentSigninAsync_end: "silentSigninAsync_end",
282
274
  silentSigninAsync_error: "silentSigninAsync_error",
275
+ syncTokensAsync_begin: "syncTokensAsync_begin",
276
+ syncTokensAsync_end: "syncTokensAsync_end",
277
+ syncTokensAsync_error: "syncTokensAsync_error"
283
278
  };
284
279
  var getRandomInt = function (max) {
285
280
  return Math.floor(Math.random() * max);
@@ -287,6 +282,7 @@ var getRandomInt = function (max) {
287
282
  var Oidc = /** @class */ (function () {
288
283
  function Oidc(configuration, configurationName) {
289
284
  if (configurationName === void 0) { configurationName = "default"; }
285
+ this.iFrameSession = {};
290
286
  this.initAsyncPromise = null;
291
287
  this.tryKeepExistingSessionPromise = null;
292
288
  this.syncTokensAsyncPromise = null;
@@ -341,51 +337,59 @@ var Oidc = /** @class */ (function () {
341
337
  };
342
338
  Oidc.prototype.silentSigninAsync = function () {
343
339
  return __awaiter(this, void 0, void 0, function () {
344
- var configuration, link, iframe, self;
340
+ var configuration_1, link, iframe_1, self_1;
345
341
  return __generator(this, function (_a) {
346
342
  if (!this.configuration.silent_redirect_uri) {
347
343
  return [2 /*return*/, Promise.resolve(null)];
348
344
  }
349
- this.publishEvent(eventNames.silentSigninAsync_begin, {});
350
- configuration = this.configuration;
351
- link = configuration.silent_redirect_uri;
352
- iframe = document.createElement('iframe');
353
- iframe.width = "0px";
354
- iframe.height = "0px";
355
- iframe.id = "".concat(this.configurationName, "_oidc_iframe");
356
- iframe.setAttribute("src", link);
357
- document.body.appendChild(iframe);
358
- self = this;
359
- return [2 /*return*/, new Promise(function (resolve, reject) {
360
- try {
361
- var isResolved_1 = false;
362
- window.onmessage = function (e) {
363
- var key = "".concat(self.configurationName, "_oidc_tokens:");
364
- if (e.data && typeof (e.data) === "string" && e.data.startsWith(key)) {
345
+ try {
346
+ this.publishEvent(eventNames.silentSigninAsync_begin, {});
347
+ configuration_1 = this.configuration;
348
+ link = configuration_1.silent_redirect_uri;
349
+ iframe_1 = document.createElement('iframe');
350
+ iframe_1.width = "0px";
351
+ iframe_1.height = "0px";
352
+ iframe_1.id = "".concat(this.configurationName, "_oidc_iframe");
353
+ iframe_1.setAttribute("src", link);
354
+ document.body.appendChild(iframe_1);
355
+ self_1 = this;
356
+ return [2 /*return*/, new Promise(function (resolve, reject) {
357
+ try {
358
+ var isResolved_1 = false;
359
+ window.onmessage = function (e) {
360
+ var key = "".concat(self_1.configurationName, "_oidc_tokens:");
361
+ if (e.data && typeof (e.data) === "string" && e.data.startsWith(key)) {
362
+ if (!isResolved_1) {
363
+ var result = JSON.parse(e.data.replace(key, ''));
364
+ self_1.publishEvent(eventNames.silentSigninAsync_end, result);
365
+ iframe_1.remove();
366
+ isResolved_1 = true;
367
+ resolve(result);
368
+ }
369
+ }
370
+ };
371
+ var silentSigninTimeout = configuration_1.silent_signin_timeout ? configuration_1.silent_signin_timeout : 12000;
372
+ setTimeout(function () {
365
373
  if (!isResolved_1) {
366
- self.publishEvent(eventNames.silentSigninAsync_end, {});
367
- resolve(JSON.parse(e.data.replace(key, '')));
368
- iframe.remove();
374
+ self_1.publishEvent(eventNames.silentSigninAsync_error, "timeout");
375
+ iframe_1.remove();
369
376
  isResolved_1 = true;
377
+ reject("timeout");
370
378
  }
371
- }
372
- };
373
- var silentSigninTimeout = configuration.silent_signin_timeout ? configuration.silent_signin_timeout : 12000;
374
- setTimeout(function () {
375
- if (!isResolved_1) {
376
- reject("timeout");
377
- self.publishEvent(eventNames.silentSigninAsync_error, new Error("timeout"));
378
- iframe.remove();
379
- isResolved_1 = true;
380
- }
381
- }, silentSigninTimeout);
382
- }
383
- catch (e) {
384
- iframe.remove();
385
- reject(e);
386
- self.publishEvent(eventNames.silentSigninAsync_error, e);
387
- }
388
- })];
379
+ }, silentSigninTimeout);
380
+ }
381
+ catch (e) {
382
+ iframe_1.remove();
383
+ self_1.publishEvent(eventNames.silentSigninAsync_error, e);
384
+ reject(e);
385
+ }
386
+ })];
387
+ }
388
+ catch (e) {
389
+ this.publishEvent(eventNames.silentSigninAsync_error, e);
390
+ throw e;
391
+ }
392
+ return [2 /*return*/];
389
393
  });
390
394
  });
391
395
  };
@@ -425,58 +429,54 @@ var Oidc = /** @class */ (function () {
425
429
  return [2 /*return*/, this.tryKeepExistingSessionPromise];
426
430
  }
427
431
  funcAsync = function () { return __awaiter(_this, void 0, void 0, function () {
428
- var serviceWorker, configuration, oidcServerConfiguration, tokens, updatedTokens, _a, _b, session, tokens, updatedTokens, _c, _d, exception_1;
429
- return __generator(this, function (_e) {
430
- switch (_e.label) {
432
+ var serviceWorker, configuration, oidcServerConfiguration, tokens, updatedTokens, _a, session, tokens, updatedTokens, _b, exception_1;
433
+ return __generator(this, function (_c) {
434
+ switch (_c.label) {
431
435
  case 0:
432
436
  if (this.tokens != null) {
433
437
  return [2 /*return*/, false];
434
438
  }
435
439
  this.publishEvent(eventNames.tryKeepExistingSessionAsync_begin, {});
436
- _e.label = 1;
440
+ _c.label = 1;
437
441
  case 1:
438
- _e.trys.push([1, 15, , 18]);
442
+ _c.trys.push([1, 13, , 16]);
439
443
  configuration = this.configuration;
440
444
  return [4 /*yield*/, this.initAsync(configuration.authority, configuration.authority_configuration)];
441
445
  case 2:
442
- oidcServerConfiguration = _e.sent();
446
+ oidcServerConfiguration = _c.sent();
443
447
  return [4 /*yield*/, (0, initWorker_1.initWorkerAsync)(configuration.service_worker_relative_url, this.configurationName)];
444
448
  case 3:
445
- serviceWorker = _e.sent();
446
- if (!serviceWorker) return [3 /*break*/, 9];
449
+ serviceWorker = _c.sent();
450
+ if (!serviceWorker) return [3 /*break*/, 8];
447
451
  return [4 /*yield*/, serviceWorker.initAsync(oidcServerConfiguration, "tryKeepExistingSessionAsync")];
448
452
  case 4:
449
- tokens = (_e.sent()).tokens;
450
- if (!tokens) return [3 /*break*/, 8];
453
+ tokens = (_c.sent()).tokens;
454
+ if (!tokens) return [3 /*break*/, 7];
451
455
  serviceWorker.startKeepAliveServiceWorker();
452
456
  return [4 /*yield*/, this.refreshTokensAsync(tokens.refresh_token, true)];
453
457
  case 5:
454
- updatedTokens = _e.sent();
458
+ updatedTokens = _c.sent();
455
459
  // @ts-ignore
456
460
  _a = this;
457
461
  return [4 /*yield*/, setTokensAsync(serviceWorker, updatedTokens)];
458
462
  case 6:
459
463
  // @ts-ignore
460
- _a.tokens = _e.sent();
464
+ _a.tokens = _c.sent();
461
465
  this.serviceWorker = serviceWorker;
462
466
  // @ts-ignore
463
- _b = this;
464
- return [4 /*yield*/, autoRenewTokensAsync(this, updatedTokens.refreshToken, this.tokens.expiresAt)];
465
- case 7:
466
- // @ts-ignore
467
- _b.timeoutId = _e.sent();
467
+ this.timeoutId = autoRenewTokens(this, updatedTokens.refreshToken, this.tokens.expiresAt);
468
468
  this.publishEvent(eventNames.tryKeepExistingSessionAsync_end, {
469
469
  success: true,
470
470
  message: "tokens inside ServiceWorker are valid"
471
471
  });
472
472
  return [2 /*return*/, true];
473
- case 8:
473
+ case 7:
474
474
  this.publishEvent(eventNames.tryKeepExistingSessionAsync_end, {
475
475
  success: false,
476
476
  message: "no exiting session found"
477
477
  });
478
- return [3 /*break*/, 14];
479
- case 9:
478
+ return [3 /*break*/, 12];
479
+ case 8:
480
480
  if (configuration.service_worker_relative_url) {
481
481
  this.publishEvent(eventNames.service_worker_not_supported_by_browser, {
482
482
  message: "service worker is not supported by this browser"
@@ -484,48 +484,44 @@ var Oidc = /** @class */ (function () {
484
484
  }
485
485
  session = (0, initSession_1.initSession)(this.configurationName);
486
486
  return [4 /*yield*/, session.initAsync()];
487
- case 10:
488
- tokens = (_e.sent()).tokens;
489
- if (!tokens) return [3 /*break*/, 14];
487
+ case 9:
488
+ tokens = (_c.sent()).tokens;
489
+ if (!tokens) return [3 /*break*/, 12];
490
490
  return [4 /*yield*/, this.refreshTokensAsync(tokens.refreshToken, true)];
491
- case 11:
492
- updatedTokens = _e.sent();
491
+ case 10:
492
+ updatedTokens = _c.sent();
493
493
  // @ts-ignore
494
- _c = this;
494
+ _b = this;
495
495
  return [4 /*yield*/, setTokensAsync(serviceWorker, updatedTokens)];
496
- case 12:
496
+ case 11:
497
497
  // @ts-ignore
498
- _c.tokens = _e.sent();
498
+ _b.tokens = _c.sent();
499
499
  session.setTokens(this.tokens);
500
500
  this.session = session;
501
501
  // @ts-ignore
502
- _d = this;
503
- return [4 /*yield*/, autoRenewTokensAsync(this, updatedTokens.refreshToken, this.tokens.expiresAt)];
504
- case 13:
505
- // @ts-ignore
506
- _d.timeoutId = _e.sent();
502
+ this.timeoutId = autoRenewTokens(this, updatedTokens.refreshToken, this.tokens.expiresAt);
507
503
  this.publishEvent(eventNames.tryKeepExistingSessionAsync_end, {
508
504
  success: true,
509
505
  message: "tokens inside ServiceWorker are valid"
510
506
  });
511
507
  return [2 /*return*/, true];
512
- case 14:
508
+ case 12:
513
509
  this.publishEvent(eventNames.tryKeepExistingSessionAsync_end, {
514
510
  success: false,
515
- message: "no service worker"
511
+ message: serviceWorker ? "service worker sessions not retrieved" : "session storage sessions not retrieved"
516
512
  });
517
513
  return [2 /*return*/, false];
518
- case 15:
519
- exception_1 = _e.sent();
520
- if (!serviceWorker) return [3 /*break*/, 17];
514
+ case 13:
515
+ exception_1 = _c.sent();
516
+ if (!serviceWorker) return [3 /*break*/, 15];
521
517
  return [4 /*yield*/, serviceWorker.clearAsync()];
522
- case 16:
523
- _e.sent();
524
- _e.label = 17;
525
- case 17:
518
+ case 14:
519
+ _c.sent();
520
+ _c.label = 15;
521
+ case 15:
526
522
  this.publishEvent(eventNames.tryKeepExistingSessionAsync_error, "tokens inside ServiceWorker are invalid");
527
523
  return [2 /*return*/, false];
528
- case 18: return [2 /*return*/];
524
+ case 16: return [2 /*return*/];
529
525
  }
530
526
  });
531
527
  }); };
@@ -634,10 +630,13 @@ var Oidc = /** @class */ (function () {
634
630
  _b.label = 4;
635
631
  case 4:
636
632
  _b.trys.push([4, 9, , 10]);
633
+ this.publishEvent(eventNames.syncTokensAsync_begin, {});
637
634
  this.syncTokensAsyncPromise = this.silentSigninAsync();
638
635
  return [4 /*yield*/, this.syncTokensAsyncPromise];
639
636
  case 5:
640
637
  silent_token_response = _b.sent();
638
+ console.log("silent_token_response");
639
+ console.log(silent_token_response);
641
640
  if (!silent_token_response) return [3 /*break*/, 7];
642
641
  _a = this;
643
642
  return [4 /*yield*/, setTokensAsync(serviceWorker, silent_token_response)];
@@ -645,16 +644,25 @@ var Oidc = /** @class */ (function () {
645
644
  _a.tokens = _b.sent();
646
645
  return [3 /*break*/, 8];
647
646
  case 7:
648
- this.publishEvent(eventNames.refreshTokensAsync_error, null);
649
- _b.label = 8;
647
+ this.publishEvent(eventNames.syncTokensAsync_error, null);
648
+ if (this.timeoutId) {
649
+ timer_1.default.clearTimeout(this.timeoutId);
650
+ this.timeoutId = null;
651
+ }
652
+ return [2 /*return*/];
650
653
  case 8: return [3 /*break*/, 10];
651
654
  case 9:
652
655
  exceptionSilent_1 = _b.sent();
653
656
  console.error(exceptionSilent_1);
654
- this.publishEvent(eventNames.refreshTokensAsync_error, exceptionSilent_1);
655
- return [3 /*break*/, 10];
657
+ this.publishEvent(eventNames.syncTokensAsync_error, exceptionSilent_1);
658
+ if (this.timeoutId) {
659
+ timer_1.default.clearTimeout(this.timeoutId);
660
+ this.timeoutId = null;
661
+ }
662
+ return [2 /*return*/];
656
663
  case 10:
657
664
  this.syncTokensAsyncPromise = null;
665
+ this.publishEvent(eventNames.syncTokensAsync_end, {});
658
666
  _b.label = 11;
659
667
  case 11: return [2 /*return*/];
660
668
  }
@@ -663,22 +671,22 @@ var Oidc = /** @class */ (function () {
663
671
  };
664
672
  Oidc.prototype.loginCallbackAsync = function () {
665
673
  return __awaiter(this, void 0, void 0, function () {
666
- var configuration_1, clientId_1, redirectURL_1, authority, tokenRequestTimeout_1, oidcServerConfiguration_1, serviceWorker, storage_1, items, dummy, session, items, exception_3;
674
+ var configuration_2, clientId_1, redirectURL_1, authority, tokenRequestTimeout_1, oidcServerConfiguration_1, serviceWorker, storage_1, items, dummy, session, items, exception_3;
667
675
  var _this = this;
668
676
  return __generator(this, function (_a) {
669
677
  switch (_a.label) {
670
678
  case 0:
671
679
  _a.trys.push([0, 10, , 11]);
672
680
  this.publishEvent(eventNames.loginCallbackAsync_begin, {});
673
- configuration_1 = this.configuration;
674
- clientId_1 = configuration_1.client_id;
675
- redirectURL_1 = configuration_1.redirect_uri;
676
- authority = configuration_1.authority;
677
- tokenRequestTimeout_1 = configuration_1.token_request_timeout;
678
- return [4 /*yield*/, this.initAsync(authority, configuration_1.authority_configuration)];
681
+ configuration_2 = this.configuration;
682
+ clientId_1 = configuration_2.client_id;
683
+ redirectURL_1 = configuration_2.redirect_uri;
684
+ authority = configuration_2.authority;
685
+ tokenRequestTimeout_1 = configuration_2.token_request_timeout;
686
+ return [4 /*yield*/, this.initAsync(authority, configuration_2.authority_configuration)];
679
687
  case 1:
680
688
  oidcServerConfiguration_1 = _a.sent();
681
- return [4 /*yield*/, (0, initWorker_1.initWorkerAsync)(configuration_1.service_worker_relative_url, this.configurationName)];
689
+ return [4 /*yield*/, (0, initWorker_1.initWorkerAsync)(configuration_2.service_worker_relative_url, this.configurationName)];
682
690
  case 2:
683
691
  serviceWorker = _a.sent();
684
692
  storage_1 = null;
@@ -712,7 +720,7 @@ var Oidc = /** @class */ (function () {
712
720
  _a.label = 9;
713
721
  case 9: return [2 /*return*/, new Promise(function (resolve, reject) {
714
722
  // @ts-ignore
715
- var queryStringUtil = configuration_1.redirect_uri.includes("#") ? new noHashQueryStringUtils_1.HashQueryStringUtils() : new noHashQueryStringUtils_1.NoHashQueryStringUtils();
723
+ var queryStringUtil = configuration_2.redirect_uri.includes("#") ? new noHashQueryStringUtils_1.HashQueryStringUtils() : new noHashQueryStringUtils_1.NoHashQueryStringUtils();
716
724
  // @ts-ignore
717
725
  var authorizationHandler = new appauth_1.RedirectRequestHandler(storage_1, queryStringUtil, window.location, new appauth_1.DefaultCrypto());
718
726
  var notifier = new appauth_1.AuthorizationNotifier();
@@ -730,8 +738,8 @@ var Oidc = /** @class */ (function () {
730
738
  if (request && request.internal) {
731
739
  extras = {};
732
740
  extras.code_verifier = request.internal.code_verifier;
733
- if (configuration_1.token_request_extras) {
734
- for (var _i = 0, _a = Object.entries(configuration_1.token_request_extras); _i < _a.length; _i++) {
741
+ if (configuration_2.token_request_extras) {
742
+ for (var _i = 0, _a = Object.entries(configuration_2.token_request_extras); _i < _a.length; _i++) {
735
743
  var _b = _a[_i], key = _b[0], value = _b[1];
736
744
  extras[key] = value;
737
745
  }
@@ -755,18 +763,20 @@ var Oidc = /** @class */ (function () {
755
763
  if (timeoutId) {
756
764
  var loginParams = (0, exports.getLoginParams)(_this.configurationName);
757
765
  clearTimeout(timeoutId);
766
+ _this.timeoutId = null;
767
+ _this.publishEvent(eventNames.loginCallbackAsync_end, {});
758
768
  resolve({
759
769
  tokens: tokenResponse,
760
770
  state: request.state,
761
771
  callbackPath: loginParams.callbackPath,
762
772
  });
763
- _this.publishEvent(eventNames.loginCallbackAsync_end, {});
764
773
  }
765
774
  });
766
775
  }
767
776
  catch (exception) {
768
777
  if (timeoutId) {
769
778
  clearTimeout(timeoutId);
779
+ _this.timeoutId = null;
770
780
  _this.publishEvent(eventNames.loginCallbackAsync_error, exception);
771
781
  console.error(exception);
772
782
  reject(exception);
@@ -813,6 +823,10 @@ var Oidc = /** @class */ (function () {
813
823
  console.error(exceptionSilent_2);
814
824
  return [3 /*break*/, 3];
815
825
  case 3:
826
+ if (this.timeoutId) {
827
+ timer_1.default.clearTimeout(this.timeoutId);
828
+ this.timeoutId = null;
829
+ }
816
830
  this.publishEvent(silentEvent ? eventNames.refreshTokensAsync_silent_error : eventNames.refreshTokensAsync_error, exception);
817
831
  return [2 /*return*/, null];
818
832
  }
@@ -901,6 +915,7 @@ var Oidc = /** @class */ (function () {
901
915
  this.userInfo = null;
902
916
  this.events = [];
903
917
  timer_1.default.clearTimeout(this.timeoutId);
918
+ this.timeoutId = null;
904
919
  return [2 /*return*/];
905
920
  }
906
921
  });