npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gc_rsa

v1.3.10

Published

gc_rsa 是用于加密前端请求的库。

Downloads

151

Readme

说明

gc_rsa 是用于加密前端请求的库。

使用方式

  1. 安装
npm install gc_rsa
  1. 在入口文件中引入
import gc_rsa from "gc_rsa";

//普通示例
gc_rsa({
  appkey: "123",
  appsecret: "345",
});

//网站示例
gc_rsa({
  appkey: "123",
  appsecret: "345",
  adapter:"fly"
});

//微信小程序示例
gc_rsa({
  appkey: "123",
  appsecret: "345",
  engineType:"fly", //如果使用了fly作为请求库
  adapter:"wx"
});

//uniapp示例
gc_rsa({
  appkey: "123",
  appsecret: "345",
  engineType:"fly",
  adapter:"uni"
});

3.不使用gc_rsa进行独立自定义校验

import signature from "gc_rsa/src/lib/signature";

在axios或其他拦截器按如下示例使用: config为axios拦截器中request实例

signature(config, {
  appkey: "123",
  appsecret: "345",
  originQuery: config.params
})

不执行校验

方法1:在请求头里面加入noSign跳过签名用以避免未知错误

{
  "headers": {
    "noSign": true
  }
}

方法2:在配置中注入exclude

gc_rsa({
  appkey: "123",
  appsecret: "456",
  exclude: ["unReadNum"] //排除路径
});

参数说明

| 参数名 | 参数说明 | 默认值 | | ---------- | ----------------------------- | ---------- | | appkey | app 唯一标识 | 25396816 | | appsecret | app 秘钥 | 联系管理员 | | engineType | 是否使用了fly作为底层请求库 | 无 | | adapter | 请求适配器,转换成预期的请求库 | fetch | | contentSign | 是否对请求体签名,确保在没有特殊字符的情况下使用此项 | false |

engineType

| 可选值 | 参数说明 | 是否默认 | | -------------- | --------------- | -------- | | XMLHttpRequest | 默认 | 是 | | fly | 如果使用了fly库 | 否 |

adapter

| 参数名 | 参数说明 | 默认值 | | ------ | ------------------------------------------------------------------ | ------ | | fly | 使用fly发送请求,在未使用fly的程序中使用,与{ engineType:fly}互斥 | 否 | | wx | 使用wx底层发送请求,小程序里面需要配合 { engineType:fly} 进行设置 | 否 | | uni | 使用uni底层发送请求,小程序里面需要配合 { engineType:fly} 进行设置 | 否 |

注意事项

可能出现post传参校验失败的情况(不规范问题请避免),如遇到这种情况校验无法通过,请尝试修改Content-Type为application/json

相关文档

rsa 加密文档