@shopsbuilder/auth-sdk 1.2.10 → 1.2.11

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.
@@ -20,6 +20,7 @@ declare class SaleorAuthClient {
20
20
  private tokenRefreshPromise;
21
21
  private onAuthRefresh?;
22
22
  private saleorApiUrl;
23
+ private storageKeyPrefix;
23
24
  /**
24
25
  * Persistent storage (for refresh token)
25
26
  */
@@ -20,6 +20,7 @@ declare class SaleorAuthClient {
20
20
  private tokenRefreshPromise;
21
21
  private onAuthRefresh?;
22
22
  private saleorApiUrl;
23
+ private storageKeyPrefix;
23
24
  /**
24
25
  * Persistent storage (for refresh token)
25
26
  */
@@ -272,6 +272,7 @@ var SaleorAuthClient = class {
272
272
  tokenRefreshPromise = null;
273
273
  onAuthRefresh;
274
274
  saleorApiUrl;
275
+ storageKeyPrefix;
275
276
  /**
276
277
  * Persistent storage (for refresh token)
277
278
  */
@@ -307,7 +308,8 @@ var SaleorAuthClient = class {
307
308
  }
308
309
  this.onAuthRefresh = onAuthRefresh;
309
310
  this.saleorApiUrl = saleorApiUrl;
310
- const keyPrefix = storageKeyPrefix ?? saleorApiUrl;
311
+ this.storageKeyPrefix = storageKeyPrefix ?? saleorApiUrl;
312
+ const keyPrefix = this.storageKeyPrefix;
311
313
  const refreshTokenRepo = refreshTokenStorage ?? (typeof window !== "undefined" ? window.localStorage : void 0);
312
314
  this.refreshTokenStorage = refreshTokenRepo ? new SaleorRefreshTokenStorageHandler(refreshTokenRepo, keyPrefix) : null;
313
315
  const accessTokenRepo = accessTokenStorage ?? getInMemoryAccessTokenStorage();
@@ -332,7 +334,8 @@ var SaleorAuthClient = class {
332
334
  }
333
335
  };
334
336
  const iss = getTokenIss(token);
335
- const issuerAndDomainMatch = getURL(input) === iss;
337
+ const requestUrl = getURL(input);
338
+ const issuerAndDomainMatch = requestUrl === iss || this.storageKeyPrefix === iss;
336
339
  const shouldAddAuthorizationHeader = issuerAndDomainMatch || additionalParams?.allowPassingTokenToThirdPartyDomains;
337
340
  if (!issuerAndDomainMatch) {
338
341
  if (shouldAddAuthorizationHeader) {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SaleorAuthClient,
3
3
  createSaleorAuthClient
4
- } from "./chunk-3UGMWVQN.mjs";
4
+ } from "./chunk-CKQ223DC.mjs";
5
5
  import "./chunk-B326YIV6.mjs";
6
6
  import "./chunk-263DHBMK.mjs";
7
7
  import "./chunk-UDLCOX6B.mjs";
@@ -25,6 +25,7 @@ var SaleorAuthClient = class {
25
25
  tokenRefreshPromise = null;
26
26
  onAuthRefresh;
27
27
  saleorApiUrl;
28
+ storageKeyPrefix;
28
29
  /**
29
30
  * Persistent storage (for refresh token)
30
31
  */
@@ -60,7 +61,8 @@ var SaleorAuthClient = class {
60
61
  }
61
62
  this.onAuthRefresh = onAuthRefresh;
62
63
  this.saleorApiUrl = saleorApiUrl;
63
- const keyPrefix = storageKeyPrefix ?? saleorApiUrl;
64
+ this.storageKeyPrefix = storageKeyPrefix ?? saleorApiUrl;
65
+ const keyPrefix = this.storageKeyPrefix;
64
66
  const refreshTokenRepo = refreshTokenStorage ?? (typeof window !== "undefined" ? window.localStorage : void 0);
65
67
  this.refreshTokenStorage = refreshTokenRepo ? new SaleorRefreshTokenStorageHandler(refreshTokenRepo, keyPrefix) : null;
66
68
  const accessTokenRepo = accessTokenStorage ?? getInMemoryAccessTokenStorage();
@@ -85,7 +87,8 @@ var SaleorAuthClient = class {
85
87
  }
86
88
  };
87
89
  const iss = getTokenIss(token);
88
- const issuerAndDomainMatch = getURL(input) === iss;
90
+ const requestUrl = getURL(input);
91
+ const issuerAndDomainMatch = requestUrl === iss || this.storageKeyPrefix === iss;
89
92
  const shouldAddAuthorizationHeader = issuerAndDomainMatch || additionalParams?.allowPassingTokenToThirdPartyDomains;
90
93
  if (!issuerAndDomainMatch) {
91
94
  if (shouldAddAuthorizationHeader) {
package/dist/index.js CHANGED
@@ -275,6 +275,7 @@ var SaleorAuthClient = class {
275
275
  tokenRefreshPromise = null;
276
276
  onAuthRefresh;
277
277
  saleorApiUrl;
278
+ storageKeyPrefix;
278
279
  /**
279
280
  * Persistent storage (for refresh token)
280
281
  */
@@ -310,7 +311,8 @@ var SaleorAuthClient = class {
310
311
  }
311
312
  this.onAuthRefresh = onAuthRefresh;
312
313
  this.saleorApiUrl = saleorApiUrl;
313
- const keyPrefix = storageKeyPrefix ?? saleorApiUrl;
314
+ this.storageKeyPrefix = storageKeyPrefix ?? saleorApiUrl;
315
+ const keyPrefix = this.storageKeyPrefix;
314
316
  const refreshTokenRepo = refreshTokenStorage ?? (typeof window !== "undefined" ? window.localStorage : void 0);
315
317
  this.refreshTokenStorage = refreshTokenRepo ? new SaleorRefreshTokenStorageHandler(refreshTokenRepo, keyPrefix) : null;
316
318
  const accessTokenRepo = accessTokenStorage ?? getInMemoryAccessTokenStorage();
@@ -335,7 +337,8 @@ var SaleorAuthClient = class {
335
337
  }
336
338
  };
337
339
  const iss = getTokenIss(token);
338
- const issuerAndDomainMatch = getURL(input) === iss;
340
+ const requestUrl = getURL(input);
341
+ const issuerAndDomainMatch = requestUrl === iss || this.storageKeyPrefix === iss;
339
342
  const shouldAddAuthorizationHeader = issuerAndDomainMatch || additionalParams?.allowPassingTokenToThirdPartyDomains;
340
343
  if (!issuerAndDomainMatch) {
341
344
  if (shouldAddAuthorizationHeader) {
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SaleorAuthClient,
3
3
  createSaleorAuthClient
4
- } from "./chunk-3UGMWVQN.mjs";
4
+ } from "./chunk-CKQ223DC.mjs";
5
5
  import "./chunk-B326YIV6.mjs";
6
6
  import "./chunk-263DHBMK.mjs";
7
7
  import {
@@ -2,7 +2,7 @@ import {
2
2
  SaleorAuthProvider
3
3
  } from "../chunk-74GMXOK4.mjs";
4
4
  import "../chunk-NAQNA6DI.mjs";
5
- import "../chunk-3UGMWVQN.mjs";
5
+ import "../chunk-CKQ223DC.mjs";
6
6
  import "../chunk-B326YIV6.mjs";
7
7
  import "../chunk-263DHBMK.mjs";
8
8
  import "../chunk-UDLCOX6B.mjs";
@@ -3,7 +3,7 @@ import {
3
3
  createSafeContext,
4
4
  useSaleorAuthContext
5
5
  } from "../chunk-NAQNA6DI.mjs";
6
- import "../chunk-3UGMWVQN.mjs";
6
+ import "../chunk-CKQ223DC.mjs";
7
7
  import "../chunk-B326YIV6.mjs";
8
8
  import "../chunk-263DHBMK.mjs";
9
9
  import "../chunk-UDLCOX6B.mjs";
@@ -12,7 +12,7 @@ import {
12
12
  import {
13
13
  useSaleorExternalAuth
14
14
  } from "../chunk-Q3UFWDCC.mjs";
15
- import "../chunk-3UGMWVQN.mjs";
15
+ import "../chunk-CKQ223DC.mjs";
16
16
  import "../chunk-B326YIV6.mjs";
17
17
  import "../chunk-263DHBMK.mjs";
18
18
  import "../chunk-T35JF4IS.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopsbuilder/auth-sdk",
3
- "version": "1.2.10",
3
+ "version": "1.2.11",
4
4
  "description": "Auth SDK for Saleor",
5
5
  "sideEffects": false,
6
6
  "files": ["dist/", "README.md"],