@baclet/sdk 0.2.4 → 0.2.5
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.js +13 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -419,9 +419,19 @@ export class BacletClient {
|
|
|
419
419
|
accessToken,
|
|
420
420
|
}).then((result) => result.user);
|
|
421
421
|
}
|
|
422
|
-
storageRequest(path, options = {}) {
|
|
423
|
-
const
|
|
424
|
-
|
|
422
|
+
async storageRequest(path, options = {}) {
|
|
423
|
+
const tokens = this.readTokens();
|
|
424
|
+
const accessToken = options.accessToken ?? tokens?.access_token;
|
|
425
|
+
try {
|
|
426
|
+
return await this.request(path, { ...options, accessToken });
|
|
427
|
+
}
|
|
428
|
+
catch (error) {
|
|
429
|
+
if (!hasStatus(error, 401) || options.accessToken || !this.autoRefresh || !tokens?.refresh_token) {
|
|
430
|
+
throw error;
|
|
431
|
+
}
|
|
432
|
+
const session = await this.refreshSession(tokens.refresh_token);
|
|
433
|
+
return this.request(path, { ...options, accessToken: session.tokens.access_token });
|
|
434
|
+
}
|
|
425
435
|
}
|
|
426
436
|
async request(path, options = {}) {
|
|
427
437
|
const headers = {
|