{"id":14384463,"url":"https://github.com/tabcat/encrypted-docstore","last_synced_at":"2025-08-23T17:32:19.625Z","repository":{"id":35077604,"uuid":"196662420","full_name":"tabcat/encrypted-docstore","owner":"tabcat","description":"create and mount encrypted orbit docstores in the browser","archived":true,"fork":false,"pushed_at":"2022-01-22T09:32:00.000Z","size":1244,"stargazers_count":6,"open_issues_count":13,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-25T17:43:58.579Z","etag":null,"topics":[],"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/tabcat.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":"2019-07-13T00:51:59.000Z","updated_at":"2023-08-26T02:06:18.000Z","dependencies_parsed_at":"2022-08-08T04:16:26.607Z","dependency_job_id":null,"html_url":"https://github.com/tabcat/encrypted-docstore","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/tabcat%2Fencrypted-docstore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tabcat%2Fencrypted-docstore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tabcat%2Fencrypted-docstore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tabcat%2Fencrypted-docstore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tabcat","download_url":"https://codeload.github.com/tabcat/encrypted-docstore/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230716530,"owners_count":18269783,"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":[],"created_at":"2024-08-28T18:01:24.551Z","updated_at":"2024-12-21T12:30:37.335Z","avatar_url":"https://github.com/tabcat.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# encrypted-docstore\ncreate and mount encrypted [orbit-db](https://github.com/orbitdb/orbit-db/) docstores\n\n**DISCLAIMER: cryptography in this repo has been implemented by an amateur and has not been auditted. \u003cbr/\u003ePlease :fire:roast:fire: me in Issues if u find a vulnerability.**\n\nNOTE: version 3.0.0 changes how EncryptedDocstore determines the orbitdb address, this is a breaking change. Some changes have been made to the api as well, mostly naming.\n\n## Usage\ninstall with npm:\n```\nnpm install @tabcat/encrypted-docstore\n```\ncreate orbitdb instance: https://github.com/orbitdb/orbit-db/blob/master/README.md#usage\n\ncreate encrypted docstore:\n```javascript\nconst EncryptedDocstore = require('@tabcat/encrypted-docstore')\n\n// create the encryption key\nconst aesKey = EncryptedDocstore.generateKey()\n\n// create the docstore with orbitdb:\nconst dbConfig = { name:'asdf', options: {} } // type will always be 'docstore'\nconst encAddr = await EncryptedDocstore.determineAddress(orbitdb, dbConfig, aesKey)\nconst docstore = await orbitdb.docs(encAddr, dbConfig.options)\n\nconst encDocstore = await EncryptedDocstore.mount(docstore, aesKey)\n// get,put, del, query all exposed on encDocstore and returned results should be identical to docstore methods\n\n```\n\n## API \u003cbr/\u003e\n\u003eEncDoc = EncryptedDocstore\n\n### Static Methods:\n#### EncDoc.mount(docstore, aesKey)\n\u003emount an encrypted docstore\n\n*docstore:* orbit docstore made with name from EncDoc.determineEncDbName or address from EncDoc.determineEncDbAddress\u003cbr/\u003e\n*aesKey:* instance of AesKey from generateKey, deriveKey, or importKey static methods.\n\nreturns a promise that resolves to an instance of EncDoc\n#### EncDoc.determineAddress(orbitdb, dbConfig, aesKey)\n\u003edetermine the docstore address for the encryptedDocstore, this is adding a way to check the aesKey against the db name\n\n*orbitdb:* an instance of OrbitDB\u003cbr/\u003e\n*dbConfig:* an object containing name and options for an orbit store settings\u003cbr/\u003e\n*aesKey:* instance of AesKey from generateKey, deriveKey, or importKey static methods.\u003cbr/\u003e\n\nreturns a promise that resolves to an instance of orbit address\n#### EncDoc.keyCheck(encAddr, aesKey)\n\u003echeck if an orbitdb address and aesKey are a match\n\n*encAddr:* instance of orbit address from EncDoc.determineAddress\u003cbr/\u003e\n*aesKey:* instance of AesKey from generateKey, deriveKey, or importKey static methods.\u003cbr/\u003e\n\nreturns a promise that resolves to a boolean\n#### EncDoc.generateKey([length])\n\u003egenerates a new aesKey\n\n*length:* number, aesKey length, defaults to 128. can be  128, 192, or 256\u003cbr/\u003e\n\nreturns an instance of AesKey\n#### EncDoc.deriveKey(bytes, salt[, length])\n\u003ederive an instance of AesKey from bytes and salt, uses PBKDF2 with 10k iterations\n\n*bytes:* Uint8Array made from randomness or a strong password\u003cbr/\u003e\n*salt:* Uint8Array to be used as salt for deriving the key, optimally a 128bit random value\u003cbr/\u003e\n*length:* number, aesKey length, defaults to 128. can be  128, 192, or 256\u003cbr/\u003e\n\nreturns an instance of AesKey\n#### EncDoc.importKey(rawKey)\n\u003eimport an exported aesKey\n\n*rawKey:* Uint8Array from EncDoc.exportKey\n\nreturns an instance of AesKey\n#### EncDoc.exportKey(aesKey)\n\u003eexport an aesKey\n\n*aesKey:* instance of AesKey\n\nreturns a Uint8Array rawKey\n\n### Instance Methods:\n  - get, put, del, query all work by encapsulating the whole doc and pass docstore tests for the orbitdb repo: https://github.com/orbitdb/orbit-db/blob/master/test/docstore.test.js\n#### encDoc.get(key)\nsee: https://github.com/orbitdb/orbit-db/blob/master/API.md#getkey-1\n\ndifferences:\n  - is an async function\n#### encDoc.put(doc)\n\u003esee: https://github.com/orbitdb/orbit-db/blob/master/API.md#putdoc\n\nno visible differences\n#### encDoc.del(key)\n\u003esee: https://github.com/orbitdb/orbit-db/blob/master/API.md#delkey-1\n\nno visible differences\n#### encDoc.query(mapper)\n\u003esee: https://github.com/orbitdb/orbit-db/blob/master/API.md#querymapper\n\ndifferences:\n  - is an async function\n  - when calling with option fullOp:\n    + the payload.value is the decrypted/decapsulated doc.\n    + anything in the fullOp entry relating to hashing the real payload.value will not match the payload.value\n  - when not calling with option fullOp:\n    + no visible differences\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftabcat%2Fencrypted-docstore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftabcat%2Fencrypted-docstore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftabcat%2Fencrypted-docstore/lists"}