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

sinosun-jwe

v0.0.3

Published

sinosun jwe tools

Downloads

1

Readme

sinosunJWE

发布到私仓

修改全局npm配置,添加访问私仓的身份令牌,避免每次发布都要登录 always-auth=true _auth="c2lub3N1bi1mcm9udC1ucG0tdXNlcjpzaW5vc3VuLWZyb250="

如果不是首次发布,需要修改组件包的版本号 方法一:直接修改package.json中的version字段 方法二:输入命令,小版本号自动加一 npm version patch

将组件包发布到私仓 1、安装依赖 npm install 2、编译 npm run pub 3、发布 npm publish

查看私仓中的组件包 地址:http://10.0.5.26:8081/#browse/browse:sinosun-front-npm-hosted 用户名:sinosun-front-npm-user 密码:sinosun-front

一般性执行流程:

jwe 加密(明文数据) -> request -> response(JWE-string) -> jwe 解密(JWE-string) -> 明文数据

其中在 **jwe 加密(明文数据)**时,会保存随机生成的 cek,在 **jwe 解密(JWE-string)**时会用到,具体可参考以下加解密案例:

import {
  CompactEncrypt,
  compactDecrypt,
  encoder,
  decoder,
  KeyLike,
} from "./index";

class Jose {
  static cek: KeyLike | string;

  // jwe加密
  static async compactEnc(): Promise<any> {
    const plaintext = JSON.stringify({
      url: "http://approval/getFlowId",
      data: {
        creator: "sda3213131dsasda",
        creatorName: "江哲",
        memeber: [
          { id: 1001, name: "test1" },
          { id: 1002, name: "test2" },
          { id: 1002, name: "test2" },
          { id: 1002, name: "test2" },
          { id: 1002, name: "test2" },
          { id: 1002, name: "test2" },
          { id: 1002, name: "test2" },
        ],
        source: "browser",
      },
    });
    const header = { alg: "SM2", enc: "G128CBC-HG128" }; //TODO 暂时没有使用压缩  zip: "DEF"
    const publicKey =
      "04" +
      "23C0F8DCD02606990A6B5C6F363D0B19870C2197B3885026DA704D5E60C60F5799C077E5A9EBAE30822B4E458FB28A0BDE539EA49ABE44963D9C12AF8B6B8DB0";
    const jweAndcek = await new CompactEncrypt(encoder.encode(plaintext))
      .setProtectedHeader(header)
      .encrypt(publicKey);
    this.cek = jweAndcek["cek"];
    console.log(`[JWE CompactEnc]: ${jweAndcek["jwe"]}`);
    console.log(`[CEK]: ${this.cek}`);
  }

  // jwe 解密
  static async compactDec(): Promise<any> {
    // await this.compactEnc();
    // 这里的 jwe 是请求回来的数据,这里做演示
    const jwe =
      "eyJhbGciOiJTTTIiLCJlbmMiOiJHMTI4Q0JDLUhHMTI4Iiwia2lkIjoidGVzdEtpZCJ9.1GbEPUoDC__uVhrMuRUNW-_lGxHWHRl06FjVJZ2u4E5PwFn3rT0cbIQtIVRD04vNV3rR5xzZi-fcT6z9-B6633CCHT7XTelaXLn4UY-lsACEzeYS6pOaLQ9oiouSAzDmVhq3llbJu5wIbl6vz0dcfcg1wtc1bKj74xIgnETFD-Q=.eyEbaD27JszMZRgQBR3FEQ==.CEpkra642HWsq8HJcquhCY6o7Cd4OjEghczioXeq9XibiM1xjHOQltUp1Ea-1-O_wEBHL-i9HfSQlmHfAWuryQ==.1en-qfZvbaU_hPFsuPbX-g==Iden";
    // cek 在加密时缓存,解密时直接用,这里做演示
    const cek = [
      7,
      96,
      174,
      211,
      13,
      160,
      173,
      112,
      190,
      90,
      146,
      64,
      70,
      155,
      225,
      98,
      226,
      207,
      81,
      13,
      24,
      181,
      113,
      176,
      32,
      12,
      140,
      234,
      83,
      16,
      49,
      213,
    ];
    this.cek = new Uint8Array(cek);

    /**
     * 解密时确保这两者的数据格式不能有误
     * jwe: string
     * cek: Uint8Array
     */
    const { plaintext, protectedHeader } = await compactDecrypt(jwe, this.cek);
    console.log(
      `[JWE CompactDec]: ${decoder.decode(plaintext)} -- ${JSON.stringify(
        protectedHeader
      )}`
    );
  }
}

Jose.compactDec();