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

Commit

Permalink
updating the example
Browse files Browse the repository at this point in the history
  • Loading branch information
Alen Šiljak committed Jun 22, 2021
1 parent 57c3413 commit 16d904e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
10 changes: 10 additions & 0 deletions examples/browser-ipns-publish/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@ <h1 class="aqua fw2 montserrat dib ma0 pv2 ph1 v-mid fr f3 lh-copy">
>
Connect
</button>
<!-- For localhost:
placeholder=""
-->
<div
class="custom-block callout"
style="font-size: 0.75em; width: 75%; margin: 1em;"
>
For connecting to a local go-ipfs node, you may need to use
<pre>/ip4/127.0.0.1/tcp/4003/ws/p2p/QmTheirServerPeerId</pre>
</div>
</div>

<div class="ph3 mb3">
Expand Down
15 changes: 15 additions & 0 deletions examples/browser-ipns-publish/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ const cryptoKeys = require("human-crypto-keys"); // { getKeyPairFromSeed }
const uint8ArrayToString = require('uint8arrays/to-string')
const uint8ArrayFromString = require('uint8arrays/from-string')

const WS = require('libp2p-websockets')
const transportKey = WS.prototype[Symbol.toStringTag]
const filters = require('libp2p-websockets/src/filters')

const { sleep, Logger, onEnterPress, catchAndLog } = require("./util");

async function main() {
Expand Down Expand Up @@ -39,6 +43,17 @@ async function main() {
ipfsBrowser = await IPFS.create({
pass: "01234567890123456789",
EXPERIMENTAL: { ipnsPubsub: true },
libp2p: {
config: {
transport: {
// This is added for local demo!
// In a production environment the default filter should be used
// where only DNS + WSS addresses will be dialed by websockets in the browser.
[transportKey]: {
filter: filters.all
}
}
}}
});
const { id } = await ipfsBrowser.id();
log(`Browser IPFS ready! Node id: ${id}`);
Expand Down

0 comments on commit 16d904e

Please sign in to comment.