{"id":18542702,"url":"https://github.com/securitybunker/databunker-store","last_synced_at":"2025-05-15T05:09:53.914Z","repository":{"id":57106081,"uuid":"322059601","full_name":"securitybunker/databunker-store","owner":"securitybunker","description":"Databunker storage class for nodejs","archived":false,"fork":false,"pushed_at":"2021-04-10T21:46:38.000Z","size":16,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-15T05:09:37.140Z","etag":null,"topics":["databunker","login","login-system","passportjs","privacy","security","tokenization"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/securitybunker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-16T17:49:52.000Z","updated_at":"2022-02-14T10:16:09.000Z","dependencies_parsed_at":"2022-08-20T23:50:51.174Z","dependency_job_id":null,"html_url":"https://github.com/securitybunker/databunker-store","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/securitybunker%2Fdatabunker-store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/securitybunker%2Fdatabunker-store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/securitybunker%2Fdatabunker-store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/securitybunker%2Fdatabunker-store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/securitybunker","download_url":"https://codeload.github.com/securitybunker/databunker-store/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254276463,"owners_count":22043868,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["databunker","login","login-system","passportjs","privacy","security","tokenization"],"created_at":"2024-11-06T20:09:40.815Z","updated_at":"2025-05-15T05:09:48.905Z","avatar_url":"https://github.com/securitybunker.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# databunker-store\n\nThe **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**:\n\n* https://databunker.org/\n* https://databunker.org/use-case/privacy-by-design-default/\n\n\nPrerequisites\n-------------\nYou need to have **databunker** service up and running.\n\nYou can use the following command to start Databunker in development mode:\n\n```docker run -p 3000:3000 -d --rm --name dbunker securitybunker/databunker demo```\n\nFor production use, follow the Databunker installation guide: https://databunker.org/doc/install/\n\n\nInstallation\n------------\n\n```npm install --save @databunker/store```\n\n\n# Examples\n\n## Init access\n\n```\nconst DatabunkerStore = require('@databunker/store');\nconst databunker = new DatabunkerStore({\n  url: process.env.DATABUNKER_URL,\n  token: process.env.DATABUNKER_TOKEN\n});\n```\n\n## Create user record\n\n```\nconst newUser = {\n  issuer: user.issuer,\n  email: userMetadata.email,\n  lastLoginAt: user.claim.iat\n};\nconst result = await databunker.users.create(newUser);\n```\n\n## Get user record\n\n```\nconst user = await databunker.users.get(\"email\", \"user@gmail.com\");\nconst user2 = await databunker.users.get(\"token\", \"a3542566-4491-11eb-8269-2e04ce962524\");\n```\n\n## Update user record\n```\ncont change = { lastLoginAt: user.claim.iat };\nawait databunker.users.set(\"token\", \"a3542566-4491-11eb-8269-2e04ce962524\", change);\n```\n\n## Extract all agreements to displayed on the signup page\n```\nasync function loadSignupAgreements() {\n  const allAgreements = await databunker.agreements.rawlist();\n  let agreements = [];\n  if (allAgreements.status == \"ok\") {\n    for (const idx in allAgreements.rows) {\n      const r = allAgreements.rows[idx];\n      if (r.module == 'signup-page' \u0026\u0026 r.basistype == \"consent\") {\n        agreements.push(r);\n      }\n    }\n  }\n  return agreements;\n}\n```\n\n## Save data in user app collection\n```\nconst appData = {country: \"EU\"}\nawait databunker.collection(\"data\").set(\"token\", \"a3542566-4491-11eb-8269-2e04ce962524\", data);\n```\n\n## Read user data from app collection\n```\nconst data = await databunker.collection(\"data\").get(\"token\", req.user.token);\n```\n\n## Accept an agreement\n```\nawait databunker.agreements.accept(\"email\", req.body.email, \"privacy-accept\", {});\n```\n\n## Withdraw an agreement\n```\nawait databunker.agreements.withdraw(\"email\", req.body.email, \"privacy-accept\");\n```\n\n## Full example\n\n```\nconst { v4: uuidv4 } = require('uuid');\nconst app = require('express')();\nconst DatabunkerStore = require('@databunker/store');\n\nconst port = 3200;\nconst host = '0.0.0.0';\nconst DataBunkerConf = {\n  url: 'http://localhost:3000',\n  token: 'DEMO'\n};\nconst databunker = new DatabunkerStore(DataBunkerConf);\n\napp.get('/', async (req, res) =\u003e {\n  const user = await databunker.users.get(\"phone\", \"4444\");\n  const data = user.data;\n  res.send(\"user: \"+data[\"email\"]+\"\\n\");\n  res.end();\n})\n\napp.listen(port, host, () =\u003e {\n  console.log(`Example app listening at http://${host}:${port}`)\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsecuritybunker%2Fdatabunker-store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsecuritybunker%2Fdatabunker-store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsecuritybunker%2Fdatabunker-store/lists"}