@maiyunnet/kebab 2.0.16 → 3.0.1

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 (82) hide show
  1. package/README.md +1 -5
  2. package/bin/kebab.js +1 -1
  3. package/index.d.ts +1 -1
  4. package/index.js +16 -18
  5. package/lib/buffer.js +4 -11
  6. package/lib/captcha.js +6 -44
  7. package/lib/consistent.js +8 -51
  8. package/lib/core.d.ts +4 -4
  9. package/lib/core.js +70 -132
  10. package/lib/crypto.js +43 -99
  11. package/lib/db.d.ts +5 -5
  12. package/lib/db.js +31 -68
  13. package/lib/dns.d.ts +1 -1
  14. package/lib/dns.js +12 -50
  15. package/lib/fs.js +26 -81
  16. package/lib/jwt.d.ts +3 -3
  17. package/lib/jwt.js +9 -50
  18. package/lib/kv.d.ts +4 -4
  19. package/lib/kv.js +31 -69
  20. package/lib/lan.js +4 -41
  21. package/lib/net/cacert.pem +78 -2
  22. package/lib/net/formdata.js +5 -42
  23. package/lib/net/request.d.ts +2 -2
  24. package/lib/net/request.js +3 -42
  25. package/lib/net/response.d.ts +1 -1
  26. package/lib/net/response.js +1 -5
  27. package/lib/net.d.ts +5 -5
  28. package/lib/net.js +24 -73
  29. package/lib/s3.d.ts +1 -1
  30. package/lib/s3.js +20 -59
  31. package/lib/scan.d.ts +3 -3
  32. package/lib/scan.js +10 -50
  33. package/lib/session.d.ts +3 -3
  34. package/lib/session.js +9 -46
  35. package/lib/sql.d.ts +2 -2
  36. package/lib/sql.js +9 -50
  37. package/lib/ssh/sftp.js +5 -46
  38. package/lib/ssh/shell.js +2 -39
  39. package/lib/ssh.d.ts +2 -2
  40. package/lib/ssh.js +5 -43
  41. package/lib/text.d.ts +1 -1
  42. package/lib/text.js +40 -104
  43. package/lib/time.d.ts +1 -1
  44. package/lib/time.js +10 -50
  45. package/lib/turnstile.d.ts +1 -1
  46. package/lib/turnstile.js +6 -43
  47. package/lib/ws.d.ts +2 -2
  48. package/lib/ws.js +14 -56
  49. package/lib/zip.d.ts +1 -1
  50. package/lib/zip.js +6 -47
  51. package/lib/zlib.js +17 -68
  52. package/main.js +6 -44
  53. package/package.json +9 -8
  54. package/sys/child.js +10 -45
  55. package/sys/cmd.js +8 -43
  56. package/sys/ctr.d.ts +5 -5
  57. package/sys/ctr.js +9 -47
  58. package/sys/master.js +11 -46
  59. package/sys/mod.d.ts +9 -5
  60. package/sys/mod.js +9 -43
  61. package/sys/route.d.ts +2 -2
  62. package/sys/route.js +24 -64
  63. package/types/index.d.ts +1 -0
  64. package/www/example/ctr/main.d.ts +1 -1
  65. package/www/example/ctr/main.js +2 -38
  66. package/www/example/ctr/middle.d.ts +2 -2
  67. package/www/example/ctr/middle.js +2 -38
  68. package/www/example/ctr/test.d.ts +2 -2
  69. package/www/example/ctr/test.js +65 -72
  70. package/www/example/mod/test.d.ts +2 -2
  71. package/www/example/mod/test.js +4 -42
  72. package/www/example/mod/testdata.d.ts +1 -1
  73. package/www/example/mod/testdata.js +3 -8
  74. package/www/example/ws/mproxy.d.ts +1 -1
  75. package/www/example/ws/mproxy.js +6 -41
  76. package/www/example/ws/rproxy.d.ts +1 -1
  77. package/www/example/ws/rproxy.js +5 -40
  78. package/www/example/ws/rsocket.d.ts +1 -1
  79. package/www/example/ws/rsocket.js +5 -40
  80. package/www/example/ws/test.d.ts +1 -1
  81. package/www/example/ws/test.js +7 -42
  82. package/eslint.config.js +0 -22
package/lib/dns.js CHANGED
@@ -1,65 +1,28 @@
1
- "use strict";
2
1
  /**
3
2
  * Project: Kebab, User: JianSuoQiYue
4
3
  * Date: 2019-6-19
5
4
  * Last: 2022-09-12 20:58:07, 2024-2-21 17:55:54, 2025-6-13 19:08:56
6
5
  */
7
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
- if (k2 === undefined) k2 = k;
9
- var desc = Object.getOwnPropertyDescriptor(m, k);
10
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
- desc = { enumerable: true, get: function() { return m[k]; } };
12
- }
13
- Object.defineProperty(o, k2, desc);
14
- }) : (function(o, m, k, k2) {
15
- if (k2 === undefined) k2 = k;
16
- o[k2] = m[k];
17
- }));
18
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
- Object.defineProperty(o, "default", { enumerable: true, value: v });
20
- }) : function(o, v) {
21
- o["default"] = v;
22
- });
23
- var __importStar = (this && this.__importStar) || (function () {
24
- var ownKeys = function(o) {
25
- ownKeys = Object.getOwnPropertyNames || function (o) {
26
- var ar = [];
27
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
- return ar;
29
- };
30
- return ownKeys(o);
31
- };
32
- return function (mod) {
33
- if (mod && mod.__esModule) return mod;
34
- var result = {};
35
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
- __setModuleDefault(result, mod);
37
- return result;
38
- };
39
- })();
40
- Object.defineProperty(exports, "__esModule", { value: true });
41
- exports.Dns = exports.ERecordLine = exports.RECORD_TYPE = exports.ESERVICE = void 0;
42
- exports.get = get;
43
6
  // --- 库和定义 ---
44
- const net = __importStar(require("~/lib/net"));
45
- const core = __importStar(require("~/lib/core"));
46
- const text = __importStar(require("~/lib/text"));
47
- const crypto = __importStar(require("~/lib/crypto"));
48
- const response = __importStar(require("~/lib/net/response"));
7
+ import * as net from '../lib/net.js';
8
+ import * as core from '../lib/core.js';
9
+ import * as text from '../lib/text.js';
10
+ import * as crypto from '../lib/crypto.js';
11
+ import * as response from '../lib/net/response.js';
49
12
  /**
50
13
  * 0.DNSPod:https://www.dnspod.cn/docs/index.html(腾讯云也请使用 DNSPod 的 API)
51
14
  * 1.阿里云:https://help.aliyun.com/document_detail/29745.html
52
15
  */
53
16
  /** --- 服务商定义 --- */
54
- var ESERVICE;
17
+ export var ESERVICE;
55
18
  (function (ESERVICE) {
56
19
  ESERVICE[ESERVICE["DNSPOD"] = 0] = "DNSPOD";
57
20
  ESERVICE[ESERVICE["ALIBABA"] = 1] = "ALIBABA";
58
- })(ESERVICE || (exports.ESERVICE = ESERVICE = {}));
21
+ })(ESERVICE || (ESERVICE = {}));
59
22
  /**
60
23
  * --- 记录值类型 ---
61
24
  */
62
- exports.RECORD_TYPE = {
25
+ export const RECORD_TYPE = {
63
26
  'A': 'A',
64
27
  'NS': 'NS',
65
28
  'MX': 'MX',
@@ -71,7 +34,7 @@ exports.RECORD_TYPE = {
71
34
  /**
72
35
  * --- 记录值线路 ---
73
36
  */
74
- var ERecordLine;
37
+ export var ERecordLine;
75
38
  (function (ERecordLine) {
76
39
  ERecordLine[ERecordLine["DEFAULT"] = 0] = "DEFAULT";
77
40
  ERecordLine[ERecordLine["TELECOM"] = 1] = "TELECOM";
@@ -79,7 +42,7 @@ var ERecordLine;
79
42
  ERecordLine[ERecordLine["MOBILE"] = 3] = "MOBILE";
80
43
  ERecordLine[ERecordLine["EDU"] = 4] = "EDU";
81
44
  ERecordLine[ERecordLine["OVERSEA"] = 5] = "OVERSEA";
82
- })(ERecordLine || (exports.ERecordLine = ERecordLine = {}));
45
+ })(ERecordLine || (ERecordLine = {}));
83
46
  const recordLine = {
84
47
  [ESERVICE.DNSPOD]: [
85
48
  '默认',
@@ -98,7 +61,7 @@ const recordLine = {
98
61
  'oversea'
99
62
  ]
100
63
  };
101
- class Dns {
64
+ export class Dns {
102
65
  constructor(ctr, opt) {
103
66
  const config = ctr.getPrototype('_config');
104
67
  opt.secretId ??= config.dns?.[ESERVICE[opt.service]].sid;
@@ -363,11 +326,10 @@ class Dns {
363
326
  return null;
364
327
  }
365
328
  }
366
- exports.Dns = Dns;
367
329
  /**
368
330
  * --- 创建一个第三方 Dns 对象 ---
369
331
  * @param opt 选项
370
332
  */
371
- function get(ctr, opt) {
333
+ export function get(ctr, opt) {
372
334
  return new Dns(ctr, opt);
373
335
  }
package/lib/fs.js CHANGED
@@ -1,75 +1,20 @@
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.getContent = getContent;
37
- exports.putContent = putContent;
38
- exports.readLink = readLink;
39
- exports.symlink = symlink;
40
- exports.unlink = unlink;
41
- exports.stats = stats;
42
- exports.isDir = isDir;
43
- exports.isFile = isFile;
44
- exports.mkdir = mkdir;
45
- exports.rmdir = rmdir;
46
- exports.rmdirDeep = rmdirDeep;
47
- exports.chmod = chmod;
48
- exports.rename = rename;
49
- exports.readDir = readDir;
50
- exports.copyFolder = copyFolder;
51
- exports.copyFile = copyFile;
52
- exports.createReadStream = createReadStream;
53
- exports.pipe = pipe;
54
- exports.createWriteStream = createWriteStream;
55
- exports.readToResponse = readToResponse;
56
1
  /**
57
2
  * Project: Kebab, User: JianSuoQiYue
58
3
  * Date: 2019-3-29 23:03:07
59
4
  * Last: 2020-3-11 22:21:51, 2022-12-29 01:18:25, 2023-12-13 20:50:09
60
5
  */
61
- const fs = __importStar(require("fs"));
62
- const http2 = __importStar(require("http2"));
63
- const mime = __importStar(require("@litert/mime"));
64
- const text = __importStar(require("./text"));
65
- const core = __importStar(require("./core"));
66
- const zlib = __importStar(require("./zlib"));
6
+ import * as fs from 'fs';
7
+ import * as http2 from 'http2';
8
+ import * as mime from '@litert/mime';
9
+ import * as text from './text.js';
10
+ import * as core from './core.js';
11
+ import * as zlib from './zlib.js';
67
12
  /**
68
13
  * --- 读取完整文件或一段 ---
69
14
  * @param path 文件路径
70
15
  * @param options 编码或选项
71
16
  */
72
- async function getContent(path, options) {
17
+ export async function getContent(path, options) {
73
18
  if (typeof options === 'string') {
74
19
  options = {
75
20
  'encoding': options
@@ -129,7 +74,7 @@ async function getContent(path, options) {
129
74
  * @param data 要写入的内容
130
75
  * @param options 选项
131
76
  */
132
- async function putContent(path, data, options = {}) {
77
+ export async function putContent(path, data, options = {}) {
133
78
  try {
134
79
  await fs.promises.writeFile(path, data, options);
135
80
  return true;
@@ -143,7 +88,7 @@ async function putContent(path, data, options = {}) {
143
88
  * @param path 要读取的路径
144
89
  * @param encoding 编码
145
90
  */
146
- async function readLink(path, encoding) {
91
+ export async function readLink(path, encoding) {
147
92
  try {
148
93
  return await fs.promises.readlink(path, {
149
94
  'encoding': encoding
@@ -159,7 +104,7 @@ async function readLink(path, encoding) {
159
104
  * @param linkPath 连接路径
160
105
  * @param type 仅 Windows,类型,默认 file
161
106
  */
162
- async function symlink(filePath, linkPath, type) {
107
+ export async function symlink(filePath, linkPath, type) {
163
108
  try {
164
109
  await fs.promises.symlink(filePath, linkPath, type);
165
110
  return true;
@@ -172,7 +117,7 @@ async function symlink(filePath, linkPath, type) {
172
117
  * --- 删除一个文件 ---
173
118
  * @param path 要删除的文件路径
174
119
  */
175
- async function unlink(path) {
120
+ export async function unlink(path) {
176
121
  for (let i = 0; i <= 2; ++i) {
177
122
  try {
178
123
  await fs.promises.unlink(path);
@@ -194,7 +139,7 @@ async function unlink(path) {
194
139
  * --- 获取对象是否存在,存在则返回 stats 对象,否则返回 null ---
195
140
  * @param path 对象路径
196
141
  */
197
- async function stats(path) {
142
+ export async function stats(path) {
198
143
  try {
199
144
  return await fs.promises.lstat(path);
200
145
  }
@@ -206,7 +151,7 @@ async function stats(path) {
206
151
  * --- 判断是否是目录或目录是否存在,是的话返回 stats ---
207
152
  * @param path 判断路径
208
153
  */
209
- async function isDir(path) {
154
+ export async function isDir(path) {
210
155
  const pstats = await stats(path);
211
156
  if (!pstats?.isDirectory()) {
212
157
  return false;
@@ -217,7 +162,7 @@ async function isDir(path) {
217
162
  * --- 判断是否是文件或文件是否存在,是的话返回 stats ---
218
163
  * @param path 判断路径
219
164
  */
220
- async function isFile(path) {
165
+ export async function isFile(path) {
221
166
  const pstats = await stats(path);
222
167
  if (!pstats?.isFile()) {
223
168
  return false;
@@ -229,7 +174,7 @@ async function isFile(path) {
229
174
  * @param path 要创建的路径,如 /a/b/c/
230
175
  * @param mode 权限
231
176
  */
232
- async function mkdir(path, mode = 0o755) {
177
+ export async function mkdir(path, mode = 0o755) {
233
178
  if (await isDir(path)) {
234
179
  return true;
235
180
  }
@@ -249,7 +194,7 @@ async function mkdir(path, mode = 0o755) {
249
194
  * --- 删除空目录 ---
250
195
  * @param path 要删除的目录
251
196
  */
252
- async function rmdir(path) {
197
+ export async function rmdir(path) {
253
198
  if (!(await isDir(path))) {
254
199
  return true;
255
200
  }
@@ -266,7 +211,7 @@ async function rmdir(path) {
266
211
  * --- This f**king is a danger function, please don't use it ---
267
212
  * --- 删除一个非空目录 ---
268
213
  */
269
- async function rmdirDeep(path) {
214
+ export async function rmdirDeep(path) {
270
215
  if (!path.endsWith('/')) {
271
216
  path += '/';
272
217
  }
@@ -297,7 +242,7 @@ async function rmdirDeep(path) {
297
242
  * @param path 要修改的路径
298
243
  * @param mod 权限
299
244
  */
300
- async function chmod(path, mod) {
245
+ export async function chmod(path, mod) {
301
246
  try {
302
247
  await fs.promises.chmod(path, mod);
303
248
  return true;
@@ -311,7 +256,7 @@ async function chmod(path, mod) {
311
256
  * @param oldPath 老名
312
257
  * @param newPath 新名
313
258
  */
314
- async function rename(oldPath, newPath) {
259
+ export async function rename(oldPath, newPath) {
315
260
  try {
316
261
  await fs.promises.rename(oldPath, newPath);
317
262
  return true;
@@ -324,7 +269,7 @@ async function rename(oldPath, newPath) {
324
269
  * --- 获取文件夹下文件列表 ---
325
270
  * @param path 文件夹路径
326
271
  */
327
- async function readDir(path, encoding) {
272
+ export async function readDir(path, encoding) {
328
273
  try {
329
274
  const list = [];
330
275
  const dlist = await fs.promises.readdir(path, {
@@ -359,7 +304,7 @@ async function readDir(path, encoding) {
359
304
  * @param to 目标,末尾加 /
360
305
  * @param ignore 忽略的文件
361
306
  */
362
- async function copyFolder(from, to, ignore = []) {
307
+ export async function copyFolder(from, to, ignore = []) {
363
308
  let num = 0;
364
309
  // --- 如果源目录不存在或不是目录,则直接成功 :) ---
365
310
  if (!await isDir(from)) {
@@ -403,7 +348,7 @@ async function copyFolder(from, to, ignore = []) {
403
348
  * @param src 源文件
404
349
  * @param dest 目标文件
405
350
  */
406
- async function copyFile(src, dest) {
351
+ export async function copyFile(src, dest) {
407
352
  try {
408
353
  await fs.promises.copyFile(src, dest);
409
354
  return true;
@@ -417,7 +362,7 @@ async function copyFile(src, dest) {
417
362
  * @param path 文件地址
418
363
  * @param options 编码或配置
419
364
  */
420
- function createReadStream(path, options) {
365
+ export function createReadStream(path, options) {
421
366
  if (typeof options === 'string') {
422
367
  options = {
423
368
  'encoding': options
@@ -440,7 +385,7 @@ function createReadStream(path, options) {
440
385
  * @param destination 要写入的流
441
386
  * @param options 写入后是否终止写入流,默认终止
442
387
  */
443
- function pipe(path, destination, options) {
388
+ export function pipe(path, destination, options) {
444
389
  return new Promise((resolve) => {
445
390
  createReadStream(path).on('error', function () {
446
391
  resolve(false);
@@ -454,7 +399,7 @@ function pipe(path, destination, options) {
454
399
  * @param path 文件地址
455
400
  * @param options 编码或配置
456
401
  */
457
- function createWriteStream(path, options) {
402
+ export function createWriteStream(path, options) {
458
403
  if (typeof options === 'string') {
459
404
  options = {
460
405
  'encoding': options
@@ -478,7 +423,7 @@ function createWriteStream(path, options) {
478
423
  * @param res http 响应对象
479
424
  * @param stat 文件的 stat(如果有)
480
425
  */
481
- async function readToResponse(path, req, res, stat) {
426
+ export async function readToResponse(path, req, res, stat) {
482
427
  stat ??= await stats(path);
483
428
  if (!stat) {
484
429
  res.setHeader('content-length', 22);
package/lib/jwt.d.ts CHANGED
@@ -3,9 +3,9 @@
3
3
  * Date: 2023-1-31 20:34:47
4
4
  * Last: 2023-1-31 20:34:47, 2023-12-8 13:55:09
5
5
  */
6
- import * as kv from '~/lib/kv';
7
- import * as ctr from '~/sys/ctr';
8
- import * as types from '~/types';
6
+ import * as kv from '../lib/kv.js';
7
+ import * as ctr from '../sys/ctr.js';
8
+ import * as types from '../types/index.js';
9
9
  export interface IOptions {
10
10
  'name'?: string;
11
11
  'ttl'?: number;
package/lib/jwt.js CHANGED
@@ -1,54 +1,14 @@
1
- "use strict";
2
1
  /**
3
2
  * Project: Kebab, User: JianSuoQiYue
4
3
  * Date: 2023-1-31 20:34:47
5
4
  * Last: 2023-1-31 20:34:47, 2023-12-8 13:55:09
6
5
  */
7
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
- if (k2 === undefined) k2 = k;
9
- var desc = Object.getOwnPropertyDescriptor(m, k);
10
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
- desc = { enumerable: true, get: function() { return m[k]; } };
12
- }
13
- Object.defineProperty(o, k2, desc);
14
- }) : (function(o, m, k, k2) {
15
- if (k2 === undefined) k2 = k;
16
- o[k2] = m[k];
17
- }));
18
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
- Object.defineProperty(o, "default", { enumerable: true, value: v });
20
- }) : function(o, v) {
21
- o["default"] = v;
22
- });
23
- var __importStar = (this && this.__importStar) || (function () {
24
- var ownKeys = function(o) {
25
- ownKeys = Object.getOwnPropertyNames || function (o) {
26
- var ar = [];
27
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
- return ar;
29
- };
30
- return ownKeys(o);
31
- };
32
- return function (mod) {
33
- if (mod && mod.__esModule) return mod;
34
- var result = {};
35
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
- __setModuleDefault(result, mod);
37
- return result;
38
- };
39
- })();
40
- Object.defineProperty(exports, "__esModule", { value: true });
41
- exports.Jwt = void 0;
42
- exports.getOrigin = getOrigin;
43
- exports.decode = decode;
44
- exports.block = block;
45
- exports.get = get;
46
6
  // --- 库和定义 ---
47
- const lCore = __importStar(require("~/lib/core"));
48
- const lTime = __importStar(require("~/lib/time"));
49
- const lText = __importStar(require("~/lib/text"));
50
- const lCrypto = __importStar(require("~/lib/crypto"));
51
- class Jwt {
7
+ import * as lCore from '../lib/core.js';
8
+ import * as lTime from '../lib/time.js';
9
+ import * as lText from '../lib/text.js';
10
+ import * as lCrypto from '../lib/crypto.js';
11
+ export class Jwt {
52
12
  /**
53
13
  * --- 初始化函数,相当于 construct ---
54
14
  * @param ctr 模型实例
@@ -159,11 +119,10 @@ class Jwt {
159
119
  };
160
120
  }
161
121
  }
162
- exports.Jwt = Jwt;
163
122
  /**
164
123
  * --- 获取 jwt 原始字符串,不保证有效 ---
165
124
  */
166
- function getOrigin(ctr, name = '', auth = false) {
125
+ export function getOrigin(ctr, name = '', auth = false) {
167
126
  if (!name) {
168
127
  name = ctr.getPrototype('_config').jwt.name;
169
128
  }
@@ -188,7 +147,7 @@ function getOrigin(ctr, name = '', auth = false) {
188
147
  * --- decode ---
189
148
  * 不传入 link 的话,将不做 block 有效校验,只做本身的 exp 有效校验
190
149
  */
191
- async function decode(ctr, val, link, name = '', secret = '') {
150
+ export async function decode(ctr, val, link, name = '', secret = '') {
192
151
  if (!val) {
193
152
  return false;
194
153
  }
@@ -244,7 +203,7 @@ async function decode(ctr, val, link, name = '', secret = '') {
244
203
  /**
245
204
  * --- 仅往 redis 写禁止相关 token 的数据,一般用于异步通知时在异处的服务器来调用的 ---
246
205
  */
247
- async function block(ctr, token, exp, link, name = '') {
206
+ export async function block(ctr, token, exp, link, name = '') {
248
207
  const time = lTime.stamp();
249
208
  if (!name) {
250
209
  name = ctr.getPrototype('_config').jwt.name;
@@ -261,7 +220,7 @@ async function block(ctr, token, exp, link, name = '') {
261
220
  * @param opt name, ttl, ssl, secret, auth: false, true 则优先从头 Authorization 或 post _auth 值读取 token
262
221
  * @param link 实例
263
222
  */
264
- async function get(ctr, opt = {}, link) {
223
+ export async function get(ctr, opt = {}, link) {
265
224
  const jwt = new Jwt();
266
225
  await jwt.init(ctr, opt, link);
267
226
  return jwt;
package/lib/kv.d.ts CHANGED
@@ -4,8 +4,8 @@
4
4
  * Last: 2020-3-28 18:54:04, 2022-09-12 23:24:45, 2022-09-22 01:06:22, 2024-2-21 13:32:56, 2024-8-21 16:59:57
5
5
  */
6
6
  import * as redis from '@litert/redis';
7
- import * as ctr from '~/sys/ctr';
8
- import * as types from '~/types';
7
+ import * as sCtr from '../sys/ctr.js';
8
+ import * as types from '../types/index.js';
9
9
  /** --- 连接信息 --- */
10
10
  export interface IConnectionInfo {
11
11
  'id': number;
@@ -18,7 +18,7 @@ export interface IConnectionInfo {
18
18
  export declare class Pool {
19
19
  /** --- 当前 Pool 对象的 kv 连接信息 --- */
20
20
  private readonly _etc;
21
- constructor(ctr: ctr.Ctr, etc?: types.IConfigKv);
21
+ constructor(ctr: sCtr.Ctr, etc?: types.IConfigKv);
22
22
  /**
23
23
  * --- 设定一个值 ---
24
24
  * @param key
@@ -466,7 +466,7 @@ export declare class Connection {
466
466
  * --- 获取 Kv Pool 对象 ---
467
467
  * @param etc 配置信息可留空
468
468
  */
469
- export declare function get(ctr: ctr.Ctr, etc?: types.IConfigKv): Pool;
469
+ export declare function get(ctr: sCtr.Ctr, etc?: types.IConfigKv): Pool;
470
470
  /**
471
471
  * --- 获取当前连接池中所有连接的信息 ---
472
472
  */