@axa-fr/react-oidc 6.13.4 → 6.14.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.
Files changed (52) hide show
  1. package/dist/OidcServiceWorker.js +36 -9
  2. package/dist/vanilla/crypto.d.ts +4 -0
  3. package/dist/vanilla/crypto.d.ts.map +1 -0
  4. package/dist/vanilla/crypto.js +81 -0
  5. package/dist/vanilla/crypto.js.map +1 -0
  6. package/dist/vanilla/initSession.d.ts +6 -4
  7. package/dist/vanilla/initSession.d.ts.map +1 -1
  8. package/dist/vanilla/initSession.js +22 -15
  9. package/dist/vanilla/initSession.js.map +1 -1
  10. package/dist/vanilla/initWorker.d.ts +4 -2
  11. package/dist/vanilla/initWorker.d.ts.map +1 -1
  12. package/dist/vanilla/initWorker.js +39 -18
  13. package/dist/vanilla/initWorker.js.map +1 -1
  14. package/dist/vanilla/login.d.ts +5 -1
  15. package/dist/vanilla/login.d.ts.map +1 -1
  16. package/dist/vanilla/login.js +70 -143
  17. package/dist/vanilla/login.js.map +1 -1
  18. package/dist/vanilla/logout.d.ts +4 -0
  19. package/dist/vanilla/logout.d.ts.map +1 -0
  20. package/dist/vanilla/logout.js +113 -0
  21. package/dist/vanilla/logout.js.map +1 -0
  22. package/dist/vanilla/oidc.d.ts +11 -6
  23. package/dist/vanilla/oidc.d.ts.map +1 -1
  24. package/dist/vanilla/oidc.js +26 -94
  25. package/dist/vanilla/oidc.js.map +1 -1
  26. package/dist/vanilla/requests.d.ts +14 -0
  27. package/dist/vanilla/requests.d.ts.map +1 -1
  28. package/dist/vanilla/requests.js +56 -1
  29. package/dist/vanilla/requests.js.map +1 -1
  30. package/dist/vanilla/route-utils.js +2 -2
  31. package/dist/vanilla/route-utils.js.map +1 -1
  32. package/package.json +2 -2
  33. package/src/oidc/vanilla/OidcServiceWorker.js +36 -9
  34. package/src/oidc/vanilla/crypto.ts +57 -0
  35. package/src/oidc/vanilla/initSession.ts +25 -15
  36. package/src/oidc/vanilla/initWorker.ts +43 -18
  37. package/src/oidc/vanilla/login.ts +76 -148
  38. package/src/oidc/vanilla/logout.ts +95 -0
  39. package/src/oidc/vanilla/oidc.ts +35 -98
  40. package/src/oidc/vanilla/requests.spec.ts +4 -0
  41. package/src/oidc/vanilla/requests.ts +55 -0
  42. package/src/oidc/vanilla/route-utils.ts +2 -2
  43. package/dist/vanilla/memoryStorageBackend.d.ts +0 -11
  44. package/dist/vanilla/memoryStorageBackend.d.ts.map +0 -1
  45. package/dist/vanilla/memoryStorageBackend.js +0 -31
  46. package/dist/vanilla/memoryStorageBackend.js.map +0 -1
  47. package/dist/vanilla/noHashQueryStringUtils.d.ts +0 -8
  48. package/dist/vanilla/noHashQueryStringUtils.d.ts.map +0 -1
  49. package/dist/vanilla/noHashQueryStringUtils.js +0 -32
  50. package/dist/vanilla/noHashQueryStringUtils.js.map +0 -1
  51. package/src/oidc/vanilla/memoryStorageBackend.ts +0 -40
  52. package/src/oidc/vanilla/noHashQueryStringUtils.ts +0 -32
@@ -1,8 +1,3 @@
1
- import {
2
- AuthorizationServiceConfiguration,
3
- GRANT_TYPE_REFRESH_TOKEN,
4
- } from '@openid/appauth';
5
- import { AuthorizationServiceConfigurationJson } from '@openid/appauth/src/authorization_service_configuration';
6
1
 
7
2
  import { startCheckSessionAsync as defaultStartCheckSessionAsync } from './checkSession';
8
3
  import { CheckSessionIFrame } from './checkSessionIFrame';
@@ -10,6 +5,7 @@ import { eventNames } from './events';
10
5
  import { initSession } from './initSession';
11
6
  import { initWorkerAsync, sleepAsync } from './initWorker';
12
7
  import { defaultLoginAsync, loginCallbackAsync } from './login';
8
+ import { destroyAsync, logoutAsync } from './logout';
13
9
  import {
14
10
  computeTimeLeft,
15
11
  isTokensOidcValid,
@@ -17,30 +13,35 @@ import {
17
13
  Tokens,
18
14
  } from './parseTokens';
19
15
  import { autoRenewTokens, renewTokensAndStartTimerAsync } from './renewTokens';
20
- import { fetchFromIssuer, performRevocationRequestAsync, performTokenRequestAsync, TOKEN_TYPE } from './requests';
16
+ import { fetchFromIssuer, performTokenRequestAsync } from './requests';
21
17
  import { getParseQueryStringFromLocation } from './route-utils';
22
18
  import defaultSilentLoginAsync, { _silentLoginAsync } from './silentLogin';
23
19
  import timer from './timer';
24
20
  import { AuthorityConfiguration, OidcConfiguration, StringMap } from './types';
25
21
  import { userInfoAsync } from './user';
26
22
 
27
- export interface OidcAuthorizationServiceConfigurationJson extends AuthorizationServiceConfigurationJson{
23
+ export interface OidcAuthorizationServiceConfigurationJson {
28
24
  check_session_iframe?: string;
29
25
  issuer:string;
30
26
  }
31
27
 
32
- export class OidcAuthorizationServiceConfiguration extends AuthorizationServiceConfiguration {
33
- private check_session_iframe: string;
28
+ export class OidcAuthorizationServiceConfiguration {
29
+ private checkSessionIframe: string;
34
30
  private issuer: string;
31
+ private authorizationEndpoint: string;
32
+ private tokenEndpoint: string;
33
+ private revocationEndpoint: string;
34
+ private userInfoEndpoint: string;
35
+ private endSessionEndpoint: string;
35
36
 
36
37
  constructor(request: any) {
37
- super(request);
38
38
  this.authorizationEndpoint = request.authorization_endpoint;
39
39
  this.tokenEndpoint = request.token_endpoint;
40
40
  this.revocationEndpoint = request.revocation_endpoint;
41
41
  this.userInfoEndpoint = request.userinfo_endpoint;
42
- this.check_session_iframe = request.check_session_iframe;
42
+ this.checkSessionIframe = request.check_session_iframe;
43
43
  this.issuer = request.issuer;
44
+ this.endSessionEndpoint = request.end_session_endpoint;
44
45
  }
45
46
  }
46
47
 
@@ -246,7 +247,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
246
247
  const getLoginParams = session.getLoginParams(this.configurationName);
247
248
  // @ts-ignore
248
249
  this.timeoutId = autoRenewTokens(this, tokens.refreshToken, this.tokens.expiresAt, getLoginParams.extras);
249
- const sessionState = session.getSessionState();
250
+ const sessionState = await session.getSessionStateAsync();
250
251
  // @ts-ignore
251
252
  await this.startCheckSessionAsync(oidcServerConfiguration.check_session_iframe, configuration.client_id, sessionState);
252
253
  this.publishEvent(eventNames.tryKeepExistingSessionAsync_end, {
@@ -314,7 +315,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
314
315
  // @ts-ignore
315
316
  const parsedTokens = response.tokens;
316
317
  // @ts-ignore
317
- this.tokens = response.tokens;
318
+ this.tokens = parsedTokens;
318
319
  const serviceWorker = await initWorkerAsync(this.configuration.service_worker_relative_url, this.configurationName);
319
320
  if (!serviceWorker) {
320
321
  const session = initSession(this.configurationName, this.configuration.storage);
@@ -360,7 +361,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
360
361
  };
361
362
  const localsilentLoginAsync = async () => {
362
363
  try {
363
- let loginParams = null;
364
+ let loginParams;
364
365
  const serviceWorker = await initWorkerAsync(configuration.service_worker_relative_url, this.configurationName);
365
366
  if (serviceWorker) {
366
367
  loginParams = serviceWorker.getLoginParams(this.configurationName);
@@ -440,7 +441,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
440
441
  const details = {
441
442
  client_id: clientId,
442
443
  redirect_uri: redirectUri,
443
- grant_type: GRANT_TYPE_REFRESH_TOKEN,
444
+ grant_type: 'refresh_token',
444
445
  refresh_token: tokens.refreshToken,
445
446
  };
446
447
  const oidcServerConfiguration = await this.initAsync(authority, configuration.authority_configuration);
@@ -548,31 +549,26 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
548
549
  });
549
550
  }
550
551
 
552
+ renewTokensPromise:Promise<any> = null;
553
+
551
554
  async renewTokensAsync (extras:StringMap = null) {
555
+ if (this.renewTokensPromise !== null) {
556
+ return this.renewTokensPromise;
557
+ }
552
558
  if (!this.timeoutId) {
553
559
  return;
554
560
  }
555
561
  timer.clearTimeout(this.timeoutId);
556
562
  // @ts-ignore
557
- await renewTokensAndStartTimerAsync(this, this.tokens.refreshToken, true, extras);
563
+ this.renewTokensPromise = renewTokensAndStartTimerAsync(this, this.tokens.refreshToken, true, extras);
564
+ return this.renewTokensPromise.then(result => {
565
+ this.renewTokensPromise = null;
566
+ return result;
567
+ });
558
568
  }
559
569
 
560
570
  async destroyAsync(status) {
561
- timer.clearTimeout(this.timeoutId);
562
- this.timeoutId = null;
563
- if (this.checkSessionIFrame) {
564
- this.checkSessionIFrame.stop();
565
- }
566
- const serviceWorker = await initWorkerAsync(this.configuration.service_worker_relative_url, this.configurationName);
567
- if (!serviceWorker) {
568
- const session = initSession(this.configurationName, this.configuration.storage);
569
- await session.clearAsync(status);
570
- } else {
571
- await serviceWorker.clearAsync(status);
572
- }
573
- this.tokens = null;
574
- this.userInfo = null;
575
- // this.events = [];
571
+ return await destroyAsync(this)(status);
576
572
  }
577
573
 
578
574
  async logoutSameTabAsync(clientId: string, sub: any) {
@@ -591,75 +587,16 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
591
587
  }
592
588
  }
593
589
 
590
+ logoutPromise:Promise<void> = null;
594
591
  async logoutAsync(callbackPathOrUrl: string | null | undefined = undefined, extras: StringMap = null) {
595
- const configuration = this.configuration;
596
- const oidcServerConfiguration = await this.initAsync(configuration.authority, configuration.authority_configuration);
597
- if (callbackPathOrUrl && (typeof callbackPathOrUrl !== 'string')) {
598
- callbackPathOrUrl = undefined;
599
- console.warn('callbackPathOrUrl path is not a string');
600
- }
601
- const path = (callbackPathOrUrl === null || callbackPathOrUrl === undefined) ? location.pathname + (location.search || '') + (location.hash || '') : callbackPathOrUrl;
602
- let isUri = false;
603
- if (callbackPathOrUrl) {
604
- isUri = callbackPathOrUrl.includes('https://') || callbackPathOrUrl.includes('http://');
605
- }
606
- const url = isUri ? callbackPathOrUrl : window.location.origin + path;
607
- // @ts-ignore
608
- const idToken = this.tokens ? this.tokens.idToken : '';
609
- try {
610
- const revocationEndpoint = oidcServerConfiguration.revocationEndpoint;
611
- if (revocationEndpoint) {
612
- const promises = [];
613
- if (this.tokens.accessToken) {
614
- const revokeAccessTokenPromise = performRevocationRequestAsync(revocationEndpoint, this.tokens.accessToken, TOKEN_TYPE.access_token, configuration.client_id);
615
- promises.push(revokeAccessTokenPromise);
616
- }
617
- if (this.tokens.refreshToken) {
618
- const revokeRefreshTokenPromise = performRevocationRequestAsync(revocationEndpoint, this.tokens.refreshToken, TOKEN_TYPE.refresh_token, configuration.client_id);
619
- promises.push(revokeRefreshTokenPromise);
620
- }
621
- if (promises.length > 0) {
622
- await Promise.all(promises);
623
- }
624
- }
625
- } catch (exception) {
626
- console.warn(exception);
627
- }
628
- // @ts-ignore
629
- const sub = this.tokens && this.tokens.idTokenPayload ? this.tokens.idTokenPayload.sub : null;
630
- await this.destroyAsync('LOGGED_OUT');
631
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
632
- for (const [key, oidc] of Object.entries(oidcDatabase)) {
633
- if (oidc !== this) {
634
- // @ts-ignore
635
- await oidc.logoutSameTabAsync(this.configuration.client_id, sub);
636
- }
637
- }
638
-
639
- if (oidcServerConfiguration.endSessionEndpoint) {
640
- if (!extras) {
641
- extras = {
642
- id_token_hint: idToken,
643
- };
644
- if (callbackPathOrUrl !== null) {
645
- extras.post_logout_redirect_uri = url;
646
- }
647
- }
648
- let queryString = '';
649
- if (extras) {
650
- for (const [key, value] of Object.entries(extras)) {
651
- if (queryString === '') {
652
- queryString += '?';
653
- } else {
654
- queryString += '&';
655
- }
656
- queryString += `${key}=${encodeURIComponent(value)}`;
657
- }
658
- }
659
- window.location.href = `${oidcServerConfiguration.endSessionEndpoint}${queryString}`;
660
- } else {
661
- window.location.reload();
592
+ if (this.logoutPromise) {
593
+ return this.logoutPromise;
662
594
  }
595
+ this.logoutPromise = logoutAsync(this, oidcDatabase)(callbackPathOrUrl, extras);
596
+ return this.logoutPromise.then(result => {
597
+ this.logoutPromise = null;
598
+ return result;
599
+ });
663
600
  }
664
601
  }
665
602
 
@@ -0,0 +1,4 @@
1
+ 
2
+ test('performAuthorizationRequestAsync', async () => {
3
+ expect(true).toBe(true);
4
+ });
@@ -1,6 +1,8 @@
1
1
  import { getFromCache, setCache } from './cache';
2
+ import { deriveChallengeAsync, generateRandom } from './crypto';
2
3
  import { OidcAuthorizationServiceConfiguration } from './oidc';
3
4
  import { parseOriginalTokens } from './parseTokens';
5
+ import { StringMap } from './types';
4
6
 
5
7
  const oneHourSecond = 60 * 60;
6
8
  export const fetchFromIssuer = async (openIdIssuerUrl: string, timeCacheSecond = oneHourSecond, storage = window.sessionStorage):
@@ -112,3 +114,56 @@ export const performTokenRequestAsync = async (url, details, extras, oldTokens,
112
114
  data: parseOriginalTokens(tokens, oldTokens, tokenRenewMode),
113
115
  };
114
116
  };
117
+
118
+ export const performAuthorizationRequestAsync = (storage: any) => async (url, extras: StringMap) => {
119
+ extras = extras ? { ...extras } : {};
120
+ const codeVerifier = generateRandom(128);
121
+ const codeChallenge = await deriveChallengeAsync(codeVerifier);
122
+ await storage.setCodeVerifierAsync(codeVerifier);
123
+ await storage.setStateAsync(extras.state);
124
+ extras.code_challenge = codeChallenge;
125
+ extras.code_challenge_method = 'S256';
126
+ let queryString = '';
127
+ if (extras) {
128
+ for (const [key, value] of Object.entries(extras)) {
129
+ if (queryString === '') {
130
+ queryString += '?';
131
+ } else {
132
+ queryString += '&';
133
+ }
134
+ queryString += `${key}=${encodeURIComponent(value)}`;
135
+ }
136
+ }
137
+ window.location.href = `${url}${queryString}`;
138
+ };
139
+
140
+ export const performFirstTokenRequestAsync = (storage:any) => async (url, extras, tokenRenewMode: string, timeoutMs = 10000) => {
141
+ extras = extras ? { ...extras } : {};
142
+ extras.code_verifier = await storage.getCodeVerifierAsync();
143
+ const formBody = [];
144
+ for (const property in extras) {
145
+ const encodedKey = encodeURIComponent(property);
146
+ const encodedValue = encodeURIComponent(extras[property]);
147
+ formBody.push(`${encodedKey}=${encodedValue}`);
148
+ }
149
+ const formBodyString = formBody.join('&');
150
+ const response = await internalFetch(url, {
151
+ method: 'POST',
152
+ headers: {
153
+ 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
154
+ },
155
+ body: formBodyString,
156
+ }, timeoutMs);
157
+ await Promise.all([storage.setCodeVerifierAsync(null), storage.setStateAsync(null)]);
158
+ if (response.status !== 200) {
159
+ return { success: false, status: response.status };
160
+ }
161
+ const tokens = await response.json();
162
+ return {
163
+ success: true,
164
+ data: {
165
+ state: extras.state,
166
+ tokens: parseOriginalTokens(tokens, null, tokenRenewMode),
167
+ },
168
+ };
169
+ };
@@ -18,7 +18,7 @@ export const getLocation = (href: string) => {
18
18
  }
19
19
  }
20
20
 
21
- if (search) {
21
+ if (search.startsWith('?')) {
22
22
  search = search.slice(1);
23
23
  }
24
24
 
@@ -72,7 +72,7 @@ const parseQueryString = (queryString:string) => {
72
72
  // Convert the array of strings into an object
73
73
  for (i = 0, l = queries.length; i < l; i++) {
74
74
  temp = queries[i].split('=');
75
- params[decodeURIComponent(temp[0])] = temp[1];
75
+ params[decodeURIComponent(temp[0])] = decodeURIComponent(temp[1]);
76
76
  }
77
77
 
78
78
  return params;
@@ -1,11 +0,0 @@
1
- export declare type ItemName = string | number;
2
- export declare class MemoryStorageBackend {
3
- items: any;
4
- private saveItemsAsync;
5
- constructor(saveItemsAsync: any, items?: {});
6
- getItem(name: ItemName): Promise<any>;
7
- removeItem(name: ItemName): Promise<any>;
8
- clear(): Promise<any>;
9
- setItem(name: ItemName, value: any): Promise<any>;
10
- }
11
- //# sourceMappingURL=memoryStorageBackend.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"memoryStorageBackend.d.ts","sourceRoot":"","sources":["../../src/oidc/vanilla/memoryStorageBackend.ts"],"names":[],"mappings":"AAKA,oBAAY,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAEvC,qBAAa,oBAAoB;IACtB,KAAK,EAAE,GAAG,CAAC;IAClB,OAAO,CAAC,cAAc,CAAc;gBAExB,cAAc,KAAA,EAAE,KAAK,KAAK;IAUtC,OAAO,CAAC,IAAI,EAAE,QAAQ;IAItB,UAAU,CAAC,IAAI,EAAE,QAAQ;IAKzB,KAAK;IAKL,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG;CAIrC"}
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MemoryStorageBackend = void 0;
4
- class MemoryStorageBackend {
5
- constructor(saveItemsAsync, items = {}) {
6
- this.items = items;
7
- this.saveItemsAsync = saveItemsAsync;
8
- this.saveItemsAsync.bind(this);
9
- this.getItem.bind(this);
10
- this.removeItem.bind(this);
11
- this.clear.bind(this);
12
- this.setItem.bind(this);
13
- }
14
- getItem(name) {
15
- return Promise.resolve(this.items[name]);
16
- }
17
- removeItem(name) {
18
- delete this.items[name];
19
- return this.saveItemsAsync(this.items);
20
- }
21
- clear() {
22
- this.items = {};
23
- return this.saveItemsAsync(this.items);
24
- }
25
- setItem(name, value) {
26
- this.items[name] = value;
27
- return this.saveItemsAsync(this.items);
28
- }
29
- }
30
- exports.MemoryStorageBackend = MemoryStorageBackend;
31
- //# sourceMappingURL=memoryStorageBackend.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"memoryStorageBackend.js","sourceRoot":"","sources":["../../src/oidc/vanilla/memoryStorageBackend.ts"],"names":[],"mappings":";;;AAOA,MAAa,oBAAoB;IAI7B,YAAY,cAAc,EAAE,KAAK,GAAG,EAAE;QAClC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,CAAC,IAAc;QAClB,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED,UAAU,CAAC,IAAc;QACrB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACxB,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK;QACD,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO,CAAC,IAAc,EAAE,KAAU;QAC9B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QACzB,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;CACJ;AAhCD,oDAgCC"}
@@ -1,8 +0,0 @@
1
- import { BasicQueryStringUtils, LocationLike } from '@openid/appauth';
2
- export declare class NoHashQueryStringUtils extends BasicQueryStringUtils {
3
- parse(input: LocationLike, _useHash: boolean): import("@openid/appauth").StringMap;
4
- }
5
- export declare class HashQueryStringUtils extends BasicQueryStringUtils {
6
- parse(input: LocationLike, _useHash: boolean): import("@openid/appauth").StringMap;
7
- }
8
- //# sourceMappingURL=noHashQueryStringUtils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"noHashQueryStringUtils.d.ts","sourceRoot":"","sources":["../../src/oidc/vanilla/noHashQueryStringUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEtE,qBAAa,sBAAuB,SAAQ,qBAAqB;IAC7D,KAAK,CAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO;CAG/C;AAID,qBAAa,oBAAqB,SAAQ,qBAAqB;IAC3D,KAAK,CAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO;CAoB/C"}
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HashQueryStringUtils = exports.NoHashQueryStringUtils = void 0;
4
- const appauth_1 = require("@openid/appauth");
5
- class NoHashQueryStringUtils extends appauth_1.BasicQueryStringUtils {
6
- parse(input, _useHash) {
7
- return super.parse(input, false /* never use hash */);
8
- }
9
- }
10
- exports.NoHashQueryStringUtils = NoHashQueryStringUtils;
11
- const keys = ['code', 'session_state', 'state'];
12
- class HashQueryStringUtils extends appauth_1.BasicQueryStringUtils {
13
- parse(input, _useHash) {
14
- const output = super.parse(input, true /* use hash */);
15
- // Fix AppAuthJs behavior
16
- let propertyToDelelete = null;
17
- Object.entries(output).forEach(([key, value]) => {
18
- keys.forEach(k => {
19
- if (key.endsWith(`?${k}`)) {
20
- output[k] = value;
21
- propertyToDelelete = key;
22
- }
23
- });
24
- });
25
- if (propertyToDelelete) {
26
- delete output[propertyToDelelete];
27
- }
28
- return output;
29
- }
30
- }
31
- exports.HashQueryStringUtils = HashQueryStringUtils;
32
- //# sourceMappingURL=noHashQueryStringUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"noHashQueryStringUtils.js","sourceRoot":"","sources":["../../src/oidc/vanilla/noHashQueryStringUtils.ts"],"names":[],"mappings":";;;AAAA,6CAAsE;AAEtE,MAAa,sBAAuB,SAAQ,+BAAqB;IAC7D,KAAK,CAAC,KAAmB,EAAE,QAAiB;QACxC,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,oBAAoB,CAAC,CAAC;IAC1D,CAAC;CACJ;AAJD,wDAIC;AAED,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;AAEhD,MAAa,oBAAqB,SAAQ,+BAAqB;IAC3D,KAAK,CAAC,KAAmB,EAAE,QAAiB;QACxC,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QAEvD,yBAAyB;QACzB,IAAI,kBAAkB,GAAG,IAAI,CAAC;QAC9B,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YAC5C,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;gBACb,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;oBACvB,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;oBAClB,kBAAkB,GAAG,GAAG,CAAC;iBAC5B;YACL,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QAEH,IAAI,kBAAkB,EAAE;YACpB,OAAO,MAAM,CAAC,kBAAkB,CAAC,CAAC;SACrC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AArBD,oDAqBC"}
@@ -1,40 +0,0 @@
1
-
2
- interface SaveItemsFn {
3
- (items:any):Promise<any>;
4
- }
5
-
6
- export type ItemName = string | number;
7
-
8
- export class MemoryStorageBackend {
9
- public items: any;
10
- private saveItemsAsync: SaveItemsFn;
11
-
12
- constructor(saveItemsAsync, items = {}) {
13
- this.items = items;
14
- this.saveItemsAsync = saveItemsAsync;
15
- this.saveItemsAsync.bind(this);
16
- this.getItem.bind(this);
17
- this.removeItem.bind(this);
18
- this.clear.bind(this);
19
- this.setItem.bind(this);
20
- }
21
-
22
- getItem(name: ItemName) {
23
- return Promise.resolve(this.items[name]);
24
- }
25
-
26
- removeItem(name: ItemName) {
27
- delete this.items[name];
28
- return this.saveItemsAsync(this.items);
29
- }
30
-
31
- clear() {
32
- this.items = {};
33
- return this.saveItemsAsync(this.items);
34
- }
35
-
36
- setItem(name: ItemName, value: any) {
37
- this.items[name] = value;
38
- return this.saveItemsAsync(this.items);
39
- }
40
- }
@@ -1,32 +0,0 @@
1
- import { BasicQueryStringUtils, LocationLike } from '@openid/appauth';
2
-
3
- export class NoHashQueryStringUtils extends BasicQueryStringUtils {
4
- parse(input: LocationLike, _useHash: boolean) {
5
- return super.parse(input, false /* never use hash */);
6
- }
7
- }
8
-
9
- const keys = ['code', 'session_state', 'state'];
10
-
11
- export class HashQueryStringUtils extends BasicQueryStringUtils {
12
- parse(input: LocationLike, _useHash: boolean) {
13
- const output = super.parse(input, true /* use hash */);
14
-
15
- // Fix AppAuthJs behavior
16
- let propertyToDelelete = null;
17
- Object.entries(output).forEach(([key, value]) => {
18
- keys.forEach(k => {
19
- if (key.endsWith(`?${k}`)) {
20
- output[k] = value;
21
- propertyToDelelete = key;
22
- }
23
- });
24
- });
25
-
26
- if (propertyToDelelete) {
27
- delete output[propertyToDelelete];
28
- }
29
-
30
- return output;
31
- }
32
- }