Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

zhike-jwt

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zhike-jwt

## Dependencies

  • 0.1.13
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-75%
Maintainers
1
Weekly downloads
 
Created
Source

Node.js SDK for Zhike JWT authentication

Dependencies

What you need to run this app:

  • Node.Js
  • node-jsonwebtoken

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('zhangsan@innobuddy.com');
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.

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

Keywords

FAQs

Package last updated on 30 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc