A shared, encrypted cloud storage using Nostr.

Overview

nostr-storage

A shared, encrypted cloud data store using Nostr.

Installation

This package is designed to work in both the browser and nodejs.

<!-- Browser import -->
<script src='https://bundle.run/[email protected]'></script>
<script src="https://unpkg.com/@cmdcode/nostr-emitter"></script>
<script src="https://unpkg.com/@cmdcode/nostr-storage"></script>
// Commonjs import.
const NostrStorage = require('@cmdcode/nostr-storage')
// ES6 import.
import NostrStorage from '@cmdcode/nostr-storage'

How to Use

To 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.

// Declare a new store object.
const store = new NostrStore()

// Connect your store to the relay.
await store.connect(
  'wss://nostr-relay.wlvs.space',
  'secret-string'
)

// NostrStore exposes a basic Map / localStorage API.
store
  .has('key') => Promise(true || false)
  .get('key') => Promise('value')
  .keys()     => [ 'key1', 'key2' ... ]
  .values()   => [ 'val1', 'val2' ... ]
  .entries()  => [ ['key1', 'val1'], ['key2', 'val2'] ... ]

// You can use NostrStore in an iterator.
for (let [ key, val ] of store) {
  console.log(key, val)
}

// These methods will return whether the data operation suceeded.
store
  .set('key', 'value') => Promise(true || false)
  .delete('key')       => Promise(true || false)
  .clear()             => Promise(true || false)

// These methods assist with data fetching under the hood.
store
  .refresh()  // Fetch the latest copy of data from the relay.
  .commit()   // Commit the current data store to the relay.
  .destroy()  // Marks the data store for deletion (using NIP 9).

// NostrStore is configurable with some basic options.
const store = new NostrStore({
  refreshTimeout: 5000,  // Timeout to refresh data before a has/get op.
  commitTimeout: 5000,   // Timeout on confirming a commit op suceeded.
  emitter: { /* You can also configure the emitter here. */ }
})

How it Works

Nostr 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.

It is safe to reveal the encryption key, without revealing the signature key.

This project uses nostr-emitter. To fully understand how it all works, see this link: https://github.com/cmdruid/nostr-emitter

Resources

Nostr Emitter
Used under-the-hood for talking to relays.
https://github.com/cmdruid/nostr-emitter

Nostr Implementation Possibilities
https://github.com/nostr-protocol/nips

Nostr-tools
https://github.com/fiatjaf/nostr-tools

Contributions

All contributions are welcome!

You might also like...

Mag🔥Lit - A super fast and easy-to-use free and open source private encrypted Magnet/HTTP(s) Link Shortener

Mag🔥Lit - A super fast and easy-to-use free and open source private encrypted Magnet/HTTP(s) Link Shortener

Mag 🔥 Lit Mag 🔥 Lit - A super fast and easy-to-use free and open source private encrypted Magnet/HTTP(s) Link Shortener https://maglit.ml Features ✅

Jan 8, 2023

This CLI tool allows you to convert the encrypted Akamai 2.0 sensor data payload back to its plaintext form.

Akamai 2.0 Sensor Data Decryption Tool This CLI tool allows you to convert the encrypted Akamai 2.0 sensor data payload back to its plaintext form. Us

Jan 1, 2023

An end-to-end encrypted note taking alternative to Evernote

An end-to-end encrypted note taking alternative to Evernote

Notesnook An end-to-end encrypted note taking alternative to Evernote. Website | About us | Roadmap | Downloads | Twitter | Discord To celebrate the o

Dec 28, 2022

Solid.js library adding a services layer for global shared state.

Solid.js library adding a services layer for global shared state.

Solid Services Services are "global" objects useful for features that require shared state or persistent connections. Example uses of services might i

Dec 30, 2022

Shared eslint configuration for Strapi v4 plugins & applications.

This package is currently under development and should be consider ALPHA in terms of state. I/We are currently accepting contributions and/or dedicated contributors to help develop and maintain this package.

Oct 28, 2022

MultiSafe is a shared crypto wallet for managing Stacks (STX) and Bitcoin (BTC).

MultiSafe MultiSafe is a shared crypto wallet for managing Stacks (STX) and Bitcoin (BTC). Deploy a MultiSafe https://app.multisafe.xyz/ Features Curr

Dec 26, 2022

🧠 My second brain — Ideas, thoughts, resources, notes… All publicly shared in one place.

🧠 Second Brain Welcome to my second brain. This is a collection of notes, journals, and resources written or collected by me (@pixelsbyeryc), in an a

May 4, 2022

⚙️ Monorepo for shared configurations used in Alphaworks

@alpha-dao/shared-config Usage Shared Config Wondering which configuration to use when starting a new project? Then you're probably looking for this m

Nov 17, 2022

Example code for MFE routing, shared state, build-time & runtime deploy video

Turborepo starter with pnpm This is an official starter turborepo. What's inside? This turborepo uses pnpm as a packages manager. It includes the foll

Nov 2, 2022
Owner
cmd
I enjoy the bleeding-edge of technology. #Python #Typescript #React #Node #Docker #Tor #Bitcoin #Lightning <3
cmd
Vaultacks lets users store files off-chain on Gaia. Files are encrypted by default but also can be made public and shared

Vaultacks Vaultacks is built on the Stacks Chain. It lets users upload files to Gaia, a off-chain data storage system. Vaultacks currently uses the de

Anish De 5 Sep 14, 2022
decentralized social network using #nostr

Nauka Nauka is an attempt at creating a social network using the nostr protocol. For now it is just a nostr relay that runs on nodejs, but is going to

null 12 Aug 31, 2022
Send encrypted messages and decrypt them without sharing keys. Built using the Handshake blockchain.

zmsg Encrypt and decrypt messages using AEAD with an ephemeral key Learn more by joining the Handshake Discord Community I noticed that there wasn't a

Publius Federalist 31 Jul 27, 2022
Keyauth v1 example, includes a demo and is encrypted using aes.

Keyauth Keyauth V1.0 api wrapper in nodejs that includes requests being encrypted using aes. Discord & Support Server . Keyauth Example const Keyauth

null 3 Nov 27, 2022
A GitHub Action to cache your workload to a Google Cloud Storage bucket.

Google Cloud Storage Cache Action GitHub already provides an awesome action to cache your workload to Azure's servers hosted in United States. However

MansaGroup 9 Dec 15, 2022
The officially supported cloud storage plugin for Payload CMS.

Payload Cloud Storage Plugin This repository contains the officially supported Payload Cloud Storage plugin. It extends Payload to allow you to store

Payload 43 Dec 21, 2022
Exploit chrome's profile sync for free cloud storage

BookmarkFS - the dumbest project i've ever made Exploits the google chrome bookmark sync service to store files for free Installation and usage Go to

CoolElectronics 319 Dec 30, 2022
Keep your sensitive information out of chat logs, emails, and more with heavily encrypted secrets.

Free encrypted secret sharing for everyone! This application is to be used to share encrypted secrets cross organizations, or as private persons. Hemm

Hemmelig 246 Dec 31, 2022
Send encrypted and decrypted messages with verifiable keys and human readable names.

zooko-msg Encrypt and decrypt messages using AES with a preshared ECDH key generated using keys associated with Handshake names. I noticed that there

Publius Federalist 31 Jul 27, 2022
End-to-end encrypted environments

Welcome to the EnvKey v2 monorepo! All EnvKey's open source code lives here. End-to-end encrypted environments Fixes configuration sprawl and sloppy s

EnvKey 360 Jan 1, 2023