Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 91a84e4

Browse files
misteryvasco-santosAlen Šiljakachingbrain
authored
docs: update browser ipns publish example (#3596)
Applying all the magic from #3584, updating the dependencies, adding tips (address example) for working with a local node Co-authored-by: Vasco Santos <[email protected]> Co-authored-by: Alen Šiljak <[email protected]> Co-authored-by: achingbrain <[email protected]>
1 parent 399ce36 commit 91a84e4

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

examples/browser-ipns-publish/index.html

+7
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ <h1 class="aqua fw2 montserrat dib ma0 pv2 ph1 v-mid fr f3 lh-copy">
137137
>
138138
Connect
139139
</button>
140+
<div
141+
class="custom-block callout"
142+
style="font-size: 0.75em; width: 75%; margin: 1em;"
143+
>
144+
For connecting to a local go-ipfs node, you can check its listening address similar to:
145+
<pre>/ip4/127.0.0.1/tcp/4003/ws/p2p/QmTheirServerPeerId</pre>
146+
</div>
140147
</div>
141148

142149
<div class="ph3 mb3">

examples/browser-ipns-publish/index.js

+15
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ const uint8ArrayToString = require('uint8arrays/to-string')
1010
const uint8ArrayFromString = require('uint8arrays/from-string')
1111
const { sha256 } = require('multiformats/hashes/sha2')
1212

13+
const WS = require('libp2p-websockets')
14+
const transportKey = WS.prototype[Symbol.toStringTag]
15+
const filters = require('libp2p-websockets/src/filters')
16+
1317
const { sleep, Logger, onEnterPress, catchAndLog } = require("./util");
1418

1519
async function main() {
@@ -40,6 +44,17 @@ async function main() {
4044
ipfsBrowser = await IPFS.create({
4145
pass: "01234567890123456789",
4246
EXPERIMENTAL: { ipnsPubsub: true },
47+
libp2p: {
48+
config: {
49+
transport: {
50+
// This is added for local demo!
51+
// In a production environment the default filter should be used
52+
// where only DNS + WSS addresses will be dialed by websockets in the browser.
53+
[transportKey]: {
54+
filter: filters.all
55+
}
56+
}
57+
}}
4358
});
4459
const { id } = await ipfsBrowser.id();
4560
log(`Browser IPFS ready! Node id: ${id}`);

0 commit comments

Comments
 (0)