zju-authenticator
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

zju-authenticator

Helper utilities for login to and get user information from the Zhejiang University Unified Identity Authentication Platform (浙大统一身份认证平台).

Usage

CLI

Use command line arguments:

❯ npx zju-authenticator -u username -p password
Logged in successfully, the user information is below:
{
  userId: 00000,
  loginName: '...',
  userName: '...',
  // ...
}

Or let zju-authenticator prompts you with questions:

❯ npx zju-authenticator
✔ Username: username
✔ Password: password
Logged in successfully, the user information is below:
{
  userId: 00000,
  loginName: '...',
  userName: '...',
  // ...
}

API

const { ZjuAuthenticator } = require('zju-authenticator')
// or in ES Module format:
// import { ZjuAuthenticator } from 'zju-authenticator'

const zjuAuthenticator = new ZjuAuthenticator({
  username: '...',
  password: '...'
})

zjuAuthenticator
  .login()
  .then(userInfo => {
    console.log(userInfo)
    // {
    //     userId: 00000,
    //     loginName: '...',
    //     userName: '...',
    //     // ...
    // }
  })
  .catch(err => {
    if (err.message === ZjuAuthenticator.STATUS.INCORRECT_CREDENTIALS) {
      console.error('Incorrect credentials, please check your input!')
    } else if (err.message === ZjuAuthenticator.STATUS.UNEXPECTED_ERROR) {
      console.error('Unexpected error at:', err.stack)
    } else {
      console.error(err.stack)
    }
  })

Disclaimer

Never disclose your username and password publicly or to someone you do not trust, Remember to add your secret files to .gitignore and as secrets.

Readme

Keywords

Package Sidebar

Install

npm i zju-authenticator

Weekly Downloads

1

Version

0.0.2

License

GNU GPLv3

Unpacked Size

1.98 MB

Total Files

19

Last publish

Collaborators

  • upupming