@alfa-wells/alfa-security-client
v0.1.0
Published
Client for Alfa-Security
Downloads
2
Readme
Alfa-Security-Client
Client for Alfa-Security service REST API.
How to use
Install
npm install @alfa-wells/alfa-security-client --save
Example
const SecurityClient = require('@alfa-wells/alfa-security-client')
const client = Client('http://localhost:3003')
//Inside an async function
let instances = await client.instances()
// instance = [ { id: 'my-instance', name: 'My Instance', type: 'oracle' } ]
let session = await client.login('my-instance', 'john.doe', '12345')
let user = await session.get('user')
// user == { name: 'john.doe', ... }
await session.set('lastWindowPosition', { top: 27, left: 100 })
// New property is saved immediately
// Later...
let session = await client.session(sessionId)
let position = await retrieved.get('lastWindowPosition')
// position.top == 27 && position.left == 100
await session.update({
lastWindowPosition: { top: 50, left: 25 },
user: undefined
})
// Property `lastWindowPosition` is updated, property `user` is removed
await session.logout()
// Session no longer exist
try {
// Throws an exception
session = await client.session(sessionId)
} catch (err) {
// err.code == 'alfa.security.sessionExpired'
}