Longshot Authentication API
Installation
As a dependency:
npm install ls-auth-api --save
As a standalone server:
git clone https://github.com/longshot-io/auth-api && cd auth-api
npm install
Usage
As a dependency:
var Auth = ;// Optionally, start the web APIauthApi; authApi;
As a standalone server:
// Example: npm start [portNumber]
npm start 8181
API
Programmatic
User
interface User username: string; password: string; enabled?: number; // Optional
Registration
register(...): Returns a promise containing the new user ID
Auth: Promise<number>;
Authentication
login(...): Returns a promise containing the new JWT token or gets rejected
Auth: Promise<string>;
Token/Session Verification
verify(...): Returns a promise that resolves a boolean. True if the token is valid
Auth: Promise<boolean>;
Web Server Initialization
startWebServer(...): Returns void
Auth: void;
HTTP Endpoints
POST /login
Accepts PAYLOAD:
username: string
password: string
POST /register
Accepts PAYLOAD:
username: string
password: string
POST /verify
Accepts PAYLOAD:
token: string
License
MIT