@teambistux/piece-http-binary 0.0.0-stage → 0.1.0
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 +21 -4
- package/src/index.d.ts +4 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +18 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/send-http-request-action.d.ts +15 -0
- package/src/lib/actions/send-http-request-action.d.ts.map +1 -0
- package/src/lib/actions/send-http-request-action.js +370 -0
- package/src/lib/actions/send-http-request-action.js.map +1 -0
- package/src/lib/auth.d.ts +3 -0
- package/src/lib/auth.d.ts.map +1 -0
- package/src/lib/auth.js +31 -0
- package/src/lib/auth.js.map +1 -0
- package/README.md +0 -3
package/package.json
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambistux/piece-http-binary",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"displayName": "HTTP (Binary)",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"main": "./src/index.js",
|
|
6
|
+
"types": "./src/index.d.ts",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@activepieces/pieces-common": "*",
|
|
9
|
+
"@activepieces/pieces-framework": "*",
|
|
10
|
+
"form-data": "4.0.6",
|
|
11
|
+
"undici": "7.29.1"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"tslib": "2.6.2",
|
|
15
|
+
"vitest": "3.2.6"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc -p tsconfig.lib.json && cp package.json dist/",
|
|
19
|
+
"bundle": "node ../../../../dist/packages/cli/src/index.js pieces bundle",
|
|
20
|
+
"lint": "eslint 'src/**/*.ts'",
|
|
21
|
+
"test": "vitest run"
|
|
22
|
+
}
|
|
23
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { httpOauth2Auth } from './lib/auth';
|
|
2
|
+
declare const httpBinaryPiece: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
|
3
|
+
export { httpOauth2Auth, httpBinaryPiece };
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5C,QAAA,MAAM,eAAe,+JAQnB,CAAC;AAEH,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,CAAC"}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.httpBinaryPiece = exports.httpOauth2Auth = void 0;
|
|
4
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
5
|
+
const auth_1 = require("./lib/auth");
|
|
6
|
+
Object.defineProperty(exports, "httpOauth2Auth", { enumerable: true, get: function () { return auth_1.httpOauth2Auth; } });
|
|
7
|
+
const send_http_request_action_1 = require("./lib/actions/send-http-request-action");
|
|
8
|
+
const httpBinaryPiece = (0, pieces_framework_1.createPiece)({
|
|
9
|
+
displayName: 'HTTP (Binary)',
|
|
10
|
+
auth: auth_1.httpOauth2Auth,
|
|
11
|
+
minimumSupportedRelease: '0.56.0',
|
|
12
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/new-core/http.svg',
|
|
13
|
+
authors: ['mhshiba'],
|
|
14
|
+
actions: [send_http_request_action_1.httpBinaryRequestAction],
|
|
15
|
+
triggers: [],
|
|
16
|
+
});
|
|
17
|
+
exports.httpBinaryPiece = httpBinaryPiece;
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,qEAA6D;AAC7D,qCAA4C;AAanC,+FAbA,qBAAc,OAaA;AAZvB,qFAAiF;AAEjF,MAAM,eAAe,GAAG,IAAA,8BAAW,EAAC;IAClC,WAAW,EAAE,eAAe;IAC5B,IAAI,EAAE,qBAAc;IACpB,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,uDAAuD;IAChE,OAAO,EAAE,CAAC,SAAS,CAAC;IACpB,OAAO,EAAE,CAAC,kDAAuB,CAAC;IAClC,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC;AAEsB,0CAAe"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { HttpMethod } from '@activepieces/pieces-common';
|
|
2
|
+
declare const httpBinaryRequestAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
3
|
+
url: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
method: import("@activepieces/pieces-framework").StaticDropdownProperty<HttpMethod, true>;
|
|
5
|
+
headers: import("@activepieces/pieces-framework").ObjectProperty<false>;
|
|
6
|
+
queryParams: import("@activepieces/pieces-framework").ObjectProperty<false>;
|
|
7
|
+
body_type: import("@activepieces/pieces-framework").DropdownProperty<string, false, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
|
8
|
+
body: import("@activepieces/pieces-framework").DynamicProperties<false, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
|
9
|
+
use_proxy: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
10
|
+
proxy_settings: import("@activepieces/pieces-framework").DynamicProperties<false, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
|
|
11
|
+
failsafe: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
12
|
+
timeout: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
13
|
+
}>;
|
|
14
|
+
export { httpBinaryRequestAction };
|
|
15
|
+
//# sourceMappingURL=send-http-request-action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-http-request-action.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/send-http-request-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,UAAU,EAIX,MAAM,6BAA6B,CAAC;AAYrC,QAAA,MAAM,uBAAuB;;;;;;;;;;;EA2Y3B,CAAC;AA2BH,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.httpBinaryRequestAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
6
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
|
+
const form_data_1 = tslib_1.__importDefault(require("form-data"));
|
|
8
|
+
const undici_1 = require("undici");
|
|
9
|
+
const auth_1 = require("../auth");
|
|
10
|
+
const httpBinaryRequestAction = (0, pieces_framework_1.createAction)({
|
|
11
|
+
audience: 'both',
|
|
12
|
+
auth: auth_1.httpOauth2Auth,
|
|
13
|
+
name: 'send_request',
|
|
14
|
+
classification: 'WRITE',
|
|
15
|
+
displayName: 'Send HTTP request',
|
|
16
|
+
description: 'Sends HTTP request to a specified URL with OAuth 2.0 authorization, supporting raw binary, JSON, raw text, and form data.',
|
|
17
|
+
aiMetadata: {
|
|
18
|
+
description: 'Calls any HTTP endpoint with an OAuth 2.0 bearer token injected from the connection, supporting binary from URL, binary base64, JSON, raw, or form data.',
|
|
19
|
+
idempotent: false,
|
|
20
|
+
},
|
|
21
|
+
props: {
|
|
22
|
+
url: pieces_framework_1.Property.ShortText({
|
|
23
|
+
displayName: 'URL',
|
|
24
|
+
required: true,
|
|
25
|
+
}),
|
|
26
|
+
method: pieces_framework_1.Property.StaticDropdown({
|
|
27
|
+
displayName: 'Method',
|
|
28
|
+
required: true,
|
|
29
|
+
options: {
|
|
30
|
+
options: [
|
|
31
|
+
{ value: pieces_common_1.HttpMethod.GET, label: 'GET' },
|
|
32
|
+
{ value: pieces_common_1.HttpMethod.POST, label: 'POST' },
|
|
33
|
+
{ value: pieces_common_1.HttpMethod.PUT, label: 'PUT' },
|
|
34
|
+
{ value: pieces_common_1.HttpMethod.PATCH, label: 'PATCH' },
|
|
35
|
+
{ value: pieces_common_1.HttpMethod.DELETE, label: 'DELETE' },
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
39
|
+
headers: pieces_framework_1.Property.Object({
|
|
40
|
+
displayName: 'Headers',
|
|
41
|
+
required: false,
|
|
42
|
+
}),
|
|
43
|
+
queryParams: pieces_framework_1.Property.Object({
|
|
44
|
+
displayName: 'Query Parameters',
|
|
45
|
+
required: false,
|
|
46
|
+
}),
|
|
47
|
+
body_type: pieces_framework_1.Property.Dropdown({
|
|
48
|
+
displayName: 'Body Type',
|
|
49
|
+
required: false,
|
|
50
|
+
defaultValue: 'none',
|
|
51
|
+
auth: auth_1.httpOauth2Auth,
|
|
52
|
+
refreshers: ['method'],
|
|
53
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ method }) {
|
|
54
|
+
if (!(0, pieces_common_1.acceptsRequestBody)(method)) {
|
|
55
|
+
return {
|
|
56
|
+
disabled: true,
|
|
57
|
+
placeholder: 'Not available for GET requests',
|
|
58
|
+
options: [],
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
disabled: false,
|
|
63
|
+
options: [
|
|
64
|
+
{ label: 'None', value: 'none' },
|
|
65
|
+
{ label: 'Form Data', value: 'form_data' },
|
|
66
|
+
{ label: 'JSON', value: 'json' },
|
|
67
|
+
{ label: 'Raw', value: 'raw' },
|
|
68
|
+
{ label: 'Binary (from URL)', value: 'binary_url' },
|
|
69
|
+
{ label: 'Binary (base64)', value: 'binary_base64' },
|
|
70
|
+
],
|
|
71
|
+
};
|
|
72
|
+
}),
|
|
73
|
+
}),
|
|
74
|
+
body: pieces_framework_1.Property.DynamicProperties({
|
|
75
|
+
displayName: 'Body',
|
|
76
|
+
auth: auth_1.httpOauth2Auth,
|
|
77
|
+
refreshers: ['body_type', 'method'],
|
|
78
|
+
required: false,
|
|
79
|
+
props: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ body_type, method }) {
|
|
80
|
+
if (!body_type || !(0, pieces_common_1.acceptsRequestBody)(method))
|
|
81
|
+
return {};
|
|
82
|
+
const bodyTypeInput = body_type;
|
|
83
|
+
const fields = {};
|
|
84
|
+
switch (bodyTypeInput) {
|
|
85
|
+
case 'none':
|
|
86
|
+
break;
|
|
87
|
+
case 'json':
|
|
88
|
+
fields['data'] = pieces_framework_1.Property.Json({
|
|
89
|
+
displayName: 'JSON Body',
|
|
90
|
+
required: true,
|
|
91
|
+
});
|
|
92
|
+
break;
|
|
93
|
+
case 'raw':
|
|
94
|
+
fields['data'] = pieces_framework_1.Property.LongText({
|
|
95
|
+
displayName: 'Raw Body',
|
|
96
|
+
required: true,
|
|
97
|
+
});
|
|
98
|
+
break;
|
|
99
|
+
case 'form_data':
|
|
100
|
+
fields['data'] = pieces_framework_1.Property.Object({
|
|
101
|
+
displayName: 'Form Data',
|
|
102
|
+
required: true,
|
|
103
|
+
});
|
|
104
|
+
break;
|
|
105
|
+
case 'binary_url':
|
|
106
|
+
fields['binary_url'] = pieces_framework_1.Property.ShortText({
|
|
107
|
+
displayName: 'Binary (from URL)',
|
|
108
|
+
description: 'The URL to download the binary file from.',
|
|
109
|
+
required: true,
|
|
110
|
+
});
|
|
111
|
+
break;
|
|
112
|
+
case 'binary_base64':
|
|
113
|
+
fields['binary_base64'] = pieces_framework_1.Property.LongText({
|
|
114
|
+
displayName: 'Binary (base64)',
|
|
115
|
+
description: 'The base64 encoded binary content.',
|
|
116
|
+
required: true,
|
|
117
|
+
});
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
return fields;
|
|
121
|
+
}),
|
|
122
|
+
}),
|
|
123
|
+
use_proxy: pieces_framework_1.Property.Checkbox({
|
|
124
|
+
displayName: 'Use Proxy',
|
|
125
|
+
defaultValue: false,
|
|
126
|
+
description: 'Use a proxy for this request',
|
|
127
|
+
required: false,
|
|
128
|
+
}),
|
|
129
|
+
proxy_settings: pieces_framework_1.Property.DynamicProperties({
|
|
130
|
+
displayName: 'Proxy Settings',
|
|
131
|
+
auth: auth_1.httpOauth2Auth,
|
|
132
|
+
refreshers: ['use_proxy'],
|
|
133
|
+
required: false,
|
|
134
|
+
props: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ use_proxy }) {
|
|
135
|
+
if (!use_proxy)
|
|
136
|
+
return {};
|
|
137
|
+
const fields = {};
|
|
138
|
+
fields['proxy_host'] = pieces_framework_1.Property.ShortText({
|
|
139
|
+
displayName: 'Proxy Host',
|
|
140
|
+
required: true,
|
|
141
|
+
});
|
|
142
|
+
fields['proxy_port'] = pieces_framework_1.Property.Number({
|
|
143
|
+
displayName: 'Proxy Port',
|
|
144
|
+
required: true,
|
|
145
|
+
});
|
|
146
|
+
fields['proxy_username'] = pieces_framework_1.Property.ShortText({
|
|
147
|
+
displayName: 'Proxy Username',
|
|
148
|
+
required: false,
|
|
149
|
+
});
|
|
150
|
+
fields['proxy_password'] = pieces_framework_1.Property.ShortText({
|
|
151
|
+
displayName: 'Proxy Password',
|
|
152
|
+
required: false,
|
|
153
|
+
});
|
|
154
|
+
return fields;
|
|
155
|
+
}),
|
|
156
|
+
}),
|
|
157
|
+
failsafe: pieces_framework_1.Property.Checkbox({
|
|
158
|
+
displayName: 'No Error on Failure',
|
|
159
|
+
required: false,
|
|
160
|
+
}),
|
|
161
|
+
timeout: pieces_framework_1.Property.Number({
|
|
162
|
+
displayName: 'Timeout (in seconds)',
|
|
163
|
+
required: false,
|
|
164
|
+
}),
|
|
165
|
+
},
|
|
166
|
+
errorHandlingOptions: {
|
|
167
|
+
continueOnFailure: { hide: true },
|
|
168
|
+
retryOnFailure: { defaultValue: true },
|
|
169
|
+
},
|
|
170
|
+
run(context) {
|
|
171
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
172
|
+
var _a, _b, _c, _d, _e;
|
|
173
|
+
const { method, url, headers, queryParams, body, body_type, timeout, failsafe, use_proxy, } = context.propsValue;
|
|
174
|
+
const { auth } = context;
|
|
175
|
+
(0, pieces_framework_1.assertNotNullOrUndefined)(method, 'Method');
|
|
176
|
+
(0, pieces_framework_1.assertNotNullOrUndefined)(url, 'URL');
|
|
177
|
+
const requestHeaders = {};
|
|
178
|
+
if (headers && typeof headers === 'object') {
|
|
179
|
+
for (const [key, val] of Object.entries(headers)) {
|
|
180
|
+
if (val !== undefined && val !== null) {
|
|
181
|
+
requestHeaders[key] = String(val);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
const request = {
|
|
186
|
+
method,
|
|
187
|
+
url,
|
|
188
|
+
headers: requestHeaders,
|
|
189
|
+
queryParams: queryParams,
|
|
190
|
+
timeout: timeout ? timeout * 1000 : 0,
|
|
191
|
+
authentication: {
|
|
192
|
+
type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
|
|
193
|
+
token: auth.access_token,
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
let sentBytes = 0;
|
|
197
|
+
try {
|
|
198
|
+
if (body_type === 'binary_url') {
|
|
199
|
+
const rawUrl = (_a = body === null || body === void 0 ? void 0 : body['binary_url']) !== null && _a !== void 0 ? _a : body === null || body === void 0 ? void 0 : body['data'];
|
|
200
|
+
(0, pieces_framework_1.assertNotNullOrUndefined)(rawUrl, 'Binary URL');
|
|
201
|
+
const binaryUrl = String(rawUrl);
|
|
202
|
+
const downloadResponse = yield fetch(binaryUrl, {
|
|
203
|
+
method: 'GET',
|
|
204
|
+
headers: {
|
|
205
|
+
'User-Agent': 'Mozilla/5.0',
|
|
206
|
+
},
|
|
207
|
+
redirect: 'follow',
|
|
208
|
+
signal: AbortSignal.timeout(120000),
|
|
209
|
+
});
|
|
210
|
+
if (!downloadResponse.ok) {
|
|
211
|
+
throw new Error(`Failed to download binary from URL (${downloadResponse.status} ${downloadResponse.statusText}): ${binaryUrl}`);
|
|
212
|
+
}
|
|
213
|
+
const downloadedContentType = downloadResponse.headers.get('content-type');
|
|
214
|
+
const arrayBuffer = yield downloadResponse.arrayBuffer();
|
|
215
|
+
const buffer = Buffer.from(arrayBuffer);
|
|
216
|
+
if (buffer.length === 0) {
|
|
217
|
+
throw new Error('Downloaded binary is empty (0 bytes).');
|
|
218
|
+
}
|
|
219
|
+
if (buffer.length < 1024) {
|
|
220
|
+
const preview = buffer.toString('utf-8', 0, Math.min(200, buffer.length));
|
|
221
|
+
throw new Error(`Downloaded binary is under 1 KB (${buffer.length} bytes), which usually indicates an error or HTML page: ${preview}`);
|
|
222
|
+
}
|
|
223
|
+
request.body = buffer;
|
|
224
|
+
sentBytes = buffer.length;
|
|
225
|
+
if (!hasContentTypeHeader({ headers: request.headers })) {
|
|
226
|
+
request.headers = Object.assign(Object.assign({}, request.headers), { 'Content-Type': downloadedContentType || 'application/octet-stream' });
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
else if (body_type === 'binary_base64') {
|
|
230
|
+
const rawBase64 = (_b = body === null || body === void 0 ? void 0 : body['binary_base64']) !== null && _b !== void 0 ? _b : body === null || body === void 0 ? void 0 : body['data'];
|
|
231
|
+
(0, pieces_framework_1.assertNotNullOrUndefined)(rawBase64, 'Binary base64');
|
|
232
|
+
const base64String = String(rawBase64);
|
|
233
|
+
const buffer = Buffer.from(base64String, 'base64');
|
|
234
|
+
if (buffer.length === 0) {
|
|
235
|
+
throw new Error('Decoded base64 binary is empty (0 bytes).');
|
|
236
|
+
}
|
|
237
|
+
if (buffer.length < 1024) {
|
|
238
|
+
const preview = buffer.toString('utf-8', 0, Math.min(200, buffer.length));
|
|
239
|
+
throw new Error(`Decoded binary is under 1 KB (${buffer.length} bytes), which usually indicates an error or HTML page: ${preview}`);
|
|
240
|
+
}
|
|
241
|
+
request.body = buffer;
|
|
242
|
+
sentBytes = buffer.length;
|
|
243
|
+
if (!hasContentTypeHeader({ headers: request.headers })) {
|
|
244
|
+
request.headers = Object.assign(Object.assign({}, request.headers), { 'Content-Type': 'application/octet-stream' });
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
else if (body) {
|
|
248
|
+
const bodyInput = body['data'];
|
|
249
|
+
if (body_type === 'form_data') {
|
|
250
|
+
const formData = new form_data_1.default();
|
|
251
|
+
for (const key in bodyInput) {
|
|
252
|
+
formData.append(key, bodyInput[key]);
|
|
253
|
+
}
|
|
254
|
+
request.body = formData;
|
|
255
|
+
request.headers = Object.assign(Object.assign({}, request.headers), formData.getHeaders());
|
|
256
|
+
try {
|
|
257
|
+
sentBytes = formData.getLengthSync();
|
|
258
|
+
}
|
|
259
|
+
catch (_f) {
|
|
260
|
+
sentBytes = 0;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
request.body = bodyInput;
|
|
265
|
+
if (typeof bodyInput === 'string') {
|
|
266
|
+
sentBytes = Buffer.byteLength(bodyInput, 'utf-8');
|
|
267
|
+
}
|
|
268
|
+
else if (bodyInput !== undefined && bodyInput !== null) {
|
|
269
|
+
sentBytes = Buffer.byteLength(JSON.stringify(bodyInput), 'utf-8');
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
if (use_proxy) {
|
|
274
|
+
const proxySettings = context.propsValue.proxy_settings;
|
|
275
|
+
(0, pieces_framework_1.assertNotNullOrUndefined)(proxySettings, 'Proxy Settings');
|
|
276
|
+
(0, pieces_framework_1.assertNotNullOrUndefined)(proxySettings['proxy_host'], 'Proxy Host');
|
|
277
|
+
(0, pieces_framework_1.assertNotNullOrUndefined)(proxySettings['proxy_port'], 'Proxy Port');
|
|
278
|
+
let proxyUrl = '';
|
|
279
|
+
if (proxySettings['proxy_username'] &&
|
|
280
|
+
proxySettings['proxy_password']) {
|
|
281
|
+
proxyUrl = `http://${proxySettings['proxy_username']}:${proxySettings['proxy_password']}@${proxySettings['proxy_host']}:${proxySettings['proxy_port']}`;
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
proxyUrl = `http://${proxySettings['proxy_host']}:${proxySettings['proxy_port']}`;
|
|
285
|
+
}
|
|
286
|
+
const proxyAgent = new undici_1.ProxyAgent(proxyUrl);
|
|
287
|
+
const proxyUrlWithParams = new URL(request.url);
|
|
288
|
+
for (const [key, value] of Object.entries((_c = request.queryParams) !== null && _c !== void 0 ? _c : {})) {
|
|
289
|
+
proxyUrlWithParams.searchParams.append(key, value);
|
|
290
|
+
}
|
|
291
|
+
const proxyHeaders = {
|
|
292
|
+
Authorization: `Bearer ${auth.access_token}`,
|
|
293
|
+
};
|
|
294
|
+
for (const [key, value] of Object.entries((_d = request.headers) !== null && _d !== void 0 ? _d : {})) {
|
|
295
|
+
if (value !== undefined) {
|
|
296
|
+
proxyHeaders[key] = Array.isArray(value) ? value.join(', ') : value;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
let proxyBody;
|
|
300
|
+
if (request.method !== pieces_common_1.HttpMethod.GET &&
|
|
301
|
+
request.method !== pieces_common_1.HttpMethod.HEAD &&
|
|
302
|
+
!(0, pieces_framework_1.isNil)(request.body)) {
|
|
303
|
+
if (request.body instanceof form_data_1.default) {
|
|
304
|
+
proxyBody = request.body.getBuffer();
|
|
305
|
+
}
|
|
306
|
+
else if (Buffer.isBuffer(request.body)) {
|
|
307
|
+
proxyBody = request.body;
|
|
308
|
+
}
|
|
309
|
+
else if (typeof request.body === 'string') {
|
|
310
|
+
proxyBody = request.body;
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
proxyBody = JSON.stringify(request.body);
|
|
314
|
+
if (!hasContentTypeHeader({ headers: proxyHeaders })) {
|
|
315
|
+
proxyHeaders['Content-Type'] = 'application/json';
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
const proxiedResponse = yield fetch(proxyUrlWithParams.toString(), {
|
|
320
|
+
method: request.method.toString(),
|
|
321
|
+
headers: proxyHeaders,
|
|
322
|
+
body: proxyBody,
|
|
323
|
+
dispatcher: proxyAgent,
|
|
324
|
+
});
|
|
325
|
+
const proxyContentType = (_e = proxiedResponse.headers.get('content-type')) !== null && _e !== void 0 ? _e : '';
|
|
326
|
+
const proxyData = proxyContentType.includes('application/json')
|
|
327
|
+
? yield proxiedResponse.json()
|
|
328
|
+
: yield proxiedResponse.text();
|
|
329
|
+
return {
|
|
330
|
+
status: proxiedResponse.status,
|
|
331
|
+
headers: toHeadersObject({ headers: proxiedResponse.headers }),
|
|
332
|
+
body: proxyData,
|
|
333
|
+
sentBytes,
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
const response = yield pieces_common_1.httpClient.sendRequest(request);
|
|
337
|
+
return {
|
|
338
|
+
status: response.status,
|
|
339
|
+
headers: response.headers,
|
|
340
|
+
body: response.body,
|
|
341
|
+
sentBytes,
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
catch (error) {
|
|
345
|
+
if (failsafe) {
|
|
346
|
+
const safeRequestBody = Buffer.isBuffer(request.body)
|
|
347
|
+
? `[binary data ${request.body.length} bytes]`
|
|
348
|
+
: request.body;
|
|
349
|
+
return (0, pieces_common_1.toFailsafeOutput)({ error, requestBody: safeRequestBody });
|
|
350
|
+
}
|
|
351
|
+
throw error;
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
},
|
|
355
|
+
});
|
|
356
|
+
exports.httpBinaryRequestAction = httpBinaryRequestAction;
|
|
357
|
+
function hasContentTypeHeader({ headers, }) {
|
|
358
|
+
if (!headers) {
|
|
359
|
+
return false;
|
|
360
|
+
}
|
|
361
|
+
return Object.keys(headers).some((key) => key.toLowerCase() === 'content-type');
|
|
362
|
+
}
|
|
363
|
+
function toHeadersObject({ headers, }) {
|
|
364
|
+
const result = {};
|
|
365
|
+
headers.forEach((value, key) => {
|
|
366
|
+
result[key] = value;
|
|
367
|
+
});
|
|
368
|
+
return result;
|
|
369
|
+
}
|
|
370
|
+
//# sourceMappingURL=send-http-request-action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-http-request-action.js","sourceRoot":"","sources":["../../../../src/lib/actions/send-http-request-action.ts"],"names":[],"mappings":";;;;AAAA,+DAQqC;AACrC,qEAMwC;AACxC,kEAAiC;AACjC,mCAAoC;AACpC,kCAAyC;AAEzC,MAAM,uBAAuB,GAAG,IAAA,+BAAY,EAAC;IAC3C,QAAQ,EAAE,MAAM;IAChB,IAAI,EAAE,qBAAc;IACpB,IAAI,EAAE,cAAc;IACpB,cAAc,EAAE,OAAO;IACvB,WAAW,EAAE,mBAAmB;IAChC,WAAW,EACT,2HAA2H;IAC7H,UAAU,EAAE;QACV,WAAW,EACT,0JAA0J;QAC5J,UAAU,EAAE,KAAK;KAClB;IACD,KAAK,EAAE;QACL,GAAG,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACtB,WAAW,EAAE,KAAK;YAClB,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,MAAM,EAAE,2BAAQ,CAAC,cAAc,CAAC;YAC9B,WAAW,EAAE,QAAQ;YACrB,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,EAAE,KAAK,EAAE,0BAAU,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE;oBACvC,EAAE,KAAK,EAAE,0BAAU,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE;oBACzC,EAAE,KAAK,EAAE,0BAAU,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE;oBACvC,EAAE,KAAK,EAAE,0BAAU,C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QAAQ,EAAE,CAAC;oBACb,MAAM,eAAe,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC;wBACnD,CAAC,CAAC,gBAAgB,OAAO,CAAC,IAAI,CAAC,MAAM,SAAS;wBAC9C,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;oBACjB,OAAO,IAAA,gCAAgB,EAAC,EAAE,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC,CAAC;gBACnE,CAAC;gBAED,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC;AA2BM,0DAAuB;AAzBhC,SAAS,oBAAoB,CAAC,EAC5B,OAAO,GAGR;IACC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAC9B,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,cAAc,CAC9C,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,EACvB,OAAO,GAGR;IACC,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAC7B,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACtB,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/lib/auth.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,cAAc,+GAwBlB,CAAC;AAEH,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
package/src/lib/auth.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.httpOauth2Auth = void 0;
|
|
4
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
5
|
+
const httpOauth2Auth = pieces_framework_1.PieceAuth.OAuth2({
|
|
6
|
+
description: 'OAuth2',
|
|
7
|
+
authUrl: '{authUrl}',
|
|
8
|
+
tokenUrl: '{tokenUrl}',
|
|
9
|
+
required: true,
|
|
10
|
+
scope: '{scopes}'.split(' '),
|
|
11
|
+
grantType: 'both_client_credentials_and_authorization_code',
|
|
12
|
+
props: {
|
|
13
|
+
authUrl: pieces_framework_1.Property.ShortText({
|
|
14
|
+
displayName: 'Authorize URL',
|
|
15
|
+
required: true,
|
|
16
|
+
description: 'OAuth2 Authorize URL',
|
|
17
|
+
}),
|
|
18
|
+
tokenUrl: pieces_framework_1.Property.ShortText({
|
|
19
|
+
displayName: 'Token URL',
|
|
20
|
+
required: true,
|
|
21
|
+
description: 'OAuth2 Token URL',
|
|
22
|
+
}),
|
|
23
|
+
scopes: pieces_framework_1.Property.ShortText({
|
|
24
|
+
displayName: 'Scopes (whitespace separated)',
|
|
25
|
+
required: true,
|
|
26
|
+
description: 'OAuth2 Scopes',
|
|
27
|
+
}),
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
exports.httpOauth2Auth = httpOauth2Auth;
|
|
31
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/lib/auth.ts"],"names":[],"mappings":";;;AAAA,qEAAqE;AAErE,MAAM,cAAc,GAAG,4BAAS,CAAC,MAAM,CAAC;IACtC,WAAW,EAAE,QAAQ;IACrB,OAAO,EAAE,WAAW;IACpB,QAAQ,EAAE,YAAY;IACtB,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC;IAC5B,SAAS,EAAE,gDAAgD;IAC3D,KAAK,EAAE;QACL,OAAO,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC1B,WAAW,EAAE,eAAe;YAC5B,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,sBAAsB;SACpC,CAAC;QACF,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC3B,WAAW,EAAE,WAAW;YACxB,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,kBAAkB;SAChC,CAAC;QACF,MAAM,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACzB,WAAW,EAAE,+BAA+B;YAC5C,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,eAAe;SAC7B,CAAC;KACH;CACF,CAAC,CAAC;AAEM,wCAAc"}
|
package/README.md
DELETED