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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@holyhigh/juth2-client.js

v0.6.0

Published

A Juth2 client for javascript

Readme

Juth2-client.js

介绍

Juth2-client.js 是一个基于javascript的Juth2客户端实现。基于HTTP Header进行鉴权信息传输,实现了JWT处理、鉴权状态保持、接口封装等特性,包括

  • 使用sessionStorage进行状态保持,并支持多页签共享,但不会像cookie样出现CSRF
  • 与axios保持一致的请求接口 get/post/request
  • 内置signIn/signOut/refreshToken(deamon模式自动)等接口
  • JWT Claims完整度处理,确保残缺信息无法通过Juth2-Server

Juth2

Juth2是一整套跨域鉴权解决方案。基于JWT + OAuth2.0标准,由Java + Javascript实现(目前)。提供可配置鉴权/授权参数、透明中间层、对应(OAuth2.0)标准API,实现安装即用的前/后台套件。
更多信息可以 点此查看

安装

  1. NPM
npm i @holyhigh/juth2-client.js

使用

  1. NPM导入
import j2c from '@holyhigh/juth2-client.js';
  1. 初始化Juth2-client
j2c.init({
    clientId: cid,//服务端生成的客户Id
    scope: 'a b',//授权范围
    origin: 'http://yy.yy.yy',//自己的服务器域名
    domain: 'http://xxx.xxx.xx',//验证服务器域名
    secret: 'juth2',//密钥,用于请求签名
    credentials: false,//是否启用credentials
    daemon: false, // 守护模式,开启后会自动在token过期前请求刷新token。注意,必须拥有刷新token权限,否则服务端会报错
    log:false//是否开启日志
}).then(signedIn => {//j2c内部实现了
    console.log('signedIn=>', signedIn)
});
  1. 发起登录请求(password授权模式,使用HS256加密)
try {
    const rs = await j2c.signIn(username, password);
    //如果不使用juth2-client提供的get/post/request方法,比如外部axios
    //请务必获取rs中的headers数据的Authorization并设置到外部axios中
} catch (e) {
    console.error(e);
}
  1. 登陆后可以访问其他服务
juth2.get('/r/show/me/the/money').then(rs => {
    console.log(rs);
});