From 8af80fdd615a5b65912abed165c49dce7c9e8b8f Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Fri, 22 Feb 2019 14:13:47 +0000 Subject: [PATCH 1/7] feat: add connection License: MIT Signed-off-by: Henrique Dias --- .vscode/settings.json | 3 ++ package-lock.json | 47 +++++++++++++------ public/locales/en/peers.json | 4 +- src/bundles/peers.js | 16 +++++++ src/peers/AddConnection/AddConnection.js | 60 ++++++++++++++++++++++++ src/peers/PeersPage.js | 6 +++ 6 files changed, 121 insertions(+), 15 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 src/peers/AddConnection/AddConnection.js diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..b3fb20879 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "C_Cpp.dimInactiveRegions": false +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index c2c1b53d0..c3ff18449 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7710,7 +7710,8 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true + "bundled": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -7728,11 +7729,13 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true + "bundled": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -7745,15 +7748,18 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "concat-map": { "version": "0.0.1", - "bundled": true + "bundled": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -7856,7 +7862,8 @@ }, "inherits": { "version": "2.0.3", - "bundled": true + "bundled": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -7866,6 +7873,7 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -7878,17 +7886,20 @@ "minimatch": { "version": "3.0.4", "bundled": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true + "bundled": true, + "optional": true }, "minipass": { "version": "2.2.4", "bundled": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -7905,6 +7916,7 @@ "mkdirp": { "version": "0.5.1", "bundled": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -7977,7 +7989,8 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true + "bundled": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -7987,6 +8000,7 @@ "once": { "version": "1.4.0", "bundled": true, + "optional": true, "requires": { "wrappy": "1" } @@ -8062,7 +8076,8 @@ }, "safe-buffer": { "version": "5.1.1", - "bundled": true + "bundled": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -8092,6 +8107,7 @@ "string-width": { "version": "1.0.2", "bundled": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -8109,6 +8125,7 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -8147,11 +8164,13 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true + "bundled": true, + "optional": true }, "yallist": { "version": "3.0.2", - "bundled": true + "bundled": true, + "optional": true } } }, @@ -12211,9 +12230,9 @@ }, "dependencies": { "multiaddr": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/multiaddr/-/multiaddr-6.0.3.tgz", - "integrity": "sha512-ZYKAmSQ6j3x3fJQGF8yoAb5aDwrNFT/QVhfN8rId+M4/E1RYR3fsitFwMG3l7TuWhow+ET01mA+BViz+8NaktQ==", + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/multiaddr/-/multiaddr-6.0.4.tgz", + "integrity": "sha512-oi7ImOEwPTRjHSOeOe0DgoxHLChHniME2on8G00fUwD88k4R2J2yrpd5643M9c8EqVuyvjy/e/zAZofpKIISyw==", "requires": { "bs58": "^4.0.1", "class-is": "^1.1.0", diff --git a/public/locales/en/peers.json b/public/locales/en/peers.json index 9e7781841..d0a1ea506 100644 --- a/public/locales/en/peers.json +++ b/public/locales/en/peers.json @@ -4,5 +4,7 @@ "peers": "Peers", "address": "Address", "location": "Location", - "unknownLocation": "Unknown" + "unknownLocation": "Unknown", + "addConnection": "Add Connection", + "add": "Add" } diff --git a/src/bundles/peers.js b/src/bundles/peers.js index ff01061b0..675297e88 100644 --- a/src/bundles/peers.js +++ b/src/bundles/peers.js @@ -23,6 +23,22 @@ bundle.selectPeersCount = createSelector( } ) +bundle.doConnectSwarm = addr => async ({ dispatch, getIpfs }) => { + dispatch({ type: 'CONNECT_SWARM_STARTED', payload: { addr } }) + const ipfs = getIpfs() + + try { + await ipfs.swarm.connect(addr) + } catch (err) { + return dispatch({ + type: 'CONNECT_SWARM_FAILED', + payload: { addr, error: err } + }) + } + + dispatch({ type: 'CONNECT_SWARM_FINISHED', payload: { addr } }) +} + // Update the peers if they are stale (appTime - lastSuccess > staleAfter) bundle.reactPeersFetchWhenIdle = createSelector( 'selectPeersShouldUpdate', diff --git a/src/peers/AddConnection/AddConnection.js b/src/peers/AddConnection/AddConnection.js new file mode 100644 index 000000000..80f92c039 --- /dev/null +++ b/src/peers/AddConnection/AddConnection.js @@ -0,0 +1,60 @@ +import React from 'react' +import { translate } from 'react-i18next' +import { connect } from 'redux-bundler-react' +import toUri from 'multiaddr-to-uri' + +import Icon from '../../icons/StrokeDecentralization' +import Button from '../../components/button/Button' +import Overlay from '../../components/overlay/Overlay' +import TextInputModal from '../../components/text-input-modal/TextInputModal' + +class AddConnection extends React.Component { + state = { + open: false + } + + toggleModal = () => { + this.setState({ + open: !this.state.open + }) + } + + addConnection = (maddr) => { + this.props.doConnectSwarm(maddr) + this.toggleModal() + } + + validate = (maddr) => { + try { + toUri(maddr) + return true + } catch (_) { + return false + } + } + + render () { + const { open } = this.state + const { t } = this.props + + return ( +
+ + + + + +
+ ) + } +} + +export default connect('doConnectSwarm', translate('peers')(AddConnection)) diff --git a/src/peers/PeersPage.js b/src/peers/PeersPage.js index a023ab89c..9f6f83c00 100644 --- a/src/peers/PeersPage.js +++ b/src/peers/PeersPage.js @@ -6,12 +6,18 @@ import { translate } from 'react-i18next' import Box from '../components/box/Box' import WorldMap from './WorldMap/WorldMap' import PeersTable from './PeersTable/PeersTable' +import AddConnection from './AddConnection/AddConnection' const PeersPage = ({ t }) => (
{t('title')} - IPFS + +
+ +
+ From f6800ad1ca6a708fd5cddd03e497ce175a9b4f9b Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Fri, 22 Feb 2019 14:14:56 +0000 Subject: [PATCH 2/7] feat: translate one sentence License: MIT Signed-off-by: Henrique Dias --- public/locales/en/peers.json | 1 + src/peers/AddConnection/AddConnection.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/public/locales/en/peers.json b/public/locales/en/peers.json index d0a1ea506..3908591dd 100644 --- a/public/locales/en/peers.json +++ b/public/locales/en/peers.json @@ -6,5 +6,6 @@ "location": "Location", "unknownLocation": "Unknown", "addConnection": "Add Connection", + "insertSwarmAddress": "Insert the swarm address you want to connect to.", "add": "Add" } diff --git a/src/peers/AddConnection/AddConnection.js b/src/peers/AddConnection/AddConnection.js index 80f92c039..98f8448cc 100644 --- a/src/peers/AddConnection/AddConnection.js +++ b/src/peers/AddConnection/AddConnection.js @@ -49,7 +49,7 @@ class AddConnection extends React.Component { submitText={t('add')} icon={Icon} title={t('addConnection')} - description='Insert the multiaddress of the swarm' + description={t('insertSwarmAddress')} />
From a370a04da512f518dcee72d260a6ebd677feb4e1 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Sat, 23 Feb 2019 10:40:18 +0000 Subject: [PATCH 3/7] fix: remove vscode stuff License: MIT Signed-off-by: Henrique Dias --- .gitignore | 2 ++ .vscode/settings.json | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.gitignore b/.gitignore index d30f40ef4..248ff0906 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,5 @@ npm-debug.log* yarn-debug.log* yarn-error.log* + +.vscode diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index b3fb20879..000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "C_Cpp.dimInactiveRegions": false -} \ No newline at end of file From 0bc4561a2ef373fe27ce0ca21e4fa013dda6a80b Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Sat, 23 Feb 2019 10:56:20 +0000 Subject: [PATCH 4/7] feat: notify on error/success License: MIT Signed-off-by: Henrique Dias --- public/locales/en/notify.json | 4 +++- public/locales/en/peers.json | 3 ++- src/bundles/notify.js | 17 +++++++++++++++++ src/bundles/peers.js | 6 +++--- src/peers/AddConnection/AddConnection.js | 15 ++++++++++++++- 5 files changed, 39 insertions(+), 6 deletions(-) diff --git a/public/locales/en/notify.json b/public/locales/en/notify.json index 4943fd5e0..db23a9168 100644 --- a/public/locales/en/notify.json +++ b/public/locales/en/notify.json @@ -5,5 +5,7 @@ "windowIpfsRequestFailed": "IPFS request failed. Please check your IPFS Companion settings.", "ipfsIsBack": "Normal IPFS service has resumed. Enjoy!", "filesEventFailed": "Failed to add files to IPFS. Please try again.", - "folderExists": "A folder with that name already exists. Please choose another." + "folderExists": "A folder with that name already exists. Please choose another.", + "couldntConnectToSwarm": "Could not connect to the swarm.", + "connectedToSwarm": "Successfully connected to the swarm." } diff --git a/public/locales/en/peers.json b/public/locales/en/peers.json index 3908591dd..fa22e8ee9 100644 --- a/public/locales/en/peers.json +++ b/public/locales/en/peers.json @@ -7,5 +7,6 @@ "unknownLocation": "Unknown", "addConnection": "Add Connection", "insertSwarmAddress": "Insert the swarm address you want to connect to.", - "add": "Add" + "add": "Add", + "example": "Example:" } diff --git a/src/bundles/notify.js b/src/bundles/notify.js index b5304ac1c..d1a34c705 100644 --- a/src/bundles/notify.js +++ b/src/bundles/notify.js @@ -50,6 +50,15 @@ const notify = { } } + if (action.type === 'SWARM_CONNECT_FAILED' || action.type === 'SWARM_CONNECT_FINISHED') { + return { + ...state, + show: true, + error: action.type === 'SWARM_CONNECT_FAILED', + eventId: action.type + } + } + return state }, @@ -73,6 +82,14 @@ const notify = { return 'ipfsIsBack' } + if (eventId === 'SWARM_CONNECT_FAILED') { + return 'couldntConnectToSwarm' + } + + if (eventId === 'SWARM_CONNECT_FINISHED') { + return 'connectedToSwarm' + } + return eventId } ), diff --git a/src/bundles/peers.js b/src/bundles/peers.js index 675297e88..93457a900 100644 --- a/src/bundles/peers.js +++ b/src/bundles/peers.js @@ -24,19 +24,19 @@ bundle.selectPeersCount = createSelector( ) bundle.doConnectSwarm = addr => async ({ dispatch, getIpfs }) => { - dispatch({ type: 'CONNECT_SWARM_STARTED', payload: { addr } }) + dispatch({ type: 'SWARM_CONNECT_STARTED', payload: { addr } }) const ipfs = getIpfs() try { await ipfs.swarm.connect(addr) } catch (err) { return dispatch({ - type: 'CONNECT_SWARM_FAILED', + type: 'SWARM_CONNECT_FAILED', payload: { addr, error: err } }) } - dispatch({ type: 'CONNECT_SWARM_FINISHED', payload: { addr } }) + dispatch({ type: 'SWARM_CONNECT_FINISHED', payload: { addr } }) } // Update the peers if they are stale (appTime - lastSuccess > staleAfter) diff --git a/src/peers/AddConnection/AddConnection.js b/src/peers/AddConnection/AddConnection.js index 98f8448cc..a3c0e9c8b 100644 --- a/src/peers/AddConnection/AddConnection.js +++ b/src/peers/AddConnection/AddConnection.js @@ -33,6 +33,19 @@ class AddConnection extends React.Component { } } + getDescription = () => { + const { t } = this.props + const codeClass = 'w-90 mb1 pa1 bg-snow f7 charcoal-muted truncate' + + return ( +
+

{t('insertSwarmAddress')}

+ {t('example')} + /ip4/76.176.168.65/tcp/4001/ipfs/QmbBHw1Xx9pUpAbrVZUKTPL5Rsph5Q9GQhRvcWVBPFgGtC +
+ ) + } + render () { const { open } = this.state const { t } = this.props @@ -49,7 +62,7 @@ class AddConnection extends React.Component { submitText={t('add')} icon={Icon} title={t('addConnection')} - description={t('insertSwarmAddress')} + description={this.getDescription()} /> From 9cca51272a4c7db07330f615945859f91a9ae1c8 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Sat, 23 Feb 2019 10:59:15 +0000 Subject: [PATCH 5/7] fix: revert pkg-lock License: MIT Signed-off-by: Henrique Dias --- package-lock.json | 47 ++++++++++++++--------------------------------- 1 file changed, 14 insertions(+), 33 deletions(-) diff --git a/package-lock.json b/package-lock.json index c3ff18449..c2c1b53d0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7710,8 +7710,7 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true, - "optional": true + "bundled": true }, "aproba": { "version": "1.2.0", @@ -7729,13 +7728,11 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true, - "optional": true + "bundled": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -7748,18 +7745,15 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "concat-map": { "version": "0.0.1", - "bundled": true, - "optional": true + "bundled": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true, - "optional": true + "bundled": true }, "core-util-is": { "version": "1.0.2", @@ -7862,8 +7856,7 @@ }, "inherits": { "version": "2.0.3", - "bundled": true, - "optional": true + "bundled": true }, "ini": { "version": "1.3.5", @@ -7873,7 +7866,6 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -7886,20 +7878,17 @@ "minimatch": { "version": "3.0.4", "bundled": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true, - "optional": true + "bundled": true }, "minipass": { "version": "2.2.4", "bundled": true, - "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -7916,7 +7905,6 @@ "mkdirp": { "version": "0.5.1", "bundled": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -7989,8 +7977,7 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true, - "optional": true + "bundled": true }, "object-assign": { "version": "4.1.1", @@ -8000,7 +7987,6 @@ "once": { "version": "1.4.0", "bundled": true, - "optional": true, "requires": { "wrappy": "1" } @@ -8076,8 +8062,7 @@ }, "safe-buffer": { "version": "5.1.1", - "bundled": true, - "optional": true + "bundled": true }, "safer-buffer": { "version": "2.1.2", @@ -8107,7 +8092,6 @@ "string-width": { "version": "1.0.2", "bundled": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -8125,7 +8109,6 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -8164,13 +8147,11 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true, - "optional": true + "bundled": true }, "yallist": { "version": "3.0.2", - "bundled": true, - "optional": true + "bundled": true } } }, @@ -12230,9 +12211,9 @@ }, "dependencies": { "multiaddr": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/multiaddr/-/multiaddr-6.0.4.tgz", - "integrity": "sha512-oi7ImOEwPTRjHSOeOe0DgoxHLChHniME2on8G00fUwD88k4R2J2yrpd5643M9c8EqVuyvjy/e/zAZofpKIISyw==", + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/multiaddr/-/multiaddr-6.0.3.tgz", + "integrity": "sha512-ZYKAmSQ6j3x3fJQGF8yoAb5aDwrNFT/QVhfN8rId+M4/E1RYR3fsitFwMG3l7TuWhow+ET01mA+BViz+8NaktQ==", "requires": { "bs58": "^4.0.1", "class-is": "^1.1.0", From 5a8fe90d321cfbd02e1ce5515197f1a26545c6a8 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Sun, 24 Feb 2019 00:19:36 +0000 Subject: [PATCH 6/7] feat: replace by peer License: MIT Signed-off-by: Henrique Dias --- public/locales/en/notify.json | 4 ++-- public/locales/en/peers.json | 2 +- src/bundles/notify.js | 4 ++-- src/peers/AddConnection/AddConnection.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/public/locales/en/notify.json b/public/locales/en/notify.json index db23a9168..22a26d077 100644 --- a/public/locales/en/notify.json +++ b/public/locales/en/notify.json @@ -6,6 +6,6 @@ "ipfsIsBack": "Normal IPFS service has resumed. Enjoy!", "filesEventFailed": "Failed to add files to IPFS. Please try again.", "folderExists": "A folder with that name already exists. Please choose another.", - "couldntConnectToSwarm": "Could not connect to the swarm.", - "connectedToSwarm": "Successfully connected to the swarm." + "couldntConnectToPeer": "Could not connect to the provided peer.", + "connectedToPeer": "Successfully connected to the provided peer." } diff --git a/public/locales/en/peers.json b/public/locales/en/peers.json index fa22e8ee9..4bcaf5c4a 100644 --- a/public/locales/en/peers.json +++ b/public/locales/en/peers.json @@ -6,7 +6,7 @@ "location": "Location", "unknownLocation": "Unknown", "addConnection": "Add Connection", - "insertSwarmAddress": "Insert the swarm address you want to connect to.", + "insertPeerAddress": "Insert the peer address you want to connect to.", "add": "Add", "example": "Example:" } diff --git a/src/bundles/notify.js b/src/bundles/notify.js index d1a34c705..a4b2539fb 100644 --- a/src/bundles/notify.js +++ b/src/bundles/notify.js @@ -83,11 +83,11 @@ const notify = { } if (eventId === 'SWARM_CONNECT_FAILED') { - return 'couldntConnectToSwarm' + return 'couldntConnectToPeer' } if (eventId === 'SWARM_CONNECT_FINISHED') { - return 'connectedToSwarm' + return 'connectedToPeer' } return eventId diff --git a/src/peers/AddConnection/AddConnection.js b/src/peers/AddConnection/AddConnection.js index a3c0e9c8b..2b78d945b 100644 --- a/src/peers/AddConnection/AddConnection.js +++ b/src/peers/AddConnection/AddConnection.js @@ -39,7 +39,7 @@ class AddConnection extends React.Component { return (
-

{t('insertSwarmAddress')}

+

{t('insertPeerAddress')}

{t('example')} /ip4/76.176.168.65/tcp/4001/ipfs/QmbBHw1Xx9pUpAbrVZUKTPL5Rsph5Q9GQhRvcWVBPFgGtC
From 9acbceb009de000f4c7915b5365851a391419c32 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Mon, 4 Mar 2019 08:47:59 +0000 Subject: [PATCH 7/7] feat: use is-ipfs 0.6 License: MIT Signed-off-by: Henrique Dias --- package-lock.json | 110 +++++++++++++++++++---- package.json | 2 +- src/peers/AddConnection/AddConnection.js | 13 +-- 3 files changed, 98 insertions(+), 27 deletions(-) diff --git a/package-lock.json b/package-lock.json index c2c1b53d0..79353b116 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7710,7 +7710,8 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true + "bundled": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -7728,11 +7729,13 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true + "bundled": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -7745,15 +7748,18 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "concat-map": { "version": "0.0.1", - "bundled": true + "bundled": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -7856,7 +7862,8 @@ }, "inherits": { "version": "2.0.3", - "bundled": true + "bundled": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -7866,6 +7873,7 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -7878,17 +7886,20 @@ "minimatch": { "version": "3.0.4", "bundled": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true + "bundled": true, + "optional": true }, "minipass": { "version": "2.2.4", "bundled": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -7905,6 +7916,7 @@ "mkdirp": { "version": "0.5.1", "bundled": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -7977,7 +7989,8 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true + "bundled": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -7987,6 +8000,7 @@ "once": { "version": "1.4.0", "bundled": true, + "optional": true, "requires": { "wrappy": "1" } @@ -8062,7 +8076,8 @@ }, "safe-buffer": { "version": "5.1.1", - "bundled": true + "bundled": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -8092,6 +8107,7 @@ "string-width": { "version": "1.0.2", "bundled": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -8109,6 +8125,7 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -8147,11 +8164,13 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true + "bundled": true, + "optional": true }, "yallist": { "version": "3.0.2", - "bundled": true + "bundled": true, + "optional": true } } }, @@ -9584,6 +9603,17 @@ "ms": "^2.1.1" } }, + "is-ipfs": { + "version": "0.4.8", + "resolved": "https://registry.npmjs.org/is-ipfs/-/is-ipfs-0.4.8.tgz", + "integrity": "sha512-xIKUeA24IFMfkmeAPEOZL448X7a08c/KzAGQp1e/QxC9bx/NNEdT/ohob3SW6eJO2UwJNjsbfMeNZ2B+Dk2Fdg==", + "requires": { + "bs58": "4.0.1", + "cids": "~0.5.6", + "multibase": "~0.6.0", + "multihashes": "~0.4.13" + } + }, "lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", @@ -9689,6 +9719,19 @@ "pull-stream": "^3.6.9", "pull-traverse": "^1.0.3", "stable": "~0.1.8" + }, + "dependencies": { + "is-ipfs": { + "version": "0.4.8", + "resolved": "https://registry.npmjs.org/is-ipfs/-/is-ipfs-0.4.8.tgz", + "integrity": "sha512-xIKUeA24IFMfkmeAPEOZL448X7a08c/KzAGQp1e/QxC9bx/NNEdT/ohob3SW6eJO2UwJNjsbfMeNZ2B+Dk2Fdg==", + "requires": { + "bs58": "4.0.1", + "cids": "~0.5.6", + "multibase": "~0.6.0", + "multihashes": "~0.4.13" + } + } } } } @@ -9753,6 +9796,19 @@ "pull-stream": "^3.6.9", "pull-traverse": "^1.0.3", "stable": "~0.1.8" + }, + "dependencies": { + "is-ipfs": { + "version": "0.4.8", + "resolved": "https://registry.npmjs.org/is-ipfs/-/is-ipfs-0.4.8.tgz", + "integrity": "sha512-xIKUeA24IFMfkmeAPEOZL448X7a08c/KzAGQp1e/QxC9bx/NNEdT/ohob3SW6eJO2UwJNjsbfMeNZ2B+Dk2Fdg==", + "requires": { + "bs58": "4.0.1", + "cids": "~0.5.6", + "multibase": "~0.6.0", + "multihashes": "~0.4.13" + } + } } }, "ipld-ethereum": { @@ -10049,14 +10105,38 @@ } }, "is-ipfs": { - "version": "0.4.8", - "resolved": "https://registry.npmjs.org/is-ipfs/-/is-ipfs-0.4.8.tgz", - "integrity": "sha512-xIKUeA24IFMfkmeAPEOZL448X7a08c/KzAGQp1e/QxC9bx/NNEdT/ohob3SW6eJO2UwJNjsbfMeNZ2B+Dk2Fdg==", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/is-ipfs/-/is-ipfs-0.6.0.tgz", + "integrity": "sha512-q/CO69rN+vbw9eGXGQOAa15zXq+pSyhdKvE7mqvuplDu67LyT3H9t3RyYQvKpueN7dL4f6fbyjEMPp9J3rJ4qA==", "requires": { - "bs58": "4.0.1", + "bs58": "^4.0.1", "cids": "~0.5.6", + "mafmt": "^v6.0.7", + "multiaddr": "^6.0.4", "multibase": "~0.6.0", "multihashes": "~0.4.13" + }, + "dependencies": { + "mafmt": { + "version": "6.0.7", + "resolved": "https://registry.npmjs.org/mafmt/-/mafmt-6.0.7.tgz", + "integrity": "sha512-2OG/EGAJZmpZBl7YRT1hD83sZa2gKsUEdegRuURreIOe7B4VeHU1rYYmhgk7BkLzknGL3xGYsDx3bbSgEEzE7g==", + "requires": { + "multiaddr": "^6.0.4" + } + }, + "multiaddr": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/multiaddr/-/multiaddr-6.0.5.tgz", + "integrity": "sha512-sS0lFPImtycB7w14TGPYtzbT/xgu6ByGIIu+26bkmavgYwXLud5OxU7ytlbdHmTTAgtOEL9k8yjZ+xMrCO2jeQ==", + "requires": { + "bs58": "^4.0.1", + "class-is": "^1.1.0", + "ip": "^1.1.5", + "is-ip": "^2.0.0", + "varint": "^5.0.0" + } + } } }, "is-npm": { diff --git a/package.json b/package.json index ca5f1915b..793a296e4 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "ipld": "^0.21.1", "ipld-explorer-components": "^1.2.0", "is-binary": "^0.1.0", - "is-ipfs": "^0.4.2", + "is-ipfs": "^0.6.0", "milliseconds": "^1.0.3", "money-clip": "^2.1.0", "multiaddr": "^6.0.2", diff --git a/src/peers/AddConnection/AddConnection.js b/src/peers/AddConnection/AddConnection.js index 2b78d945b..14cebc0f9 100644 --- a/src/peers/AddConnection/AddConnection.js +++ b/src/peers/AddConnection/AddConnection.js @@ -1,7 +1,7 @@ import React from 'react' import { translate } from 'react-i18next' import { connect } from 'redux-bundler-react' -import toUri from 'multiaddr-to-uri' +import isIPFS from 'is-ipfs' import Icon from '../../icons/StrokeDecentralization' import Button from '../../components/button/Button' @@ -24,15 +24,6 @@ class AddConnection extends React.Component { this.toggleModal() } - validate = (maddr) => { - try { - toUri(maddr) - return true - } catch (_) { - return false - } - } - getDescription = () => { const { t } = this.props const codeClass = 'w-90 mb1 pa1 bg-snow f7 charcoal-muted truncate' @@ -56,7 +47,7 @@ class AddConnection extends React.Component {