@shopsbuilder/auth-sdk 1.2.10 → 1.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SaleorAuthClient.d.mts +1 -0
- package/dist/SaleorAuthClient.d.ts +1 -0
- package/dist/SaleorAuthClient.js +10 -7
- package/dist/SaleorAuthClient.mjs +1 -1
- package/dist/{chunk-3UGMWVQN.mjs → chunk-E4ERLV5W.mjs} +10 -7
- package/dist/index.js +10 -7
- package/dist/index.mjs +1 -1
- package/dist/react/SaleorAuthProvider.mjs +1 -1
- package/dist/react/context.mjs +1 -1
- package/dist/react/index.mjs +1 -1
- package/package.json +1 -1
package/dist/SaleorAuthClient.js
CHANGED
|
@@ -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
|
-
|
|
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();
|
|
@@ -321,7 +323,7 @@ var SaleorAuthClient = class {
|
|
|
321
323
|
if (!token) {
|
|
322
324
|
return fetch(input, init);
|
|
323
325
|
}
|
|
324
|
-
const headers = init?.headers
|
|
326
|
+
const headers = new Headers(init?.headers);
|
|
325
327
|
const getURL = (input2) => {
|
|
326
328
|
if (typeof input2 === "string") {
|
|
327
329
|
return input2;
|
|
@@ -332,7 +334,8 @@ var SaleorAuthClient = class {
|
|
|
332
334
|
}
|
|
333
335
|
};
|
|
334
336
|
const iss = getTokenIss(token);
|
|
335
|
-
const
|
|
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) {
|
|
@@ -345,10 +348,10 @@ var SaleorAuthClient = class {
|
|
|
345
348
|
);
|
|
346
349
|
}
|
|
347
350
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
});
|
|
351
|
+
if (shouldAddAuthorizationHeader) {
|
|
352
|
+
headers.set("Authorization", `Bearer ${token}`);
|
|
353
|
+
}
|
|
354
|
+
return fetch(input, { ...init, headers });
|
|
352
355
|
};
|
|
353
356
|
handleRequestWithTokenRefresh = async (input, requestInit, additionalParams) => {
|
|
354
357
|
const refreshToken = this.refreshTokenStorage?.getRefreshToken();
|
|
@@ -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
|
-
|
|
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();
|
|
@@ -74,7 +76,7 @@ var SaleorAuthClient = class {
|
|
|
74
76
|
if (!token) {
|
|
75
77
|
return fetch(input, init);
|
|
76
78
|
}
|
|
77
|
-
const headers = init?.headers
|
|
79
|
+
const headers = new Headers(init?.headers);
|
|
78
80
|
const getURL = (input2) => {
|
|
79
81
|
if (typeof input2 === "string") {
|
|
80
82
|
return input2;
|
|
@@ -85,7 +87,8 @@ var SaleorAuthClient = class {
|
|
|
85
87
|
}
|
|
86
88
|
};
|
|
87
89
|
const iss = getTokenIss(token);
|
|
88
|
-
const
|
|
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) {
|
|
@@ -98,10 +101,10 @@ var SaleorAuthClient = class {
|
|
|
98
101
|
);
|
|
99
102
|
}
|
|
100
103
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
});
|
|
104
|
+
if (shouldAddAuthorizationHeader) {
|
|
105
|
+
headers.set("Authorization", `Bearer ${token}`);
|
|
106
|
+
}
|
|
107
|
+
return fetch(input, { ...init, headers });
|
|
105
108
|
};
|
|
106
109
|
handleRequestWithTokenRefresh = async (input, requestInit, additionalParams) => {
|
|
107
110
|
const refreshToken = this.refreshTokenStorage?.getRefreshToken();
|
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
|
-
|
|
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();
|
|
@@ -324,7 +326,7 @@ var SaleorAuthClient = class {
|
|
|
324
326
|
if (!token) {
|
|
325
327
|
return fetch(input, init);
|
|
326
328
|
}
|
|
327
|
-
const headers = init?.headers
|
|
329
|
+
const headers = new Headers(init?.headers);
|
|
328
330
|
const getURL = (input2) => {
|
|
329
331
|
if (typeof input2 === "string") {
|
|
330
332
|
return input2;
|
|
@@ -335,7 +337,8 @@ var SaleorAuthClient = class {
|
|
|
335
337
|
}
|
|
336
338
|
};
|
|
337
339
|
const iss = getTokenIss(token);
|
|
338
|
-
const
|
|
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) {
|
|
@@ -348,10 +351,10 @@ var SaleorAuthClient = class {
|
|
|
348
351
|
);
|
|
349
352
|
}
|
|
350
353
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
});
|
|
354
|
+
if (shouldAddAuthorizationHeader) {
|
|
355
|
+
headers.set("Authorization", `Bearer ${token}`);
|
|
356
|
+
}
|
|
357
|
+
return fetch(input, { ...init, headers });
|
|
355
358
|
};
|
|
356
359
|
handleRequestWithTokenRefresh = async (input, requestInit, additionalParams) => {
|
|
357
360
|
const refreshToken = this.refreshTokenStorage?.getRefreshToken();
|
package/dist/index.mjs
CHANGED
package/dist/react/context.mjs
CHANGED
package/dist/react/index.mjs
CHANGED