npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dao-xyz/peerbit-trusted-network

v1.0.5

Published

Access controller that operates on a DB

Downloads

187

Readme

Trusted network

A store that lets you build trusted networks of identities The store is defined by the "root trust" which have the responsibility in the beginning to trust additional identities. Later, these identities can add more identities to the network. Trusted identities can also be revoked.

Distributing content among untrusted peers will be unreliable and not resilient to malicious parties that starts to participate in the replication process with large amount (>> min replicas) of nodes and shutting them down simultaneously (no way for the original peers recover all lost data). To mitigate this you can launch your program in a "Network", which is basically a list of nodes that trust each other. Symbolically you could thing of this as a VPC.

To do this, you only have to implement the "Network" interface:

import { Peerbit, Network } from '@dao-xyz/peerbit'
import { Log } from '@dao-xyz/peerbit-log'
import { Program } from '@dao-xyz/peerbit-program' 
import { TrustedNetwork } from '@dao-xyz/peerbit-trusted-network' 
import { field, variant } from '@dao-xyz/borst-ts' 

@variant("string_store") 
@network({property: 'network'})
class StringStore extends Program
{
    @field({type: Store})
    log: Log<string>

    @field({type: TrustedNetwork}) 
    network: TrustedNetwork // this is a database storing all peers. Peers that are trusted can add new peers

    constructor(properties:{ log: Store<any>, network: TrustedNetwork }) {
       
		this.log = properties.store
		this.network = properties.network;
        
    }

    async setup() 
    {
        await store.setup({ encoding: ... , canAppend: ..., canRead: ...})
        await trustedNetwork.setup()
    }
}


// Later 
const peer1 = await Peerbit.create(LIBP2P_CLIENT, {... options ...})
const peer2 = await Peerbit.create(LIBP2P_CLIENT_2, {... options ...})

const programPeer1 = await peer1.open(new StringStore({log: new Log(), network: new TrustedNetwork()}), {... options ...})

// add trust to another peer
await program.network.add(peer2.identity.publicKey) 


// peer2 also has to "join" the network, in practice this means that peer2 adds a record telling that its Peer ID trusts its libp2p Id
const programPeer2 = await peer2.open(programPeer1.address, {... options ...})
await peer2.join(programPeer2) // This might fail with "AccessError" if you do this too quickly after "open", because it has not yet recieved the full trust graph from peer1 yet

See this test(s) for working examples