1.0.6-2 • Published 8 months ago
cedar-crypto v1.0.6-2
报文加密工具
项目采用国密算法,对 post 格式报文进行加密
npm install cedar-crypto
yarn add cedar-crypto
// request.ts
import { encryptAxios, decryptAxios } from "cedar-crypto";
_axios.interceptors.request.use(
async (config: standardConfig) => {
// ...
return encryptAxios(config, { publicKey: "041xxxxx", apiUrl: "/api" });
},
(error) => {
//...
}
);
_axios.interceptors.response.use(
(res) => {
// ...
res = decryptAxios(res, {
publicKey: "041xxxxx",
apiUrl: "/api",
checkResponse: false,
});
// ...
return Promise.resolve(res);
},
(err) => {
// ...
}
);
interface Options {
// 1. 服务端⽣成应⽤的公钥,线下下发公钥内容;
publicKey: string;
// baseurl
apiUrl: string;
// 是否校验相应报文摘要,不校验需要显示传值 false
checkResponse: boolean;
}
对于某些无需加密的报文,可单独设置例外,组件会判断config?.headers?.ignoreEnctype === true
// 例如文件下载
export const exportRes = () =>
defHttp.post({
url: Api.exportXlsUrl,
headers: { ignoreEnctype: true },
responseType: "blob",
});
1.0.1
10 months ago
1.0.6
8 months ago
1.0.5
8 months ago
1.0.4
10 months ago
1.0.3
10 months ago
1.0.6-2
8 months ago
1.0.6-1
8 months ago
1.0.0
12 months ago
0.0.15
12 months ago
0.0.14
12 months ago
0.0.13
12 months ago
0.0.12
12 months ago
0.0.11
12 months ago
0.0.10
12 months ago
0.0.9
12 months ago
0.0.8
12 months ago
0.0.7
12 months ago
0.0.6
12 months ago
0.0.5
12 months ago
0.0.4
12 months ago
0.0.3
12 months ago
0.0.2
12 months ago
0.0.1
12 months ago
0.0.0
12 months ago