1.0.6-2 • Published 2 years ago

cedar-crypto v1.0.6-2

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

报文加密工具

项目采用国密算法,对 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

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.6-2

2 years ago

1.0.6-1

2 years ago

1.0.0

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

0.0.0

2 years ago