@shopsbuilder/auth-sdk 1.2.0 → 1.2.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.
- package/dist/SaleorAuthClient.js +21 -8
- package/dist/SaleorAuthClient.mjs +1 -1
- package/dist/{chunk-STBUJJV4.mjs → chunk-OGC5TPQ2.mjs} +21 -8
- package/dist/index.js +21 -8
- 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
|
@@ -324,15 +324,28 @@ var SaleorAuthClient = class {
|
|
|
324
324
|
this.onAuthRefresh?.(true);
|
|
325
325
|
if (this.tokenRefreshPromise) {
|
|
326
326
|
const response = await this.tokenRefreshPromise;
|
|
327
|
-
const
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
327
|
+
const responseClone = response.clone();
|
|
328
|
+
let res;
|
|
329
|
+
try {
|
|
330
|
+
res = await responseClone.json();
|
|
331
|
+
} catch {
|
|
332
|
+
console.error("[auth-sdk] Token refresh response is not valid JSON, status:", response.status);
|
|
333
|
+
this.onAuthRefresh?.(false);
|
|
334
|
+
this.tokenRefreshPromise = null;
|
|
335
|
+
this.refreshTokenStorage?.clearAuthStorage();
|
|
336
|
+
return fetch(input, requestInit);
|
|
337
|
+
}
|
|
338
|
+
const graphqlErrors = res.errors;
|
|
339
|
+
const token = res.data?.tokenRefresh?.token;
|
|
340
|
+
const refreshErrors = res.data?.tokenRefresh?.errors;
|
|
334
341
|
this.onAuthRefresh?.(false);
|
|
335
|
-
if (
|
|
342
|
+
if (refreshErrors?.length || graphqlErrors?.length || !token) {
|
|
343
|
+
console.warn("[auth-sdk] Token refresh failed:", JSON.stringify({
|
|
344
|
+
graphqlErrors: graphqlErrors?.length ?? 0,
|
|
345
|
+
refreshErrors: refreshErrors?.map((e) => e.message),
|
|
346
|
+
hasToken: Boolean(token),
|
|
347
|
+
httpStatus: response.status
|
|
348
|
+
}));
|
|
336
349
|
this.tokenRefreshPromise = null;
|
|
337
350
|
this.refreshTokenStorage?.clearAuthStorage();
|
|
338
351
|
return fetch(input, requestInit);
|
|
@@ -87,15 +87,28 @@ var SaleorAuthClient = class {
|
|
|
87
87
|
this.onAuthRefresh?.(true);
|
|
88
88
|
if (this.tokenRefreshPromise) {
|
|
89
89
|
const response = await this.tokenRefreshPromise;
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
90
|
+
const responseClone = response.clone();
|
|
91
|
+
let res;
|
|
92
|
+
try {
|
|
93
|
+
res = await responseClone.json();
|
|
94
|
+
} catch {
|
|
95
|
+
console.error("[auth-sdk] Token refresh response is not valid JSON, status:", response.status);
|
|
96
|
+
this.onAuthRefresh?.(false);
|
|
97
|
+
this.tokenRefreshPromise = null;
|
|
98
|
+
this.refreshTokenStorage?.clearAuthStorage();
|
|
99
|
+
return fetch(input, requestInit);
|
|
100
|
+
}
|
|
101
|
+
const graphqlErrors = res.errors;
|
|
102
|
+
const token = res.data?.tokenRefresh?.token;
|
|
103
|
+
const refreshErrors = res.data?.tokenRefresh?.errors;
|
|
97
104
|
this.onAuthRefresh?.(false);
|
|
98
|
-
if (
|
|
105
|
+
if (refreshErrors?.length || graphqlErrors?.length || !token) {
|
|
106
|
+
console.warn("[auth-sdk] Token refresh failed:", JSON.stringify({
|
|
107
|
+
graphqlErrors: graphqlErrors?.length ?? 0,
|
|
108
|
+
refreshErrors: refreshErrors?.map((e) => e.message),
|
|
109
|
+
hasToken: Boolean(token),
|
|
110
|
+
httpStatus: response.status
|
|
111
|
+
}));
|
|
99
112
|
this.tokenRefreshPromise = null;
|
|
100
113
|
this.refreshTokenStorage?.clearAuthStorage();
|
|
101
114
|
return fetch(input, requestInit);
|
package/dist/index.js
CHANGED
|
@@ -327,15 +327,28 @@ var SaleorAuthClient = class {
|
|
|
327
327
|
this.onAuthRefresh?.(true);
|
|
328
328
|
if (this.tokenRefreshPromise) {
|
|
329
329
|
const response = await this.tokenRefreshPromise;
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
330
|
+
const responseClone = response.clone();
|
|
331
|
+
let res;
|
|
332
|
+
try {
|
|
333
|
+
res = await responseClone.json();
|
|
334
|
+
} catch {
|
|
335
|
+
console.error("[auth-sdk] Token refresh response is not valid JSON, status:", response.status);
|
|
336
|
+
this.onAuthRefresh?.(false);
|
|
337
|
+
this.tokenRefreshPromise = null;
|
|
338
|
+
this.refreshTokenStorage?.clearAuthStorage();
|
|
339
|
+
return fetch(input, requestInit);
|
|
340
|
+
}
|
|
341
|
+
const graphqlErrors = res.errors;
|
|
342
|
+
const token = res.data?.tokenRefresh?.token;
|
|
343
|
+
const refreshErrors = res.data?.tokenRefresh?.errors;
|
|
337
344
|
this.onAuthRefresh?.(false);
|
|
338
|
-
if (
|
|
345
|
+
if (refreshErrors?.length || graphqlErrors?.length || !token) {
|
|
346
|
+
console.warn("[auth-sdk] Token refresh failed:", JSON.stringify({
|
|
347
|
+
graphqlErrors: graphqlErrors?.length ?? 0,
|
|
348
|
+
refreshErrors: refreshErrors?.map((e) => e.message),
|
|
349
|
+
hasToken: Boolean(token),
|
|
350
|
+
httpStatus: response.status
|
|
351
|
+
}));
|
|
339
352
|
this.tokenRefreshPromise = null;
|
|
340
353
|
this.refreshTokenStorage?.clearAuthStorage();
|
|
341
354
|
return fetch(input, requestInit);
|
package/dist/index.mjs
CHANGED
package/dist/react/context.mjs
CHANGED
package/dist/react/index.mjs
CHANGED