kong-did

HELPLESS-DID authorize library


License
ISC
Install
npm install kong-did@1.0.8

Documentation

kong-DID

Current Release

🚀 Getting Started

Run the following command:

npm install kong-did

🛠 Setting Config

Javascript

// did.js

const { DID } = require('kong-did');

const config = {
  clientId: 'clientId' //API key
  redirectURI: 'redirectURI' // redirect URI that you wrote down when you apply application from DID site
};

const did = new DID(config);

module.exports = did;

Typescript

// did.ts

import { DID, IConfig } from 'kong-did';

const config: IConfig = {
  clientId: 'clientId' //API key
  redirectURI: 'redirectURI' // redirect URI that you wrote down when you apply application from DID site
};

const did = new DID(config);

export default did;

🫒 Using kong-DID

Get user information

// server.ts

const express = require('express');
const app = express();
const did = require('./did');

app.get('/did', (req, res) => {
  const authUrl = did.getAuthUrl();
  res.redirect(authUrl);
});

app.get('/did/redirect', async (req, res) => {
  const userInfo = await did.getUserInfo(req);
  console.log(userInfo);
  /* 
  userInfo example:
    {
      name: 'dev_kong',
      birth: '930126',
      gender: 'male',
      email: 'example@gmail.com',
      userCode: 'random5474768asdlkfjd65756765'
    }
  */
});

app.listen(3000);

Disconnect

const express = require('express');
const app = express();
const did = require('./did');

app.post('/disconnect', (req, res) => {
  const { userCode } = req.body;
  const result = did.disconnect(userCode); // return boolean
});

app.listen(3000);

Check point

const express = require('express');
const app = express();
const did = require('./did');

app.post('/checkPoint', (req, res) => {
  const { userCode } = req.body;
  const result = did.checkPoint(userCode);

  console.log(result);
  /*
  [
    {
      idx: 44,
      name: 'site-a',
      pt: 2800
    }
    ...
  ]
  */
});

app.listen(3000);

That's it, have fun.