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 10, 2021
1 parent c91ef59 commit db374af
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 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
17 changes: 8 additions & 9 deletions examples/browser-ipns-publish/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@
"private": true,
"main": "index.js",
"scripts": {
"clean": "rimraf ./dist ./.cache ./.parcel-cache",
"build": "parcel build index.html --no-scope-hoist",
"build": "parcel build index.html --public-url ./",
"start": "parcel index.html",
"test": "test-ipfs-example"
},
"author": "Doug Anderson",
"license": "MIT",
"dependencies": {
"human-crypto-keys": "^0.1.4",
"ipfs": "^0.55.3",
"ipfs-http-client": "^50.1.1",
"ipfs-utils": "^8.1.2",
"ipns": "^0.11.0",
"ipfs": "^0.54.4",
"ipfs-http-client": "^49.0.4",
"ipfs-utils": "^6.0.1",
"ipns": "^0.10.0",
"it-last": "^1.0.4",
"p-retry": "^4.2.0",
"uint8arrays": "^2.1.3"
Expand All @@ -26,11 +25,11 @@
"last 2 versions and not dead and > 2%"
],
"devDependencies": {
"delay": "^5.0.0",
"delay": "^4.4.0",
"execa": "^5.0.0",
"ipfsd-ctl": "^8.0.1",
"ipfsd-ctl": "^7.2.0",
"go-ipfs": "0.8.0",
"parcel": "2.0.0-beta.2",
"parcel-bundler": "^1.12.5",
"path": "^0.12.7",
"test-ipfs-example": "^3.0.0"
},
Expand Down

0 comments on commit db374af

Please sign in to comment.