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

dzhyun-token

v1.0.8

Published

大智慧云平台token管理模块

Downloads

13

Readme

大智慧云平台token前端管理模块

可以在前端根据appid和secret_key生成token

提供webpack插件,将明文的appid和secret_key在打包时加密

编码方式,将指定的关键字转换hex后拼上short_id从左开始拼接成2位字符,将appid和key的hex分别按位加上关键字转换hex数值取两位字符,然后生成的hex按3位一个转成字符得到转换后的字符串

使用

1、global

<script src="dist/dzhyun-token.min.js"></script>
<script>
  var tokenManager = new DzhyunTokenManager({appid: 'xxxxxx', secret_key: 'xxxxxx', shortid: 'xxxxxx'});
  tokenManager.getToken(86400).then(function(token) {
    ...
  });
</script>

2、模块化

安装

npm install dzhyun-token

使用

import DzhyunTokenManager from 'dzhyun-token';
...

API

new DzhyunTokenManager({address: 'xxxxxx', appid: 'xxxxxx', secret_key: 'xxxxxx', shortid: 'xxxxxx'})

  • address String 可选,无法本地生成token时改为向远程地址请求token,需要依赖dzhyun-connection模块
  • appid String 必填
  • secret_key String 必填
  • shortid String 必填

DzhyunTokenManager.prototype.getToken(duration) 得到token, 返回Promise对象,会缓存生成的token

  • duration Number 可选,生成token的有效期秒数,默认不传时默认1天有效期

DzhyunTokenManager.prototype.generateToken(duration) 生成新的token, 返回Promise对象

  • duration Number 可选,生成token的有效期秒数,默认不传时默认1天有效期

webpack插件使用

const DzhyunTokenManagerPlugin = require('dzhyun-token/plugin');

plugins: [
    ...
    new DzhyunTokenManagerPlugin({ useFake: true, keyword: 'abcdef' })
],

参数说明

  • useFake Boolean 可选,是否填充伪造假的appid信息
  • keyword String 可选,指定加密混浊用关键字,默认使用随机字符每次编译混浊后的编码会不同,指定了关键字能保证每次编译后混浊后编码相同