From c5442cbb1a838d66c7d97fee249494872a3418ee Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Fri, 22 Sep 2023 15:25:43 +0200 Subject: [PATCH 1/4] feat: show full rpc backend version we now have useful AgentVersion returned by 'ipfs id' Kubo RPC command which allows for including suffix (e.g. in brave). this makes it more obvious that kubo backend is used, and in which version, and removes perception that kubo version === ipfs version --- add-on/_locales/en/messages.json | 10 ++----- add-on/src/lib/ipfs-companion.js | 30 ++++++++++++++----- .../popup/browser-action/gateway-status.js | 4 +-- .../src/popup/browser-action/ipfs-version.js | 11 ++++--- add-on/src/popup/browser-action/store.js | 8 ++--- 5 files changed, 36 insertions(+), 27 deletions(-) diff --git a/add-on/_locales/en/messages.json b/add-on/_locales/en/messages.json index 8129f65ef..9674cf5f6 100644 --- a/add-on/_locales/en/messages.json +++ b/add-on/_locales/en/messages.json @@ -35,13 +35,9 @@ "message": "The URL of your local Kubo RPC", "description": "A label in Node status section of Browser Action pop-up (panel_statusApiAddressTitle)" }, - "panel_statusGatewayVersion": { - "message": "version", - "description": "A label in Node status section of Browser Action pop-up (panel_statusGatewayVersion)" - }, - "panel_statusGatewayVersionTitle": { - "message": "The version of IPFS your local node is using", - "description": "A label in Node status section of Browser Action pop-up (panel_statusGatewayVersionTitle)" + "panel_kuboRpcBackendVersionTitle": { + "message": "The version of IPFS backend this extension talks to over Kubo RPC API", + "description": "A label in Node status section of Browser Action pop-up (panel_kuboRpcBackendVersionTitle)" }, "panel_statusSwarmPeers": { "message": "Peers", diff --git a/add-on/src/lib/ipfs-companion.js b/add-on/src/lib/ipfs-companion.js index 480975b02..c6dd1ba6f 100644 --- a/add-on/src/lib/ipfs-companion.js +++ b/add-on/src/lib/ipfs-companion.js @@ -230,6 +230,25 @@ export default async function init (inQuickImport = false) { handler(message) } + async function fetchKuboRpcBackendVersion () { + // prefer AgentVersion string from 'ipfs id' , but if that fails, use 'ipfs version' + try { + const id = await ipfs.id() + if (id) { + return id.agentVersion + } + } catch (_) { + try { + const v = await ipfs.version() + if (v) { + return v.commit ? v.version + '/' + v.commit : v.version + } + } catch (_) { + } + } + return null + } + async function sendStatusUpdateToBrowserAction () { if (!browserActionPort) return const currentTab = await browser.tabs.query({ active: true, currentWindow: true }).then(tabs => tabs[0]) @@ -250,14 +269,9 @@ export default async function init (inQuickImport = false) { newVersion: state.dismissedUpdate !== version ? version : null, currentTab } - try { - const v = await ipfs.version() - if (v) { - info.gatewayVersion = v.commit ? v.version + '/' + v.commit : v.version - } - } catch (error) { - info.gatewayVersion = null - } + + info.kuboRpcBackendVersion = await fetchKuboRpcBackendVersion() + if (state.active && info.currentTab) { const url = info.currentTab.url info.isIpfsContext = ipfsPathValidator.isIpfsPageActionsContext(url) diff --git a/add-on/src/popup/browser-action/gateway-status.js b/add-on/src/popup/browser-action/gateway-status.js index b877d27d7..c1ead02aa 100644 --- a/add-on/src/popup/browser-action/gateway-status.js +++ b/add-on/src/popup/browser-action/gateway-status.js @@ -19,7 +19,7 @@ function statusEntry ({ label, labelLegend, value, check, itemClass = '', valueC export default function gatewayStatus ({ gatewayAddress, - gatewayVersion, + kuboRpcBackendVersion, ipfsApiUrl, swarmPeers }) { @@ -42,7 +42,7 @@ export default function gatewayStatus ({ label: 'panel_statusApiAddress', labelLegend: 'panel_statusApiAddressTitle', value: api, - check: gatewayVersion + check: kuboRpcBackendVersion })} ` diff --git a/add-on/src/popup/browser-action/ipfs-version.js b/add-on/src/popup/browser-action/ipfs-version.js index 7aa265e19..8ab56d72f 100644 --- a/add-on/src/popup/browser-action/ipfs-version.js +++ b/add-on/src/popup/browser-action/ipfs-version.js @@ -11,20 +11,19 @@ function statusEntry ({ label, labelLegend, title, value, check, valueClass = '' value = value || value === 0 ? value : offline return html`
- ${value.substring(0, 13)} + ${value.substring(0, 18)}
` } export default function ipfsVersion ({ - gatewayVersion + kuboRpcBackendVersion }) { return html` ${statusEntry({ - label: 'panel_statusGatewayVersion', - title: browser.i18n.getMessage('panel_statusGatewayVersionTitle'), - value: gatewayVersion, - check: gatewayVersion + title: browser.i18n.getMessage('panel_kuboRpcBackendVersionTitle'), + value: kuboRpcBackendVersion, + check: kuboRpcBackendVersion })} ` } diff --git a/add-on/src/popup/browser-action/store.js b/add-on/src/popup/browser-action/store.js index c0ede3974..e87ac1aa8 100644 --- a/add-on/src/popup/browser-action/store.js +++ b/add-on/src/popup/browser-action/store.js @@ -27,7 +27,7 @@ export default (state, emitter) => { publicSubdomainGatewayUrl: null, gatewayAddress: null, swarmPeers: null, - gatewayVersion: null, + kuboRpcBackendVersion: null, isApiAvailable: false, // isRedirectContext currentTab: null, @@ -215,7 +215,7 @@ export default (state, emitter) => { if (!state.active) { state.gatewayAddress = state.pubGwURLString state.ipfsApiUrl = null - state.gatewayVersion = null + state.kuboRpcBackendVersion = null state.swarmPeers = null state.isIpfsOnline = false } @@ -241,13 +241,13 @@ export default (state, emitter) => { state.isApiAvailable = state.active && !browser.extension.inIncognitoContext // https://github.com/ipfs-shipyard/ipfs-companion/issues/243 state.swarmPeers = !state.active || status.peerCount === -1 ? null : status.peerCount state.isIpfsOnline = state.active && status.peerCount > -1 - state.gatewayVersion = state.active && status.gatewayVersion ? status.gatewayVersion : null + state.kuboRpcBackendVersion = state.active && status.kuboRpcBackendVersion ? status.kuboRpcBackendVersion : null state.ipfsApiUrl = state.active ? status.apiURLString : null } else { state.ipfsNodeType = 'external' state.swarmPeers = null state.isIpfsOnline = false - state.gatewayVersion = null + state.kuboRpcBackendVersion = null state.isIpfsContext = false state.isRedirectContext = false } From 90f32c853b1b5cc222d817015989f7f158aef099 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Sat, 23 Sep 2023 15:18:48 +0200 Subject: [PATCH 2/4] refactor: simplify version fetch --- add-on/src/lib/ipfs-companion.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/add-on/src/lib/ipfs-companion.js b/add-on/src/lib/ipfs-companion.js index c6dd1ba6f..aca4e7d16 100644 --- a/add-on/src/lib/ipfs-companion.js +++ b/add-on/src/lib/ipfs-companion.js @@ -233,19 +233,15 @@ export default async function init (inQuickImport = false) { async function fetchKuboRpcBackendVersion () { // prefer AgentVersion string from 'ipfs id' , but if that fails, use 'ipfs version' try { - const id = await ipfs.id() - if (id) { - return id.agentVersion + const { agentVersion } = await ipfs.id() + if (agentVersion) { + return agentVersion } - } catch (_) { - try { - const v = await ipfs.version() - if (v) { - return v.commit ? v.version + '/' + v.commit : v.version - } - } catch (_) { + const { version, commit } = await ipfs.version() + if (version || commit) { + return [version, commit].filter(Boolean).join('/') } - } + } catch (_) {} return null } From eac436c8fa67a447cd481b222d9ac24228abb4d7 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Sat, 23 Sep 2023 15:30:33 +0200 Subject: [PATCH 3/4] docs: clarify external IS kubo rpc --- add-on/_locales/en/messages.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add-on/_locales/en/messages.json b/add-on/_locales/en/messages.json index 9674cf5f6..5d6169c02 100644 --- a/add-on/_locales/en/messages.json +++ b/add-on/_locales/en/messages.json @@ -256,7 +256,7 @@ "description": "An option title on the Preferences screen (option_ipfsNodeConfig_title)" }, "option_ipfsNodeType_external": { - "message": "External", + "message": "External (Kubo RPC)", "description": "An option on the Preferences screen (option_ipfsNodeType_external)" }, "option_ipfsNodeType_brave": { From a94b34d4037939e4781157272a40f74e1710de6d Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Mon, 25 Sep 2023 19:02:01 +0200 Subject: [PATCH 4/4] fix: make ipfs-desktop version fit Co-authored-by: Nishant Arora <1895906+whizzzkid@users.noreply.github.com> --- add-on/src/popup/browser-action/ipfs-version.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/add-on/src/popup/browser-action/ipfs-version.js b/add-on/src/popup/browser-action/ipfs-version.js index 8ab56d72f..988352ba6 100644 --- a/add-on/src/popup/browser-action/ipfs-version.js +++ b/add-on/src/popup/browser-action/ipfs-version.js @@ -11,7 +11,7 @@ function statusEntry ({ label, labelLegend, title, value, check, valueClass = '' value = value || value === 0 ? value : offline return html`
- ${value.substring(0, 18)} + ${value.substring(0, 20)}
` }