dfws-ve-taro-request 0.0.1 → 0.0.2
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/dist/index.esm.js +19 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +19 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +19 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/config/index.ts +3 -0
- package/src/index.ts +8 -1
- package/src/utils/instance.ts +13 -2
package/package.json
CHANGED
package/src/config/index.ts
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
// 接口加密密钥
|
2
2
|
export const secretkey:string = "dz15z9z2z15z11z8zf";
|
3
3
|
|
4
|
+
// 图片验证码加密密钥
|
5
|
+
export const captchaKey = "#DFws082#2312";
|
6
|
+
|
4
7
|
// 项目渠道配置:管理后台-138美业人才-系统设置-渠道管理
|
5
8
|
export const channel:IChannel = { "project": "VE", "origin": "C", "platform": "XCX", "device": "ZJDF", "version": "1.0.0" };
|
package/src/index.ts
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
import getPublicChannel from "dfws-channel/dist/taro"
|
3
3
|
import { channel } from './config'
|
4
4
|
import request from "./utils/request";
|
5
|
+
import { decryptByDES, encryptByDES, encryptBySso } from "./utils/instance";
|
5
6
|
|
6
7
|
export default {
|
7
8
|
request: (taro: any, projectChannel: IChannel = {}, url: string, data: any, method: string, headers: any = {}) => {
|
@@ -20,5 +21,11 @@ export default {
|
|
20
21
|
params: JSON.stringify(dfws_header.queryChannels()),
|
21
22
|
...headers
|
22
23
|
}, taro)
|
23
|
-
}
|
24
|
+
},
|
25
|
+
// 接口解密
|
26
|
+
decryptByDES,
|
27
|
+
// 接口加密
|
28
|
+
encryptByDES,
|
29
|
+
// 验证码加密
|
30
|
+
encryptBySso
|
24
31
|
}
|
package/src/utils/instance.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import dfwsCrypto from "dfws-crypto";
|
2
|
-
import { secretkey } from "../config";
|
2
|
+
import { secretkey, captchaKey } from "../config";
|
3
3
|
|
4
4
|
// 是否进行接口解密
|
5
5
|
export const isEncoding = (url = '') => {
|
@@ -18,7 +18,7 @@ export const decryptByDES = (params: string) => {
|
|
18
18
|
console.log(`获取内容:`, data)
|
19
19
|
return data
|
20
20
|
};
|
21
|
-
|
21
|
+
// 对象转URL字符串
|
22
22
|
export const objectToQueryString = (obj: object) => {
|
23
23
|
return Object.keys(obj)
|
24
24
|
.map(key => {
|
@@ -29,9 +29,20 @@ export const objectToQueryString = (obj: object) => {
|
|
29
29
|
.join('&');
|
30
30
|
}
|
31
31
|
|
32
|
+
//短信/邮箱验证码加密
|
33
|
+
export const encryptBySso = (value:string) => {
|
34
|
+
const key = Date.parse(new Date().toString())
|
35
|
+
const sign = encryptByDES(`${captchaKey}${value}${key}`)
|
36
|
+
return {
|
37
|
+
check_sign: sign,
|
38
|
+
check_key: key,
|
39
|
+
}
|
40
|
+
};
|
41
|
+
|
32
42
|
export default {
|
33
43
|
isEncoding,
|
34
44
|
encryptByDES,
|
35
45
|
decryptByDES,
|
46
|
+
encryptBySso,
|
36
47
|
objectToQueryString
|
37
48
|
};
|