Open saranrapjs opened 6 years ago
Based on my understanding of how hypercore
and hyperdb
work, there
can only be one feed for a given keypair. The hyperdb internals assume
this.
hyperdb doesn't expose hooks for adding your own authorization checks yet. If that gets implemented, it'd be easier to block or ingore writes that don't match your constraint (signed by a certain private key).
Can you say a bit more about what you're trying to do this for? There might be another way of doing what you're after.
Ah, that's clarifying. What I'm after: slightly more permissive peer-replicated hypercores, without losing the crypto verification/signatures. I like how the Dat key is used as a capability token for reading feeds, and was hoping to build something where: having the public key grants you "write" access to a hypercore or set of hypercores, without requiring explicit authorization by the original "owner" of the hypercore. It seems like I might just need to cook something up with vanilla hypercore, or just think this thru a little further first at a minimum...
Maybe you could implement this by putting a layer over the hyperdb replication stream:
db.authorize()
sometime during this handshake).
I'm curious to implement a hyperdb where the public/private keypair are treated as a "capability" code, where anyone who has them can write to the same hyperdb. Is replication between the same keypair something which should (theoretically) work with hyperdb/hypercore?
I tried something like the following, but the replication doesn't seem to work (totally possible I'm doing this the wrong way):
I was looking into the
hypercore-protocol
code, which has a hook for specifying a stream id to "to detect if you connect to yourself". I'd be happy to dig in further (while admitting that I'm a little out of my depth here!) unless there's some fundamental architectural reason why replicating between identical keypairs shouldn't be supported?