1.0.4 • Published 6 years ago

@christopy/tokenator v1.0.4

Weekly downloads
2
License
MIT
Repository
-
Last release
6 years ago

Installation

npm install @christopy/tokenator --save

Usage

// Import Tokenator.
const Tokenator = require ("@christopy/tokenator");

Creating Tokens

The returned data is used after to check the Token

const myNewToken = Tokenator.Create ({
    data: "I'm a precious data", // The Token data
    expiration: "05/04/2019",    // When the Token expires (default is 24H)
  },
  "A super secure key"           // The key for the Token encryption (required)
);

Checking Tokens

To check Tokens, your Id is used for it. The id is returned from the Tokenator.Create () function.
If the Id is wrong or the key couldn't decrypt the Token correctly, it returns null. If the Token is invalid or doesn't exists, it returns false. If the Token is valid, it returns true.

Tokenator.Check (myNewToken, "A super secure key");

Why web tokens?

Sometimes to learn something you need make your own implementation.

Version

1.0.4