@flashbacktech/tsclient 0.4.71 → 0.4.73
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/index.cjs +7 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -4
- package/dist/index.d.ts +19 -4
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -61,7 +61,7 @@ var BaseClient = class {
|
|
|
61
61
|
delete(path, options) {
|
|
62
62
|
return this.request("DELETE", path, options);
|
|
63
63
|
}
|
|
64
|
-
async request(method, path, options = {}) {
|
|
64
|
+
async request(method, path, options = {}, retrying = false) {
|
|
65
65
|
const url = this.buildUrl(path, options.query);
|
|
66
66
|
const headers = { ...this.defaultHeaders, ...options.headers ?? {} };
|
|
67
67
|
if (!options.skipAuth && this.getToken) {
|
|
@@ -100,11 +100,15 @@ var BaseClient = class {
|
|
|
100
100
|
console.debug("[flashbacktech/tsclient] \u2190", res.status, url, parsed);
|
|
101
101
|
}
|
|
102
102
|
if (!res.ok) {
|
|
103
|
-
if (res.status === 401 && this.onUnauthorized) {
|
|
103
|
+
if (res.status === 401 && this.onUnauthorized && !options.skipAuth && !retrying) {
|
|
104
|
+
let refreshed = false;
|
|
104
105
|
try {
|
|
105
|
-
await this.onUnauthorized();
|
|
106
|
+
refreshed = await this.onUnauthorized() !== false;
|
|
106
107
|
} catch {
|
|
107
108
|
}
|
|
109
|
+
if (refreshed) {
|
|
110
|
+
return this.request(method, path, options, true);
|
|
111
|
+
}
|
|
108
112
|
}
|
|
109
113
|
throw new HttpError(res.status, res.statusText, parsed);
|
|
110
114
|
}
|