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-js

v1.0.3

Published

支持加密请求

Downloads

3

Readme

1 、下载与安装

环境依赖

Node:用于下载和安装node编译运行环境,请前往node官网进行下载

安装SDK

执行以下命令安装Storage JS SDK:

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

2、开始使用

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

import create from "storage-sdk-js"

const http = create({
  baseURL: "http://dev-gw.sunac.com.cn",
  crypto: {
    type: "aes",
    key: 'kkkkkkkkkkkkkkkk',
    cfg: {
      iv: "kkkkkkkkkkkkkkkk",
    },
  },
  signQuery: {
    ak: "ccccc",
    sk: "bbbbb",
  },
});
http.post("/storage/api/v1/tenant/insertOne?tenantId=tenantId_3001",
          {
            tenantId: "tenantId_3001",
            tempId: "tempId-01",
            data: {
              name: "ssss",
              phone: "15811388293",
            },
          }
         )
.then((res) => {
  console.log(res);
});

3、初始化http对象

3.1 初始化create对象参数说明

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

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])

5、Webpack5 注意事项 -- 废弃

需要安装对接的模块,支持node-rsa运行

const Webpack = require('webpack')
module.exports = {
  ...
  resolve: {
    fallback: {
      // 添加垫片
      "assert": require.resolve("assert"),
      "buffer": require.resolve("buffer"),
      "stream": require.resolve("stream-browserify"),
      "constants": require.resolve("constants-browserify"),
      "crypto": require.resolve("crypto-browserify")
    }
  },
  plugins: [
    new Webpack.ProvidePlugin({
        Buffer: ['buffer', 'Buffer']
    }),
    new Webpack.ProvidePlugin({
        process: 'process/browser',
    }),
  ]
};