Skip to content

Commit a37cb46

Browse files
committed
release 3.2.0
1 parent d040b86 commit a37cb46

File tree

6 files changed

+1241
-1602
lines changed

6 files changed

+1241
-1602
lines changed

API.md

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
# API说明
2+
3+
## class WxCrypto
4+
5+
- 使用:`new WxCrypto(token, aesKey, appID, options)`
6+
- 参数:
7+
8+
<div class="table-prop">
9+
10+
| 参数 | 说明 | 类型 | 可选值 | 必填 | 默认 |
11+
| ------- | ------------------------------------------------------------------------------------------------- | -------- | ------ | ---- | ---- |
12+
| token | 消息校验Token,开发者在代替公众号或小程序接收到消息时,用此Token来校验消息 | `String` | - || - |
13+
| aesKey | 消息加解密Key,在代替公众号或小程序收发消息过程中使用。必须是长度为43位的字符串,只能是字母和数字 | `String` | - || - |
14+
| appID | 小程序appID | `String` | - || - |
15+
| options | Options | `Object` | - || - |
16+
17+
</div>
18+
19+
- 示例:
20+
21+
```ts
22+
const wxCrypto = new WxCrypto(token, aesKey, appID, options)
23+
```
24+
25+
## function PKCS7Encode
26+
27+
- 使用:`PKCS7Encode(data)`
28+
- 参数:
29+
30+
<div class="table-prop">
31+
32+
| 参数 | 说明 | 类型 | 可选值 | 必填 | 默认 |
33+
| ---- | ---------- | -------- | ------ | ---- | ---- |
34+
| data | Buffer数据 | `Buffer` | - || - |
35+
36+
</div>
37+
38+
- 示例:
39+
40+
```ts
41+
const result = PKCS7Encode(data)
42+
// Buffer
43+
```
44+
45+
## function PKCS7Decode
46+
47+
- 使用:`PKCS7Decode(data)`
48+
- 参数:
49+
50+
<div class="table-prop">
51+
52+
| 参数 | 说明 | 类型 | 可选值 | 必填 | 默认 |
53+
| ---- | ---------- | -------- | ------ | ---- | ---- |
54+
| data | Buffer数据 | `Buffer` | - || - |
55+
56+
</div>
57+
58+
- 示例:
59+
60+
```ts
61+
const result = PKCS7Decode(data)
62+
// Buffer
63+
```
64+
65+
## function aes256Encrypt
66+
67+
- 使用:`aes256Encrypt(algorithm, key, iv, inputEncoding?, outputEncoding?, options?)`
68+
- 参数:
69+
70+
<div class="table-prop">
71+
72+
| 参数 | 说明 | 类型 | 可选值 | 必填 | 默认 |
73+
| -------------- | ------------------------- | ------------------ | ------ | ---- | ---- |
74+
| algorithm | algorithm buffer data | `Buffer[]` | - || - |
75+
| key | AESKey | `Buffer` | - || - |
76+
| iv | iv | `Buffer` | - || - |
77+
| inputEncoding | encoding | `Encoding` | - || - |
78+
| outputEncoding | encoding | `Encoding` | - || - |
79+
| options | options of createCipheriv | `CipherGCMOptions` | - || - |
80+
81+
</div>
82+
83+
- 示例:
84+
85+
```ts
86+
const result = aes256Encrypt(algorithm, key, iv)
87+
// string
88+
```
89+
90+
## function aes256Decrypt
91+
92+
- 使用:`aes256Decrypt(algorithm, key, iv, inputEncoding?, outputEncoding?, options?)`
93+
- 参数:
94+
95+
<div class="table-prop">
96+
97+
| 参数 | 说明 | 类型 | 可选值 | 必填 | 默认 |
98+
| -------------- | --------------------------- | ------------------ | ------ | ---- | ---- |
99+
| algorithm | algorithm data | `String` | - || - |
100+
| key | encodingAESKey | `Buffer` | - || - |
101+
| iv | iv | `Buffer` | - || - |
102+
| inputEncoding | encoding | `Encoding` | - || - |
103+
| outputEncoding | encoding | `Encoding` | - || - |
104+
| options | options of stream.transform | `CipherCCMOptions` | - || - |
105+
106+
</div>
107+
108+
- 示例:
109+
110+
```ts
111+
const result = aes256Decrypt(algorithm, key, iv)
112+
// string
113+
```
114+
115+
## function buildXML buildXMLSync
116+
117+
- 使用:`buildXML(data, options?), buildXMLSync(data, options?, callback?)`
118+
- 参数:
119+
120+
<div class="table-prop">
121+
122+
| 参数 | 说明 | 类型 | 可选值 | 必填 | 默认 |
123+
| -------- | ----------- | ----------------- | ------ | ---- | ---- |
124+
| data | 数据 | `Object` | - || - |
125+
| options | xml生成配置 | `BuildXMLOptions` | - || - |
126+
| callback | 回调方法 | `Function` | - || - |
127+
128+
</div>
129+
130+
- 示例:
131+
132+
```ts
133+
const result = buildXML(data)
134+
// string
135+
```
136+
137+
## function parseXML parseXMLSync
138+
139+
- 使用:`parseXML(data, options?), parseXMLSync(data, options?, callback?)`
140+
- 参数:
141+
142+
<div class="table-prop">
143+
144+
| 参数 | 说明 | 类型 | 可选值 | 必填 | 默认 |
145+
| -------- | ----------- | --------------------- | ------ | ---- | ---- |
146+
| data | 数据 | `convertableToString` | - || - |
147+
| options | xml解析配置 | `ParserXMLOptions` | - || - |
148+
| callback | 回调方法 | `Function` | - || - |
149+
150+
</div>
151+
152+
- 示例:
153+
154+
```ts
155+
const result = parseXML(data)
156+
// string
157+
```
158+
159+
## function sha1
160+
161+
- 使用:`sha1(...data)`
162+
- 参数:
163+
164+
<div class="table-prop">
165+
166+
| 参数 | 说明 | 类型 | 可选值 | 必填 | 默认 |
167+
| ------- | ---- | ---------- | ------ | ---- | ---- |
168+
| ...data | 数据 | `string[]` | - || - |
169+
170+
</div>
171+
172+
- 示例:
173+
174+
```ts
175+
const result = sha1(data)
176+
// string
177+
```

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 更新日志
22

3-
## 2023.11.13 v3.2.0
3+
## 2024.03.05 v3.2.0
44

55
1. 完善文档
66
2. 升级依赖包

README.md

Lines changed: 2 additions & 176 deletions
Original file line numberDiff line numberDiff line change
@@ -74,183 +74,9 @@ const wxCrypto = new WxCrypto(token, aesKey, appID, {
7474
const data = await wxCrypto.decrypt(encrypt, timestamp, nonce, options)
7575
```
7676

77-
## API说明
77+
## API
7878

79-
### class WxCrypto
80-
81-
- 使用:`new WxCrypto(token, aesKey, appID, options)`
82-
- 参数:
83-
84-
<div class="table-prop">
85-
86-
| 参数 | 说明 | 类型 | 可选值 | 必填 | 默认 |
87-
| ------- | ------------------------------------------------------------------------------------------------- | -------- | ------ | ---- | ---- |
88-
| token | 消息校验Token,开发者在代替公众号或小程序接收到消息时,用此Token来校验消息 | `String` | - || - |
89-
| aesKey | 消息加解密Key,在代替公众号或小程序收发消息过程中使用。必须是长度为43位的字符串,只能是字母和数字 | `String` | - || - |
90-
| appID | 小程序appID | `String` | - || - |
91-
| options | Options | `Object` | - || - |
92-
93-
</div>
94-
95-
- 示例:
96-
97-
```ts
98-
const wxCrypto = new WxCrypto(token, aesKey, appID, options)
99-
```
100-
101-
### function PKCS7Encode
102-
103-
- 使用:`PKCS7Encode(data)`
104-
- 参数:
105-
106-
<div class="table-prop">
107-
108-
| 参数 | 说明 | 类型 | 可选值 | 必填 | 默认 |
109-
| ---- | ---------- | -------- | ------ | ---- | ---- |
110-
| data | Buffer数据 | `Buffer` | - || - |
111-
112-
</div>
113-
114-
- 示例:
115-
116-
```ts
117-
const result = PKCS7Encode(data)
118-
// Buffer
119-
```
120-
121-
### function PKCS7Decode
122-
123-
- 使用:`PKCS7Decode(data)`
124-
- 参数:
125-
126-
<div class="table-prop">
127-
128-
| 参数 | 说明 | 类型 | 可选值 | 必填 | 默认 |
129-
| ---- | ---------- | -------- | ------ | ---- | ---- |
130-
| data | Buffer数据 | `Buffer` | - || - |
131-
132-
</div>
133-
134-
- 示例:
135-
136-
```ts
137-
const result = PKCS7Decode(data)
138-
// Buffer
139-
```
140-
141-
### function aes256Encrypt
142-
143-
- 使用:`aes256Encrypt(algorithm, key, iv, inputEncoding?, outputEncoding?, options?)`
144-
- 参数:
145-
146-
<div class="table-prop">
147-
148-
| 参数 | 说明 | 类型 | 可选值 | 必填 | 默认 |
149-
| -------------- | ------------------------- | ------------------ | ------ | ---- | ---- |
150-
| algorithm | algorithm buffer data | `Buffer[]` | - || - |
151-
| key | AESKey | `Buffer` | - || - |
152-
| iv | iv | `Buffer` | - || - |
153-
| inputEncoding | encoding | `Encoding` | - || - |
154-
| outputEncoding | encoding | `Encoding` | - || - |
155-
| options | options of createCipheriv | `CipherGCMOptions` | - || - |
156-
157-
</div>
158-
159-
- 示例:
160-
161-
```ts
162-
const result = aes256Encrypt(algorithm, key, iv)
163-
// string
164-
```
165-
166-
### function aes256Decrypt
167-
168-
- 使用:`aes256Decrypt(algorithm, key, iv, inputEncoding?, outputEncoding?, options?)`
169-
- 参数:
170-
171-
<div class="table-prop">
172-
173-
| 参数 | 说明 | 类型 | 可选值 | 必填 | 默认 |
174-
| -------------- | --------------------------- | ------------------ | ------ | ---- | ---- |
175-
| algorithm | algorithm data | `String` | - || - |
176-
| key | encodingAESKey | `Buffer` | - || - |
177-
| iv | iv | `Buffer` | - || - |
178-
| inputEncoding | encoding | `Encoding` | - || - |
179-
| outputEncoding | encoding | `Encoding` | - || - |
180-
| options | options of stream.transform | `CipherCCMOptions` | - || - |
181-
182-
</div>
183-
184-
- 示例:
185-
186-
```ts
187-
const result = aes256Decrypt(algorithm, key, iv)
188-
// string
189-
```
190-
191-
### function buildXML buildXMLSync
192-
193-
- 使用:`buildXML(data, options?), buildXMLSync(data, options?, callback?)`
194-
- 参数:
195-
196-
<div class="table-prop">
197-
198-
| 参数 | 说明 | 类型 | 可选值 | 必填 | 默认 |
199-
| -------- | ----------- | ----------------- | ------ | ---- | ---- |
200-
| data | 数据 | `Object` | - || - |
201-
| options | xml生成配置 | `BuildXMLOptions` | - || - |
202-
| callback | 回调方法 | `Function` | - || - |
203-
204-
</div>
205-
206-
- 示例:
207-
208-
```ts
209-
const result = buildXML(data)
210-
// string
211-
```
212-
213-
### function parseXML parseXMLSync
214-
215-
- 使用:`parseXML(data, options?), parseXMLSync(data, options?, callback?)`
216-
- 参数:
217-
218-
<div class="table-prop">
219-
220-
| 参数 | 说明 | 类型 | 可选值 | 必填 | 默认 |
221-
| -------- | ----------- | --------------------- | ------ | ---- | ---- |
222-
| data | 数据 | `convertableToString` | - || - |
223-
| options | xml解析配置 | `ParserXMLOptions` | - || - |
224-
| callback | 回调方法 | `Function` | - || - |
225-
226-
</div>
227-
228-
- 示例:
229-
230-
```ts
231-
const result = parseXML(data)
232-
// string
233-
```
234-
235-
### function sha1
236-
237-
- 使用:`sha1(...data)`
238-
- 参数:
239-
240-
<div class="table-prop">
241-
242-
| 参数 | 说明 | 类型 | 可选值 | 必填 | 默认 |
243-
| ------- | ---- | ---------- | ------ | ---- | ---- |
244-
| ...data | 数据 | `string[]` | - || - |
245-
246-
</div>
247-
248-
- 示例:
249-
250-
```ts
251-
const result = sha1(data)
252-
// string
253-
```
79+
详见:[API说明文档](API.md)
25480

25581
## 类型
25682

jest.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ module.exports = {
3939
testMatch: ['<rootDir>/src/**/__tests__/**/*spec.[jt]s?(x)'],
4040
testPathIgnorePatterns: process.env.SKIP_E2E
4141
? // ignore example tests on netlify builds since they don't contribute
42-
// to coverage and can cause netlify builds to fail
43-
['/node_modules/', '/examples/__tests__']
42+
// to coverage and can cause netlify builds to fail
43+
['/node_modules/', '/examples/__tests__']
4444
: ['/node_modules/']
4545
}

0 commit comments

Comments
 (0)