{"id":19178048,"url":"https://github.com/cmdruid/nostr-storage","last_synced_at":"2025-06-10T09:06:02.994Z","repository":{"id":61630031,"uuid":"553221368","full_name":"cmdruid/nostr-storage","owner":"cmdruid","description":"A shared, encrypted cloud storage using Nostr.","archived":false,"fork":false,"pushed_at":"2022-11-06T07:08:09.000Z","size":43,"stargazers_count":21,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-07T20:43:31.213Z","etag":null,"topics":["cloud-storage","collaboration","end-to-end-encryption","nostr"],"latest_commit_sha":null,"homepage":"https://cmdruid.github.io/nostr-storage/example/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cmdruid.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":"2022-10-17T22:51:28.000Z","updated_at":"2025-03-25T14:29:09.000Z","dependencies_parsed_at":"2023-01-21T23:05:09.713Z","dependency_job_id":null,"html_url":"https://github.com/cmdruid/nostr-storage","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/cmdruid%2Fnostr-storage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmdruid%2Fnostr-storage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmdruid%2Fnostr-storage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmdruid%2Fnostr-storage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cmdruid","download_url":"https://codeload.github.com/cmdruid/nostr-storage/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmdruid%2Fnostr-storage/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":258788726,"owners_count":22758226,"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":["cloud-storage","collaboration","end-to-end-encryption","nostr"],"created_at":"2024-11-09T10:36:30.810Z","updated_at":"2025-06-10T09:06:02.962Z","avatar_url":"https://github.com/cmdruid.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nostr-storage\nA shared, encrypted cloud data store using Nostr.\n\n## Installation\nThis package is designed to work in both the browser and nodejs.\n\n```html\n\u003c!-- Browser import --\u003e\n\u003cscript src='https://bundle.run/noble-secp256k1@1.2.14'\u003e\u003c/script\u003e\n\u003cscript src=\"https://unpkg.com/@cmdcode/nostr-emitter\"\u003e\u003c/script\u003e\n\u003cscript src=\"https://unpkg.com/@cmdcode/nostr-storage\"\u003e\u003c/script\u003e\n```\n\n```js\n// Commonjs import.\nconst NostrStorage = require('@cmdcode/nostr-storage')\n// ES6 import.\nimport NostrStorage from '@cmdcode/nostr-storage'\n```\n\n## How to Use\nTo get started, define a `new NostrStore()` object, then provide a relay server and shared secret to `store.connect()`. Once connected, the store behaves like a typical localStorage object.\n\n```js\n// Declare a new store object.\nconst store = new NostrStore()\n\n// Connect your store to the relay.\nawait store.connect(\n  'wss://nostr-relay.wlvs.space',\n  'secret-string'\n)\n\n// NostrStore exposes a basic Map / localStorage API.\nstore\n  .has('key') =\u003e Promise(true || false)\n  .get('key') =\u003e Promise('value')\n  .keys()     =\u003e [ 'key1', 'key2' ... ]\n  .values()   =\u003e [ 'val1', 'val2' ... ]\n  .entries()  =\u003e [ ['key1', 'val1'], ['key2', 'val2'] ... ]\n\n// You can use NostrStore in an iterator.\nfor (let [ key, val ] of store) {\n  console.log(key, val)\n}\n\n// These methods will return whether the data operation suceeded.\nstore\n  .set('key', 'value') =\u003e Promise(true || false)\n  .delete('key')       =\u003e Promise(true || false)\n  .clear()             =\u003e Promise(true || false)\n\n// These methods assist with data fetching under the hood.\nstore\n  .refresh()  // Fetch the latest copy of data from the relay.\n  .commit()   // Commit the current data store to the relay.\n  .destroy()  // Marks the data store for deletion (using NIP 9).\n\n// NostrStore is configurable with some basic options.\nconst store = new NostrStore({\n  refreshTimeout: 5000,  // Timeout to refresh data before a has/get op.\n  commitTimeout: 5000,   // Timeout on confirming a commit op suceeded.\n  emitter: { /* You can also configure the emitter here. */ }\n})\n```\n\n## How it Works\nNostr Storage uses replace-able events in order to store a serialized (and encrypted) copy of the data store. The shared secret is hashed multiple times, with each round used to generate the signature keys, encryption keys, and finally a label for filtering the events.\n\nIt is safe to reveal the encryption key, without revealing the signature key.\n\nThis project uses nostr-emitter. To fully understand how it all works, see this link: https://github.com/cmdruid/nostr-emitter\n\n\n## Resources\n\n**Nostr Emitter**  \nUsed under-the-hood for talking to relays.  \nhttps://github.com/cmdruid/nostr-emitter\n\n**Nostr Implementation Possibilities**  \nhttps://github.com/nostr-protocol/nips\n\n**Nostr-tools**  \nhttps://github.com/fiatjaf/nostr-tools\n\n## Contributions\nAll contributions are welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmdruid%2Fnostr-storage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcmdruid%2Fnostr-storage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmdruid%2Fnostr-storage/lists"}