@scopieflows/apps-common 0.12.3 → 0.12.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/package.json +13 -5
- package/src/lib/http/axios/axios-http-client.d.ts.map +1 -1
- package/src/lib/http/axios/axios-http-client.js +27 -2
- package/src/lib/http/axios/axios-http-client.js.map +1 -1
- package/src/lib/http/core/http-error.d.ts +7 -1
- package/src/lib/http/core/http-error.d.ts.map +1 -1
- package/src/lib/http/core/http-error.js +85 -4
- package/src/lib/http/core/http-error.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scopieflows/apps-common",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.5",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc -p tsconfig.lib.json && cp package.json dist/",
|
|
9
|
+
"lint": "eslint 'src/**/*.ts'",
|
|
10
|
+
"test": "node --test \"tests/**/*.test.mjs\""
|
|
11
|
+
},
|
|
7
12
|
"dependencies": {
|
|
8
|
-
"@scopieflows/apps-framework": "0.28.
|
|
9
|
-
"@scopieflows/shared": "0.
|
|
10
|
-
"axios": "1.
|
|
13
|
+
"@scopieflows/apps-framework": "^0.28.4",
|
|
14
|
+
"@scopieflows/shared": "^0.60.1",
|
|
15
|
+
"axios": "1.19.0",
|
|
11
16
|
"axios-retry": "4.4.1",
|
|
12
17
|
"form-data": "4.0.4",
|
|
13
18
|
"http-proxy-agent": "7.0.2",
|
|
@@ -15,5 +20,8 @@
|
|
|
15
20
|
"mime-types": "2.1.35",
|
|
16
21
|
"tslib": "2.6.2",
|
|
17
22
|
"zod": "4.3.6"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/mime-types": "2.1.1"
|
|
18
26
|
}
|
|
19
|
-
}
|
|
27
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axios-http-client.d.ts","sourceRoot":"","sources":["../../../../../src/lib/http/axios/axios-http-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"axios-http-client.d.ts","sourceRoot":"","sources":["../../../../../src/lib/http/axios/axios-http-client.ts"],"names":[],"mappings":"AACA,OAAc,EAAE,aAAa,EAAsB,MAAM,OAAO,CAAC;AAIjE,OAAO,EAAE,iCAAiC,EAAE,MAAM,6CAA6C,CAAC;AAChG,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG1D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AA0B5D,qBAAa,eAAgB,SAAQ,cAAc;gBAE/C,OAAO,SAAK,EACZ,uBAAuB,GAAE,iCAA2E;IAKhG,WAAW,CAAC,YAAY,SAAS,eAAe,GAAG,GAAG,EAC1D,OAAO,EAAE,WAAW,CAAC,eAAe,CAAC,EACrC,WAAW,CAAC,EAAE,aAAa,GAC1B,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;IAuFtC,OAAO,CAAC,qBAAqB;CAG9B"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AxiosHttpClient = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const node_https_1 = tslib_1.__importDefault(require("node:https"));
|
|
5
6
|
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
6
7
|
const axios_retry_1 = tslib_1.__importDefault(require("axios-retry"));
|
|
7
8
|
const http_proxy_agent_1 = require("http-proxy-agent");
|
|
@@ -9,6 +10,25 @@ const https_proxy_agent_1 = require("https-proxy-agent");
|
|
|
9
10
|
const delegating_authentication_converter_1 = require("../core/delegating-authentication-converter");
|
|
10
11
|
const base_http_client_1 = require("../core/base-http-client");
|
|
11
12
|
const http_error_1 = require("../core/http-error");
|
|
13
|
+
// TLS certificate validation is ON by default. Historically this client set
|
|
14
|
+
// NODE_TLS_REJECT_UNAUTHORIZED='0' on every request (inherited from upstream
|
|
15
|
+
// Activepieces, commit 4465202a "fix: accept unauthorized requests"), which
|
|
16
|
+
// disabled cert checks for the ENTIRE worker/engine process — not just this
|
|
17
|
+
// client. Deployments that genuinely need to reach self-signed HTTPS endpoints
|
|
18
|
+
// (local-dev AI providers, on-prem services) must now opt in explicitly with
|
|
19
|
+
// SF_INSECURE_TLS=1 (same switch the agent-cli bootstrap honors), which scopes
|
|
20
|
+
// the relaxation to this client's requests via a per-agent TLS option instead
|
|
21
|
+
// of mutating process-global state.
|
|
22
|
+
const INSECURE_TLS_ENV = 'SF_INSECURE_TLS';
|
|
23
|
+
let warnedInsecureTls = false;
|
|
24
|
+
function insecureTlsOptedIn() {
|
|
25
|
+
const optedIn = process.env[INSECURE_TLS_ENV] === '1';
|
|
26
|
+
if (optedIn && !warnedInsecureTls) {
|
|
27
|
+
warnedInsecureTls = true;
|
|
28
|
+
console.warn(`[HttpClient] ${INSECURE_TLS_ENV}=1 — TLS certificate validation is DISABLED for piece HTTP requests. Do not use this in production.`);
|
|
29
|
+
}
|
|
30
|
+
return optedIn;
|
|
31
|
+
}
|
|
12
32
|
class AxiosHttpClient extends base_http_client_1.BaseHttpClient {
|
|
13
33
|
constructor(baseUrl = '', authenticationConverter = new delegating_authentication_converter_1.DelegatingAuthenticationConverter()) {
|
|
14
34
|
super(baseUrl, authenticationConverter);
|
|
@@ -18,7 +38,6 @@ class AxiosHttpClient extends base_http_client_1.BaseHttpClient {
|
|
|
18
38
|
var _a, _b;
|
|
19
39
|
try {
|
|
20
40
|
const axiosInstance = axiosClient || axios_1.default.create();
|
|
21
|
-
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0';
|
|
22
41
|
const { urlWithoutQueryParams, queryParams: urlQueryParams } = this.getUrl(request);
|
|
23
42
|
const headers = this.getHeaders(request);
|
|
24
43
|
const axiosRequestMethod = this.getAxiosRequestMethod(request.method);
|
|
@@ -37,13 +56,19 @@ class AxiosHttpClient extends base_http_client_1.BaseHttpClient {
|
|
|
37
56
|
timeout,
|
|
38
57
|
responseType,
|
|
39
58
|
};
|
|
59
|
+
const insecureTls = insecureTlsOptedIn();
|
|
40
60
|
const httpProxy = (_a = process.env['HTTP_PROXY']) !== null && _a !== void 0 ? _a : process.env['http_proxy'];
|
|
41
61
|
const httpsProxy = (_b = process.env['HTTPS_PROXY']) !== null && _b !== void 0 ? _b : process.env['https_proxy'];
|
|
42
62
|
if (httpProxy) {
|
|
43
63
|
config.httpAgent = new http_proxy_agent_1.HttpProxyAgent(httpProxy);
|
|
44
64
|
}
|
|
45
65
|
if (httpsProxy) {
|
|
46
|
-
config.httpsAgent =
|
|
66
|
+
config.httpsAgent = insecureTls
|
|
67
|
+
? new https_proxy_agent_1.HttpsProxyAgent(httpsProxy, { rejectUnauthorized: false })
|
|
68
|
+
: new https_proxy_agent_1.HttpsProxyAgent(httpsProxy);
|
|
69
|
+
}
|
|
70
|
+
else if (insecureTls) {
|
|
71
|
+
config.httpsAgent = new node_https_1.default.Agent({ rejectUnauthorized: false });
|
|
47
72
|
}
|
|
48
73
|
if (httpProxy || httpsProxy) {
|
|
49
74
|
config.proxy = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axios-http-client.js","sourceRoot":"","sources":["../../../../../src/lib/http/axios/axios-http-client.ts"],"names":[],"mappings":";;;;AAAA,0DAAiE;AACjE,sEAAqC;AACrC,uDAAkD;AAClD,yDAAoD;AACpD,qGAAgG;AAChG,+DAA0D;AAC1D,mDAA+C;
|
|
1
|
+
{"version":3,"file":"axios-http-client.js","sourceRoot":"","sources":["../../../../../src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AE,QAAQ,CAAC,MAAM;oBACvB,OAAO,EAAE,QAAQ,CAAC,OAAsB;oBACxC,IAAI,EAAE,QAAQ,CAAC,IAAI;iBACpB,CAAC;YACJ,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,IAAI,eAAK,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;oBAC1B,MAAM,SAAS,GAAG,IAAI,sBAAS,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;oBACjD,OAAO,CAAC,KAAK,CACX,wDAAwD,EACxD,SAAS,CACV,CAAC;oBACF,MAAM,SAAS,CAAC;gBAClB,CAAC;gBACD,MAAM,CAAC,CAAC;YACV,CAAC;QACH,CAAC;KAAA;IAEO,qBAAqB,CAAC,UAAsB;QAClD,OAAO,UAAU,CAAC,QAAQ,EAAE,CAAC;IAC/B,CAAC;CACF;AArGD,0CAqGC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AxiosError } from 'axios';
|
|
2
2
|
export declare class HttpError extends Error {
|
|
3
|
-
private readonly requestBody;
|
|
4
3
|
private readonly status;
|
|
5
4
|
private readonly responseBody;
|
|
5
|
+
private readonly safeRequestBody;
|
|
6
6
|
constructor(requestBody: unknown, err: AxiosError);
|
|
7
7
|
errorMessage(): {
|
|
8
8
|
response: {
|
|
@@ -17,6 +17,12 @@ export declare class HttpError extends Error {
|
|
|
17
17
|
status: number;
|
|
18
18
|
body: unknown;
|
|
19
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* The request body with credentials removed.
|
|
22
|
+
*
|
|
23
|
+
* Deliberately NOT the raw body: this is read by piece error handlers and
|
|
24
|
+
* ends up in user-visible run output.
|
|
25
|
+
*/
|
|
20
26
|
get request(): {
|
|
21
27
|
body: unknown;
|
|
22
28
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-error.d.ts","sourceRoot":"","sources":["../../../../../src/lib/http/core/http-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"http-error.d.ts","sourceRoot":"","sources":["../../../../../src/lib/http/core/http-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AA6EnC,qBAAa,SAAU,SAAQ,KAAK;IAClC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAU;IACvC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAU;gBAK9B,WAAW,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU;IAsB1C,YAAY;;;;;;;;;IAYnB,IAAI,QAAQ;;;MAKX;IAED;;;;;OAKG;IACH,IAAI,OAAO;;MAIV;CACF"}
|
|
@@ -1,23 +1,98 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HttpError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Keys whose values are credentials rather than debuggable input.
|
|
6
|
+
*
|
|
7
|
+
* Matched case-insensitively against a normalised key (non-alphanumerics
|
|
8
|
+
* stripped), so `client_secret`, `clientSecret` and `Client-Secret` all hit the
|
|
9
|
+
* same entry.
|
|
10
|
+
*/
|
|
11
|
+
const SENSITIVE_KEYS = new Set([
|
|
12
|
+
'password',
|
|
13
|
+
'passwd',
|
|
14
|
+
'passphrase',
|
|
15
|
+
'secret',
|
|
16
|
+
'clientsecret',
|
|
17
|
+
'apikey',
|
|
18
|
+
'apitoken',
|
|
19
|
+
'token',
|
|
20
|
+
'accesstoken',
|
|
21
|
+
'refreshtoken',
|
|
22
|
+
'idtoken',
|
|
23
|
+
'authorization',
|
|
24
|
+
'auth',
|
|
25
|
+
'totp',
|
|
26
|
+
'otp',
|
|
27
|
+
'mfa',
|
|
28
|
+
'mfasecret',
|
|
29
|
+
'pin',
|
|
30
|
+
'codeverifier',
|
|
31
|
+
'privatekey',
|
|
32
|
+
'subscriptionkey',
|
|
33
|
+
'sessionkey',
|
|
34
|
+
'credentials',
|
|
35
|
+
]);
|
|
36
|
+
const REDACTED = '[redacted]';
|
|
37
|
+
const MAX_DEPTH = 6;
|
|
38
|
+
function isSensitive(key) {
|
|
39
|
+
return SENSITIVE_KEYS.has(key.toLowerCase().replace(/[^a-z0-9]/gi, ''));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Strip credentials from a request body before it is recorded on the error.
|
|
43
|
+
*
|
|
44
|
+
* Why this exists: the request body is kept because knowing what you sent is
|
|
45
|
+
* usually the whole point of a failed-request error. But on an auth endpoint the
|
|
46
|
+
* body IS the credential — a login posts a password, a token exchange posts a
|
|
47
|
+
* client secret — and this error's message is JSON.stringify'd into
|
|
48
|
+
* `Error.message`, which reaches the server console, a piece's error handler
|
|
49
|
+
* and the flow run output a user can read.
|
|
50
|
+
*
|
|
51
|
+
* Redaction preserves the shape, so the error still shows which fields were
|
|
52
|
+
* sent and what their names were; only the values go.
|
|
53
|
+
*/
|
|
54
|
+
function redact(value, depth = 0) {
|
|
55
|
+
var _a, _b;
|
|
56
|
+
if (depth > MAX_DEPTH || value === null || typeof value !== 'object') {
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
if (Array.isArray(value)) {
|
|
60
|
+
return value.map((item) => redact(item, depth + 1));
|
|
61
|
+
}
|
|
62
|
+
// Preserve non-plain objects (Buffer, streams, FormData) by description
|
|
63
|
+
// rather than walking them — they are not useful in an error message and may
|
|
64
|
+
// be large.
|
|
65
|
+
const proto = Object.getPrototypeOf(value);
|
|
66
|
+
if (proto !== Object.prototype && proto !== null) {
|
|
67
|
+
return `[${(_b = (_a = value.constructor) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : 'object'}]`;
|
|
68
|
+
}
|
|
69
|
+
const out = {};
|
|
70
|
+
for (const [key, item] of Object.entries(value)) {
|
|
71
|
+
out[key] = isSensitive(key) ? REDACTED : redact(item, depth + 1);
|
|
72
|
+
}
|
|
73
|
+
return out;
|
|
74
|
+
}
|
|
4
75
|
class HttpError extends Error {
|
|
76
|
+
// `requestBody` is deliberately a plain parameter, not a property: retaining
|
|
77
|
+
// the raw body would leave credentials on the instance for anything that
|
|
78
|
+
// enumerates it, and TypeScript's `private` is compile-time only.
|
|
5
79
|
constructor(requestBody, err) {
|
|
6
80
|
var _a, _b, _c, _d;
|
|
7
81
|
const status = ((_a = err === null || err === void 0 ? void 0 : err.response) === null || _a === void 0 ? void 0 : _a.status) || 500;
|
|
8
82
|
const responseBody = Buffer.isBuffer((_b = err === null || err === void 0 ? void 0 : err.response) === null || _b === void 0 ? void 0 : _b.data) ? (_c = err === null || err === void 0 ? void 0 : err.response) === null || _c === void 0 ? void 0 : _c.data.toString() : (_d = err === null || err === void 0 ? void 0 : err.response) === null || _d === void 0 ? void 0 : _d.data;
|
|
83
|
+
const safeRequestBody = redact(requestBody);
|
|
9
84
|
super(JSON.stringify({
|
|
10
85
|
response: {
|
|
11
86
|
status: status,
|
|
12
87
|
body: responseBody,
|
|
13
88
|
},
|
|
14
89
|
request: {
|
|
15
|
-
body:
|
|
90
|
+
body: safeRequestBody,
|
|
16
91
|
},
|
|
17
92
|
}));
|
|
18
|
-
this.requestBody = requestBody;
|
|
19
93
|
this.status = status;
|
|
20
94
|
this.responseBody = responseBody;
|
|
95
|
+
this.safeRequestBody = safeRequestBody;
|
|
21
96
|
}
|
|
22
97
|
errorMessage() {
|
|
23
98
|
return {
|
|
@@ -26,7 +101,7 @@ class HttpError extends Error {
|
|
|
26
101
|
body: this.responseBody,
|
|
27
102
|
},
|
|
28
103
|
request: {
|
|
29
|
-
body: this.
|
|
104
|
+
body: this.safeRequestBody,
|
|
30
105
|
},
|
|
31
106
|
};
|
|
32
107
|
}
|
|
@@ -36,9 +111,15 @@ class HttpError extends Error {
|
|
|
36
111
|
body: this.responseBody,
|
|
37
112
|
};
|
|
38
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* The request body with credentials removed.
|
|
116
|
+
*
|
|
117
|
+
* Deliberately NOT the raw body: this is read by piece error handlers and
|
|
118
|
+
* ends up in user-visible run output.
|
|
119
|
+
*/
|
|
39
120
|
get request() {
|
|
40
121
|
return {
|
|
41
|
-
body: this.
|
|
122
|
+
body: this.safeRequestBody,
|
|
42
123
|
};
|
|
43
124
|
}
|
|
44
125
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-error.js","sourceRoot":"","sources":["../../../../../src/lib/http/core/http-error.ts"],"names":[],"mappings":";;;AAEA,MAAa,SAAU,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"http-error.js","sourceRoot":"","sources":["../../../../../src/lib/http/core/http-error.ts"],"names":[],"mappings":";;;AAEA;;;;;;GAMG;AACH,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC7B,UAAU;IACV,QAAQ;IACR,YAAY;IACZ,QAAQ;IACR,cAAc;IACd,QAAQ;IACR,UAAU;IACV,OAAO;IACP,aAAa;IACb,cAAc;IACd,SAAS;IACT,eAAe;IACf,MAAM;IACN,MAAM;IACN,KAAK;IACL,KAAK;IACL,WAAW;IACX,KAAK;IACL,cAAc;IACd,YAAY;IACZ,iBAAiB;IACjB,YAAY;IACZ,aAAa;CACd,CAAC,CAAC;AAEH,MAAM,QAAQ,GAAG,YAAY,CAAC;AAC9B,MAAM,SAAS,GAAG,CAAC,CAAC;AAEpB,SAAS,WAAW,CAAC,GAAW;IAC9B,OAAO,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,CAAC;AAC1E,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAS,MAAM,CAAC,KAAc,EAAE,KAAK,GAAG,CAAC;;IACvC,IAAI,KAAK,GAAG,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACrE,O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