@maiyunnet/kebab 2.0.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/.VSCodeCounter/2025-02-14_14-46-44/details.md +82 -0
- package/.VSCodeCounter/2025-02-14_14-46-44/diff-details.md +15 -0
- package/.VSCodeCounter/2025-02-14_14-46-44/diff.csv +2 -0
- package/.VSCodeCounter/2025-02-14_14-46-44/diff.md +19 -0
- package/.VSCodeCounter/2025-02-14_14-46-44/diff.txt +22 -0
- package/.VSCodeCounter/2025-02-14_14-46-44/results.csv +69 -0
- package/.VSCodeCounter/2025-02-14_14-46-44/results.json +1 -0
- package/.VSCodeCounter/2025-02-14_14-46-44/results.md +48 -0
- package/.VSCodeCounter/2025-02-14_14-46-44/results.txt +118 -0
- package/.vscode/tasks.json +15 -0
- package/LICENSE +201 -0
- package/README.md +201 -0
- package/bin/kebab.js +2 -0
- package/eslint.config.js +22 -0
- package/index.js +19 -0
- package/index.ts +33 -0
- package/lib/buffer.js +108 -0
- package/lib/buffer.ts +152 -0
- package/lib/captcha/zcool-addict-italic.ttf +0 -0
- package/lib/captcha.js +71 -0
- package/lib/captcha.ts +63 -0
- package/lib/consistent.js +171 -0
- package/lib/consistent.ts +219 -0
- package/lib/core.js +663 -0
- package/lib/core.ts +880 -0
- package/lib/crypto.js +256 -0
- package/lib/crypto.ts +384 -0
- package/lib/db.js +521 -0
- package/lib/db.ts +719 -0
- package/lib/dns.js +321 -0
- package/lib/dns.ts +405 -0
- package/lib/fs.js +405 -0
- package/lib/fs.ts +527 -0
- package/lib/jwt.js +223 -0
- package/lib/jwt.ts +276 -0
- package/lib/kv.js +1004 -0
- package/lib/kv.ts +1489 -0
- package/lib/lan.js +99 -0
- package/lib/lan.ts +87 -0
- package/lib/net/cacert.pem +3480 -0
- package/lib/net/formdata.js +137 -0
- package/lib/net/formdata.ts +166 -0
- package/lib/net/request.js +102 -0
- package/lib/net/request.ts +150 -0
- package/lib/net/response.js +28 -0
- package/lib/net/response.ts +59 -0
- package/lib/net.js +462 -0
- package/lib/net.ts +662 -0
- package/lib/s3.js +180 -0
- package/lib/s3.ts +235 -0
- package/lib/scan.js +276 -0
- package/lib/scan.ts +364 -0
- package/lib/session.js +177 -0
- package/lib/session.ts +230 -0
- package/lib/sql.js +818 -0
- package/lib/sql.ts +1151 -0
- package/lib/ssh/sftp.js +373 -0
- package/lib/ssh/sftp.ts +508 -0
- package/lib/ssh/shell.js +109 -0
- package/lib/ssh/shell.ts +123 -0
- package/lib/ssh.js +171 -0
- package/lib/ssh.ts +191 -0
- package/lib/text/tld.json +1 -0
- package/lib/text.js +452 -0
- package/lib/text.ts +607 -0
- package/lib/time.js +216 -0
- package/lib/time.ts +254 -0
- package/lib/ws.js +373 -0
- package/lib/ws.ts +523 -0
- package/lib/zip.js +381 -0
- package/lib/zip.ts +447 -0
- package/lib/zlib.js +289 -0
- package/lib/zlib.ts +350 -0
- package/main.js +51 -0
- package/main.ts +27 -0
- package/package.json +37 -0
- package/sys/child.js +585 -0
- package/sys/child.ts +678 -0
- package/sys/cmd.js +226 -0
- package/sys/cmd.ts +225 -0
- package/sys/ctr.js +608 -0
- package/sys/ctr.ts +904 -0
- package/sys/master.js +314 -0
- package/sys/master.ts +355 -0
- package/sys/mod.js +1273 -0
- package/sys/mod.ts +1871 -0
- package/sys/route.js +922 -0
- package/sys/route.ts +1113 -0
- package/types/index.d.ts +283 -0
- package/www/example/ctr/main.js +42 -0
- package/www/example/ctr/main.ts +9 -0
- package/www/example/ctr/middle.js +57 -0
- package/www/example/ctr/middle.ts +26 -0
- package/www/example/ctr/test.js +2818 -0
- package/www/example/ctr/test.ts +3218 -0
- package/www/example/data/locale/en.test.json +8 -0
- package/www/example/data/locale/index.html +1 -0
- package/www/example/data/locale/ja.test.json +8 -0
- package/www/example/data/locale/sc.test.json +8 -0
- package/www/example/data/locale/tc.test.json +8 -0
- package/www/example/data/test.zip +0 -0
- package/www/example/kebab.json +24 -0
- package/www/example/mod/test.js +49 -0
- package/www/example/mod/test.ts +47 -0
- package/www/example/mod/testdata.js +11 -0
- package/www/example/mod/testdata.ts +30 -0
- package/www/example/route.json +6 -0
- package/www/example/view/test.ejs +11 -0
- package/www/example/ws/mproxy.js +49 -0
- package/www/example/ws/mproxy.ts +16 -0
- package/www/example/ws/rproxy.js +47 -0
- package/www/example/ws/rproxy.ts +14 -0
- package/www/example/ws/test.js +68 -0
- package/www/example/ws/test.ts +36 -0
package/lib/ssh/sftp.js
ADDED
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Connection = void 0;
|
|
37
|
+
const core = __importStar(require("~/lib/core"));
|
|
38
|
+
const text = __importStar(require("~/lib/text"));
|
|
39
|
+
class Connection {
|
|
40
|
+
constructor(sftp, path) {
|
|
41
|
+
this._client = sftp;
|
|
42
|
+
this._path = path;
|
|
43
|
+
}
|
|
44
|
+
getContent(path, options) {
|
|
45
|
+
path = text.urlResolve(this._path, path);
|
|
46
|
+
if (typeof options === 'string') {
|
|
47
|
+
options = {
|
|
48
|
+
'encoding': options
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
else if (!options) {
|
|
52
|
+
options = {};
|
|
53
|
+
}
|
|
54
|
+
const encoding = options.encoding;
|
|
55
|
+
const start = options.start;
|
|
56
|
+
const end = options.end;
|
|
57
|
+
return new Promise((resolve) => {
|
|
58
|
+
if (start ?? end) {
|
|
59
|
+
const rs = this.createReadStream(path, {
|
|
60
|
+
'encoding': encoding,
|
|
61
|
+
'start': start,
|
|
62
|
+
'end': end
|
|
63
|
+
});
|
|
64
|
+
const data = [];
|
|
65
|
+
rs.on('data', function (chunk) {
|
|
66
|
+
data.push(chunk);
|
|
67
|
+
}).on('end', function () {
|
|
68
|
+
const buf = Buffer.concat(data);
|
|
69
|
+
if (encoding) {
|
|
70
|
+
resolve(buf.toString());
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
resolve(buf);
|
|
74
|
+
}
|
|
75
|
+
}).on('error', function () {
|
|
76
|
+
resolve(null);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
if (encoding) {
|
|
81
|
+
this._client.readFile(path, {
|
|
82
|
+
'encoding': encoding
|
|
83
|
+
}, function (err, data) {
|
|
84
|
+
if (err) {
|
|
85
|
+
resolve(null);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
resolve(data);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
this._client.readFile(path, function (err, data) {
|
|
94
|
+
if (err) {
|
|
95
|
+
resolve(null);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
resolve(data);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
putContent(path, data, options = {}) {
|
|
106
|
+
path = text.urlResolve(this._path, path);
|
|
107
|
+
return new Promise((resolve) => {
|
|
108
|
+
this._client.writeFile(path, data, options, function (err) {
|
|
109
|
+
if (err) {
|
|
110
|
+
resolve(false);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
resolve(true);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
readLink(path) {
|
|
119
|
+
path = text.urlResolve(this._path, path);
|
|
120
|
+
return new Promise((resolve) => {
|
|
121
|
+
this._client.readlink(path, function (err, target) {
|
|
122
|
+
if (err) {
|
|
123
|
+
resolve(null);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
resolve(target);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
symlink(filePath, linkPath) {
|
|
132
|
+
filePath = text.urlResolve(this._path, filePath);
|
|
133
|
+
linkPath = text.urlResolve(this._path, linkPath);
|
|
134
|
+
return new Promise((resolve) => {
|
|
135
|
+
this._client.symlink(filePath, linkPath, function (err) {
|
|
136
|
+
if (err) {
|
|
137
|
+
resolve(false);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
resolve(true);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
async unlink(path) {
|
|
146
|
+
path = text.urlResolve(this._path, path);
|
|
147
|
+
for (let i = 0; i < 2; ++i) {
|
|
148
|
+
const bol = await this._unlink(path);
|
|
149
|
+
if (bol) {
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
await core.sleep(250);
|
|
153
|
+
}
|
|
154
|
+
return this._unlink(path);
|
|
155
|
+
}
|
|
156
|
+
_unlink(path) {
|
|
157
|
+
return new Promise((resolve) => {
|
|
158
|
+
this._client.unlink(path, function (err) {
|
|
159
|
+
if (err) {
|
|
160
|
+
resolve(false);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
resolve(true);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
stats(path) {
|
|
169
|
+
path = text.urlResolve(this._path, path);
|
|
170
|
+
return new Promise((resolve) => {
|
|
171
|
+
this._client.lstat(path, function (err, stat) {
|
|
172
|
+
if (err) {
|
|
173
|
+
resolve(null);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
resolve(stat);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
async isDir(path) {
|
|
182
|
+
const pstats = await this.stats(path);
|
|
183
|
+
if (!pstats?.isDirectory()) {
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
return pstats;
|
|
187
|
+
}
|
|
188
|
+
async isFile(path) {
|
|
189
|
+
const pstats = await this.stats(path);
|
|
190
|
+
if (!pstats?.isFile()) {
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
return pstats;
|
|
194
|
+
}
|
|
195
|
+
async mkdir(path, mode = 0o755) {
|
|
196
|
+
path = text.urlResolve(this._path, path);
|
|
197
|
+
if (await this.isDir(path)) {
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
if (path.endsWith('/')) {
|
|
201
|
+
path.slice(0, -1);
|
|
202
|
+
}
|
|
203
|
+
const lio = path.lastIndexOf('/');
|
|
204
|
+
if (!(await this.mkdir(path.slice(0, lio), mode))) {
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
if (!(await new Promise((resolve) => {
|
|
208
|
+
this._client.mkdir(path.slice(0, lio), {
|
|
209
|
+
'mode': mode
|
|
210
|
+
}, function (err) {
|
|
211
|
+
if (err) {
|
|
212
|
+
resolve(false);
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
resolve(true);
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
}))) {
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
return true;
|
|
222
|
+
}
|
|
223
|
+
async rmdir(path) {
|
|
224
|
+
path = text.urlResolve(this._path, path);
|
|
225
|
+
if (!(await this.isDir(path))) {
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
return new Promise((resolve) => {
|
|
229
|
+
this._client.rmdir(path, function (err) {
|
|
230
|
+
if (err) {
|
|
231
|
+
resolve(false);
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
resolve(true);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
async rmdirDeep(path) {
|
|
240
|
+
path = text.urlResolve(this._path, path);
|
|
241
|
+
if (!path.endsWith('/')) {
|
|
242
|
+
path += '/';
|
|
243
|
+
}
|
|
244
|
+
const list = await this.readDir(path);
|
|
245
|
+
for (const item of list) {
|
|
246
|
+
if (item.filename === '.' || item.filename === '..') {
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
const stat = await this.stats(item.filename);
|
|
250
|
+
if (!stat) {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
if (stat.isDirectory()) {
|
|
254
|
+
const rtn = await this.rmdirDeep(path + item.filename);
|
|
255
|
+
if (!rtn) {
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
const rtn = await this.unlink(path + item.filename);
|
|
261
|
+
if (!rtn) {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return this.rmdir(path);
|
|
267
|
+
}
|
|
268
|
+
chmod(path, mode) {
|
|
269
|
+
path = text.urlResolve(this._path, path);
|
|
270
|
+
return new Promise((resolve) => {
|
|
271
|
+
this._client.chmod(path, mode, function (err) {
|
|
272
|
+
if (err) {
|
|
273
|
+
resolve(false);
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
resolve(true);
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
rename(oldPath, newPath) {
|
|
282
|
+
oldPath = text.urlResolve(this._path, oldPath);
|
|
283
|
+
newPath = text.urlResolve(this._path, newPath);
|
|
284
|
+
return new Promise((resolve) => {
|
|
285
|
+
this._client.rename(oldPath, newPath, function (err) {
|
|
286
|
+
if (err) {
|
|
287
|
+
resolve(false);
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
resolve(true);
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
readDir(path) {
|
|
296
|
+
path = text.urlResolve(this._path, path);
|
|
297
|
+
return new Promise((resolve) => {
|
|
298
|
+
this._client.readdir(path, function (err, files) {
|
|
299
|
+
if (err) {
|
|
300
|
+
resolve([]);
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
resolve(files);
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
createReadStream(path, options) {
|
|
309
|
+
path = text.urlResolve(this._path, path);
|
|
310
|
+
return this._client.createReadStream(path, options);
|
|
311
|
+
}
|
|
312
|
+
pipe(path, destination, options = {}) {
|
|
313
|
+
path = text.urlResolve(this._path, path);
|
|
314
|
+
return new Promise((resolve) => {
|
|
315
|
+
this._client.createReadStream(path).on('error', function () {
|
|
316
|
+
resolve(false);
|
|
317
|
+
}).on('end', function () {
|
|
318
|
+
resolve(true);
|
|
319
|
+
}).pipe(destination, options);
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
createWriteStream(path, options) {
|
|
323
|
+
if (typeof options === 'string') {
|
|
324
|
+
options = {
|
|
325
|
+
'encoding': options
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
else if (!options) {
|
|
329
|
+
options = {};
|
|
330
|
+
}
|
|
331
|
+
return this._client.createWriteStream(path, options);
|
|
332
|
+
}
|
|
333
|
+
pwd() {
|
|
334
|
+
return this._path.slice(0, -1);
|
|
335
|
+
}
|
|
336
|
+
downloadFile(remoteFile, localFile, options = {}) {
|
|
337
|
+
remoteFile = text.urlResolve(this._path, remoteFile);
|
|
338
|
+
return new Promise((resolve) => {
|
|
339
|
+
this._client.fastGet(remoteFile, localFile, options, function (err) {
|
|
340
|
+
if (err) {
|
|
341
|
+
resolve(false);
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
resolve(true);
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
uploadFile(localFile, remoteFile, options = {}) {
|
|
350
|
+
remoteFile = text.urlResolve(this._path, remoteFile);
|
|
351
|
+
return new Promise((resolve) => {
|
|
352
|
+
this._client.fastPut(localFile, remoteFile, options, function (err) {
|
|
353
|
+
if (err) {
|
|
354
|
+
resolve(false);
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
resolve(true);
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
cd(dir) {
|
|
363
|
+
this._path = text.urlResolve(this._path, dir);
|
|
364
|
+
if (!this._path.endsWith('/')) {
|
|
365
|
+
this._path += '/';
|
|
366
|
+
}
|
|
367
|
+
return this._path;
|
|
368
|
+
}
|
|
369
|
+
close() {
|
|
370
|
+
this._client.end();
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
exports.Connection = Connection;
|