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

@fe-cookie/client-request-crypto

v1.0.1

Published

## 客户端接口加密设计

Downloads

2

Readme

client-request-check

客户端接口加密设计

加密规则

  1. 全局拦截API 请求的参数[GET/POST],并转换为 JSON 格式。
  2. 请求体中附加时间戳参数,参数字段为_,值为时间戳。
  3. 对转换后的请求体 JSON 进行排序,
  4. 对排序好的 JSON 进行字符串拼接,
  5. 拼接好的字符串(通过key=val&)最后再附加上固定盐值得到最后需要加密的字符串(即...&key=val&salt)。
  6. 使用MD5的方式加密最后拼接的字符串,得到加密密钥。

排序规则

  1. 只对对象的 key 进行排序。
  2. 进行深度遍历排序。
  3. 当遇到数组时,检测数组的每项值,若为对象(Object/Array)则遍历对象进行递归排序,其他类型不做处理。

拼接规则

  1. 遍历 JSON 对象(只遍历第一层),通过key=val& 的方式进行拼接 (使用&符合进行字段间的拼接)。
  2. 当某个 key 对应的值为Object类型时候(即:JSON/Array)时,通过JSON.stringify 转换为字符串再进行拼接。

Started

import { clientCrypto } from '@fe-cookie/client-request-crypto'

// mock api params
// GET OR POST 请求

const getParams = {
	name: 'gaga',
	age: 20
}

const { sign } = clientCrypto({ params, salt: 'xxx' })

axios({
	url: 'xxx',
	method: 'GET',
	headers: {
		'X-AUTHO-TOKEN': sign
	}
})