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

storage-sdk-xcx

v1.0.1

Published

支持加密请求

Downloads

6

Readme

1 、下载与安装

环境依赖

微信开发者工具

安装SDK

执行以下命令安装小程序npm扩展包:

// 安装前置模块 
npm install crypto-js
// 安装加密SDK
npm install storage-sdk-xcx

2、开始使用

下面为您演示使用Storage JS SDK完成一个基础操作,如创建一条数据。

// app.js
const { create } = require('storage-sdk-xcx')
const http = create({
   baseUrl: 'http://dev-gw.sunac.com.cn',
   crypto: {
      type: 'des',
      key: 'kkkkkkkkkkkkkkkk',
      cfg: {
         iv: 'kkkkkkkkkkkkkkkk'
      }
   },
   signQuery: {
      ak: "ccccc",
      sk: "bbbbb"
   }
})

http.post('/storage/api/v1/tenant/insertOne?tenantId=tenantId_3002', {
   "tenantId": "tenantId_3002",
   "tempId": "tempId-01",
   "data": {
      "name": "ssss",
			"phone": "15811388293"
   }
}, {
   unEncryt: false
}).then(res => {
   console.log(res)
})

3、初始化http对象

3.1 初始化create对象参数说明

| 参数 | 说明 | 类型 | 默认值 | | ------------- | :----------------------------------------------------------- | ------- | ------ | | baseUrl | base 地址 | string | - | | crypto | 加密对象 | object | - | | unEncryt | 禁用加密,在create 实例传入将覆盖至所有接口,单个接口使用,在config添加该属性中也生效 | boolean | falase | | signQuery | 签名参数配置 | object | - | | …… | 其余参数均和 【wx.request】 配置相同 | - | - |

3.2 crypto参数说明

| 参数 | 类型 | 是否必填 | 针对加密对象 | | ---- | ------------------------------------------------------------ | -------- | ------------ | | type | aes|des |rsa_PKCS1 | 是 | all | | key | string 加密key值 | 是 | all | | cfg | 调整aes、des的加密模式、填充模式等等具体可以查看文档 【crypto-js】, 目前仅支持mode:CBC padding: Pkcs7,其中iv参数非必填项默认为""。 | 否 | ase|ase |

3.3 signQuery参数说明

| 参数 | 说明 | 类型 | 默认值 | | :--- | --------------------- | ------ | ------ | | sk | sercetKey | string | - | | ak | accessKey | string | - | | exp | 单位:秒。exp秒后过期 | number | 900 |

4、实例方法

拦截器
// 请求拦截器
http.interceptors.request.use((config) => {
   return config;
});

// 响应拦截器
http.interceptors.response.use((res) => {
   // 自定义错误
   if (res.code !== 200) {
      return Promise.reject(new Error("Request Error"));
   };

   return res;
}, (error) => {
   const { message, response, config } = error;
   return Promise.reject(error);
});
请求
http.request(config)

http.get(url[, data[, config]])

http.post(url[, data[, config]])

http.put(url[, data[, config]])

http.delete(url[, config])

http.head(url[, config])

http.options(url[, config])

http.connect(url[, config])