@maiyunnet/kebab 2.0.4 → 2.0.6

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/index.d.ts +14 -0
  2. package/index.js +1 -1
  3. package/lib/buffer.d.ts +25 -0
  4. package/lib/captcha.d.ts +12 -0
  5. package/lib/captcha.js +2 -2
  6. package/lib/consistent.d.ts +20 -0
  7. package/lib/consistent.js +1 -1
  8. package/lib/core.d.ts +85 -0
  9. package/lib/core.js +8 -8
  10. package/lib/crypto.d.ts +47 -0
  11. package/lib/crypto.js +1 -1
  12. package/lib/db.d.ts +88 -0
  13. package/lib/db.js +5 -5
  14. package/lib/dns.d.ts +75 -0
  15. package/lib/dns.js +5 -5
  16. package/lib/fs.d.ts +49 -0
  17. package/lib/jwt.d.ts +30 -0
  18. package/lib/jwt.js +4 -4
  19. package/lib/kv.d.ts +111 -0
  20. package/lib/kv.js +2 -2
  21. package/lib/lan.d.ts +10 -0
  22. package/lib/lan.js +1 -1
  23. package/lib/net/formdata.d.ts +23 -0
  24. package/lib/net/formdata.js +2 -2
  25. package/lib/net/request.d.ts +23 -0
  26. package/lib/net/request.js +1 -1
  27. package/lib/net/response.d.ts +14 -0
  28. package/lib/net.d.ts +65 -0
  29. package/lib/net.js +4 -4
  30. package/lib/s3.d.ts +35 -0
  31. package/lib/s3.js +2 -2
  32. package/lib/scan.d.ts +31 -0
  33. package/lib/scan.js +6 -6
  34. package/lib/session.d.ts +22 -0
  35. package/lib/session.js +6 -6
  36. package/lib/sql.d.ts +57 -0
  37. package/lib/sql.js +3 -3
  38. package/lib/ssh/sftp.d.ts +40 -0
  39. package/lib/ssh/sftp.js +2 -2
  40. package/lib/ssh/shell.d.ts +13 -0
  41. package/lib/ssh/shell.js +1 -1
  42. package/lib/ssh.d.ts +24 -0
  43. package/lib/text.d.ts +40 -0
  44. package/lib/text.js +1 -1
  45. package/lib/time.d.ts +22 -0
  46. package/lib/time.js +1 -1
  47. package/lib/ws.d.ts +87 -0
  48. package/lib/ws.js +2 -2
  49. package/lib/zip.d.ts +40 -0
  50. package/lib/zip.js +1 -1
  51. package/lib/zlib.d.ts +25 -0
  52. package/main.d.ts +1 -0
  53. package/package.json +3 -3
  54. package/sys/child.d.ts +1 -0
  55. package/sys/child.js +6 -6
  56. package/sys/cmd.d.ts +1 -0
  57. package/sys/cmd.js +6 -6
  58. package/sys/ctr.d.ts +96 -0
  59. package/sys/master.d.ts +1 -0
  60. package/sys/master.js +8 -8
  61. package/sys/mod.d.ts +205 -0
  62. package/sys/mod.js +5 -5
  63. package/sys/route.d.ts +31 -0
  64. package/sys/route.js +8 -8
  65. package/types/index.d.ts +283 -0
  66. package/www/example/ctr/main.d.ts +4 -0
  67. package/www/example/ctr/main.js +1 -1
  68. package/www/example/ctr/middle.d.ts +6 -0
  69. package/www/example/ctr/middle.js +1 -1
  70. package/www/example/ctr/test.d.ts +94 -0
  71. package/www/example/ctr/test.js +21 -21
  72. package/www/example/mod/test.d.ts +20 -0
  73. package/www/example/mod/test.js +2 -2
  74. package/www/example/mod/testdata.d.ts +9 -0
  75. package/www/example/mod/testdata.js +1 -1
  76. package/www/example/ws/mproxy.d.ts +4 -0
  77. package/www/example/ws/mproxy.js +2 -2
  78. package/www/example/ws/rproxy.d.ts +4 -0
  79. package/www/example/ws/rproxy.js +2 -2
  80. package/www/example/ws/test.d.ts +7 -0
  81. package/www/example/ws/test.js +2 -2
  82. package/tsconfig.json +0 -27
package/index.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ export declare const VER = "2.0.6";
2
+ export declare const ROOT_PATH: string;
3
+ export declare const LIB_PATH: string;
4
+ export declare const SYS_PATH: string;
5
+ export declare const ROOT_CWD: string;
6
+ export declare const CONF_CWD: string;
7
+ export declare const CERT_CWD: string;
8
+ export declare const VHOST_CWD: string;
9
+ export declare const LIB_CWD: string;
10
+ export declare const LOG_CWD: string;
11
+ export declare const WWW_CWD: string;
12
+ export declare const IND_CWD: string;
13
+ export declare const FTMP_CWD: string;
14
+ export declare const MOD_CWD: string;
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MOD_CWD = exports.FTMP_CWD = exports.IND_CWD = exports.WWW_CWD = exports.LOG_CWD = exports.LIB_CWD = exports.VHOST_CWD = exports.CERT_CWD = exports.CONF_CWD = exports.ROOT_CWD = exports.SYS_PATH = exports.LIB_PATH = exports.ROOT_PATH = exports.VER = void 0;
4
- exports.VER = '2.0.4';
4
+ exports.VER = '2.0.6';
5
5
  const dirname = __dirname.replace(/\\/g, '/');
6
6
  exports.ROOT_PATH = dirname + '/';
7
7
  exports.LIB_PATH = exports.ROOT_PATH + 'lib/';
@@ -0,0 +1,25 @@
1
+ export declare class Reader {
2
+ private readonly _buffer;
3
+ private _offset;
4
+ constructor(buffer: Buffer);
5
+ readUInt8(): number;
6
+ readUInt16BE(): number;
7
+ readUInt32BE(): number;
8
+ readBCDString(length?: number): string;
9
+ readString(length?: number, encoding?: BufferEncoding): string;
10
+ readBuffer(length?: number): Buffer;
11
+ length(): number;
12
+ }
13
+ export declare class Writer {
14
+ private readonly _buffer;
15
+ private _offset;
16
+ constructor(size: number);
17
+ writeUInt8(value: number): void;
18
+ writeUInt16BE(value: number): void;
19
+ writeUInt32BE(value: number): void;
20
+ writeBCDString(value: string): void;
21
+ writeString(value: string, encoding?: BufferEncoding): number;
22
+ get(): Buffer;
23
+ }
24
+ export declare function getReader(buffer: Buffer): Reader;
25
+ export declare function getWriter(size: number): Writer;
@@ -0,0 +1,12 @@
1
+ export declare class Captcha {
2
+ private readonly _link;
3
+ constructor(opt: {
4
+ 'width': number;
5
+ 'height': number;
6
+ 'length': number;
7
+ });
8
+ getBuffer(): string;
9
+ getBase64(): string;
10
+ getPhrase(): string;
11
+ }
12
+ export declare function get(width: number, height: number, length?: number): Captcha;
package/lib/captcha.js CHANGED
@@ -37,8 +37,8 @@ exports.Captcha = void 0;
37
37
  exports.get = get;
38
38
  const svgCaptcha = __importStar(require("svg-captcha"));
39
39
  const mime = __importStar(require("@litert/mime"));
40
- const core = __importStar(require("~/lib/core"));
41
- const kebab = __importStar(require("~/index"));
40
+ const core = __importStar(require("../lib/core"));
41
+ const kebab = __importStar(require("../index"));
42
42
  svgCaptcha.loadFont(kebab.LIB_PATH + 'captcha/zcool-addict-italic.ttf');
43
43
  class Captcha {
44
44
  constructor(opt) {
@@ -0,0 +1,20 @@
1
+ export declare class Consistent {
2
+ private readonly _vcount;
3
+ private readonly _circle;
4
+ private _keys;
5
+ constructor(vcount: number);
6
+ getVcount(): number;
7
+ add(node: string | string[]): void;
8
+ remove(node: string | string[]): void;
9
+ find(key: string | number): string | null;
10
+ migration(keys: string | number | Array<string | number>, node: string | string[]): Record<string, {
11
+ 'old': string;
12
+ 'new': string;
13
+ }>;
14
+ }
15
+ export declare function get(vcount?: number): Consistent;
16
+ export declare function fast(key: string | number, nodes: string | string[], vcount?: number): string | null;
17
+ export declare function hash(val: string | number): number;
18
+ export declare function getRange(min: number, max: number, pre?: string): string[];
19
+ export declare function addToCircle(circle: Record<string, string>, node: string | string[], vcount?: number): void;
20
+ export declare function findInCircle(circle: Record<string, string>, key: string | number, keys?: string[]): string | null;
package/lib/consistent.js CHANGED
@@ -40,7 +40,7 @@ exports.hash = hash;
40
40
  exports.getRange = getRange;
41
41
  exports.addToCircle = addToCircle;
42
42
  exports.findInCircle = findInCircle;
43
- const crypto = __importStar(require("~/lib/crypto"));
43
+ const crypto = __importStar(require("../lib/crypto"));
44
44
  class Consistent {
45
45
  constructor(vcount) {
46
46
  this._vcount = 300;
package/lib/core.d.ts ADDED
@@ -0,0 +1,85 @@
1
+ import * as http from 'http';
2
+ import * as http2 from 'http2';
3
+ import * as stream from 'stream';
4
+ import * as lResponse from '../lib/net/response';
5
+ import * as sCtr from '../sys/ctr';
6
+ import * as types from '../types';
7
+ export declare const globalConfig: types.IConfig & {
8
+ 'httpPort': number;
9
+ 'httpsPort': number;
10
+ 'rpcPort': number;
11
+ 'rpcSecret': string;
12
+ 'debug': boolean;
13
+ 'max': number;
14
+ };
15
+ export interface ICookieOptions {
16
+ 'ttl'?: number;
17
+ 'path'?: string;
18
+ 'domain'?: string;
19
+ 'ssl'?: boolean;
20
+ 'httponly'?: boolean;
21
+ 'samesite'?: 'None' | 'Lax' | 'Strict';
22
+ }
23
+ export declare function setCookie(ctr: sCtr.Ctr, name: string, value: string, opt?: ICookieOptions): void;
24
+ export declare function rand(min: number, max: number, prec?: number): number;
25
+ export declare const RANDOM_N = "0123456789";
26
+ export declare const RANDOM_U = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
27
+ export declare const RANDOM_L = "abcdefghijklmnopqrstuvwxyz";
28
+ export declare const RANDOM_UN: string;
29
+ export declare const RANDOM_LN: string;
30
+ export declare const RANDOM_LU: string;
31
+ export declare const RANDOM_LUN: string;
32
+ export declare const RANDOM_V = "ACEFGHJKLMNPRSTWXY34567";
33
+ export declare const RANDOM_LUNS: string;
34
+ export declare function random(length?: number, source?: string, block?: string): string;
35
+ export declare const CONVERT62_CHAR = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
36
+ export declare function convert62(n: bigint | number | string): string;
37
+ export declare function unconvert62(n: string): bigint;
38
+ export declare function purify(text: string): string;
39
+ export declare function checkType(val: any, type: any, tree?: string): string;
40
+ export declare function muid(ctr: sCtr.Ctr, opt?: {
41
+ 'len'?: number;
42
+ 'bin'?: boolean;
43
+ 'key'?: string;
44
+ 'insert'?: string;
45
+ 'num'?: boolean;
46
+ }): string;
47
+ export declare function ip(ctr: sCtr.Ctr | http.IncomingHttpHeaders, req?: http2.Http2ServerRequest | http.IncomingMessage): string;
48
+ export declare const REAL_IP_X = "x-forwarded-for";
49
+ export declare const REAL_IP_CF = "cf-connecting-ip";
50
+ export declare function realIP(ctr: sCtr.Ctr, name?: string): string;
51
+ export declare function sleep(ms: number): Promise<void>;
52
+ export declare function objectSort<T extends Record<string, any>>(o: T): T;
53
+ export declare function emptyObject(obj: Record<string, types.Json>, deep?: boolean): void;
54
+ export declare function passThroughAppend(passThrough: stream.PassThrough, data: Array<stream.Readable | lResponse.Response | string | Buffer>, end?: boolean): Promise<void>;
55
+ export declare function exec(command: string): Promise<string | false>;
56
+ export declare function sendReload(hosts?: string[]): Promise<string[]>;
57
+ export declare function sendRestart(hosts?: string[]): Promise<string[]>;
58
+ export declare const global: Record<string, any>;
59
+ export declare function setGlobal(key: string, data: types.Json, hosts?: string[]): Promise<string[]>;
60
+ export declare function removeGlobal(key: string, hosts?: string[]): Promise<string[]>;
61
+ export declare function updateCode(sourcePath: string, path: string, hosts?: string[], config?: boolean): Promise<Record<string, {
62
+ 'result': boolean;
63
+ 'return': string;
64
+ }>>;
65
+ export interface ILogOptions {
66
+ 'path': string;
67
+ 'urlFull': string;
68
+ 'hostname': string;
69
+ 'req': http2.Http2ServerRequest | http.IncomingMessage | null;
70
+ 'get': Record<string, types.Json>;
71
+ 'cookie': Record<string, string>;
72
+ 'headers': http.IncomingHttpHeaders;
73
+ }
74
+ export declare function log(opt: sCtr.Ctr | ILogOptions, msg: string, fend?: string): Promise<void>;
75
+ export declare function getLog(opt: {
76
+ 'host': string;
77
+ 'path': string;
78
+ 'fend'?: string;
79
+ 'search'?: string;
80
+ 'offset'?: number;
81
+ 'limit'?: number;
82
+ }): Promise<string[][] | null | false>;
83
+ export declare function clone(obj: Record<string, any> | any[]): any[] | any;
84
+ export declare function debug(message?: any, ...optionalParams: any[]): void;
85
+ export declare function display(message?: any, ...optionalParams: any[]): void;
package/lib/core.js CHANGED
@@ -61,14 +61,14 @@ exports.debug = debug;
61
61
  exports.display = display;
62
62
  const cp = __importStar(require("child_process"));
63
63
  const stream = __importStar(require("stream"));
64
- const lTime = __importStar(require("~/lib/time"));
65
- const lFs = __importStar(require("~/lib/fs"));
66
- const lText = __importStar(require("~/lib/text"));
67
- const lNet = __importStar(require("~/lib/net"));
68
- const lCrypto = __importStar(require("~/lib/crypto"));
69
- const lResponse = __importStar(require("~/lib/net/response"));
70
- const sCtr = __importStar(require("~/sys/ctr"));
71
- const kebab = __importStar(require("~/index"));
64
+ const lTime = __importStar(require("../lib/time"));
65
+ const lFs = __importStar(require("../lib/fs"));
66
+ const lText = __importStar(require("../lib/text"));
67
+ const lNet = __importStar(require("../lib/net"));
68
+ const lCrypto = __importStar(require("../lib/crypto"));
69
+ const lResponse = __importStar(require("../lib/net/response"));
70
+ const sCtr = __importStar(require("../sys/ctr"));
71
+ const kebab = __importStar(require("../index"));
72
72
  exports.globalConfig = {};
73
73
  function setCookie(ctr, name, value, opt = {}) {
74
74
  const res = ctr.getPrototype('_res');
@@ -0,0 +1,47 @@
1
+ import * as crypto from 'crypto';
2
+ export declare function generateKeyPair(type: string, options?: {
3
+ 'modulusLength'?: number;
4
+ 'namedCurve'?: string;
5
+ 'publicKeyEncoding'?: {
6
+ 'type'?: 'pkcs1' | 'spki';
7
+ 'format'?: 'pem' | 'der';
8
+ };
9
+ 'privateKeyEncoding'?: {
10
+ 'type'?: 'pkcs1' | 'pkcs8' | 'sec1';
11
+ 'format'?: 'pem' | 'der';
12
+ };
13
+ }): Promise<{
14
+ 'public': string | Buffer;
15
+ 'private': string | Buffer;
16
+ }>;
17
+ export declare function sign(data: crypto.BinaryLike, privateKey: crypto.KeyLike | crypto.SignKeyObjectInput | crypto.SignPrivateKeyInput | crypto.SignJsonWebKeyInput, format: 'hex' | 'base64' | 'binary', algorithm?: string): string;
18
+ export declare function sign(data: crypto.BinaryLike, privateKey: crypto.KeyLike | crypto.SignKeyObjectInput | crypto.SignPrivateKeyInput | crypto.SignJsonWebKeyInput, format?: 'buffer', algorithm?: string): Buffer;
19
+ export declare function verify(data: crypto.BinaryLike, object: crypto.KeyLike | crypto.VerifyKeyObjectInput | crypto.VerifyPublicKeyInput | crypto.VerifyJsonWebKeyInput, signature: NodeJS.ArrayBufferView, algorithm?: string): boolean;
20
+ export declare function publicEncrypt(key: crypto.RsaPublicKey | crypto.RsaPrivateKey | crypto.KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
21
+ export declare function privateEncrypt(key: crypto.RsaPrivateKey | crypto.KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
22
+ export declare function publicDecrypt(key: crypto.RsaPublicKey | crypto.RsaPrivateKey | crypto.KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
23
+ export declare function privateDecrypt(key: crypto.RsaPrivateKey | crypto.KeyLike, buffer: NodeJS.ArrayBufferView): Buffer;
24
+ export declare const AES_256_ECB = "AES-256-ECB";
25
+ export declare const AES_256_CBC = "AES-256-CBC";
26
+ export declare const AES_256_CFB = "AES-256-CFB";
27
+ export declare const SM4_ECB = "SM4-ECB";
28
+ export declare const SM4_CBC = "SM4-CBC";
29
+ export declare const SM4_CFB = "SM4-CFB";
30
+ export declare function cipherEncrypt(original: string | Buffer, key: crypto.CipherKey, iv?: string, method?: string, output?: 'base64' | 'buffer'): string | Buffer | false;
31
+ export declare function aesEncrypt(original: string | Buffer, key: crypto.CipherKey, iv: string, method: string, output: 'buffer'): Buffer | false;
32
+ export declare function aesEncrypt(original: string | Buffer, key: crypto.CipherKey, iv?: string, method?: string, output?: 'base64'): string | false;
33
+ export declare function sm4Encrypt(original: string | Buffer, key: crypto.CipherKey, iv: string, method: string, output: 'buffer'): Buffer | false;
34
+ export declare function sm4Encrypt(original: string | Buffer, key: crypto.CipherKey, iv?: string, method?: string, output?: 'base64'): string | false;
35
+ export declare function cipherDecrypt(encrypt: string | Buffer, key: crypto.CipherKey, iv?: string, method?: string, output?: 'binary' | 'buffer'): string | Buffer | false;
36
+ export declare function aesDecrypt(encrypt: string | Buffer, key: crypto.CipherKey, iv: string, method: string, output: 'buffer'): Buffer | false;
37
+ export declare function aesDecrypt(encrypt: string | Buffer, key: crypto.CipherKey, iv?: string, method?: string, output?: 'binary'): string | false;
38
+ export declare function sm4Decrypt(encrypt: string | Buffer, key: crypto.CipherKey, iv: string, method: string, output: 'buffer'): Buffer | false;
39
+ export declare function sm4Decrypt(encrypt: string | Buffer, key: crypto.CipherKey, iv?: string, method?: string, output?: 'binary'): string | false;
40
+ export declare function hashHmac(algorithm: string, data: Buffer | string, key?: crypto.CipherKey, format?: 'hex' | 'base64'): string;
41
+ export declare function hashHmac(algorithm: string, data: Buffer | string, key: crypto.CipherKey | undefined, format: 'buffer'): Buffer;
42
+ export declare function hashHmacFile(algorithm: string, path: string, key?: crypto.CipherKey, encoding?: 'hex' | 'base64' | 'base64url'): Promise<string | false>;
43
+ export declare function hashHmacFile(algorithm: string, path: string, key: crypto.CipherKey, encoding: 'buffer'): Promise<Buffer | false>;
44
+ export declare function base64Encode(data: string | Buffer): string;
45
+ export declare function base64Decode(data: string, encoding: 'buffer'): Buffer;
46
+ export declare function base64Decode(data: string, encoding?: 'utf8'): string;
47
+ export declare function uuid(options?: crypto.RandomUUIDOptions): string;
package/lib/crypto.js CHANGED
@@ -53,7 +53,7 @@ exports.base64Encode = base64Encode;
53
53
  exports.base64Decode = base64Decode;
54
54
  exports.uuid = uuid;
55
55
  const crypto = __importStar(require("crypto"));
56
- const fs = __importStar(require("~/lib/fs"));
56
+ const fs = __importStar(require("../lib/fs"));
57
57
  function generateKeyPair(type, options = {}) {
58
58
  return new Promise((resolve) => {
59
59
  if (options.modulusLength === undefined) {
package/lib/db.d.ts ADDED
@@ -0,0 +1,88 @@
1
+ import * as mysql2 from 'mysql2/promise';
2
+ import * as ctr from '../sys/ctr';
3
+ import * as types from '../types';
4
+ export interface IData {
5
+ 'rows': any[] | null;
6
+ 'fields': mysql2.FieldPacket[];
7
+ 'error': {
8
+ 'message': string;
9
+ 'errno': number;
10
+ [key: string]: any;
11
+ } | null;
12
+ }
13
+ export interface IPacket {
14
+ 'packet': mysql2.ResultSetHeader | null;
15
+ 'fields': mysql2.FieldPacket[];
16
+ 'error': {
17
+ 'message': string;
18
+ 'errno': number;
19
+ [key: string]: any;
20
+ } | null;
21
+ }
22
+ export interface IConnectionInfo {
23
+ 'id': number;
24
+ 'last': number;
25
+ 'host': string;
26
+ 'port': number;
27
+ 'name': string;
28
+ 'user': string;
29
+ 'lost': boolean;
30
+ 'using': boolean;
31
+ 'transaction': boolean;
32
+ }
33
+ export declare class Pool {
34
+ private _queries;
35
+ private readonly _etc;
36
+ constructor(etc: types.IConfigDb);
37
+ query(sql: string, values?: types.DbValue[]): Promise<IData>;
38
+ execute(sql: string, values?: types.DbValue[]): Promise<IPacket>;
39
+ beginTransaction(ctr: ctr.Ctr | null): Promise<Transaction | null>;
40
+ private _getConnection;
41
+ getQueries(): number;
42
+ }
43
+ export declare class Transaction {
44
+ private _queries;
45
+ private _conn;
46
+ private readonly _ctr;
47
+ private readonly _timer;
48
+ constructor(ctr: ctr.Ctr | null, conn: Connection, opts?: {
49
+ 'warning'?: number;
50
+ 'danger'?: number;
51
+ });
52
+ query(sql: string, values?: types.DbValue[]): Promise<IData>;
53
+ execute(sql: string, values?: types.DbValue[]): Promise<IPacket>;
54
+ commit(): Promise<boolean>;
55
+ rollback(): Promise<boolean>;
56
+ }
57
+ export declare class Connection {
58
+ private _last;
59
+ private readonly _lastSql;
60
+ private readonly _link;
61
+ private _using;
62
+ private _lost;
63
+ private _transaction;
64
+ private readonly _etc;
65
+ constructor(etc: types.IConfigDb, link: mysql2.Connection);
66
+ getEtc(): types.IConfigDb;
67
+ getLast(): number;
68
+ getLastSql(): Array<{
69
+ 'sql': string;
70
+ 'values'?: types.DbValue[];
71
+ }>;
72
+ setLost(): void;
73
+ isLost(): boolean;
74
+ isTransaction(): boolean;
75
+ isUsing(): boolean;
76
+ using(): boolean;
77
+ used(): void;
78
+ refreshLast(): void;
79
+ isAvailable(): Promise<boolean>;
80
+ query(sql: string, values?: types.DbValue[]): Promise<IData>;
81
+ execute(sql: string, values?: types.DbValue[]): Promise<IPacket>;
82
+ end(): Promise<boolean>;
83
+ beginTransaction(): Promise<boolean>;
84
+ commit(): Promise<boolean>;
85
+ rollback(): Promise<boolean>;
86
+ }
87
+ export declare function get(ctrEtc: ctr.Ctr | types.IConfigDb): Pool;
88
+ export declare function getConnectionList(): IConnectionInfo[];
package/lib/db.js CHANGED
@@ -37,11 +37,11 @@ exports.Connection = exports.Transaction = exports.Pool = void 0;
37
37
  exports.get = get;
38
38
  exports.getConnectionList = getConnectionList;
39
39
  const mysql2 = __importStar(require("mysql2/promise"));
40
- const time = __importStar(require("~/lib/time"));
41
- const lSql = __importStar(require("~/lib/sql"));
42
- const core = __importStar(require("~/lib/core"));
43
- const text = __importStar(require("~/lib/text"));
44
- const ctr = __importStar(require("~/sys/ctr"));
40
+ const time = __importStar(require("../lib/time"));
41
+ const lSql = __importStar(require("../lib/sql"));
42
+ const core = __importStar(require("../lib/core"));
43
+ const text = __importStar(require("../lib/text"));
44
+ const ctr = __importStar(require("../sys/ctr"));
45
45
  const connections = [];
46
46
  async function checkConnection() {
47
47
  const now = time.stamp();
package/lib/dns.d.ts ADDED
@@ -0,0 +1,75 @@
1
+ import * as ctr from '../sys/ctr';
2
+ export declare enum ESERVICE {
3
+ 'DNSPOD' = 0,
4
+ 'ALIBABA' = 1
5
+ }
6
+ export interface IOptions {
7
+ 'service': ESERVICE;
8
+ 'secretId'?: string;
9
+ 'secretKey'?: string;
10
+ }
11
+ export interface IDomainList {
12
+ 'total': number;
13
+ 'list': Array<{
14
+ 'id': string;
15
+ 'name': string;
16
+ 'count': number;
17
+ 'punyCode': string;
18
+ }>;
19
+ }
20
+ export interface IAddDomainRecord {
21
+ 'success': boolean;
22
+ 'id': string;
23
+ }
24
+ export declare const RECORD_TYPE: {
25
+ A: string;
26
+ NS: string;
27
+ MX: string;
28
+ TXT: string;
29
+ CNAME: string;
30
+ SRV: string;
31
+ AAAA: string;
32
+ };
33
+ export declare enum ERecordLine {
34
+ 'DEFAULT' = 0,
35
+ 'TELECOM' = 1,
36
+ 'UNICOM' = 2,
37
+ 'MOBILE' = 3,
38
+ 'EDU' = 4,
39
+ 'OVERSEA' = 5
40
+ }
41
+ export declare class Dns {
42
+ private readonly _opt;
43
+ constructor(ctr: ctr.Ctr, opt: IOptions);
44
+ private _send;
45
+ getDomainList(opt: {
46
+ 'offset'?: number;
47
+ 'length'?: number;
48
+ }): Promise<IDomainList | null>;
49
+ addDomainRecord(opt: {
50
+ 'domain': string;
51
+ 'sub': string;
52
+ 'type': string;
53
+ 'value': string;
54
+ 'line'?: number;
55
+ 'ttl'?: number;
56
+ 'mx'?: number;
57
+ }): Promise<IAddDomainRecord | null>;
58
+ updateDomainRecord(opt: {
59
+ 'domain': string;
60
+ 'record': string;
61
+ 'sub': string;
62
+ 'type': string;
63
+ 'value': string;
64
+ 'line'?: number;
65
+ 'ttl'?: number;
66
+ 'mx'?: number;
67
+ }): Promise<IAddDomainRecord | null>;
68
+ deleteDomainRecord(opt: {
69
+ 'domain': string;
70
+ 'id': string;
71
+ }): Promise<{
72
+ 'success': boolean;
73
+ } | null>;
74
+ }
75
+ export declare function get(ctr: ctr.Ctr, opt: IOptions): Dns;
package/lib/dns.js CHANGED
@@ -35,11 +35,11 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.Dns = exports.ERecordLine = exports.RECORD_TYPE = exports.ESERVICE = void 0;
37
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"));
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
43
  var ESERVICE;
44
44
  (function (ESERVICE) {
45
45
  ESERVICE[ESERVICE["DNSPOD"] = 0] = "DNSPOD";
package/lib/fs.d.ts ADDED
@@ -0,0 +1,49 @@
1
+ import * as fs from 'fs';
2
+ import * as http from 'http';
3
+ import * as http2 from 'http2';
4
+ export declare function getContent(path: string, options?: {
5
+ 'start'?: number;
6
+ 'end'?: number;
7
+ }): Promise<Buffer | null>;
8
+ export declare function getContent(path: string, options: BufferEncoding | {
9
+ 'encoding': BufferEncoding;
10
+ 'start'?: number;
11
+ 'end'?: number;
12
+ }): Promise<string | null>;
13
+ export declare function putContent(path: string, data: string | Buffer, options?: {
14
+ 'encoding'?: BufferEncoding;
15
+ 'mode'?: number;
16
+ 'flag'?: string;
17
+ }): Promise<boolean>;
18
+ export declare function readLink(path: string, encoding?: BufferEncoding): Promise<string | null>;
19
+ export declare function symlink(filePath: string, linkPath: string, type?: 'dir' | 'file' | 'junction'): Promise<boolean>;
20
+ export declare function unlink(path: string): Promise<boolean>;
21
+ export declare function stats(path: string): Promise<fs.Stats | null>;
22
+ export declare function isDir(path: string): Promise<fs.Stats | false>;
23
+ export declare function isFile(path: string): Promise<fs.Stats | false>;
24
+ export declare function mkdir(path: string, mode?: number): Promise<boolean>;
25
+ export declare function rmdir(path: string): Promise<boolean>;
26
+ export declare function rmdirDeep(path: string): Promise<boolean>;
27
+ export declare function chmod(path: string, mod: string | number): Promise<boolean>;
28
+ export declare function rename(oldPath: string, newPath: string): Promise<boolean>;
29
+ export declare function readDir(path: string, encoding?: BufferEncoding): Promise<fs.Dirent[]>;
30
+ export declare function copyFolder(from: string, to: string, ignore?: RegExp[]): Promise<number>;
31
+ export declare function copyFile(src: string, dest: string): Promise<boolean>;
32
+ export declare function createReadStream(path: string, options?: BufferEncoding | {
33
+ 'flags'?: string;
34
+ 'encoding'?: BufferEncoding;
35
+ 'autoClose'?: boolean;
36
+ 'start'?: number;
37
+ 'end'?: number;
38
+ }): fs.ReadStream;
39
+ export declare function pipe(path: string, destination: NodeJS.WritableStream, options?: {
40
+ 'end'?: boolean;
41
+ }): Promise<boolean>;
42
+ export declare function createWriteStream(path: string, options?: BufferEncoding | {
43
+ 'flags'?: string;
44
+ 'encoding'?: BufferEncoding;
45
+ 'mode'?: number;
46
+ 'autoClose'?: boolean;
47
+ 'start'?: number;
48
+ }): fs.WriteStream;
49
+ export declare function readToResponse(path: string, req: http2.Http2ServerRequest | http.IncomingMessage, res: http2.Http2ServerResponse | http.ServerResponse, stat?: fs.Stats | null): Promise<void>;
package/lib/jwt.d.ts ADDED
@@ -0,0 +1,30 @@
1
+ import * as kv from '../lib/kv';
2
+ import * as ctr from '../sys/ctr';
3
+ import * as types from '../types';
4
+ export interface IOptions {
5
+ 'name'?: string;
6
+ 'ttl'?: number;
7
+ 'ssl'?: boolean;
8
+ 'secret'?: string;
9
+ 'auth'?: boolean;
10
+ }
11
+ export declare class Jwt {
12
+ private _link?;
13
+ private _name;
14
+ private _ttl;
15
+ private _ssl;
16
+ private _secret;
17
+ private _auth;
18
+ private _ctr;
19
+ init(ctr: ctr.Ctr, opt?: IOptions, link?: kv.Pool): Promise<boolean>;
20
+ renew(): string;
21
+ clearCookie(): void;
22
+ destory(): Promise<{
23
+ token: string;
24
+ exp: number;
25
+ } | boolean>;
26
+ }
27
+ export declare function getOrigin(ctr: ctr.Ctr, name?: string, auth?: boolean): string;
28
+ export declare function decode(ctr: ctr.Ctr, val: string, link?: kv.Pool, name?: string, secret?: string): Promise<Record<string, types.DbValue> | false>;
29
+ export declare function block(ctr: ctr.Ctr, token: string, exp: number, link: kv.Pool, name?: string): Promise<boolean>;
30
+ export declare function get(ctr: ctr.Ctr, opt?: IOptions, link?: kv.Pool): Promise<Jwt>;
package/lib/jwt.js CHANGED
@@ -38,10 +38,10 @@ exports.getOrigin = getOrigin;
38
38
  exports.decode = decode;
39
39
  exports.block = block;
40
40
  exports.get = get;
41
- const lCore = __importStar(require("~/lib/core"));
42
- const lTime = __importStar(require("~/lib/time"));
43
- const lText = __importStar(require("~/lib/text"));
44
- const lCrypto = __importStar(require("~/lib/crypto"));
41
+ const lCore = __importStar(require("../lib/core"));
42
+ const lTime = __importStar(require("../lib/time"));
43
+ const lText = __importStar(require("../lib/text"));
44
+ const lCrypto = __importStar(require("../lib/crypto"));
45
45
  class Jwt {
46
46
  async init(ctr, opt = {}, link) {
47
47
  const config = ctr.getPrototype('_config');