recker 1.0.15 → 1.0.17-next.316500c
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/README.md +86 -97
- package/dist/ai/providers/anthropic.d.ts.map +1 -1
- package/dist/ai/providers/anthropic.js +4 -1
- package/dist/ai/providers/base.d.ts.map +1 -1
- package/dist/ai/providers/base.js +7 -2
- package/dist/ai/rate-limiter.d.ts.map +1 -1
- package/dist/ai/rate-limiter.js +4 -1
- package/dist/bench/generator.d.ts.map +1 -1
- package/dist/bench/generator.js +8 -3
- package/dist/bench/stats.d.ts +15 -1
- package/dist/bench/stats.d.ts.map +1 -1
- package/dist/bench/stats.js +117 -5
- package/dist/cache/memory-storage.d.ts.map +1 -1
- package/dist/cache/memory-storage.js +3 -2
- package/dist/cli/handler.js +14 -14
- package/dist/cli/index.js +602 -48
- package/dist/cli/presets.js +5 -5
- package/dist/cli/tui/ai-chat.js +10 -10
- package/dist/cli/tui/load-dashboard.d.ts.map +1 -1
- package/dist/cli/tui/load-dashboard.js +127 -32
- package/dist/cli/tui/scroll-buffer.d.ts +43 -0
- package/dist/cli/tui/scroll-buffer.d.ts.map +1 -0
- package/dist/cli/tui/scroll-buffer.js +162 -0
- package/dist/cli/tui/search-panel.d.ts +41 -0
- package/dist/cli/tui/search-panel.d.ts.map +1 -0
- package/dist/cli/tui/search-panel.js +420 -0
- package/dist/cli/tui/shell.d.ts +14 -0
- package/dist/cli/tui/shell.d.ts.map +1 -1
- package/dist/cli/tui/shell.js +424 -46
- package/dist/cli/tui/websocket.js +17 -17
- package/dist/contract/index.d.ts.map +1 -1
- package/dist/contract/index.js +3 -2
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/client.js +18 -26
- package/dist/core/errors.d.ts +109 -1
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +214 -1
- package/dist/core/request-promise.d.ts.map +1 -1
- package/dist/core/request-promise.js +5 -6
- package/dist/core/response.d.ts.map +1 -1
- package/dist/core/response.js +5 -6
- package/dist/dns/index.d.ts +1 -0
- package/dist/dns/index.d.ts.map +1 -1
- package/dist/dns/index.js +1 -0
- package/dist/dns/propagation.d.ts +21 -0
- package/dist/dns/propagation.d.ts.map +1 -0
- package/dist/dns/propagation.js +169 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/mcp/client.d.ts.map +1 -1
- package/dist/mcp/client.js +10 -11
- package/dist/mcp/embeddings-loader.d.ts +18 -0
- package/dist/mcp/embeddings-loader.d.ts.map +1 -0
- package/dist/mcp/embeddings-loader.js +162 -0
- package/dist/mcp/geoip-loader.d.ts +11 -0
- package/dist/mcp/geoip-loader.d.ts.map +1 -0
- package/dist/mcp/geoip-loader.js +107 -0
- package/dist/mcp/index.d.ts +1 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1 -0
- package/dist/mcp/ip-intel.d.ts +28 -0
- package/dist/mcp/ip-intel.d.ts.map +1 -0
- package/dist/mcp/ip-intel.js +209 -0
- package/dist/mcp/search/hybrid-search.d.ts.map +1 -1
- package/dist/mcp/search/hybrid-search.js +59 -38
- package/dist/mcp/search/math.d.ts.map +1 -1
- package/dist/mcp/search/math.js +5 -1
- package/dist/mcp/server.d.ts +6 -0
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +122 -2
- package/dist/plugins/compression.js +4 -2
- package/dist/plugins/har-player.d.ts.map +1 -1
- package/dist/plugins/har-player.js +8 -11
- package/dist/plugins/odata.d.ts.map +1 -1
- package/dist/plugins/odata.js +5 -2
- package/dist/presets/aws.d.ts +20 -0
- package/dist/presets/aws.d.ts.map +1 -0
- package/dist/presets/aws.js +68 -0
- package/dist/presets/azure.d.ts +42 -0
- package/dist/presets/azure.d.ts.map +1 -0
- package/dist/presets/azure.js +104 -0
- package/dist/presets/gcp.d.ts +35 -0
- package/dist/presets/gcp.d.ts.map +1 -0
- package/dist/presets/gcp.js +91 -0
- package/dist/presets/index.d.ts +10 -0
- package/dist/presets/index.d.ts.map +1 -1
- package/dist/presets/index.js +10 -0
- package/dist/presets/mailgun.d.ts +8 -0
- package/dist/presets/mailgun.d.ts.map +1 -0
- package/dist/presets/mailgun.js +20 -0
- package/dist/presets/meta.d.ts +11 -0
- package/dist/presets/meta.d.ts.map +1 -0
- package/dist/presets/meta.js +33 -0
- package/dist/presets/oracle.d.ts +20 -0
- package/dist/presets/oracle.d.ts.map +1 -0
- package/dist/presets/oracle.js +117 -0
- package/dist/presets/registry.d.ts.map +1 -1
- package/dist/presets/registry.js +100 -0
- package/dist/presets/sinch.d.ts +10 -0
- package/dist/presets/sinch.d.ts.map +1 -0
- package/dist/presets/sinch.js +39 -0
- package/dist/presets/tiktok.d.ts +11 -0
- package/dist/presets/tiktok.d.ts.map +1 -0
- package/dist/presets/tiktok.js +38 -0
- package/dist/presets/vultr.d.ts +6 -0
- package/dist/presets/vultr.d.ts.map +1 -0
- package/dist/presets/vultr.js +16 -0
- package/dist/presets/youtube.d.ts +6 -0
- package/dist/presets/youtube.d.ts.map +1 -0
- package/dist/presets/youtube.js +20 -0
- package/dist/protocols/ftp.d.ts.map +1 -1
- package/dist/protocols/ftp.js +69 -16
- package/dist/protocols/sftp.d.ts.map +1 -1
- package/dist/protocols/sftp.js +13 -3
- package/dist/protocols/telnet.d.ts.map +1 -1
- package/dist/protocols/telnet.js +25 -6
- package/dist/recker.d.ts +47 -0
- package/dist/recker.d.ts.map +1 -0
- package/dist/recker.js +99 -0
- package/dist/transport/base-udp.d.ts.map +1 -1
- package/dist/transport/base-udp.js +7 -4
- package/dist/transport/udp-response.d.ts.map +1 -1
- package/dist/transport/udp-response.js +10 -3
- package/dist/transport/udp.d.ts.map +1 -1
- package/dist/transport/udp.js +5 -1
- package/dist/transport/undici.d.ts.map +1 -1
- package/dist/transport/undici.js +75 -63
- package/dist/utils/agent-manager.d.ts +1 -0
- package/dist/utils/agent-manager.d.ts.map +1 -1
- package/dist/utils/agent-manager.js +11 -0
- package/dist/utils/client-pool.d.ts.map +1 -1
- package/dist/utils/client-pool.js +4 -1
- package/dist/utils/colors.d.ts +16 -0
- package/dist/utils/colors.d.ts.map +1 -1
- package/dist/utils/colors.js +16 -0
- package/dist/utils/dns-toolkit.d.ts +88 -1
- package/dist/utils/dns-toolkit.d.ts.map +1 -1
- package/dist/utils/dns-toolkit.js +704 -6
- package/dist/utils/doh.d.ts.map +1 -1
- package/dist/utils/doh.js +13 -16
- package/dist/utils/download.d.ts.map +1 -1
- package/dist/utils/download.js +10 -11
- package/dist/utils/rdap.d.ts +9 -0
- package/dist/utils/rdap.d.ts.map +1 -1
- package/dist/utils/rdap.js +78 -9
- package/dist/utils/security-grader.d.ts +47 -0
- package/dist/utils/security-grader.d.ts.map +1 -0
- package/dist/utils/security-grader.js +637 -0
- package/dist/utils/sparkline.d.ts +18 -0
- package/dist/utils/sparkline.d.ts.map +1 -0
- package/dist/utils/sparkline.js +55 -0
- package/dist/utils/sse.d.ts.map +1 -1
- package/dist/utils/sse.js +5 -6
- package/dist/utils/system-metrics.d.ts +26 -0
- package/dist/utils/system-metrics.d.ts.map +1 -0
- package/dist/utils/system-metrics.js +81 -0
- package/dist/utils/tls-inspector.d.ts +6 -0
- package/dist/utils/tls-inspector.d.ts.map +1 -1
- package/dist/utils/tls-inspector.js +35 -1
- package/dist/webrtc/index.d.ts.map +1 -1
- package/dist/webrtc/index.js +21 -7
- package/dist/websocket/client.d.ts.map +1 -1
- package/dist/websocket/client.js +13 -16
- package/package.json +4 -3
- package/dist/mcp/data/embeddings.json +0 -1
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { createSign } from 'node:crypto';
|
|
2
|
+
function getOCIServiceUrl(service, region) {
|
|
3
|
+
const serviceUrls = {
|
|
4
|
+
'core': `https://iaas.${region}.oraclecloud.com`,
|
|
5
|
+
'objectstorage': `https://objectstorage.${region}.oraclecloud.com`,
|
|
6
|
+
'database': `https://database.${region}.oraclecloud.com`,
|
|
7
|
+
'identity': `https://identity.${region}.oraclecloud.com`,
|
|
8
|
+
'containerengine': `https://containerengine.${region}.oraclecloud.com`,
|
|
9
|
+
'functions': `https://functions.${region}.oraclecloud.com`,
|
|
10
|
+
'streaming': `https://streaming.${region}.oraclecloud.com`,
|
|
11
|
+
'logging': `https://logging.${region}.oraclecloud.com`,
|
|
12
|
+
'monitoring': `https://telemetry.${region}.oraclecloud.com`,
|
|
13
|
+
'vault': `https://vaults.${region}.oraclecloud.com`,
|
|
14
|
+
'kms': `https://kms.${region}.oraclecloud.com`,
|
|
15
|
+
'nosql': `https://nosql.${region}.oraclecloud.com`,
|
|
16
|
+
'apm': `https://apm.${region}.oraclecloud.com`,
|
|
17
|
+
'generativeai': `https://generativeai.${region}.oraclecloud.com`,
|
|
18
|
+
'aidocument': `https://document.${region}.oraclecloud.com`,
|
|
19
|
+
'aivision': `https://vision.${region}.oraclecloud.com`,
|
|
20
|
+
};
|
|
21
|
+
return serviceUrls[service] || `https://${service}.${region}.oraclecloud.com`;
|
|
22
|
+
}
|
|
23
|
+
function createOCISigningMiddleware(options) {
|
|
24
|
+
const keyId = `${options.tenancyId}/${options.userId}/${options.fingerprint}`;
|
|
25
|
+
return async (req, next) => {
|
|
26
|
+
const url = new URL(req.url);
|
|
27
|
+
const now = new Date();
|
|
28
|
+
const dateStr = now.toUTCString();
|
|
29
|
+
const headersToSign = ['date', '(request-target)', 'host'];
|
|
30
|
+
const methodsWithBody = ['POST', 'PUT', 'PATCH'];
|
|
31
|
+
if (methodsWithBody.includes(req.method.toUpperCase())) {
|
|
32
|
+
headersToSign.push('content-length', 'content-type', 'x-content-sha256');
|
|
33
|
+
}
|
|
34
|
+
const signingParts = [];
|
|
35
|
+
const headerValues = {
|
|
36
|
+
'date': dateStr,
|
|
37
|
+
'(request-target)': `${req.method.toLowerCase()} ${url.pathname}${url.search}`,
|
|
38
|
+
'host': url.host,
|
|
39
|
+
};
|
|
40
|
+
let bodyHash = '';
|
|
41
|
+
if (methodsWithBody.includes(req.method.toUpperCase())) {
|
|
42
|
+
let bodyContent = '';
|
|
43
|
+
if (req.body) {
|
|
44
|
+
if (typeof req.body === 'string') {
|
|
45
|
+
bodyContent = req.body;
|
|
46
|
+
}
|
|
47
|
+
else if (req.body instanceof ArrayBuffer) {
|
|
48
|
+
bodyContent = Buffer.from(req.body).toString();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const crypto = await import('node:crypto');
|
|
52
|
+
bodyHash = crypto.createHash('sha256').update(bodyContent).digest('base64');
|
|
53
|
+
headerValues['content-length'] = Buffer.byteLength(bodyContent).toString();
|
|
54
|
+
headerValues['content-type'] = 'application/json';
|
|
55
|
+
headerValues['x-content-sha256'] = bodyHash;
|
|
56
|
+
}
|
|
57
|
+
for (const header of headersToSign) {
|
|
58
|
+
signingParts.push(`${header}: ${headerValues[header]}`);
|
|
59
|
+
}
|
|
60
|
+
const signingString = signingParts.join('\n');
|
|
61
|
+
const sign = createSign('RSA-SHA256');
|
|
62
|
+
sign.update(signingString);
|
|
63
|
+
let signature;
|
|
64
|
+
if (options.passphrase) {
|
|
65
|
+
signature = sign.sign({ key: options.privateKey, passphrase: options.passphrase }, 'base64');
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
signature = sign.sign(options.privateKey, 'base64');
|
|
69
|
+
}
|
|
70
|
+
const authHeader = `Signature version="1",keyId="${keyId}",algorithm="rsa-sha256",headers="${headersToSign.join(' ')}",signature="${signature}"`;
|
|
71
|
+
let newReq = req
|
|
72
|
+
.withHeader('Authorization', authHeader)
|
|
73
|
+
.withHeader('Date', dateStr)
|
|
74
|
+
.withHeader('Host', url.host);
|
|
75
|
+
if (methodsWithBody.includes(req.method.toUpperCase())) {
|
|
76
|
+
newReq = newReq
|
|
77
|
+
.withHeader('x-content-sha256', bodyHash)
|
|
78
|
+
.withHeader('Content-Type', 'application/json');
|
|
79
|
+
}
|
|
80
|
+
return next(newReq);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export function oracle(options) {
|
|
84
|
+
const baseUrl = getOCIServiceUrl(options.service, options.region);
|
|
85
|
+
return {
|
|
86
|
+
baseUrl,
|
|
87
|
+
headers: {
|
|
88
|
+
'Content-Type': 'application/json',
|
|
89
|
+
},
|
|
90
|
+
timeout: 60 * 1000,
|
|
91
|
+
retry: {
|
|
92
|
+
maxAttempts: 3,
|
|
93
|
+
backoff: 'exponential',
|
|
94
|
+
delay: 1000,
|
|
95
|
+
statusCodes: [408, 429, 500, 502, 503, 504]
|
|
96
|
+
},
|
|
97
|
+
middlewares: [createOCISigningMiddleware(options)]
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export function ociCompute(options) {
|
|
101
|
+
return oracle({ ...options, service: 'core' });
|
|
102
|
+
}
|
|
103
|
+
export function ociObjectStorage(options) {
|
|
104
|
+
return oracle({ ...options, service: 'objectstorage' });
|
|
105
|
+
}
|
|
106
|
+
export function ociDatabase(options) {
|
|
107
|
+
return oracle({ ...options, service: 'database' });
|
|
108
|
+
}
|
|
109
|
+
export function ociKubernetes(options) {
|
|
110
|
+
return oracle({ ...options, service: 'containerengine' });
|
|
111
|
+
}
|
|
112
|
+
export function ociGenerativeAI(options) {
|
|
113
|
+
return oracle({ ...options, service: 'generativeai' });
|
|
114
|
+
}
|
|
115
|
+
export function ociVault(options) {
|
|
116
|
+
return oracle({ ...options, service: 'vault' });
|
|
117
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/presets/registry.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/presets/registry.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AA2ClD,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,GAAG,KAAK,aAAa,CAAC;AAK5D,MAAM,WAAW,UAAU;IAEzB,IAAI,EAAE,MAAM,CAAC;IAEb,WAAW,EAAE,MAAM,CAAC;IAEpB,QAAQ,EAAE,MAAM,EAAE,CAAC;IAEnB,OAAO,EAAE,aAAa,CAAC;IAEvB,QAAQ,EAAE,IAAI,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,CAAC;IAE/C,YAAY,EAAE,MAAM,EAAE,CAAC;IAEvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAKD,eAAO,MAAM,cAAc,EAAE,UAAU,EA0VtC,CAAC;AAiBF,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAShE;AAQD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAE9D;AAQD,wBAAgB,WAAW,CAAC,QAAQ,CAAC,EAAE,IAAI,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,EAAE,CAKzF;AAKD,wBAAgB,aAAa,IAAI,UAAU,EAAE,CAE5C;AAKD,wBAAgB,gBAAgB,IAAI,UAAU,EAAE,CAE/C;AAKD,wBAAgB,eAAe,IAAI,UAAU,EAAE,CAE9C;AAKD,wBAAgB,mBAAmB,IAAI,UAAU,EAAE,CAElD"}
|
package/dist/presets/registry.js
CHANGED
|
@@ -12,6 +12,13 @@ import { deepseek } from './deepseek.js';
|
|
|
12
12
|
import { fireworks } from './fireworks.js';
|
|
13
13
|
import { xai, grok } from './xai.js';
|
|
14
14
|
import { azureOpenai } from './azure-openai.js';
|
|
15
|
+
import { aws } from './aws.js';
|
|
16
|
+
import { gcp } from './gcp.js';
|
|
17
|
+
import { azure } from './azure.js';
|
|
18
|
+
import { oracle } from './oracle.js';
|
|
19
|
+
import { youtube } from './youtube.js';
|
|
20
|
+
import { meta } from './meta.js';
|
|
21
|
+
import { tiktok } from './tiktok.js';
|
|
15
22
|
import { cloudflare, cloudflareWorkersAI } from './cloudflare.js';
|
|
16
23
|
import { github } from './github.js';
|
|
17
24
|
import { gitlab } from './gitlab.js';
|
|
@@ -19,7 +26,10 @@ import { vercel } from './vercel.js';
|
|
|
19
26
|
import { supabase } from './supabase.js';
|
|
20
27
|
import { stripe } from './stripe.js';
|
|
21
28
|
import { twilio } from './twilio.js';
|
|
29
|
+
import { mailgun } from './mailgun.js';
|
|
30
|
+
import { sinch } from './sinch.js';
|
|
22
31
|
import { digitalocean } from './digitalocean.js';
|
|
32
|
+
import { vultr } from './vultr.js';
|
|
23
33
|
import { linear } from './linear.js';
|
|
24
34
|
import { notion } from './notion.js';
|
|
25
35
|
import { slack } from './slack.js';
|
|
@@ -169,6 +179,69 @@ export const presetRegistry = [
|
|
|
169
179
|
requiredAuth: ['accountId', 'apiToken'],
|
|
170
180
|
docsUrl: 'https://developers.cloudflare.com/workers-ai/',
|
|
171
181
|
},
|
|
182
|
+
{
|
|
183
|
+
name: 'aws',
|
|
184
|
+
displayName: 'Amazon Web Services',
|
|
185
|
+
patterns: [/\.amazonaws\.com/, /\.aws\.amazon\.com/],
|
|
186
|
+
factory: aws,
|
|
187
|
+
category: 'cloud',
|
|
188
|
+
requiredAuth: ['accessKeyId', 'secretAccessKey', 'region', 'service'],
|
|
189
|
+
docsUrl: 'https://docs.aws.amazon.com/',
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: 'gcp',
|
|
193
|
+
displayName: 'Google Cloud Platform',
|
|
194
|
+
patterns: [/\.googleapis\.com/],
|
|
195
|
+
factory: gcp,
|
|
196
|
+
category: 'cloud',
|
|
197
|
+
requiredAuth: ['projectId', 'auth'],
|
|
198
|
+
docsUrl: 'https://cloud.google.com/apis/docs/overview',
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
name: 'azure',
|
|
202
|
+
displayName: 'Microsoft Azure',
|
|
203
|
+
patterns: [/\.azure\.com/, /\.windows\.net/, /\.microsoft\.com/],
|
|
204
|
+
factory: azure,
|
|
205
|
+
category: 'cloud',
|
|
206
|
+
requiredAuth: ['auth'],
|
|
207
|
+
docsUrl: 'https://docs.microsoft.com/en-us/rest/api/azure/',
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
name: 'oracle',
|
|
211
|
+
displayName: 'Oracle Cloud Infrastructure',
|
|
212
|
+
patterns: [/\.oraclecloud\.com/],
|
|
213
|
+
factory: oracle,
|
|
214
|
+
category: 'cloud',
|
|
215
|
+
requiredAuth: ['tenancyId', 'userId', 'fingerprint', 'privateKey', 'region'],
|
|
216
|
+
docsUrl: 'https://docs.oracle.com/en-us/iaas/api/',
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
name: 'youtube',
|
|
220
|
+
displayName: 'YouTube Data API',
|
|
221
|
+
patterns: [/googleapis\.com\/youtube/],
|
|
222
|
+
factory: youtube,
|
|
223
|
+
category: 'saas',
|
|
224
|
+
requiredAuth: ['apiKey'],
|
|
225
|
+
docsUrl: 'https://developers.google.com/youtube/v3/docs',
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
name: 'meta',
|
|
229
|
+
displayName: 'Meta (Facebook, Instagram, WhatsApp, Threads)',
|
|
230
|
+
patterns: [/graph\.facebook\.com/],
|
|
231
|
+
factory: meta,
|
|
232
|
+
category: 'saas',
|
|
233
|
+
requiredAuth: ['accessToken'],
|
|
234
|
+
docsUrl: 'https://developers.facebook.com/docs/graph-api/',
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
name: 'tiktok',
|
|
238
|
+
displayName: 'TikTok API',
|
|
239
|
+
patterns: [/open\.tiktokapis\.com/, /business-api\.tiktok\.com/],
|
|
240
|
+
factory: tiktok,
|
|
241
|
+
category: 'saas',
|
|
242
|
+
requiredAuth: ['accessToken'],
|
|
243
|
+
docsUrl: 'https://developers.tiktok.com/doc/overview/',
|
|
244
|
+
},
|
|
172
245
|
{
|
|
173
246
|
name: 'cloudflare',
|
|
174
247
|
displayName: 'Cloudflare',
|
|
@@ -232,6 +305,24 @@ export const presetRegistry = [
|
|
|
232
305
|
requiredAuth: ['accountSid', 'authToken'],
|
|
233
306
|
docsUrl: 'https://www.twilio.com/docs/usage/api',
|
|
234
307
|
},
|
|
308
|
+
{
|
|
309
|
+
name: 'mailgun',
|
|
310
|
+
displayName: 'Mailgun',
|
|
311
|
+
patterns: [/api\.mailgun\.net/, /api\.eu\.mailgun\.net/],
|
|
312
|
+
factory: mailgun,
|
|
313
|
+
category: 'saas',
|
|
314
|
+
requiredAuth: ['apiKey'],
|
|
315
|
+
docsUrl: 'https://documentation.mailgun.com/docs/mailgun/api-reference/',
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
name: 'sinch',
|
|
319
|
+
displayName: 'Sinch',
|
|
320
|
+
patterns: [/\.api\.sinch\.com/, /sms\.api\.sinch\.com/, /calling\.api\.sinch\.com/],
|
|
321
|
+
factory: sinch,
|
|
322
|
+
category: 'saas',
|
|
323
|
+
requiredAuth: ['projectId', 'keyId', 'keySecret'],
|
|
324
|
+
docsUrl: 'https://developers.sinch.com/docs/',
|
|
325
|
+
},
|
|
235
326
|
{
|
|
236
327
|
name: 'digitalocean',
|
|
237
328
|
displayName: 'DigitalOcean',
|
|
@@ -241,6 +332,15 @@ export const presetRegistry = [
|
|
|
241
332
|
requiredAuth: ['token'],
|
|
242
333
|
docsUrl: 'https://docs.digitalocean.com/reference/api/',
|
|
243
334
|
},
|
|
335
|
+
{
|
|
336
|
+
name: 'vultr',
|
|
337
|
+
displayName: 'Vultr',
|
|
338
|
+
patterns: [/api\.vultr\.com/],
|
|
339
|
+
factory: vultr,
|
|
340
|
+
category: 'cloud',
|
|
341
|
+
requiredAuth: ['apiKey'],
|
|
342
|
+
docsUrl: 'https://www.vultr.com/api/',
|
|
343
|
+
},
|
|
244
344
|
{
|
|
245
345
|
name: 'linear',
|
|
246
346
|
displayName: 'Linear',
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ClientOptions } from '../types/index.js';
|
|
2
|
+
export interface SinchPresetOptions {
|
|
3
|
+
projectId: string;
|
|
4
|
+
keyId: string;
|
|
5
|
+
keySecret: string;
|
|
6
|
+
product?: 'sms' | 'voice' | 'conversation' | 'numbers' | 'verification';
|
|
7
|
+
region?: 'us' | 'eu' | 'au' | 'br' | 'ca';
|
|
8
|
+
}
|
|
9
|
+
export declare function sinch(options: SinchPresetOptions): ClientOptions;
|
|
10
|
+
//# sourceMappingURL=sinch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sinch.d.ts","sourceRoot":"","sources":["../../src/presets/sinch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,WAAW,kBAAkB;IAIjC,SAAS,EAAE,MAAM,CAAC;IAIlB,KAAK,EAAE,MAAM,CAAC;IAId,SAAS,EAAE,MAAM,CAAC;IAKlB,OAAO,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,cAAc,GAAG,SAAS,GAAG,cAAc,CAAC;IAKxE,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;CAC3C;AAqBD,wBAAgB,KAAK,CAAC,OAAO,EAAE,kBAAkB,GAAG,aAAa,CA0BhE"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const SMS_REGIONS = {
|
|
2
|
+
us: 'https://us.sms.api.sinch.com',
|
|
3
|
+
eu: 'https://eu.sms.api.sinch.com',
|
|
4
|
+
au: 'https://au.sms.api.sinch.com',
|
|
5
|
+
br: 'https://br.sms.api.sinch.com',
|
|
6
|
+
ca: 'https://ca.sms.api.sinch.com',
|
|
7
|
+
};
|
|
8
|
+
const PRODUCT_URLS = {
|
|
9
|
+
voice: 'https://calling.api.sinch.com',
|
|
10
|
+
conversation: 'https://us.conversation.api.sinch.com',
|
|
11
|
+
numbers: 'https://numbers.api.sinch.com',
|
|
12
|
+
verification: 'https://verification.api.sinch.com',
|
|
13
|
+
};
|
|
14
|
+
export function sinch(options) {
|
|
15
|
+
const credentials = Buffer.from(`${options.keyId}:${options.keySecret}`).toString('base64');
|
|
16
|
+
const product = options.product ?? 'sms';
|
|
17
|
+
const region = options.region ?? 'us';
|
|
18
|
+
let baseUrl;
|
|
19
|
+
if (product === 'sms') {
|
|
20
|
+
baseUrl = `${SMS_REGIONS[region]}/xms/v1/${options.projectId}`;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
baseUrl = `${PRODUCT_URLS[product]}/v1/projects/${options.projectId}`;
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
baseUrl,
|
|
27
|
+
headers: {
|
|
28
|
+
'Authorization': `Basic ${credentials}`,
|
|
29
|
+
'Content-Type': 'application/json',
|
|
30
|
+
},
|
|
31
|
+
timeout: 30 * 1000,
|
|
32
|
+
retry: {
|
|
33
|
+
maxAttempts: 3,
|
|
34
|
+
backoff: 'exponential',
|
|
35
|
+
delay: 1000,
|
|
36
|
+
statusCodes: [408, 429, 500, 502, 503, 504]
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ClientOptions } from '../types/index.js';
|
|
2
|
+
export interface TikTokPresetOptions {
|
|
3
|
+
accessToken: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function tiktok(options: TikTokPresetOptions): ClientOptions;
|
|
6
|
+
export interface TikTokBusinessPresetOptions {
|
|
7
|
+
accessToken: string;
|
|
8
|
+
advertiserId?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function tiktokBusiness(options: TikTokBusinessPresetOptions): ClientOptions;
|
|
11
|
+
//# sourceMappingURL=tiktok.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tiktok.d.ts","sourceRoot":"","sources":["../../src/presets/tiktok.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,WAAW,mBAAmB;IAKlC,WAAW,EAAE,MAAM,CAAC;CACrB;AAoCD,wBAAgB,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,aAAa,CAelE;AAED,MAAM,WAAW,2BAA2B;IAI1C,WAAW,EAAE,MAAM,CAAC;IAIpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AA0BD,wBAAgB,cAAc,CAAC,OAAO,EAAE,2BAA2B,GAAG,aAAa,CAsBlF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export function tiktok(options) {
|
|
2
|
+
return {
|
|
3
|
+
baseUrl: 'https://open.tiktokapis.com/v2',
|
|
4
|
+
headers: {
|
|
5
|
+
'Authorization': `Bearer ${options.accessToken}`,
|
|
6
|
+
'Content-Type': 'application/json',
|
|
7
|
+
},
|
|
8
|
+
timeout: 30 * 1000,
|
|
9
|
+
retry: {
|
|
10
|
+
maxAttempts: 3,
|
|
11
|
+
backoff: 'exponential',
|
|
12
|
+
delay: 1000,
|
|
13
|
+
statusCodes: [408, 429, 500, 502, 503, 504]
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function tiktokBusiness(options) {
|
|
18
|
+
const headers = {
|
|
19
|
+
'Access-Token': options.accessToken,
|
|
20
|
+
'Content-Type': 'application/json',
|
|
21
|
+
};
|
|
22
|
+
return {
|
|
23
|
+
baseUrl: 'https://business-api.tiktok.com/open_api/v1.3',
|
|
24
|
+
headers,
|
|
25
|
+
defaults: options.advertiserId ? {
|
|
26
|
+
params: {
|
|
27
|
+
advertiser_id: options.advertiserId
|
|
28
|
+
}
|
|
29
|
+
} : undefined,
|
|
30
|
+
timeout: 30 * 1000,
|
|
31
|
+
retry: {
|
|
32
|
+
maxAttempts: 3,
|
|
33
|
+
backoff: 'exponential',
|
|
34
|
+
delay: 1000,
|
|
35
|
+
statusCodes: [408, 429, 500, 502, 503, 504]
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vultr.d.ts","sourceRoot":"","sources":["../../src/presets/vultr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,WAAW,kBAAkB;IAIjC,MAAM,EAAE,MAAM,CAAC;CAChB;AAMD,wBAAgB,KAAK,CAAC,OAAO,EAAE,kBAAkB,GAAG,aAAa,CAehE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function vultr(options) {
|
|
2
|
+
return {
|
|
3
|
+
baseUrl: 'https://api.vultr.com/v2',
|
|
4
|
+
headers: {
|
|
5
|
+
'Authorization': `Bearer ${options.apiKey}`,
|
|
6
|
+
'Content-Type': 'application/json',
|
|
7
|
+
},
|
|
8
|
+
timeout: 30 * 1000,
|
|
9
|
+
retry: {
|
|
10
|
+
maxAttempts: 3,
|
|
11
|
+
backoff: 'exponential',
|
|
12
|
+
delay: 1000,
|
|
13
|
+
statusCodes: [408, 429, 500, 502, 503, 504]
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"youtube.d.ts","sourceRoot":"","sources":["../../src/presets/youtube.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,WAAW,oBAAoB;IAKnC,MAAM,EAAE,MAAM,CAAC;CAChB;AAkDD,wBAAgB,OAAO,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAmBpE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function youtube(options) {
|
|
2
|
+
return {
|
|
3
|
+
baseUrl: 'https://www.googleapis.com/youtube/v3',
|
|
4
|
+
headers: {
|
|
5
|
+
'Accept': 'application/json',
|
|
6
|
+
},
|
|
7
|
+
defaults: {
|
|
8
|
+
params: {
|
|
9
|
+
key: options.apiKey
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
timeout: 30 * 1000,
|
|
13
|
+
retry: {
|
|
14
|
+
maxAttempts: 3,
|
|
15
|
+
backoff: 'exponential',
|
|
16
|
+
delay: 1000,
|
|
17
|
+
statusCodes: [408, 429, 500, 502, 503, 504]
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ftp.d.ts","sourceRoot":"","sources":["../../src/protocols/ftp.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,SAAS,EAAyB,KAAK,iBAAiB,EAAE,MAAM,UAAU,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"ftp.d.ts","sourceRoot":"","sources":["../../src/protocols/ftp.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,SAAS,EAAyB,KAAK,iBAAiB,EAAE,MAAM,UAAU,CAAC;AACpF,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAuE3C,MAAM,WAAW,SAAS;IAExB,IAAI,EAAE,MAAM,CAAC;IAEb,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,MAAM,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IAE9B,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAE/B,cAAc,CAAC,EAAE,MAAM,MAAM,CAAC;CAC/B;AAED,MAAM,W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AAS;YAcjB,YAAY;YA0BZ,kBAAkB;YA4BlB,YAAY;YA6BZ,YAAY;YAmCZ,kBAAkB;YAiDlB,kBAAkB;YAqClB,WAAW;YAoCX,YAAY;IAiD1B,OAAO,CAAC,qBAAqB;IAc7B,OAAO,CAAC,aAAa;IAyDrB,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,SAAS;IAgCjB,OAAO,CAAC,YAAY;IA0BpB,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,OAAO;IAUf,OAAO,CAAC,KAAK;CAKd;AAiBD,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,GAAG,CAEhD;AAkBD,wBAAsB,GAAG,CAAC,CAAC,EACzB,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC,CAAC,GACrC,OAAO,CAAC,CAAC,CAAC,CAgBZ"}
|
package/dist/protocols/ftp.js
CHANGED
|
@@ -3,6 +3,7 @@ import { connect as tlsConnect } from 'node:tls';
|
|
|
3
3
|
import { Readable, Writable } from 'node:stream';
|
|
4
4
|
import { createWriteStream, createReadStream } from 'node:fs';
|
|
5
5
|
import { EventEmitter } from 'node:events';
|
|
6
|
+
import { ProtocolError, StateError, AuthenticationError, ConnectionError, TimeoutError, ParseError, } from '../core/errors.js';
|
|
6
7
|
const ResponseCode = {
|
|
7
8
|
RESTART_MARKER: 110,
|
|
8
9
|
SERVICE_READY_IN: 120,
|
|
@@ -88,7 +89,11 @@ export class FTP extends EventEmitter {
|
|
|
88
89
|
const welcome = await this.readResponse();
|
|
89
90
|
this.debug('Welcome: %s', welcome.message);
|
|
90
91
|
if (welcome.code !== ResponseCode.SERVICE_READY) {
|
|
91
|
-
throw new
|
|
92
|
+
throw new ProtocolError(`Server not ready: ${welcome.message}`, {
|
|
93
|
+
protocol: 'ftp',
|
|
94
|
+
code: welcome.code,
|
|
95
|
+
phase: 'connect',
|
|
96
|
+
});
|
|
92
97
|
}
|
|
93
98
|
await this.authenticate();
|
|
94
99
|
await this.sendCommand('TYPE I');
|
|
@@ -173,7 +178,11 @@ export class FTP extends EventEmitter {
|
|
|
173
178
|
const response = await this.readResponse();
|
|
174
179
|
if (response.code !== ResponseCode.CLOSING_DATA_CONNECTION &&
|
|
175
180
|
response.code !== ResponseCode.FILE_ACTION_OK) {
|
|
176
|
-
throw new
|
|
181
|
+
throw new ProtocolError(response.message, {
|
|
182
|
+
protocol: 'ftp',
|
|
183
|
+
code: response.code,
|
|
184
|
+
phase: 'transfer',
|
|
185
|
+
});
|
|
177
186
|
}
|
|
178
187
|
return {
|
|
179
188
|
success: true,
|
|
@@ -259,7 +268,11 @@ export class FTP extends EventEmitter {
|
|
|
259
268
|
const response = await this.readResponse();
|
|
260
269
|
if (response.code !== ResponseCode.CLOSING_DATA_CONNECTION &&
|
|
261
270
|
response.code !== ResponseCode.FILE_ACTION_OK) {
|
|
262
|
-
throw new
|
|
271
|
+
throw new ProtocolError(response.message, {
|
|
272
|
+
protocol: 'ftp',
|
|
273
|
+
code: response.code,
|
|
274
|
+
phase: 'transfer',
|
|
275
|
+
});
|
|
263
276
|
}
|
|
264
277
|
return {
|
|
265
278
|
success: true,
|
|
@@ -356,7 +369,11 @@ export class FTP extends EventEmitter {
|
|
|
356
369
|
try {
|
|
357
370
|
const rnfrResponse = await this.sendCommand(`RNFR ${oldPath}`);
|
|
358
371
|
if (rnfrResponse.code !== ResponseCode.FILE_ACTION_PENDING) {
|
|
359
|
-
throw new
|
|
372
|
+
throw new ProtocolError(rnfrResponse.message, {
|
|
373
|
+
protocol: 'ftp',
|
|
374
|
+
code: rnfrResponse.code,
|
|
375
|
+
phase: 'rename',
|
|
376
|
+
});
|
|
360
377
|
}
|
|
361
378
|
const rntoResponse = await this.sendCommand(`RNTO ${newPath}`);
|
|
362
379
|
return {
|
|
@@ -459,7 +476,10 @@ export class FTP extends EventEmitter {
|
|
|
459
476
|
}
|
|
460
477
|
getSocket() {
|
|
461
478
|
if (!this.controlSocket) {
|
|
462
|
-
throw new
|
|
479
|
+
throw new StateError('Not connected. Call connect() first.', {
|
|
480
|
+
expectedState: 'connected',
|
|
481
|
+
actualState: 'disconnected',
|
|
482
|
+
});
|
|
463
483
|
}
|
|
464
484
|
return this.controlSocket;
|
|
465
485
|
}
|
|
@@ -476,7 +496,10 @@ export class FTP extends EventEmitter {
|
|
|
476
496
|
});
|
|
477
497
|
socket.on('timeout', () => {
|
|
478
498
|
socket.destroy();
|
|
479
|
-
reject(new
|
|
499
|
+
reject(new TimeoutError(undefined, {
|
|
500
|
+
phase: 'connect',
|
|
501
|
+
timeout: this.config.timeout,
|
|
502
|
+
}));
|
|
480
503
|
});
|
|
481
504
|
socket.connect(this.config.port, this.config.host);
|
|
482
505
|
});
|
|
@@ -499,14 +522,21 @@ export class FTP extends EventEmitter {
|
|
|
499
522
|
socket.setTimeout(this.config.timeout);
|
|
500
523
|
socket.on('timeout', () => {
|
|
501
524
|
socket.destroy();
|
|
502
|
-
reject(new
|
|
525
|
+
reject(new TimeoutError(undefined, {
|
|
526
|
+
phase: 'secureConnect',
|
|
527
|
+
timeout: this.config.timeout,
|
|
528
|
+
}));
|
|
503
529
|
});
|
|
504
530
|
});
|
|
505
531
|
}
|
|
506
532
|
async upgradeToTLS() {
|
|
507
533
|
const authResponse = await this.sendCommand('AUTH TLS');
|
|
508
534
|
if (authResponse.code !== ResponseCode.AUTH_OK) {
|
|
509
|
-
throw new
|
|
535
|
+
throw new ProtocolError(`AUTH TLS failed: ${authResponse.message}`, {
|
|
536
|
+
protocol: 'ftp',
|
|
537
|
+
code: authResponse.code,
|
|
538
|
+
phase: 'tls-upgrade',
|
|
539
|
+
});
|
|
510
540
|
}
|
|
511
541
|
return new Promise((resolve, reject) => {
|
|
512
542
|
const options = {
|
|
@@ -528,11 +558,15 @@ export class FTP extends EventEmitter {
|
|
|
528
558
|
return;
|
|
529
559
|
}
|
|
530
560
|
if (userResponse.code !== ResponseCode.NEED_PASSWORD) {
|
|
531
|
-
throw new
|
|
561
|
+
throw new AuthenticationError(`Authentication failed: ${userResponse.message}`, {
|
|
562
|
+
authType: 'ftp-user',
|
|
563
|
+
});
|
|
532
564
|
}
|
|
533
565
|
const passResponse = await this.sendCommand(`PASS ${this.config.password}`);
|
|
534
566
|
if (passResponse.code !== ResponseCode.USER_LOGGED_IN) {
|
|
535
|
-
throw new
|
|
567
|
+
throw new AuthenticationError(`Authentication failed: ${passResponse.message}`, {
|
|
568
|
+
authType: 'ftp-password',
|
|
569
|
+
});
|
|
536
570
|
}
|
|
537
571
|
if (this.secureConnection) {
|
|
538
572
|
await this.sendCommand('PBSZ 0');
|
|
@@ -542,11 +576,17 @@ export class FTP extends EventEmitter {
|
|
|
542
576
|
async openDataConnection() {
|
|
543
577
|
const pasvResponse = await this.sendCommand('PASV');
|
|
544
578
|
if (pasvResponse.code !== ResponseCode.ENTERING_PASSIVE) {
|
|
545
|
-
throw new
|
|
579
|
+
throw new ProtocolError(`PASV failed: ${pasvResponse.message}`, {
|
|
580
|
+
protocol: 'ftp',
|
|
581
|
+
code: pasvResponse.code,
|
|
582
|
+
phase: 'pasv',
|
|
583
|
+
});
|
|
546
584
|
}
|
|
547
585
|
const match = pasvResponse.message.match(/\((\d+),(\d+),(\d+),(\d+),(\d+),(\d+)\)/);
|
|
548
586
|
if (!match) {
|
|
549
|
-
throw new
|
|
587
|
+
throw new ParseError('Failed to parse PASV response', {
|
|
588
|
+
format: 'pasv',
|
|
589
|
+
});
|
|
550
590
|
}
|
|
551
591
|
const host = `${match[1]}.${match[2]}.${match[3]}.${match[4]}`;
|
|
552
592
|
const port = parseInt(match[5], 10) * 256 + parseInt(match[6], 10);
|
|
@@ -584,7 +624,11 @@ export class FTP extends EventEmitter {
|
|
|
584
624
|
const response = await this.readResponse();
|
|
585
625
|
if (response.code !== ResponseCode.CLOSING_DATA_CONNECTION &&
|
|
586
626
|
response.code !== ResponseCode.FILE_ACTION_OK) {
|
|
587
|
-
reject(new
|
|
627
|
+
reject(new ProtocolError(response.message, {
|
|
628
|
+
protocol: 'ftp',
|
|
629
|
+
code: response.code,
|
|
630
|
+
phase: 'data-transfer',
|
|
631
|
+
}));
|
|
588
632
|
}
|
|
589
633
|
else {
|
|
590
634
|
resolve(data);
|
|
@@ -599,7 +643,10 @@ export class FTP extends EventEmitter {
|
|
|
599
643
|
}
|
|
600
644
|
async sendCommand(command) {
|
|
601
645
|
if (!this.controlSocket) {
|
|
602
|
-
throw new
|
|
646
|
+
throw new StateError('Not connected', {
|
|
647
|
+
expectedState: 'connected',
|
|
648
|
+
actualState: 'disconnected',
|
|
649
|
+
});
|
|
603
650
|
}
|
|
604
651
|
const displayCommand = command.startsWith('PASS ')
|
|
605
652
|
? 'PASS ****'
|
|
@@ -765,7 +812,10 @@ export class FTP extends EventEmitter {
|
|
|
765
812
|
}
|
|
766
813
|
ensureConnected() {
|
|
767
814
|
if (!this.connected || !this.controlSocket || this.controlSocket.destroyed) {
|
|
768
|
-
throw new
|
|
815
|
+
throw new StateError('Not connected to FTP server. Call connect() first.', {
|
|
816
|
+
expectedState: 'connected',
|
|
817
|
+
actualState: 'disconnected',
|
|
818
|
+
});
|
|
769
819
|
}
|
|
770
820
|
}
|
|
771
821
|
cleanup() {
|
|
@@ -791,7 +841,10 @@ export async function ftp(config, operation) {
|
|
|
791
841
|
try {
|
|
792
842
|
const result = await client.connect();
|
|
793
843
|
if (!result.success) {
|
|
794
|
-
throw new
|
|
844
|
+
throw new ConnectionError(result.message || 'Failed to connect to FTP server', {
|
|
845
|
+
host: config.host,
|
|
846
|
+
port: config.port,
|
|
847
|
+
});
|
|
795
848
|
}
|
|
796
849
|
return await operation(client);
|
|
797
850
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sftp.d.ts","sourceRoot":"","sources":["../../src/protocols/sftp.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3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