@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.
Files changed (114) hide show
  1. package/.VSCodeCounter/2025-02-14_14-46-44/details.md +82 -0
  2. package/.VSCodeCounter/2025-02-14_14-46-44/diff-details.md +15 -0
  3. package/.VSCodeCounter/2025-02-14_14-46-44/diff.csv +2 -0
  4. package/.VSCodeCounter/2025-02-14_14-46-44/diff.md +19 -0
  5. package/.VSCodeCounter/2025-02-14_14-46-44/diff.txt +22 -0
  6. package/.VSCodeCounter/2025-02-14_14-46-44/results.csv +69 -0
  7. package/.VSCodeCounter/2025-02-14_14-46-44/results.json +1 -0
  8. package/.VSCodeCounter/2025-02-14_14-46-44/results.md +48 -0
  9. package/.VSCodeCounter/2025-02-14_14-46-44/results.txt +118 -0
  10. package/.vscode/tasks.json +15 -0
  11. package/LICENSE +201 -0
  12. package/README.md +201 -0
  13. package/bin/kebab.js +2 -0
  14. package/eslint.config.js +22 -0
  15. package/index.js +19 -0
  16. package/index.ts +33 -0
  17. package/lib/buffer.js +108 -0
  18. package/lib/buffer.ts +152 -0
  19. package/lib/captcha/zcool-addict-italic.ttf +0 -0
  20. package/lib/captcha.js +71 -0
  21. package/lib/captcha.ts +63 -0
  22. package/lib/consistent.js +171 -0
  23. package/lib/consistent.ts +219 -0
  24. package/lib/core.js +663 -0
  25. package/lib/core.ts +880 -0
  26. package/lib/crypto.js +256 -0
  27. package/lib/crypto.ts +384 -0
  28. package/lib/db.js +521 -0
  29. package/lib/db.ts +719 -0
  30. package/lib/dns.js +321 -0
  31. package/lib/dns.ts +405 -0
  32. package/lib/fs.js +405 -0
  33. package/lib/fs.ts +527 -0
  34. package/lib/jwt.js +223 -0
  35. package/lib/jwt.ts +276 -0
  36. package/lib/kv.js +1004 -0
  37. package/lib/kv.ts +1489 -0
  38. package/lib/lan.js +99 -0
  39. package/lib/lan.ts +87 -0
  40. package/lib/net/cacert.pem +3480 -0
  41. package/lib/net/formdata.js +137 -0
  42. package/lib/net/formdata.ts +166 -0
  43. package/lib/net/request.js +102 -0
  44. package/lib/net/request.ts +150 -0
  45. package/lib/net/response.js +28 -0
  46. package/lib/net/response.ts +59 -0
  47. package/lib/net.js +462 -0
  48. package/lib/net.ts +662 -0
  49. package/lib/s3.js +180 -0
  50. package/lib/s3.ts +235 -0
  51. package/lib/scan.js +276 -0
  52. package/lib/scan.ts +364 -0
  53. package/lib/session.js +177 -0
  54. package/lib/session.ts +230 -0
  55. package/lib/sql.js +818 -0
  56. package/lib/sql.ts +1151 -0
  57. package/lib/ssh/sftp.js +373 -0
  58. package/lib/ssh/sftp.ts +508 -0
  59. package/lib/ssh/shell.js +109 -0
  60. package/lib/ssh/shell.ts +123 -0
  61. package/lib/ssh.js +171 -0
  62. package/lib/ssh.ts +191 -0
  63. package/lib/text/tld.json +1 -0
  64. package/lib/text.js +452 -0
  65. package/lib/text.ts +607 -0
  66. package/lib/time.js +216 -0
  67. package/lib/time.ts +254 -0
  68. package/lib/ws.js +373 -0
  69. package/lib/ws.ts +523 -0
  70. package/lib/zip.js +381 -0
  71. package/lib/zip.ts +447 -0
  72. package/lib/zlib.js +289 -0
  73. package/lib/zlib.ts +350 -0
  74. package/main.js +51 -0
  75. package/main.ts +27 -0
  76. package/package.json +37 -0
  77. package/sys/child.js +585 -0
  78. package/sys/child.ts +678 -0
  79. package/sys/cmd.js +226 -0
  80. package/sys/cmd.ts +225 -0
  81. package/sys/ctr.js +608 -0
  82. package/sys/ctr.ts +904 -0
  83. package/sys/master.js +314 -0
  84. package/sys/master.ts +355 -0
  85. package/sys/mod.js +1273 -0
  86. package/sys/mod.ts +1871 -0
  87. package/sys/route.js +922 -0
  88. package/sys/route.ts +1113 -0
  89. package/types/index.d.ts +283 -0
  90. package/www/example/ctr/main.js +42 -0
  91. package/www/example/ctr/main.ts +9 -0
  92. package/www/example/ctr/middle.js +57 -0
  93. package/www/example/ctr/middle.ts +26 -0
  94. package/www/example/ctr/test.js +2818 -0
  95. package/www/example/ctr/test.ts +3218 -0
  96. package/www/example/data/locale/en.test.json +8 -0
  97. package/www/example/data/locale/index.html +1 -0
  98. package/www/example/data/locale/ja.test.json +8 -0
  99. package/www/example/data/locale/sc.test.json +8 -0
  100. package/www/example/data/locale/tc.test.json +8 -0
  101. package/www/example/data/test.zip +0 -0
  102. package/www/example/kebab.json +24 -0
  103. package/www/example/mod/test.js +49 -0
  104. package/www/example/mod/test.ts +47 -0
  105. package/www/example/mod/testdata.js +11 -0
  106. package/www/example/mod/testdata.ts +30 -0
  107. package/www/example/route.json +6 -0
  108. package/www/example/view/test.ejs +11 -0
  109. package/www/example/ws/mproxy.js +49 -0
  110. package/www/example/ws/mproxy.ts +16 -0
  111. package/www/example/ws/rproxy.js +47 -0
  112. package/www/example/ws/rproxy.ts +14 -0
  113. package/www/example/ws/test.js +68 -0
  114. package/www/example/ws/test.ts +36 -0
package/lib/dns.js ADDED
@@ -0,0 +1,321 @@
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.Dns = exports.ERecordLine = exports.RECORD_TYPE = exports.ESERVICE = void 0;
37
+ exports.get = get;
38
+ const net = __importStar(require("~/lib/net"));
39
+ const core = __importStar(require("~/lib/core"));
40
+ const text = __importStar(require("~/lib/text"));
41
+ const crypto = __importStar(require("~/lib/crypto"));
42
+ const response = __importStar(require("~/lib/net/response"));
43
+ var ESERVICE;
44
+ (function (ESERVICE) {
45
+ ESERVICE[ESERVICE["DNSPOD"] = 0] = "DNSPOD";
46
+ ESERVICE[ESERVICE["ALIBABA"] = 1] = "ALIBABA";
47
+ })(ESERVICE || (exports.ESERVICE = ESERVICE = {}));
48
+ exports.RECORD_TYPE = {
49
+ 'A': 'A',
50
+ 'NS': 'NS',
51
+ 'MX': 'MX',
52
+ 'TXT': 'TXT',
53
+ 'CNAME': 'CNAME',
54
+ 'SRV': 'SRV',
55
+ 'AAAA': 'AAAA'
56
+ };
57
+ var ERecordLine;
58
+ (function (ERecordLine) {
59
+ ERecordLine[ERecordLine["DEFAULT"] = 0] = "DEFAULT";
60
+ ERecordLine[ERecordLine["TELECOM"] = 1] = "TELECOM";
61
+ ERecordLine[ERecordLine["UNICOM"] = 2] = "UNICOM";
62
+ ERecordLine[ERecordLine["MOBILE"] = 3] = "MOBILE";
63
+ ERecordLine[ERecordLine["EDU"] = 4] = "EDU";
64
+ ERecordLine[ERecordLine["OVERSEA"] = 5] = "OVERSEA";
65
+ })(ERecordLine || (exports.ERecordLine = ERecordLine = {}));
66
+ const recordLine = {
67
+ [ESERVICE.DNSPOD]: [
68
+ '默认',
69
+ '电信',
70
+ '联通',
71
+ '移动',
72
+ '教育网',
73
+ '境外'
74
+ ],
75
+ [ESERVICE.ALIBABA]: [
76
+ 'default',
77
+ 'telecom',
78
+ 'unicom',
79
+ 'mobile',
80
+ 'edu',
81
+ 'oversea'
82
+ ]
83
+ };
84
+ class Dns {
85
+ constructor(ctr, opt) {
86
+ const config = ctr.getPrototype('_config');
87
+ opt.secretId ??= config.dns?.[ESERVICE[opt.service]].sid;
88
+ opt.secretKey ??= config.dns?.[ESERVICE[opt.service]].skey;
89
+ this._opt = opt;
90
+ }
91
+ async _send(obj) {
92
+ for (const key in obj) {
93
+ if (obj[key] === null || obj[key] === undefined) {
94
+ delete obj[key];
95
+ }
96
+ }
97
+ switch (this._opt.service) {
98
+ case ESERVICE.DNSPOD: {
99
+ const data = Object.assign({
100
+ 'login_token': (this._opt.secretId ?? '') + '.' + (this._opt.secretKey ?? ''),
101
+ 'format': 'json'
102
+ }, obj);
103
+ const path = data['_path'];
104
+ delete data['_path'];
105
+ return net.post('https://dnsapi.cn/' + path, data);
106
+ }
107
+ case ESERVICE.ALIBABA: {
108
+ const getData = core.objectSort(Object.assign({
109
+ 'Format': 'JSON',
110
+ 'Version': '2015-01-09',
111
+ 'AccessKeyId': this._opt.secretId,
112
+ 'SignatureMethod': 'HMAC-SHA1',
113
+ 'Timestamp': (new Date()).toISOString(),
114
+ 'SignatureVersion': '1.0',
115
+ 'SignatureNonce': core.rand(1000000000, 9999999999)
116
+ }, obj));
117
+ const urlRight = text.queryStringify(getData);
118
+ const signature = crypto.hashHmac('sha1', `GET&${encodeURIComponent('/')}&${encodeURIComponent(urlRight)}`, (this._opt.secretKey ?? '') + '&', 'base64');
119
+ return net.get(`https://alidns.aliyuncs.com/?${urlRight}&Signature=${encodeURIComponent(signature)}`);
120
+ }
121
+ }
122
+ return new response.Response(null);
123
+ }
124
+ async getDomainList(opt) {
125
+ switch (this._opt.service) {
126
+ case ESERVICE.DNSPOD: {
127
+ const rtn = await this._send({
128
+ '_path': 'Domain.List',
129
+ 'offset': opt.offset ?? 0,
130
+ 'length': opt.length ?? 20
131
+ });
132
+ const res = await rtn.getContent();
133
+ if (!res) {
134
+ return res;
135
+ }
136
+ const json = text.parseJson(res.toString());
137
+ const r = {
138
+ 'total': json.info.domain_total,
139
+ 'list': []
140
+ };
141
+ for (const item of json.domains) {
142
+ r.list.push({
143
+ 'id': item.id.toString(),
144
+ 'name': item.name,
145
+ 'count': parseInt(item.records),
146
+ 'punyCode': item.punycode
147
+ });
148
+ }
149
+ return r;
150
+ }
151
+ case ESERVICE.ALIBABA: {
152
+ const length = opt.length ?? 20;
153
+ const rtn = await this._send({
154
+ 'Action': 'DescribeDomains',
155
+ 'PageNumber': opt.offset !== undefined ? opt.offset / length + 1 : 1,
156
+ 'PageSize': length
157
+ });
158
+ const res = await rtn.getContent();
159
+ if (!res) {
160
+ return res;
161
+ }
162
+ const json = text.parseJson(res.toString());
163
+ const r = {
164
+ 'total': json.TotalCount,
165
+ 'list': []
166
+ };
167
+ for (const item of json.Domains.Domain) {
168
+ r.list.push({
169
+ 'id': item.DomainId,
170
+ 'name': item.DomainName,
171
+ 'count': item.RecordCount,
172
+ 'punyCode': item.PunyCode
173
+ });
174
+ }
175
+ return r;
176
+ }
177
+ }
178
+ return null;
179
+ }
180
+ async addDomainRecord(opt) {
181
+ const line = opt.line ?? ERecordLine.DEFAULT;
182
+ const ttl = opt.ttl ?? 600;
183
+ switch (this._opt.service) {
184
+ case ESERVICE.DNSPOD: {
185
+ const rtn = await this._send({
186
+ '_path': 'Record.Create',
187
+ 'domain': opt.domain,
188
+ 'sub_domain': opt.sub,
189
+ 'record_type': opt.type,
190
+ 'record_line': recordLine[ESERVICE.DNSPOD][line],
191
+ 'value': opt.value,
192
+ 'ttl': ttl,
193
+ 'mx': opt.mx
194
+ });
195
+ const res = await rtn.getContent();
196
+ if (!res) {
197
+ return res;
198
+ }
199
+ const json = text.parseJson(res.toString());
200
+ const r = {
201
+ 'success': json.record?.id ? true : false,
202
+ 'id': json.record?.id ?? ''
203
+ };
204
+ return r;
205
+ }
206
+ case ESERVICE.ALIBABA: {
207
+ const rtn = await this._send({
208
+ 'Action': 'AddDomainRecord',
209
+ 'DomainName': opt.domain,
210
+ 'RR': opt.sub,
211
+ 'Type': opt.type,
212
+ 'Line': recordLine[ESERVICE.ALIBABA][line],
213
+ 'Value': opt.value,
214
+ 'TTL': ttl,
215
+ 'Priority': opt.mx
216
+ });
217
+ const res = await rtn.getContent();
218
+ if (!res) {
219
+ return res;
220
+ }
221
+ const json = text.parseJson(res.toString());
222
+ const r = {
223
+ 'success': json.RecordId !== undefined ? true : false,
224
+ 'id': json.RecordId ?? ''
225
+ };
226
+ return r;
227
+ }
228
+ }
229
+ return null;
230
+ }
231
+ async updateDomainRecord(opt) {
232
+ const line = opt.line ?? ERecordLine.DEFAULT;
233
+ const ttl = opt.ttl ?? 600;
234
+ switch (this._opt.service) {
235
+ case ESERVICE.DNSPOD: {
236
+ const rtn = await this._send({
237
+ '_path': 'Record.Modify',
238
+ 'domain': opt.domain,
239
+ 'record_id': opt.record,
240
+ 'sub_domain': opt.sub,
241
+ 'record_type': opt.type,
242
+ 'record_line': recordLine[ESERVICE.DNSPOD][line],
243
+ 'value': opt.value,
244
+ 'ttl': ttl,
245
+ 'mx': opt.mx
246
+ });
247
+ const res = await rtn.getContent();
248
+ if (!res) {
249
+ return res;
250
+ }
251
+ const json = text.parseJson(res.toString());
252
+ const r = {
253
+ 'success': json.record?.id ? true : false,
254
+ 'id': json.record?.id ?? ''
255
+ };
256
+ return r;
257
+ }
258
+ case ESERVICE.ALIBABA: {
259
+ const rtn = await this._send({
260
+ 'Action': 'UpdateDomainRecord',
261
+ 'RecordId': opt.record,
262
+ 'RR': opt.sub,
263
+ 'Type': opt.type,
264
+ 'Line': recordLine[ESERVICE.ALIBABA][line],
265
+ 'Value': opt.value,
266
+ 'TTL': ttl,
267
+ 'Priority': opt.mx
268
+ });
269
+ const res = await rtn.getContent();
270
+ if (!res) {
271
+ return res;
272
+ }
273
+ const json = text.parseJson(res.toString());
274
+ const r = {
275
+ 'success': json.RecordId !== undefined ? true : false,
276
+ 'id': json.RecordId ?? ''
277
+ };
278
+ return r;
279
+ }
280
+ }
281
+ return null;
282
+ }
283
+ async deleteDomainRecord(opt) {
284
+ switch (this._opt.service) {
285
+ case ESERVICE.DNSPOD: {
286
+ const rtn = await this._send({
287
+ '_path': 'Record.Remove',
288
+ 'domain': opt.domain,
289
+ 'record_id': opt.id
290
+ });
291
+ const res = await rtn.getContent();
292
+ if (!res) {
293
+ return res;
294
+ }
295
+ const json = text.parseJson(res.toString());
296
+ return {
297
+ 'success': json.status.code === '1' ? true : false
298
+ };
299
+ }
300
+ case ESERVICE.ALIBABA: {
301
+ const rtn = await this._send({
302
+ 'Action': 'DeleteDomainRecord',
303
+ 'RecordId': opt.id
304
+ });
305
+ const res = await rtn.getContent();
306
+ if (!res) {
307
+ return res;
308
+ }
309
+ const json = text.parseJson(res.toString());
310
+ return {
311
+ 'success': json.Code === undefined ? true : false
312
+ };
313
+ }
314
+ }
315
+ return null;
316
+ }
317
+ }
318
+ exports.Dns = Dns;
319
+ function get(ctr, opt) {
320
+ return new Dns(ctr, opt);
321
+ }