This project is in alpha status. The API is changing constantly, and we strongly encourage you to wait for a stable release to start using it.
masq-lib
is a JavaScript library developers can use to integrate Masq into their apps.
npm install masq-lib --save
npm install
npm test
npm run stats
npm run analyze
const Masq = require('masq-lib')
const masq = new Masq(
'TestApp',
'Some User-app',
'http://www.some-user-app.com/logo.png'
)
if (masq.isLoggedIn()) {
await masq.connectToMasq()
} else {
const link = await masq.getLoginLink()
// Display link to the user
// and ask if he wants to stay connected on restart until he signs out
const stayConnected = false
// Once the link is opened, execute the following code
await masq.logIntoMasq(stayConnected)
await masq.put('someKey', 'someValue')
const val = await masq.get('someKey')
}
Create a new instance of Masq.
appName
is the name of the app.
appDescription
is a short description of the app.
appLogoURL
is a link to a logo of the app.
Returns a boolean, true if a User is already logged into Masq, false if not. The User can read and write data stored in his Masq only if he is logged in. This does not necessarily mean the data is synced, masq.isConnected() needs to be true for data to be synced between the different connected devices.
Returns a boolean, true if a User is already logged into Masq and if the User-app is already connected to Masq. The User data is synced between the different connected devices only when the User is connected.
Connects to Masq if a User is already logged into Masq. The data will then be synced between the different connected devices of the User.
Signs out of Masq from Masq. This also means the User-app data on the device will stop being synced.
The function returns a Promise resolving to an Url which must be opened by the user in order to connect to Masq.
stayConnected
is a boolean representing if the User should stay connected until he explicitely signs out or only until he closes the User-app.
This function starts the login procedure with an instance of Masq-app Once the user accesses the link and connects to his profile, the login will end and the returned promise will resolve.
Returns a promise resolving with the value stored for the provided key
.
Returns a promise resolving when the key
/value
pair is stored.
Returns a promise resolving when the key/value pais is deleted for the specified key
.
Adds the event handler callback
called when the key/value pair for the specified key
is updated.
Returns a Promise resolving with an object containing each key/value pairs as attribute/value pairs.