3.0.40 • Published 6 days ago

@peerbit/trusted-network v3.0.40

Weekly downloads
-
License
MIT
Repository
-
Last release
6 days ago

Trusted network

🚧 Experimental state 🚧

A store that lets you build trusted networks of identities.

The store is defined by the "root trust" which has 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 start to participate in the replication process with large amount (>> min replicas) of nodes followed by 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 'peerbit'
import { Log } from '@peerbit/log'
import { Program } from '@peerbit/program' 
import { TrustedNetwork } from '@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<Uint8Array>

    @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: ... , canPerform: ..., index: {... 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 received the full trust graph from peer1 yet

See this test(s) for working examples

3.0.40-218a5bb

6 days ago

3.0.40-aa577a5

6 days ago

3.0.40-0691c73

6 days ago

3.0.40-efee9d3

29 days ago

3.0.40-a9206a8

1 month ago

3.0.40-a4f88b6

1 month ago

3.0.40

2 months ago

3.0.39

3 months ago

3.0.35

3 months ago

3.0.38

3 months ago

3.0.36

3 months ago

3.0.37

3 months ago

3.0.34

3 months ago

3.0.33

3 months ago

3.0.32

3 months ago

3.0.30

3 months ago

3.0.31

3 months ago

3.0.27

3 months ago

3.0.28

3 months ago

3.0.26

4 months ago

3.0.29

3 months ago

3.0.25

4 months ago

3.0.23

4 months ago

3.0.24

4 months ago

3.0.21

4 months ago

3.0.22

4 months ago

3.0.20

4 months ago

3.0.19

4 months ago

3.0.18

4 months ago

3.0.17

4 months ago

3.0.16

4 months ago

3.0.15

4 months ago

3.0.12

4 months ago

3.0.11

4 months ago

3.0.14

4 months ago

3.0.10

4 months ago

3.0.8

4 months ago

3.0.9

4 months ago

3.0.7

4 months ago

3.0.6

4 months ago

3.0.5

4 months ago

3.0.4

4 months ago

3.0.3

4 months ago

3.0.2

4 months ago

3.0.1

4 months ago

2.0.21

8 months ago

2.0.20

8 months ago

2.0.19

8 months ago

2.0.18

8 months ago

2.0.17

8 months ago

2.0.16

8 months ago

2.0.15

8 months ago

2.0.14

8 months ago

2.0.13

8 months ago

2.0.12

8 months ago

2.0.11

8 months ago

2.0.10

8 months ago

2.0.9

8 months ago

2.0.8

8 months ago

2.0.7

8 months ago

2.0.6

8 months ago

2.0.5

8 months ago

2.0.4

9 months ago

2.0.3

9 months ago

2.0.2

9 months ago

2.0.1

9 months ago

2.0.0

9 months ago

1.0.17

10 months ago

1.0.16

10 months ago

1.0.15

10 months ago

1.0.14

10 months ago

1.0.13

10 months ago

1.0.12

10 months ago

1.0.11

10 months ago

1.0.10

10 months ago

1.0.9

10 months ago

1.0.8

10 months ago

1.0.7

10 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago