Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/skywa04885/lxoauth2
Luke's XOATH2 Library for NodeJS, with simple Bearer.
https://github.com/skywa04885/lxoauth2
Last synced: 8 days ago
JSON representation
Luke's XOATH2 Library for NodeJS, with simple Bearer.
- Host: GitHub
- URL: https://github.com/skywa04885/lxoauth2
- Owner: skywa04885
- Created: 2022-03-24T18:43:13.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-24T20:51:49.000Z (almost 3 years ago)
- Last Synced: 2024-12-12T16:16:01.602Z (about 1 month ago)
- Language: TypeScript
- Size: 14.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Simple XOATH2 Library for NodeJS
This is a simple library for creating XOAUTH2 tokens for SASL supporting systems, also for the convenience I've added some
simple bearer creation and verification.## Usage
```ts
// Reads the public and private key.
const public_key: Buffer = fs.readFileSync(path.join(__dirname, '../../public.key'));
const private_key: Buffer = fs.readFileSync(path.join(__dirname, '../../private.key'));// Creates the signer.
const signer: Signer = new Signer(public_key, private_key);// Creates the bearer data.
const bearer_data: BearerData = new BearerData({ test: 123 });// Creates the signed bearer, validates it and creates the XOAUTH2 token.
const signed_bearer: string = signer.sign(bearer_data);
console.log(signer.validate(signed_bearer));
const token: XOATH2Token = new XOATH2Token('luke', signed_bearer);// Encodes the token, and decodes it (just to test.)
const encoded_token: string = token.encode();
console.log(encoded_token)
console.log(XOATH2Token.decode(encoded_token))```