1.0.2 • Published 4 years ago
@codemaster138/authy-client v1.0.2
Authy-client
A Client for the Authy backend
Installing
From cdn
Insert this tag into your html file:
<script src="https://unpkg.com/@codemaster138/authy-client@latest/dist/authy.js"></script>
From npm
npm i @codemaster138/authy-client
API reference
This library allows you to inteface with the Authy backend. This tutorial assumes you have followed the instructions in this repo, and have successfully set up an authy server on your machine.
Functions
async authy.init(options) : void
Used to initialized authy. Call this before any other calls on authy. params:
options:object
- Options to intialize authy withapp:string
(required) - Which app to register ashost:string
(optional) - Domain or IP of server (default:localhost
)port:number
(optional) - Server port (default:8080
)protocol:string
(optional) - Server protocol. Overwrite only for https servers (default:http
)
asnyc authy.createUser({username, email, password}) : Promise<String>
Creates a new user Will reject if:
- The user already exists
- A server error occurs params:
options:object
-username:string
- The username -email:string
- The user's email -password:string
- The user's password returns: A promise for a success message from the server
async authy.login({username, password}) : Promise<String>
Logs in to a user. Will overwrite any active sessions for that user.
Note: The session ID will automatically be stored in an HTTP-only cookie, sessionID
Will reject if:
- The password is incorrect
- A server error occurs
- The username doesn't exist params:
options:object
-username:string
- The username -password:string
- The password returns: The session ID.
async authy.core.session.write(data) : Promise<void>
Writes data to the current session params:
data:object
- Data to store
async authy.core.session.read(template) : Promise<Object>
Reads from session params:
template:object
- Template Object as described in cross-destruct
async authy.core.session.writeUser(data) : Promise<void>
Writes data to the currently logged in user's user data params:
data:object
- Data to store
async authy.core.session.readUser(template) : Promise<Object>
Reads from currently logged in user's user data params:
template:object
- Template Object as described in cross-destruct