@maiyunnet/kebab 2.0.4 → 2.0.5
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/index.d.ts +14 -0
- package/index.js +1 -1
- package/lib/buffer.d.ts +25 -0
- package/lib/captcha.d.ts +12 -0
- package/lib/consistent.d.ts +20 -0
- package/lib/core.d.ts +85 -0
- package/lib/crypto.d.ts +47 -0
- package/lib/db.d.ts +88 -0
- package/lib/dns.d.ts +75 -0
- package/lib/fs.d.ts +49 -0
- package/lib/jwt.d.ts +30 -0
- package/lib/kv.d.ts +111 -0
- package/lib/lan.d.ts +10 -0
- package/lib/net/formdata.d.ts +23 -0
- package/lib/net/request.d.ts +23 -0
- package/lib/net/response.d.ts +14 -0
- package/lib/net.d.ts +65 -0
- package/lib/s3.d.ts +35 -0
- package/lib/scan.d.ts +31 -0
- package/lib/session.d.ts +22 -0
- package/lib/sql.d.ts +57 -0
- package/lib/ssh/sftp.d.ts +40 -0
- package/lib/ssh/shell.d.ts +13 -0
- package/lib/ssh.d.ts +24 -0
- package/lib/text.d.ts +40 -0
- package/lib/time.d.ts +22 -0
- package/lib/ws.d.ts +87 -0
- package/lib/zip.d.ts +40 -0
- package/lib/zlib.d.ts +25 -0
- package/main.d.ts +1 -0
- package/package.json +1 -1
- package/sys/child.d.ts +1 -0
- package/sys/cmd.d.ts +1 -0
- package/sys/ctr.d.ts +96 -0
- package/sys/master.d.ts +1 -0
- package/sys/mod.d.ts +205 -0
- package/sys/route.d.ts +31 -0
- package/types/index.d.ts +283 -0
- package/www/example/ctr/main.d.ts +4 -0
- package/www/example/ctr/middle.d.ts +6 -0
- package/www/example/ctr/test.d.ts +94 -0
- package/www/example/mod/test.d.ts +20 -0
- package/www/example/mod/testdata.d.ts +9 -0
- package/www/example/ws/mproxy.d.ts +4 -0
- package/www/example/ws/rproxy.d.ts +4 -0
- package/www/example/ws/test.d.ts +7 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const VER = "2.0.5";
|
|
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
|
+
exports.VER = '2.0.5';
|
|
5
5
|
const dirname = __dirname.replace(/\\/g, '/');
|
|
6
6
|
exports.ROOT_PATH = dirname + '/';
|
|
7
7
|
exports.LIB_PATH = exports.ROOT_PATH + 'lib/';
|
package/lib/buffer.d.ts
ADDED
|
@@ -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;
|
package/lib/captcha.d.ts
ADDED
|
@@ -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;
|
|
@@ -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/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/crypto.d.ts
ADDED
|
@@ -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/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/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/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/kv.d.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import * as redis from '@litert/redis';
|
|
2
|
+
import * as ctr from '~/sys/ctr';
|
|
3
|
+
import * as types from '~/types';
|
|
4
|
+
export interface IConnectionInfo {
|
|
5
|
+
'id': number;
|
|
6
|
+
'last': number;
|
|
7
|
+
'host': string;
|
|
8
|
+
'port': number;
|
|
9
|
+
'index': number;
|
|
10
|
+
'lost': boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare class Pool {
|
|
13
|
+
private readonly _etc;
|
|
14
|
+
constructor(ctr: ctr.Ctr, etc?: types.IConfigKv);
|
|
15
|
+
set(key: string, val: object | string | number, ttl?: number, mod?: '' | 'nx' | 'xx'): Promise<boolean>;
|
|
16
|
+
add(key: string, val: object | string | number, ttl?: number): Promise<boolean>;
|
|
17
|
+
replace(key: string, val: object | string | number, ttl?: number): Promise<boolean>;
|
|
18
|
+
append(key: string, val: string): Promise<boolean>;
|
|
19
|
+
prepend(key: string, val: string): Promise<boolean>;
|
|
20
|
+
exists(keys: string | string[]): Promise<number>;
|
|
21
|
+
get(key: string): Promise<string | null>;
|
|
22
|
+
ttl(key: string): Promise<number | null>;
|
|
23
|
+
pttl(key: string): Promise<number | null>;
|
|
24
|
+
mSet(rows: Record<string, string | Buffer>): Promise<boolean>;
|
|
25
|
+
mGet(keys: string[]): Promise<Record<string, string | null>>;
|
|
26
|
+
getJson(key: string): Promise<any | null>;
|
|
27
|
+
del(keys: string | string[]): Promise<boolean>;
|
|
28
|
+
incr(key: string, num?: number): Promise<number | false>;
|
|
29
|
+
decr(key: string, num?: number): Promise<number | false>;
|
|
30
|
+
expire(key: string, ttl: number): Promise<boolean>;
|
|
31
|
+
keys(pattern: string): Promise<string[] | false>;
|
|
32
|
+
scan(cursor?: number, pattern?: string, count?: number): Promise<redis.IScanResult<string> | false>;
|
|
33
|
+
flushDb(): Promise<boolean>;
|
|
34
|
+
ping(): Promise<string | false>;
|
|
35
|
+
hSet(key: string, field: string, val: object | string | number, mod?: '' | 'nx'): Promise<boolean>;
|
|
36
|
+
hMSet(key: string, rows: Record<string, object | string | number>): Promise<boolean>;
|
|
37
|
+
hGet(key: string, field: string): Promise<string | null>;
|
|
38
|
+
hGetJson(key: string, field: string): Promise<any | null>;
|
|
39
|
+
hMGet(key: string, fields: string[]): Promise<Record<string, string | null>>;
|
|
40
|
+
hGetAll(key: string): Promise<Record<string, string | null> | null>;
|
|
41
|
+
hDel(key: string, fields: string | string[]): Promise<number>;
|
|
42
|
+
hExists(key: string, field: string): Promise<boolean>;
|
|
43
|
+
hIncr(key: string, field: string, increment: number): Promise<number>;
|
|
44
|
+
hKeys(key: string): Promise<string[]>;
|
|
45
|
+
lPush(key: string, values: Array<string | Buffer>): Promise<number>;
|
|
46
|
+
rPush(key: string, values: Array<string | Buffer>): Promise<number>;
|
|
47
|
+
bLMove(sourceKey: string, destKey: string, soo: 'LEFT' | 'RIGHT', deo: 'LEFT' | 'RIGHT', timeout: number): Promise<string | null>;
|
|
48
|
+
lPop(key: string): Promise<string | null>;
|
|
49
|
+
rPop(key: string): Promise<string | null>;
|
|
50
|
+
bRPop(key: string | string[], timeout: number): Promise<Record<string, string>>;
|
|
51
|
+
lRange(key: string, start: number, stop: number): Promise<string[]>;
|
|
52
|
+
lLen(key: string): Promise<number>;
|
|
53
|
+
private _getConnection;
|
|
54
|
+
}
|
|
55
|
+
export declare class Connection {
|
|
56
|
+
private _last;
|
|
57
|
+
private readonly _link;
|
|
58
|
+
private _using;
|
|
59
|
+
private _lost;
|
|
60
|
+
private readonly _etc;
|
|
61
|
+
constructor(etc: types.IConfigKv, link: redis.ICommandClient);
|
|
62
|
+
getEtc(): types.IConfigKv;
|
|
63
|
+
getLast(): number;
|
|
64
|
+
setLost(): void;
|
|
65
|
+
isLost(): boolean;
|
|
66
|
+
setUsing(): void;
|
|
67
|
+
isUsing(): boolean;
|
|
68
|
+
used(): void;
|
|
69
|
+
refreshLast(): void;
|
|
70
|
+
end(): Promise<void>;
|
|
71
|
+
set(key: string, val: object | string | number, ttl: number, mod: '' | 'nx' | 'xx', etc: types.IConfigKv): Promise<boolean>;
|
|
72
|
+
add(key: string, val: object | string | number, ttl: number, etc: types.IConfigKv): Promise<boolean>;
|
|
73
|
+
replace(key: string, val: object | string | number, ttl: number, etc: types.IConfigKv): Promise<boolean>;
|
|
74
|
+
append(key: string, val: string, etc: types.IConfigKv): Promise<boolean>;
|
|
75
|
+
prepend(key: string, val: string, etc: types.IConfigKv): Promise<boolean>;
|
|
76
|
+
exists(keys: string | string[], etc: types.IConfigKv): Promise<number>;
|
|
77
|
+
get(key: string, etc: types.IConfigKv): Promise<string | null>;
|
|
78
|
+
ttl(key: string, etc: types.IConfigKv): Promise<number | null>;
|
|
79
|
+
pttl(key: string, etc: types.IConfigKv): Promise<number | null>;
|
|
80
|
+
mGet(keys: string[], etc: types.IConfigKv): Promise<Record<string, string | null>>;
|
|
81
|
+
mSet(rows: Record<string, string | Buffer>, etc: types.IConfigKv): Promise<boolean>;
|
|
82
|
+
getJson(key: string, etc: types.IConfigKv): Promise<any | null>;
|
|
83
|
+
del(keys: string | string[], etc: types.IConfigKv): Promise<boolean>;
|
|
84
|
+
incr(key: string, num: number, etc: types.IConfigKv): Promise<number | false>;
|
|
85
|
+
decr(key: string, num: number, etc: types.IConfigKv): Promise<number | false>;
|
|
86
|
+
expire(key: string, ttl: number, etc: types.IConfigKv): Promise<boolean>;
|
|
87
|
+
keys(pattern: string, etc: types.IConfigKv): Promise<string[] | false>;
|
|
88
|
+
scan(cursor: number, pattern: string, count: number, etc: types.IConfigKv): Promise<redis.IScanResult<string> | false>;
|
|
89
|
+
flushDb(): Promise<boolean>;
|
|
90
|
+
ping(): Promise<false | string>;
|
|
91
|
+
hSet(key: string, field: string, val: object | string | number, mod: '' | 'nx', etc: types.IConfigKv): Promise<boolean>;
|
|
92
|
+
hMSet(key: string, rows: Record<string, object | string | number>, etc: types.IConfigKv): Promise<boolean>;
|
|
93
|
+
hGet(key: string, field: string, etc: types.IConfigKv): Promise<string | null>;
|
|
94
|
+
hGetJson(key: string, field: string, etc: types.IConfigKv): Promise<any | null>;
|
|
95
|
+
hMGet(key: string, fields: string[], etc: types.IConfigKv): Promise<Record<string, string | null>>;
|
|
96
|
+
hGetAll(key: string, etc: types.IConfigKv): Promise<Record<string, string | null> | null>;
|
|
97
|
+
hDel(key: string, fields: string | string[], etc: types.IConfigKv): Promise<number>;
|
|
98
|
+
hExists(key: string, field: string, etc: types.IConfigKv): Promise<boolean>;
|
|
99
|
+
hIncr(key: string, field: string, increment: number, etc: types.IConfigKv): Promise<number>;
|
|
100
|
+
hKeys(key: string, etc: types.IConfigKv): Promise<string[]>;
|
|
101
|
+
lPush(key: string, values: Array<string | Buffer>, etc: types.IConfigKv): Promise<number>;
|
|
102
|
+
rPush(key: string, values: Array<string | Buffer>, etc: types.IConfigKv): Promise<number>;
|
|
103
|
+
bLMove(sourceKey: string, destKey: string, soo: 'LEFT' | 'RIGHT', deo: 'LEFT' | 'RIGHT', timeout: number, etc: types.IConfigKv): Promise<string | null>;
|
|
104
|
+
lPop(key: string, etc: types.IConfigKv): Promise<string | null>;
|
|
105
|
+
rPop(key: string, etc: types.IConfigKv): Promise<string | null>;
|
|
106
|
+
bRPop(key: string | string[], timeout: number, etc: types.IConfigKv): Promise<Record<string, string>>;
|
|
107
|
+
lRange(key: string, start: number, stop: number, etc: types.IConfigKv): Promise<string[]>;
|
|
108
|
+
lLen(key: string, etc: types.IConfigKv): Promise<number>;
|
|
109
|
+
}
|
|
110
|
+
export declare function get(ctr: ctr.Ctr, etc?: types.IConfigKv): Pool;
|
|
111
|
+
export declare function getConnectionList(): IConnectionInfo[];
|
package/lib/lan.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as stream from 'stream';
|
|
2
|
+
export interface IItem {
|
|
3
|
+
'key': string;
|
|
4
|
+
'isFile': boolean;
|
|
5
|
+
'isString': boolean;
|
|
6
|
+
'value': string;
|
|
7
|
+
'path': string;
|
|
8
|
+
}
|
|
9
|
+
export declare class FormData extends stream.Readable {
|
|
10
|
+
private _num;
|
|
11
|
+
private readonly _data;
|
|
12
|
+
private readonly _boundary;
|
|
13
|
+
private _fileReading;
|
|
14
|
+
private _close;
|
|
15
|
+
private _length;
|
|
16
|
+
private _sent;
|
|
17
|
+
putString(key: string, val: string): void;
|
|
18
|
+
putFile(key: string, path: string, fname?: string): Promise<boolean>;
|
|
19
|
+
getBoundary(): string;
|
|
20
|
+
getLength(): number;
|
|
21
|
+
getSent(): number;
|
|
22
|
+
_read(): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as stream from 'stream';
|
|
2
|
+
import * as response from './response';
|
|
3
|
+
import * as types from '~/types';
|
|
4
|
+
export declare class Request {
|
|
5
|
+
private _data;
|
|
6
|
+
private readonly _url;
|
|
7
|
+
private _opt;
|
|
8
|
+
constructor(url: string);
|
|
9
|
+
data(data: Record<string, any> | Buffer | string | stream.Readable): this;
|
|
10
|
+
method(method: 'GET' | 'POST'): this;
|
|
11
|
+
get(): this;
|
|
12
|
+
post(): this;
|
|
13
|
+
type(type: 'form' | 'json'): this;
|
|
14
|
+
json(): this;
|
|
15
|
+
timeout(timeout: number): this;
|
|
16
|
+
follow(follow?: number): this;
|
|
17
|
+
hosts(hosts: Record<string, string>): this;
|
|
18
|
+
save(save: string): this;
|
|
19
|
+
local(addr: string): this;
|
|
20
|
+
headers(headers: types.THttpHeaders): this;
|
|
21
|
+
setHeader(name: string, val: string): this;
|
|
22
|
+
request(cookie?: Record<string, types.ICookie>): Promise<response.Response>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as hc from '@litert/http-client';
|
|
2
|
+
import * as nStream from 'stream';
|
|
3
|
+
import * as types from '~/types';
|
|
4
|
+
export declare class Response {
|
|
5
|
+
private readonly _req;
|
|
6
|
+
headers: types.THttpHeaders | null;
|
|
7
|
+
error: Error | null;
|
|
8
|
+
private _content;
|
|
9
|
+
constructor(req: hc.IResponse | null);
|
|
10
|
+
getContent(): Promise<Buffer | null>;
|
|
11
|
+
setContent(v: string | Buffer): void;
|
|
12
|
+
getStream(): nStream.Readable;
|
|
13
|
+
getRawStream(): nStream.Readable;
|
|
14
|
+
}
|