Slashtag
Slashtag is the identity layer of Slashtags protocol, that enables attaching metadata to a keypair (through Hyperdrives), and p2p communications between peers.
This module creates a node that manages a Slashtag's drives, and facilitating p2p connections between slashtags.
Installation
npm install @synonymdev/slashtag
Usage
Quick example showing how to create a Slashtag node and use it to create resolvable public profile.
NOTE: you do NOT need to wait for ready as all internals await this themselves.
import Slashtag from '@synonymdev/slashtag';
const alice = new Slashtag();
const bob = new Slashtag();
await alice.listen()
await bob.connect(alice.key).opened
API
slashtag.url
A SlashURL string in the form slash:<z-base-32 key>
.
slashtag.drivestore
Drivestore instance for this slashtag.
await slashtag.listen()
Listen on the slashtag's public key through Hyperswarm DHT p2p server
const socket = slashtag.connect(destination)
Connect to a Slashtag's server. destination
is the peer's public key, as a Buffer/Uint8Array, or encoded as a z-base-32 or slash: url.
Returns a promise of Encrypted Connection.
You can await socket.opened
.
await slashtag.close()
Destroys the Hyperswarm node, and closes the Corestore instance.
`slashtag.on('connection', (socket) => {})
Emitted whenever the dht recieves a connection as a server or client.
socket
is an end-to-end NoiseSecretStream