lazy-node-auth
Unopinionated auth manager that's good for hackathons & BAD FOR PRODUCTION.
Installation:
npm i lazy-node-auth
Concepts:
With each user account, three properties are stored:
- The
SHA256
password hash (auto-generated). - Private props (optional). (Ex. email, address).
- Public props (optional). (Ex. job title, bio).
The data types that can be stored (as public/private props) are defined in the IPrimitive
type:
string
number
boolean
array
(of accepted types).
Example Usage (Typescript of course):
Import the module:
;; // File location.
Import in JS:
const LazyNodeAuth = default;const Auth = ; // File location.
Create an account (signup):
;; Auth.registerUSERNAME, PASSWORD;
Validate username and password match (login):
;
Check if a username exists:
;
Set private props (username & password required):
Auth.setPrivatePropsUSERNAME, PASSWORD, ;
Set public props (username & password required):
Auth.setPublicPropsUSERNAME, PASSWORD, ;
Manually write to file (not really recommended):
Auth.sync
Get private props (username & password required):
;
Get public props (username required):
;
Testing:
I was too lazy to use formal unit testing. So I wrote a script to run every function with details logged. Clone the repo, Install deps (npm i
), and run the 'tests' : npm test
.