check-sign-fbmc
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

check-sign-fbmc

使用Hmac-MD5和RSA-SHA256函数来对请求和相应增加签名、验签,包体积106KB

客户端使用方法

import { CheckSignFbmcClient } from "check-sign-fbmc";
 
(async function(){
    const secret = `123456`;
    const clientPrivatePem = `...`;
    const serverPublicPem = `...`;
    const client = new CheckSignFbmcClient(secret, clientPrivatePem, serverPublicPem, { debug: true });
    const request = { a: "1" };
    const requestWithSign = client.addSignToRequest(request);
    const responseWithSign = await axios.post("/api", requestWithSign);
    const clientCheckSignResult = client.checkSign(responseWithSign);
})();

服务端使用方法

import { CheckSignFbmcServer } from "check-sign-fbmc";
 
(async function(requestWithSign){
    const secret = `123456`;
    const serverPrivatePem = `...`;
    const clientPublicPem = `...`;
    const server = new CheckSignFbmcServer(secret, serverPrivatePem, clientPublicPem, { debug: true });
    const serverCheckSignResult = server.checkSign(requestWithSign);
    const response = { a: "1" };
    const responseWithSign = server.addSignToResponse(response);
})();

Package Sidebar

Install

npm i check-sign-fbmc

Weekly Downloads

3

Version

1.0.6

License

ISC

Unpacked Size

123 kB

Total Files

10

Last publish

Collaborators

  • allfornaruto