@alfa-wells/alfa-security-client

0.1.0 • Public • Published

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'
}

Readme

Keywords

none

Package Sidebar

Install

npm i @alfa-wells/alfa-security-client

Weekly Downloads

0

Version

0.1.0

License

ISC

Unpacked Size

23.9 kB

Total Files

11

Last publish

Collaborators

  • leolobeto