lakutata 0.1.1 → 0.1.2-beta.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.
- package/build/Crypto.d.ts +504 -0
- package/build/Crypto.js +3690 -0
- package/build/Hash.d.ts +535 -0
- package/build/Hash.js +112 -0
- package/build/Helper.d.ts +243 -0
- package/build/Helper.js +57 -0
- package/build/Lakutata.d.ts +3568 -3633
- package/build/Lakutata.js +95473 -65
- package/build/ORM.d.ts +3150 -0
- package/build/ORM.js +416 -0
- package/build/ReflectMetadata.d.ts +490 -0
- package/build/ReflectMetadata.js +1 -0
- package/build/RelationMetadataArgs.d-8d416101.d.ts +18897 -0
- package/build/chunk-7LXDFQCY.js +948 -0
- package/build/chunk-BDZ4HVBZ.js +6275 -0
- package/build/chunk-CDQUWO3T.js +981 -0
- package/build/chunk-FG7RT3QU.js +111120 -0
- package/build/chunk-IZCE6VLC.js +606 -0
- package/build/chunk-OHQGLMDU.js +135 -0
- package/build/chunk-TDTTBUBP.js +186 -0
- package/package.json +36 -2
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
import './ReflectMetadata.js';
|
|
2
|
+
import { PathLike } from 'fs';
|
|
3
|
+
import { IConstructor } from './Lakutata.js';
|
|
4
|
+
import { Cipher, Decipher, KeyObject } from 'crypto';
|
|
5
|
+
import 'events';
|
|
6
|
+
import './RelationMetadataArgs.d-8d416101.js';
|
|
7
|
+
import 'tls';
|
|
8
|
+
import 'net';
|
|
9
|
+
import 'dns';
|
|
10
|
+
import 'stream';
|
|
11
|
+
import 'worker_threads';
|
|
12
|
+
import 'url';
|
|
13
|
+
import 'http';
|
|
14
|
+
import 'https';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 公钥操作方法对象接口
|
|
18
|
+
*/
|
|
19
|
+
interface AsymmetricEncryptionPublic {
|
|
20
|
+
/**
|
|
21
|
+
* 加密数据
|
|
22
|
+
* @param message
|
|
23
|
+
*/
|
|
24
|
+
encrypt(message: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* 验证签名
|
|
27
|
+
* @param message
|
|
28
|
+
* @param sign
|
|
29
|
+
*/
|
|
30
|
+
verify(message: string, sign: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* 获取公钥
|
|
33
|
+
*/
|
|
34
|
+
getPublicKey(): string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 私钥操作方法对象接口
|
|
38
|
+
*/
|
|
39
|
+
interface AsymmetricEncryptionPrivate {
|
|
40
|
+
/**
|
|
41
|
+
* 解密数据
|
|
42
|
+
* @param encryptedMessage
|
|
43
|
+
*/
|
|
44
|
+
decrypt(encryptedMessage: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* 数据签名
|
|
47
|
+
* @param message
|
|
48
|
+
*/
|
|
49
|
+
sign(message: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* 获取私钥
|
|
52
|
+
*/
|
|
53
|
+
getPrivateKey(): string;
|
|
54
|
+
}
|
|
55
|
+
interface AsymmetricEncryptionKeyPair {
|
|
56
|
+
/**
|
|
57
|
+
* 公钥字符串
|
|
58
|
+
*/
|
|
59
|
+
publicKey: string;
|
|
60
|
+
/**
|
|
61
|
+
* 私钥字符串
|
|
62
|
+
*/
|
|
63
|
+
privateKey: string;
|
|
64
|
+
}
|
|
65
|
+
declare abstract class AsymmetricEncryption {
|
|
66
|
+
protected readonly publicKeyString: string;
|
|
67
|
+
protected readonly privateKeyString: string;
|
|
68
|
+
protected readonly privateKey: any;
|
|
69
|
+
protected readonly publicKey: any;
|
|
70
|
+
protected options: Record<string, any>;
|
|
71
|
+
constructor(keyPair?: Partial<AsymmetricEncryptionKeyPair>);
|
|
72
|
+
/**
|
|
73
|
+
* 创建私钥对象
|
|
74
|
+
* @param privateKeyString
|
|
75
|
+
* @protected
|
|
76
|
+
*/
|
|
77
|
+
protected abstract createPrivateKey(privateKeyString: string): any;
|
|
78
|
+
/**
|
|
79
|
+
* 创建公钥对象
|
|
80
|
+
* @param publicKeyString
|
|
81
|
+
* @protected
|
|
82
|
+
*/
|
|
83
|
+
protected abstract createPublicKey(publicKeyString: string): any;
|
|
84
|
+
/**
|
|
85
|
+
* 加密数据,供内部调用
|
|
86
|
+
* @param message
|
|
87
|
+
* @protected
|
|
88
|
+
*/
|
|
89
|
+
protected _encrypt(message: string): string;
|
|
90
|
+
/**
|
|
91
|
+
* 加密数据
|
|
92
|
+
* @param message
|
|
93
|
+
* @protected
|
|
94
|
+
*/
|
|
95
|
+
protected abstract encrypt(message: string): string;
|
|
96
|
+
/**
|
|
97
|
+
* 解密数据,供内部调用
|
|
98
|
+
* @param encryptedMessage
|
|
99
|
+
* @protected
|
|
100
|
+
*/
|
|
101
|
+
protected _decrypt(encryptedMessage: string): string;
|
|
102
|
+
/**
|
|
103
|
+
* 解密数据
|
|
104
|
+
* @param encryptedMessage
|
|
105
|
+
* @protected
|
|
106
|
+
*/
|
|
107
|
+
protected abstract decrypt(encryptedMessage: string): string;
|
|
108
|
+
/**
|
|
109
|
+
* 数据签名,供内部调用
|
|
110
|
+
* @param message
|
|
111
|
+
* @protected
|
|
112
|
+
*/
|
|
113
|
+
protected _sign(message: string): string;
|
|
114
|
+
/**
|
|
115
|
+
* 数据签名
|
|
116
|
+
* @param message
|
|
117
|
+
* @protected
|
|
118
|
+
*/
|
|
119
|
+
protected abstract sign(message: string): string;
|
|
120
|
+
/**
|
|
121
|
+
* 验证签名,供内部调用
|
|
122
|
+
* @param message
|
|
123
|
+
* @param sign
|
|
124
|
+
* @protected
|
|
125
|
+
*/
|
|
126
|
+
protected _verify(message: string, sign: string): boolean;
|
|
127
|
+
/**
|
|
128
|
+
* 验证签名
|
|
129
|
+
* @param message
|
|
130
|
+
* @param sign
|
|
131
|
+
* @protected
|
|
132
|
+
*/
|
|
133
|
+
protected abstract verify(message: string, sign: string): boolean;
|
|
134
|
+
/**
|
|
135
|
+
* 生成密钥对
|
|
136
|
+
* @param options
|
|
137
|
+
* @protected
|
|
138
|
+
*/
|
|
139
|
+
protected abstract generateKeyPair(options?: object): Promise<AsymmetricEncryptionKeyPair>;
|
|
140
|
+
/**
|
|
141
|
+
* 获取字符串形式的公钥
|
|
142
|
+
*/
|
|
143
|
+
getPublicKey(): string;
|
|
144
|
+
/**
|
|
145
|
+
* 获取字符串形式的私钥
|
|
146
|
+
*/
|
|
147
|
+
getPrivateKey(): string;
|
|
148
|
+
/**
|
|
149
|
+
* 公钥操作方法对象
|
|
150
|
+
*/
|
|
151
|
+
get public(): AsymmetricEncryptionPublic;
|
|
152
|
+
/**
|
|
153
|
+
* 私钥操作方法对象
|
|
154
|
+
*/
|
|
155
|
+
get private(): AsymmetricEncryptionPrivate;
|
|
156
|
+
/**
|
|
157
|
+
* 生成密钥对
|
|
158
|
+
* @param options
|
|
159
|
+
*/
|
|
160
|
+
static generateKeyPair<T extends AsymmetricEncryption>(this: IConstructor<T>, options?: object): Promise<AsymmetricEncryptionKeyPair>;
|
|
161
|
+
/**
|
|
162
|
+
* 加载密钥对并返回不对称加密类实例
|
|
163
|
+
* @param keyPair
|
|
164
|
+
* @param options
|
|
165
|
+
*/
|
|
166
|
+
static loadKeyPair<T extends AsymmetricEncryption>(this: IConstructor<T>, keyPair: AsymmetricEncryptionKeyPair, options?: Record<string, any>): Promise<T>;
|
|
167
|
+
/**
|
|
168
|
+
* 加载公钥并返回公钥操作方法对象
|
|
169
|
+
* @param filename
|
|
170
|
+
* @param options
|
|
171
|
+
*/
|
|
172
|
+
static loadPublicKey(filename: PathLike, options?: Record<string, any>): Promise<AsymmetricEncryptionPublic>;
|
|
173
|
+
static loadPublicKey(keyContent: string, options?: Record<string, any>): Promise<AsymmetricEncryptionPublic>;
|
|
174
|
+
/**
|
|
175
|
+
* 加载私钥并返回私钥操作方法对象
|
|
176
|
+
* @param filename
|
|
177
|
+
* @param options
|
|
178
|
+
*/
|
|
179
|
+
static loadPrivateKey(filename: PathLike, options?: Record<string, any>): Promise<AsymmetricEncryptionPrivate>;
|
|
180
|
+
static loadPrivateKey(keyContent: string, options?: Record<string, any>): Promise<AsymmetricEncryptionPrivate>;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
interface SymmetricEncryptionValidateKeyLengthResult {
|
|
184
|
+
isValid: boolean;
|
|
185
|
+
expectBytes: number;
|
|
186
|
+
receivedBytes: number;
|
|
187
|
+
}
|
|
188
|
+
interface SymmetricEncryptionValidateIVLengthResult {
|
|
189
|
+
isValid: boolean;
|
|
190
|
+
expectBytes: number;
|
|
191
|
+
receivedBytes: number;
|
|
192
|
+
}
|
|
193
|
+
interface AlgorithmInitializer {
|
|
194
|
+
blockSize: number;
|
|
195
|
+
cipherCreator: () => Cipher;
|
|
196
|
+
decipherCreator: () => Decipher;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* 同步加密抽象类
|
|
200
|
+
*/
|
|
201
|
+
declare abstract class SymmetricEncryption {
|
|
202
|
+
/**
|
|
203
|
+
* 加解密算法
|
|
204
|
+
* @protected
|
|
205
|
+
*/
|
|
206
|
+
protected algorithm: string;
|
|
207
|
+
/**
|
|
208
|
+
* 加密分组大小
|
|
209
|
+
* @protected
|
|
210
|
+
*/
|
|
211
|
+
protected blockSize: number;
|
|
212
|
+
/**
|
|
213
|
+
* 加解密秘钥
|
|
214
|
+
* @protected
|
|
215
|
+
*/
|
|
216
|
+
protected key: Buffer;
|
|
217
|
+
/**
|
|
218
|
+
* 加解密向量
|
|
219
|
+
* @protected
|
|
220
|
+
*/
|
|
221
|
+
protected iv: Buffer;
|
|
222
|
+
/**
|
|
223
|
+
* 是否使用空向量(ECB模式)
|
|
224
|
+
* 允许则为ECB模式,否则为CBC模式
|
|
225
|
+
* @protected
|
|
226
|
+
*/
|
|
227
|
+
protected allowNullIV: boolean;
|
|
228
|
+
/**
|
|
229
|
+
* 加解密秘钥长度,以Bytes为单位
|
|
230
|
+
* @protected
|
|
231
|
+
*/
|
|
232
|
+
protected abstract readonly keyLength: number;
|
|
233
|
+
/**
|
|
234
|
+
* 加解密向量长度,以Bytes为单位
|
|
235
|
+
* @protected
|
|
236
|
+
*/
|
|
237
|
+
protected abstract readonly ivLength: number;
|
|
238
|
+
/**
|
|
239
|
+
* 加密器
|
|
240
|
+
* @constructor
|
|
241
|
+
*/
|
|
242
|
+
get Cipher(): Cipher;
|
|
243
|
+
/**
|
|
244
|
+
* 解密器
|
|
245
|
+
* @constructor
|
|
246
|
+
*/
|
|
247
|
+
get Decipher(): Decipher;
|
|
248
|
+
/**
|
|
249
|
+
* 加密器创建函数
|
|
250
|
+
* @protected
|
|
251
|
+
*/
|
|
252
|
+
protected cipherCreator: () => Cipher;
|
|
253
|
+
/**
|
|
254
|
+
* 解密器创建函数
|
|
255
|
+
* @protected
|
|
256
|
+
*/
|
|
257
|
+
protected decipherCreator: () => Decipher;
|
|
258
|
+
/**
|
|
259
|
+
* 初始化加密器
|
|
260
|
+
* @param algorithm
|
|
261
|
+
* @param allowNullIV
|
|
262
|
+
* @param key
|
|
263
|
+
* @param iv
|
|
264
|
+
* @protected
|
|
265
|
+
*/
|
|
266
|
+
protected initCipher(algorithm: string, allowNullIV: boolean, key?: Buffer | string, iv?: Buffer | string): void;
|
|
267
|
+
/**
|
|
268
|
+
* 当算法在运行环境原生支持时的初始化函数
|
|
269
|
+
* @protected
|
|
270
|
+
*/
|
|
271
|
+
protected algorithmFoundInitializer(): AlgorithmInitializer;
|
|
272
|
+
/**
|
|
273
|
+
* 当算法在运行环境原生不支持时的初始化函数
|
|
274
|
+
* @protected
|
|
275
|
+
*/
|
|
276
|
+
protected algorithmNotFoundInitializer(): AlgorithmInitializer;
|
|
277
|
+
/**
|
|
278
|
+
* 验证key的长度
|
|
279
|
+
* @param key
|
|
280
|
+
* @protected
|
|
281
|
+
*/
|
|
282
|
+
protected validateKeyLength(key: Buffer): SymmetricEncryptionValidateKeyLengthResult;
|
|
283
|
+
/**
|
|
284
|
+
* 验证iv向量的长度
|
|
285
|
+
* @param iv
|
|
286
|
+
* @protected
|
|
287
|
+
*/
|
|
288
|
+
protected validateIVLength(iv: Buffer): SymmetricEncryptionValidateIVLengthResult;
|
|
289
|
+
/**
|
|
290
|
+
* 加密消息
|
|
291
|
+
* @param message
|
|
292
|
+
*/
|
|
293
|
+
encrypt(message: string): string;
|
|
294
|
+
/**
|
|
295
|
+
* 异步加密消息
|
|
296
|
+
* @param message
|
|
297
|
+
*/
|
|
298
|
+
encryptAsync(message: string): Promise<string>;
|
|
299
|
+
/**
|
|
300
|
+
* 解密消息
|
|
301
|
+
* @param encryptedMessage
|
|
302
|
+
*/
|
|
303
|
+
decrypt(encryptedMessage: string): string;
|
|
304
|
+
/**
|
|
305
|
+
* 异步解密消息
|
|
306
|
+
* @param encryptedMessage
|
|
307
|
+
*/
|
|
308
|
+
decryptAsync(encryptedMessage: string): Promise<string>;
|
|
309
|
+
/**
|
|
310
|
+
* 获取秘钥,Hex字符串格式
|
|
311
|
+
*/
|
|
312
|
+
getKey(): string;
|
|
313
|
+
/**
|
|
314
|
+
* 获取向量,Hex字符串格式
|
|
315
|
+
*/
|
|
316
|
+
getIV(): string | null;
|
|
317
|
+
/**
|
|
318
|
+
* 生成随机秘钥,Hex字符串格式
|
|
319
|
+
*/
|
|
320
|
+
static generateKey<T extends SymmetricEncryption>(this: IConstructor<T>): string;
|
|
321
|
+
/**
|
|
322
|
+
* 生成随机向量,Hex字符串格式
|
|
323
|
+
*/
|
|
324
|
+
static generateIV<T extends SymmetricEncryption>(this: IConstructor<T>): string;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
declare class AES128 extends SymmetricEncryption {
|
|
328
|
+
protected readonly ivLength: number;
|
|
329
|
+
protected readonly keyLength: number;
|
|
330
|
+
constructor(key: Buffer, iv?: Buffer);
|
|
331
|
+
constructor(key: string, iv?: string);
|
|
332
|
+
protected algorithmNotFoundInitializer(): AlgorithmInitializer;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
declare class AES192 extends SymmetricEncryption {
|
|
336
|
+
protected readonly ivLength: number;
|
|
337
|
+
protected readonly keyLength: number;
|
|
338
|
+
constructor(key: Buffer, iv?: Buffer);
|
|
339
|
+
constructor(key: string, iv?: string);
|
|
340
|
+
protected algorithmNotFoundInitializer(): AlgorithmInitializer;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
declare class AES256 extends SymmetricEncryption {
|
|
344
|
+
protected readonly ivLength: number;
|
|
345
|
+
protected readonly keyLength: number;
|
|
346
|
+
constructor(key: Buffer, iv?: Buffer);
|
|
347
|
+
constructor(key: string, iv?: string);
|
|
348
|
+
protected algorithmNotFoundInitializer(): AlgorithmInitializer;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
declare class DES extends SymmetricEncryption {
|
|
352
|
+
protected readonly ivLength: number;
|
|
353
|
+
protected readonly keyLength: number;
|
|
354
|
+
constructor(key: Buffer, iv?: Buffer);
|
|
355
|
+
constructor(key: string, iv?: string);
|
|
356
|
+
protected algorithmNotFoundInitializer(): AlgorithmInitializer;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
declare class TripleDES extends SymmetricEncryption {
|
|
360
|
+
protected readonly ivLength: number;
|
|
361
|
+
protected readonly keyLength: number;
|
|
362
|
+
constructor(key: Buffer, iv?: Buffer);
|
|
363
|
+
constructor(key: string, iv?: string);
|
|
364
|
+
protected algorithmNotFoundInitializer(): AlgorithmInitializer;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
declare class ARIA128 extends SymmetricEncryption {
|
|
368
|
+
protected readonly ivLength: number;
|
|
369
|
+
protected readonly keyLength: number;
|
|
370
|
+
constructor(key: Buffer, iv?: Buffer);
|
|
371
|
+
constructor(key: string, iv?: string);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
declare class ARIA192 extends SymmetricEncryption {
|
|
375
|
+
protected readonly ivLength: number;
|
|
376
|
+
protected readonly keyLength: number;
|
|
377
|
+
constructor(key: Buffer, iv?: Buffer);
|
|
378
|
+
constructor(key: string, iv?: string);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
declare class ARIA256 extends SymmetricEncryption {
|
|
382
|
+
protected readonly ivLength: number;
|
|
383
|
+
protected readonly keyLength: number;
|
|
384
|
+
constructor(key: Buffer, iv?: Buffer);
|
|
385
|
+
constructor(key: string, iv?: string);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
declare class CAMELLIA128 extends SymmetricEncryption {
|
|
389
|
+
protected readonly ivLength: number;
|
|
390
|
+
protected readonly keyLength: number;
|
|
391
|
+
constructor(key: Buffer, iv?: Buffer);
|
|
392
|
+
constructor(key: string, iv?: string);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
declare class CAMELLIA192 extends SymmetricEncryption {
|
|
396
|
+
protected readonly ivLength: number;
|
|
397
|
+
protected readonly keyLength: number;
|
|
398
|
+
constructor(key: Buffer, iv?: Buffer);
|
|
399
|
+
constructor(key: string, iv?: string);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
declare class CAMELLIA256 extends SymmetricEncryption {
|
|
403
|
+
protected readonly ivLength: number;
|
|
404
|
+
protected readonly keyLength: number;
|
|
405
|
+
constructor(key: Buffer, iv?: Buffer);
|
|
406
|
+
constructor(key: string, iv?: string);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
interface RSAKeyPairOptions {
|
|
410
|
+
/**
|
|
411
|
+
* 密钥长度,以bit为单位
|
|
412
|
+
* @default 1024
|
|
413
|
+
*/
|
|
414
|
+
modulusLength?: number;
|
|
415
|
+
/**
|
|
416
|
+
* 公钥指数
|
|
417
|
+
* @default 0x10001
|
|
418
|
+
*/
|
|
419
|
+
publicExponent?: number | undefined;
|
|
420
|
+
publicKeyEncoding?: {
|
|
421
|
+
/**
|
|
422
|
+
* @default pkcs1
|
|
423
|
+
*/
|
|
424
|
+
type?: 'pkcs1' | 'spki';
|
|
425
|
+
/**
|
|
426
|
+
* @default pem
|
|
427
|
+
*/
|
|
428
|
+
format?: 'pem' | 'der';
|
|
429
|
+
};
|
|
430
|
+
privateKeyEncoding?: {
|
|
431
|
+
/**
|
|
432
|
+
* @default pem
|
|
433
|
+
*/
|
|
434
|
+
format?: 'pem' | 'der';
|
|
435
|
+
/**
|
|
436
|
+
* @default pkcs1
|
|
437
|
+
*/
|
|
438
|
+
type?: 'pkcs1' | 'pkcs8';
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
interface RSAOptions {
|
|
442
|
+
/**
|
|
443
|
+
* 签名或验签时所使用的哈希算法
|
|
444
|
+
* @default sha256
|
|
445
|
+
*/
|
|
446
|
+
signatureAlgorithm?: string;
|
|
447
|
+
}
|
|
448
|
+
declare class RSA extends AsymmetricEncryption {
|
|
449
|
+
protected options: RSAOptions;
|
|
450
|
+
protected createPrivateKey(privateKeyString: string): KeyObject;
|
|
451
|
+
protected createPublicKey(publicKeyString: string): KeyObject;
|
|
452
|
+
protected decrypt(encryptedMessage: string): string;
|
|
453
|
+
protected encrypt(message: string): string;
|
|
454
|
+
protected generateKeyPair(options?: RSAKeyPairOptions): Promise<AsymmetricEncryptionKeyPair>;
|
|
455
|
+
protected sign(message: string): string;
|
|
456
|
+
protected verify(message: string, sign: string): boolean;
|
|
457
|
+
static generateKeyPair(options?: RSAKeyPairOptions): Promise<AsymmetricEncryptionKeyPair>;
|
|
458
|
+
static loadKeyPair<T extends AsymmetricEncryption = RSA>(keyPair: AsymmetricEncryptionKeyPair, options?: RSAOptions): Promise<T>;
|
|
459
|
+
static loadPublicKey(inp: PathLike | string, options?: RSAOptions): Promise<AsymmetricEncryptionPublic>;
|
|
460
|
+
static loadPrivateKey(inp: string | PathLike, options?: RSAOptions): Promise<AsymmetricEncryptionPrivate>;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
interface SM2KeyPairOptions {
|
|
464
|
+
/**
|
|
465
|
+
* 是否将公钥长度进行压缩,从默认公钥的130位压缩至66位
|
|
466
|
+
* @default false
|
|
467
|
+
*/
|
|
468
|
+
compressPublicKey?: boolean;
|
|
469
|
+
}
|
|
470
|
+
interface SM2Options {
|
|
471
|
+
/**
|
|
472
|
+
* 加密模式
|
|
473
|
+
* 0 - C1C2C3
|
|
474
|
+
* 1 - C1C3C2
|
|
475
|
+
* @default 1
|
|
476
|
+
*/
|
|
477
|
+
cipherMode?: 0 | 1;
|
|
478
|
+
/**
|
|
479
|
+
* 是否在签名或验签当中使用SM3杂凑
|
|
480
|
+
* @default true
|
|
481
|
+
*/
|
|
482
|
+
signatureSM3Hash?: boolean;
|
|
483
|
+
/**
|
|
484
|
+
* 在签名或验签当中使用的用户标识
|
|
485
|
+
* @default undefined
|
|
486
|
+
*/
|
|
487
|
+
signatureUserId?: string;
|
|
488
|
+
}
|
|
489
|
+
declare class SM2 extends AsymmetricEncryption {
|
|
490
|
+
protected options: SM2Options;
|
|
491
|
+
protected createPrivateKey(privateKeyString: string): string;
|
|
492
|
+
protected createPublicKey(publicKeyString: string): string;
|
|
493
|
+
protected decrypt(encryptedMessage: string): string;
|
|
494
|
+
protected encrypt(message: string): string;
|
|
495
|
+
protected generateKeyPair(options?: SM2KeyPairOptions): Promise<AsymmetricEncryptionKeyPair>;
|
|
496
|
+
protected sign(message: string): string;
|
|
497
|
+
protected verify(message: string, sign: string): boolean;
|
|
498
|
+
static generateKeyPair(options?: SM2KeyPairOptions): Promise<AsymmetricEncryptionKeyPair>;
|
|
499
|
+
static loadKeyPair<T extends AsymmetricEncryption = SM2>(keyPair: AsymmetricEncryptionKeyPair, options?: SM2Options): Promise<T>;
|
|
500
|
+
static loadPublicKey(inp: PathLike | string, options?: SM2Options): Promise<AsymmetricEncryptionPublic>;
|
|
501
|
+
static loadPrivateKey(inp: string | PathLike, options?: SM2Options): Promise<AsymmetricEncryptionPrivate>;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
export { AES128, AES192, AES256, ARIA128, ARIA192, ARIA256, AsymmetricEncryption, CAMELLIA128, CAMELLIA192, CAMELLIA256, DES, RSA, RSAKeyPairOptions, RSAOptions, SM2, SM2KeyPairOptions, SM2Options, SymmetricEncryption, TripleDES };
|