The Databunker Store is a Node.js client library for Databunker API to store personal records. Databunker is a Swiss army knife tool for encrypted storage of personal records or PII:
You need to have databunker service up and running.
You can use the following command to start Databunker in development mode:
docker run -p 3000:3000 -d --rm --name dbunker securitybunker/databunker demo
For production use, follow the Databunker installation guide: https://databunker.org/doc/install/
npm install --save @databunker/store
const DatabunkerStore = require('@databunker/store');
const databunker = new DatabunkerStore({
url: process.env.DATABUNKER_URL,
token: process.env.DATABUNKER_TOKEN
});
const newUser = {
issuer: user.issuer,
email: userMetadata.email,
lastLoginAt: user.claim.iat
};
const result = await databunker.users.create(newUser);
const user = await databunker.users.get("email", "[email protected]");
const user2 = await databunker.users.get("token", "a3542566-4491-11eb-8269-2e04ce962524");
cont change = { lastLoginAt: user.claim.iat };
await databunker.users.set("token", "a3542566-4491-11eb-8269-2e04ce962524", change);
async function loadSignupAgreements() {
const allAgreements = await databunker.agreements.rawlist();
let agreements = [];
if (allAgreements.status == "ok") {
for (const idx in allAgreements.rows) {
const r = allAgreements.rows[idx];
if (r.module == 'signup-page' && r.basistype == "consent") {
agreements.push(r);
}
}
}
return agreements;
}
const appData = {country: "EU"}
await databunker.collection("data").set("token", "a3542566-4491-11eb-8269-2e04ce962524", data);
const data = await databunker.collection("data").get("token", req.user.token);
await databunker.agreements.accept("email", req.body.email, "privacy-accept", {});
await databunker.agreements.withdraw("email", req.body.email, "privacy-accept");
const { v4: uuidv4 } = require('uuid');
const app = require('express')();
const DatabunkerStore = require('@databunker/store');
const port = 3200;
const host = '0.0.0.0';
const DataBunkerConf = {
url: 'http://localhost:3000',
token: 'DEMO'
};
const databunker = new DatabunkerStore(DataBunkerConf);
app.get('/', async (req, res) => {
const user = await databunker.users.get("phone", "4444");
const data = user.data;
res.send("user: "+data["email"]+"\n");
res.end();
})
app.listen(port, host, () => {
console.log(`Example app listening at http://${host}:${port}`)
})