Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
masq-client
Advanced tools
Readme
Promise-based client library for Qwant Masq. It allows applications to connect to the Masq Hub (central data manager) to store and retrieve application data.
git clone https://github.com/QwantResearch/masq-client.git
cd client
npm install
npm start
Add the client JS reference in your page:
<script type="text/javascript" src="dist/masq.js"></script>
Or the minified version:
<script type="text/javascript" src="dist/masq.min.js"></script>
You can also use the online version hosted on Github pages:
<script type="text/javascript" src="https://qwantresearch.github.io/masq-client/dist/masq.min.js"></script>
Using the client library in your app:
// Define the hub URL (where the data will be persisted)
var hubURL = 'https://qwantresearch.github.io/masq-hub/'
// Initialize the store
var masqStore = new MasqClient()
// Your app data (store)
var appData = {}
// Load all remote app state on initial connect
var getRemoteData = function () {
return masqStore.getAll()
}
masqStore.onConnect().then(getRemoteData).then(function (res) {
// update your local store
appData = res
console.log('Loaded remote app state:', appData)
// Add some data in case it's the first time
if (!appData['counter']) {
appData['counter'] = 0
}
// Update a few values
appData['counter']++
appData['date'] = Date.now()
// persist all local data remotely
masqStore.setAll(appData).then(function () {
console.log('Wrote updated value for key "counter":', appData['counter'])
// retrieve the remote state for one particular key (e.g. counter)
masqStore.get('counter').then(function (res) {
console.log('Got remote value for key "counter":', res)
if (appData['counter'] === 2) {
// delete the counter data remotely
masqStore.del('counter').then(getRemoteData).then(function (res) {
console.log('Loaded remote app state:', res)
// clear remote store
masqStore.clear().then(getRemoteData).then(function (res) {
console.log('Loaded remote app state:', res)
})
})
}
})
})
}).catch(function (err) {
console.log(err)
})
var masqStore = new MasqClient()
var appData = {}
appData.date = Date.now() // 1510847132596
appData.text = 'Hello'
masqStore.setAll(appData).then(function () {
// success
}).catch(function (err) {
console.log(err)
})
masqStore.onConnect().then(function () {
masqStore.getAll().then(function (data) {
console.log(data) // prints { date: 1510847132596, text: "Hello" }
}).catch(function (err) {
console.log(err)
})
}).catch(function (err) {
console.log(err)
})
masqStore.set('text', 'Hello world').then(function () {
// success
}).catch(function (err) {
console.log(err)
})
masqStore.get('text').then(function (res) {
console.log(res) // prints "Hello world"
}).catch(function (err) {
console.log(err)
})
masqStore.del('date').then(function () {
// success, we have deleted the key "date"
// let's fetch all the remote data to take a look at what's left
masqStore.getAll().then(function (data) {
console.log(data) // prints { text: "Hello world" }
}).catch(function (err) {
console.log(err)
})
}).catch(function (err) {
console.log(err)
})
masqStore.clear().then(function() {
masqStore.getAll().then(function (data) {
console.log(data) // prints {}
}).catch(function (err) {
console.log(err)
})
}).catch(function (err) {
console.log(err)
})
Apache-2.0
FAQs
Client library for Masq
We found that masq-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).