-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.d.ts
75 lines (65 loc) · 1.92 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
declare module 'dingtalk-encrypt' {
/**
* 回调事件消息体加解密
* @see https://open.dingtalk.com/document/orgapp-server/callback-event-message-body-encryption-and-decryption
*/
export class DingTalkEncryptor {
protected token: string;
protected encodingAesKey: string;
protected corpIdOrSuiteKey: string;
/**
* 构造加解密对象
* @param token 固定串,随机值
* @param encodingAesKey 加密密钥,可随机获取(getRandomEncodingAesKey)
* @param corpIdOrSuiteKey 服务商 id 或 key
*/
constructor(token: string, encodingAesKey: string, corpIdOrSuiteKey: string);
/**
* 加密
* @param random 随机串
* @param plainText 未加密消息串
* @return 加密串
*/
encrypt(random: string, plainText: string): string;
/**
* 解密
* @param encrypted 待解密串
* @return 解密串
*/
decrypt(encrypted: string): string;
/**
* 计算签名
*/
getSignature(token: string, timestamp: string, nonce: string, encrypt: string): string;
/**
* 获取加密响应对象(回调函数用)
* @param plaintext
* @param timeStamp
* @param nonce
*/
getEncryptedMap(plaintext: string, timeStamp: string, nonce: string): string;
/**
* 解密回调数据
* - 校验消息签名等
* @param msgSignature
* @param timeStamp
* @param nonce
* @param encryptMsg
*/
getDecryptMsg(msgSignature: string, timeStamp: string, nonce: string, encryptMsg: string): string;
}
/**
* Utils
*/
/**
* get random string
* @param {number} size
* @return {string} random string of length {size}
*/
export const getRandomStr: (size) => string;
/**
* random aes key of encoding with base64
* @return {string} EncodingAesKey of length 43
*/
export const getRandomEncodingAesKey: () => string;
}