justlogin.xyz-client
Example
Create a server:
var db = './databases/core'var core = dbvar sessionState = core dbvar server = var sock = core sessionState sock
Create a client:
var justLoginClient = var client = clientclient
API
var client =
Server Side
var sock = client(core, sessionState)
core
is ajust-login-core
object.sessionState
is ajust-login-session-state
object.- Returns a
sock
object.
var sock = sock
Client Side
var emitter = client(dnodeEndpoint, cb)
This function handles remembering the session id in the browser's local storage.
dnodeEndpoint
is a string for the endpoint that dnode uses for communication. The string must start with a forward slash/
.cb
is a function that has the following arguments:err
is eithernull
or anError
object.newApi
is an object with methods fromjust-login-core
andjust-login-session-state
, but with thesessionId
pre-bound:beginAuthentication(contactAddress, [cb])
fromjust-login-core
isAuthenticated(cb)
fromjust-login-session-state
unauthenticate([cb])
fromjust-login-session-state
sessionExists(cb)
fromjust-login-session-state
sessionId
is the new (or previous, when applicable) session id.
- Returns
emitter
which can emit the following events:session
is emitted when a session is initiated. An object is emitted with the following properties:sessionId
The id for the current session. E.g.3879533a-1f34-11e4-a8de-c92c3319c4e0
continued
Whether or not the session was continued from a previous session. E.g.true
,false
authenticated
is emitted when the user gets authenticated.email
is the email of the user who logged in. E.g.you@youremail.com
emitter emitter
Install
Install with npm
npm install justlogin.xyz-client