Ruulul / hyper-nostr

33 stars 9 forks source link

πŸ“’ Cook Book - Problem 0: Custom Isolated App Use #9

Open benzmuircroft opened 10 months ago

benzmuircroft commented 10 months ago

Please note that this code is more than likely totally wrong (Until updated/fixed by @5-142857 as discussed on discord)

NIPs

For a full list of the Nostr protocol NIPS (Nostr Implementation Protocols) see: nostr-protocol/nips

πŸ“’ Custom Isolated App Use

Most developers using this implementation of the Nostr protocol will want to use it to build social media applications that rival Twitter and Mastadon, whereas; hyper-nostr has wide ranging, broader use cases as a tool in standalone p2p app development (where the app itself may be relying on it's own internal app users to connect data in ways that a simple hypercore/autobase lacks).

Use Cases

Reasoning

autobase falls short in linking literally everyone automatically together on a shared object due to it's single writer nature. Not to mention that It needs the developer to know and manage adding writers. Now, understand that hyper-nostr can be used to solve these problems, by working alongside autobase and being the needed shared multi-writer object! πŸ˜‰

To Do

In /hyper-nostr/swarm.js can you please add this update?

const prefix = 'hyper-nostr-'

export default async function createSwarm (sdk, _topic, opts) {
  if (!opts) opts = {}; 
  const topic = (opts.prefix) ? opts.prefix + _topic : prefix + _topic
  ...

So that developers can use this module privately with their users (optionally) like:

createSwarm(sdk, topic); // normal hyper-nostr- known to any users on nostr
// or
createSwarm(sdk, topic, { prefix: '' }); // totally isolated to the current app
// or
createSwarm(sdk, topic, { prefix: 'myapp-' }); // isolated to a network namespace on any apps who know the namespace
// or
createSwarm(sdk, topic, { prefix: `nike-${ authKey }-` }); // protected by the nike network apps
// or
createSwarm(sdk, topic, { prefix: `${aes.decode('71a936f2a1e6bbad750933436343519983d34eecfef00d7a97b32b1103dbb0db')}-` }); // known by none / hard-coded

This will optionally allow them to isolate their apps away from the default, public hyper-nostr- discovery!