New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@fe-cookie/client-request-crypto

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fe-cookie/client-request-crypto

## 客户端接口加密设计

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

client-request-check

客户端接口加密设计

加密规则

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

排序规则

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

拼接规则

  • 遍历 JSON 对象(只遍历第一层),通过key=val& 的方式进行拼接 (使用&符合进行字段间的拼接)。
  • 当某个 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
	}
})

FAQs

Package last updated on 30 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts