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

zhike-jwt

v0.1.13

Published

## Dependencies

Downloads

7

Readme

Node.js SDK for Zhike JWT authentication

Dependencies

What you need to run this app:

Install

npm install zhike-jwt

Usage

const JwtHandler = require('zhike-jwt');

let handler = new JwtHandler('./example.conf.js'); // JwtHandler also accept a js object
let promise = handler.get_user_permission('[email protected]');
promise.then((perms) => console.log(perms);

API

Constructor method

JwtHandler(path_to_conf_file)

(Synchronous) Returns the Jwt handler instance

arguments

path_to_conf_file is the path to configure file. The path can be an absolute path or a relative path. If it is a relative path, it must begin with "./", for example "./myconf.js".

Functional methods

user permission query

function definition

get_user_permission(email)

(Asynchronous) Returns user permissions in an object, and the object looks like

{
	code: 0, 
	data: [perm1, perm2, ...]
}
arguments

email The email of the target user. (Note, currently we support email only)

organization query

function definition

get_organization_tree(organizationId)

(Asynchronous) Returns organization tree in an object, and the object looks like

{
    "id": 1,
    "name": "北京新中关学习中心",
    "parent_id": 1395,
    "type": "机构",
    "children": []
}

advanced query

function definition

query(options) (Asynchronous) Returns query result in an object. How the object looks like depends on the query uri, for example

    let options = {
      method: 'POST',
      uri: `${handler.serverUrl}/api/staff/get_staff_by_userids/`,
      body: {
        ids: [41992,41974]
      },
      json: true
    }
    let staff = await handler.query(options);
arguments

options is the query options object, it contains not only the real parameter in body attribute, but also query method and the uri, like options variable in the above example.

Configure file

The configure file is a js file, see example.conf.js for example. The entries are list below, more details can be found at here.

|Entry|Description| |-----|-----------| |issuer|A string that will be checked against the iss field of the token, see jwt document for details| |serverUrl|The url of AAA service| |privateKey|The private key used to sign jwt signature, see jwt document for details| |publicKey|The public key used to verify jwt signature. It should be signed by CA, see jwt document for details| |disableTracing|是否禁止zipkin traceing,缺省为否| |zipkinServiceUrl|zipkin服务url,确实了测试环境zipkin url| |serviceName|本服务名,缺省为jwt_client,应设置为当前使用jwt的服务名,如smartstudy-backend|