From db374afef9fbfc218f2c84d27d0d0518ae13bc44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alen=20=C5=A0iljak?= Date: Fri, 19 Mar 2021 12:13:45 +0100 Subject: [PATCH] updating the example --- examples/browser-ipns-publish/index.html | 10 ++++++++++ examples/browser-ipns-publish/index.js | 15 +++++++++++++++ examples/browser-ipns-publish/package.json | 17 ++++++++--------- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/examples/browser-ipns-publish/index.html b/examples/browser-ipns-publish/index.html index ce7c5c9187..40d5b4fbd2 100644 --- a/examples/browser-ipns-publish/index.html +++ b/examples/browser-ipns-publish/index.html @@ -137,6 +137,16 @@

> Connect + +
+ For connecting to a local go-ipfs node, you may need to use +
/ip4/127.0.0.1/tcp/4003/ws/p2p/QmTheirServerPeerId
+
diff --git a/examples/browser-ipns-publish/index.js b/examples/browser-ipns-publish/index.js index e0e5ef72d2..6d5c850cf7 100644 --- a/examples/browser-ipns-publish/index.js +++ b/examples/browser-ipns-publish/index.js @@ -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() { @@ -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}`); diff --git a/examples/browser-ipns-publish/package.json b/examples/browser-ipns-publish/package.json index 681722aaa3..53e0adb673 100644 --- a/examples/browser-ipns-publish/package.json +++ b/examples/browser-ipns-publish/package.json @@ -5,8 +5,7 @@ "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" }, @@ -14,10 +13,10 @@ "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" @@ -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" },