@virtuals-protocol/acp-node 0.3.0-beta.34 → 0.3.0-beta.35

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 CHANGED
@@ -35,7 +35,7 @@ var require_package = __commonJS({
35
35
  "package.json"(exports2, module2) {
36
36
  module2.exports = {
37
37
  name: "@virtuals-protocol/acp-node",
38
- version: "0.3.0-beta.34",
38
+ version: "0.3.0-beta.35",
39
39
  main: "./dist/index.js",
40
40
  module: "./dist/index.mjs",
41
41
  types: "./dist/index.d.ts",
@@ -4885,6 +4885,18 @@ var AcpClient = class {
4885
4885
  config.headers["authorization"] = `Bearer ${accessToken}`;
4886
4886
  return config;
4887
4887
  });
4888
+ this.acpClient.interceptors.response.use(
4889
+ (response) => response,
4890
+ async (error) => {
4891
+ const originalRequest = error.config;
4892
+ if (error.response?.status === 401 && originalRequest && !originalRequest._retried) {
4893
+ originalRequest._retried = true;
4894
+ this.accessToken = null;
4895
+ return this.acpClient(originalRequest);
4896
+ }
4897
+ return Promise.reject(error);
4898
+ }
4899
+ );
4888
4900
  this.onNewTask = options.onNewTask;
4889
4901
  this.onEvaluate = options.onEvaluate || this.defaultOnEvaluate;
4890
4902
  this.init(options.skipSocketConnection);
package/dist/index.mjs CHANGED
@@ -8,7 +8,7 @@ var require_package = __commonJS({
8
8
  "package.json"(exports, module) {
9
9
  module.exports = {
10
10
  name: "@virtuals-protocol/acp-node",
11
- version: "0.3.0-beta.34",
11
+ version: "0.3.0-beta.35",
12
12
  main: "./dist/index.js",
13
13
  module: "./dist/index.mjs",
14
14
  types: "./dist/index.d.ts",
@@ -4862,6 +4862,18 @@ var AcpClient = class {
4862
4862
  config.headers["authorization"] = `Bearer ${accessToken}`;
4863
4863
  return config;
4864
4864
  });
4865
+ this.acpClient.interceptors.response.use(
4866
+ (response) => response,
4867
+ async (error) => {
4868
+ const originalRequest = error.config;
4869
+ if (error.response?.status === 401 && originalRequest && !originalRequest._retried) {
4870
+ originalRequest._retried = true;
4871
+ this.accessToken = null;
4872
+ return this.acpClient(originalRequest);
4873
+ }
4874
+ return Promise.reject(error);
4875
+ }
4876
+ );
4865
4877
  this.onNewTask = options.onNewTask;
4866
4878
  this.onEvaluate = options.onEvaluate || this.defaultOnEvaluate;
4867
4879
  this.init(options.skipSocketConnection);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@virtuals-protocol/acp-node",
3
- "version": "0.3.0-beta.34",
3
+ "version": "0.3.0-beta.35",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",