Skip to content

Commit 60eab90

Browse files
committed
work-in-progress-dont-merge :^)
1 parent 3c9e72d commit 60eab90

File tree

10 files changed

+49
-50
lines changed

10 files changed

+49
-50
lines changed

add-on/_locales/en/messages.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@
6363
"message": "Active Tab",
6464
"description": "A menu item in Browser Action pop-up (panel_activeTabSiteRedirectEnable)"
6565
},
66-
"panel_activeTabSiteRedirectToggle": {
67-
"message": "Redirect on $1",
68-
"description": "A menu item in Browser Action pop-up (panel_activeTabSiteRedirectToggle)"
66+
"panel_activeTabSiteIntegrationsToggle": {
67+
"message": "Enable integrations on $1",
68+
"description": "A menu item in Browser Action pop-up (panel_activeTabSiteIntegrationsToggle)"
6969
},
70-
"panel_activeTabSiteRedirectToggleTooltip": {
71-
"message": "Click to toggle gateway redirects on $1",
72-
"description": "A menu item tooltip in Browser Action pop-up (panel_activeTabSiteRedirectToggleTooltip)"
70+
"panel_activeTabSiteIntegrationsToggleTooltip": {
71+
"message": "Click to toggle all IPFS integrations on $1",
72+
"description": "A menu item tooltip in Browser Action pop-up (panel_activeTabSiteIntegrationsToggleTooltip)"
7373
},
7474
"panel_pinCurrentIpfsAddress": {
7575
"message": "Pin IPFS Resource",
@@ -291,12 +291,12 @@
291291
"message": "Redirecting to a path-based gateway breaks Origin-based security isolation of DNSLink website! Please leave this disabled unless you are aware of (and ok with) related risks.",
292292
"description": "A warning on the Preferences screen, displayed when URL does not belong to Secure Context (option_customGatewayUrl_warning)"
293293
},
294-
"option_noRedirectHostnames_title": {
295-
"message": "Redirect Opt-Outs",
296-
"description": "An option title on the Preferences screen (option_noRedirectHostnames_title)"
294+
"option_noIntegrationsHostnames_title": {
295+
"message": "IPFS Integrations Opt-Outs",
296+
"description": "An option title on the Preferences screen (option_noIntegrationsHostnames_title)"
297297
},
298-
"option_noRedirectHostnames_description": {
299-
"message": "List of websites that should not be redirected to the Custom Gateway (includes subresources from other domains). One hostname per line.",
298+
"option_noIntegrationsHostnames_description": {
299+
"message": "List of websites that should not have any IPFS integrations enabled. One hostname per line.",
300300
"description": "An option description on the Preferences screen (option_noRedirectHostnames_description)"
301301
},
302302
"option_publicGatewayUrl_title": {

add-on/src/lib/ipfs-companion.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ module.exports = async function init () {
241241
openViaWebUI: state.openViaWebUI,
242242
apiURLString: dropSlash(state.apiURLString),
243243
redirect: state.redirect,
244-
noRedirectHostnames: state.noRedirectHostnames,
244+
noIntegrationsHostnames: state.noIntegrationsHostnames,
245245
currentTab: await browser.tabs.query({ active: true, currentWindow: true }).then(tabs => tabs[0])
246246
}
247247
try {
@@ -257,7 +257,7 @@ module.exports = async function init () {
257257
info.isIpfsContext = ipfsPathValidator.isIpfsPageActionsContext(url)
258258
info.currentDnslinkFqdn = dnslinkResolver.findDNSLinkHostname(url)
259259
info.currentFqdn = info.currentDnslinkFqdn || new URL(url).hostname
260-
info.currentTabRedirectOptOut = info.noRedirectHostnames && info.noRedirectHostnames.includes(info.currentFqdn)
260+
info.currentTabIntegrationsOptOut = info.noIntegrationsHostnames && info.noIntegrationsHostnames.includes(info.currentFqdn)
261261
info.isRedirectContext = info.currentFqdn && ipfsPathValidator.isRedirectPageActionsContext(url)
262262
}
263263
// Still here?
@@ -679,7 +679,7 @@ module.exports = async function init () {
679679
case 'detectIpfsPathHeader':
680680
case 'preloadAtPublicGateway':
681681
case 'openViaWebUI':
682-
case 'noRedirectHostnames':
682+
case 'noIntegrationsHostnames':
683683
case 'dnslinkRedirect':
684684
state[key] = change.newValue
685685
break

add-on/src/lib/ipfs-request.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function createRequestModifier (getState, dnslinkResolver, ipfsPathValidator, ru
8080
const parentUrl = request.originUrl || request.initiator // FF: originUrl (Referer-like Origin URL), Chrome: initiator (just Origin)
8181
const fqdn = new URL(request.url).hostname
8282
const parentFqdn = parentUrl && parentUrl !== 'null' && request.url !== parentUrl ? new URL(parentUrl).hostname : null
83-
if (state.noRedirectHostnames.some(optout =>
83+
if (state.noIntegrationsHostnames.some(optout =>
8484
fqdn !== 'gateway.ipfs.io' && (fqdn.endsWith(optout) || (parentFqdn && parentFqdn.endsWith(optout))
8585
))) {
8686
ignore(request.requestId)

add-on/src/lib/options.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ exports.optionDefaults = Object.freeze({
1313
publicGatewayUrl: 'https://ipfs.io',
1414
publicSubdomainGatewayUrl: 'https://dweb.link',
1515
useCustomGateway: true,
16-
noRedirectHostnames: [],
16+
noIntegrationsHostnames: [],
1717
automaticMode: true,
1818
linkify: false,
1919
dnslinkPolicy: 'best-effort',

add-on/src/options/forms/gateways-form.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function gatewaysForm ({
1414
ipfsNodeType,
1515
customGatewayUrl,
1616
useCustomGateway,
17-
noRedirectHostnames,
17+
noIntegrationsHostnames,
1818
publicGatewayUrl,
1919
publicSubdomainGatewayUrl,
2020
onOptionChange
@@ -23,7 +23,7 @@ function gatewaysForm ({
2323
const onUseCustomGatewayChange = onOptionChange('useCustomGateway')
2424
const onPublicGatewayUrlChange = onOptionChange('publicGatewayUrl', normalizeGatewayURL)
2525
const onPublicSubdomainGatewayUrlChange = onOptionChange('publicSubdomainGatewayUrl', normalizeGatewayURL)
26-
const onNoRedirectHostnamesChange = onOptionChange('noRedirectHostnames', hostTextToArray)
26+
const onNoIntegrationsHostnamesChange = onOptionChange('noIntegrationsHostnames', hostTextToArray)
2727
const mixedContentWarning = !secureContextUrl.test(customGatewayUrl)
2828
const supportRedirectToCustomGateway = ipfsNodeType !== 'embedded'
2929
const allowChangeOfCustomGateway = ipfsNodeType !== 'embedded:chromesockets'
@@ -110,18 +110,18 @@ function gatewaysForm ({
110110
` : null}
111111
${supportRedirectToCustomGateway ? html`
112112
<div>
113-
<label for="noRedirectHostnames">
113+
<label for="noIntegrationsHostnames">
114114
<dl>
115-
<dt>${browser.i18n.getMessage('option_noRedirectHostnames_title')}</dt>
116-
<dd>${browser.i18n.getMessage('option_noRedirectHostnames_description')}</dd>
115+
<dt>${browser.i18n.getMessage('option_noIntegrationsHostnames_title')}</dt>
116+
<dd>${browser.i18n.getMessage('option_noIntegrationsHostnames_description')}</dd>
117117
</dl>
118118
</label>
119119
<textarea
120-
id="noRedirectHostnames"
120+
id="noIntegrationsHostnames"
121121
spellcheck="false"
122-
onchange=${onNoRedirectHostnamesChange}
122+
onchange=${onNoIntegrationsHostnamesChange}
123123
rows="4"
124-
>${hostArrayToText(noRedirectHostnames)}</textarea>
124+
>${hostArrayToText(noIntegrationsHostnames)}</textarea>
125125
</div>
126126
` : null}
127127
</fieldset>

add-on/src/options/page.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ module.exports = function optionsPage (state, emit) {
6969
useCustomGateway: state.options.useCustomGateway,
7070
publicGatewayUrl: state.options.publicGatewayUrl,
7171
publicSubdomainGatewayUrl: state.options.publicSubdomainGatewayUrl,
72-
noRedirectHostnames: state.options.noRedirectHostnames,
72+
noIntegrationsHostnames: state.options.noIntegrationsHostnames,
7373
onOptionChange
7474
})}
7575
${fileImportForm({

add-on/src/popup/browser-action/context-actions.js

+9-11
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ function contextActions ({
2222
currentTab,
2323
currentFqdn,
2424
currentDnslinkFqdn,
25-
currentTabRedirectOptOut,
25+
currentTabIntegrationsOptOut,
2626
ipfsNodeType,
2727
isIpfsContext,
2828
isPinning,
2929
isUnPinning,
3030
isPinned,
3131
isIpfsOnline,
3232
isApiAvailable,
33-
onToggleSiteRedirect,
33+
onToggleSiteIntegrations,
3434
onViewOnGateway,
3535
onCopy,
3636
onPin,
@@ -69,25 +69,23 @@ function contextActions ({
6969
</div>
7070
`
7171
}
72-
/* TODO: change "redirect on {fqdn}" to "disable on {fqdn}" and disable all integrations
73-
// removed per site toggle for now: ${renderSiteRedirectToggle()}
74-
const renderSiteRedirectToggle = () => {
72+
const renderSiteIntegrationsToggle = () => {
7573
if (!isRedirectContext) return
7674
return html`
7775
${navItem({
78-
text: browser.i18n.getMessage('panel_activeTabSiteRedirectToggle', currentFqdn),
79-
title: browser.i18n.getMessage('panel_activeTabSiteRedirectToggleTooltip', currentFqdn),
76+
text: browser.i18n.getMessage('panel_activeTabSiteIntegrationsToggle', currentFqdn),
77+
title: browser.i18n.getMessage('panel_activeTabSiteIntegrationsToggleTooltip', currentFqdn),
8078
style: 'truncate',
81-
disabled: !(active && redirect),
82-
switchValue: active && redirect && !currentTabRedirectOptOut,
83-
onClick: onToggleSiteRedirect
79+
disabled: !(active),
80+
switchValue: active && !currentTabIntegrationsOptOut,
81+
onClick: onToggleSiteIntegrations
8482
})}
8583
`
8684
}
87-
*/
8885
return html`
8986
<div class='fade-in pv1'>
9087
${renderIpfsContextItems()}
88+
${renderSiteIntegrationsToggle()}
9189
</div>
9290
`
9391
}

add-on/src/popup/browser-action/page.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ module.exports = function browserActionPage (state, emit) {
2020
const onOpenWebUi = () => emit('openWebUi')
2121
const onOpenPrefs = () => emit('openPrefs')
2222
const onToggleGlobalRedirect = () => emit('toggleGlobalRedirect')
23-
const onToggleSiteRedirect = () => emit('toggleSiteRedirect')
23+
const onToggleSiteIntegrations = () => emit('toggleSiteIntegrations')
2424
const onToggleActive = () => emit('toggleActive')
2525

2626
const headerProps = Object.assign({ onToggleActive, onOpenPrefs }, state)
27-
const activeTabActionsProps = Object.assign({ onViewOnGateway, onToggleSiteRedirect, onCopy, onPin, onUnPin }, state)
27+
const activeTabActionsProps = Object.assign({ onViewOnGateway, onToggleSiteIntegrations, onCopy, onPin, onUnPin }, state)
2828
const opsProps = Object.assign({ onQuickUpload, onOpenWebUi, onToggleGlobalRedirect }, state)
2929

3030
return html`

add-on/src/popup/browser-action/store.js

+11-10
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module.exports = (state, emitter) => {
3232
currentTab: null,
3333
currentFqdn: null,
3434
currentDnslinkFqdn: null,
35-
noRedirectHostnames: []
35+
noIntegrationsHostnames: []
3636
})
3737

3838
let port
@@ -166,22 +166,23 @@ module.exports = (state, emitter) => {
166166
}
167167
})
168168

169-
emitter.on('toggleSiteRedirect', async () => {
170-
state.currentTabRedirectOptOut = !state.currentTabRedirectOptOut
169+
emitter.on('toggleSiteIntegrations', async () => {
170+
state.currentTabIntegrationsOptOut = !state.currentTabIntegrationsOptOut
171171
emitter.emit('render')
172172

173173
try {
174-
let noRedirectHostnames = state.noRedirectHostnames
174+
let noIntegrationsHostnames = state.noIntegrationsHostnames
175175
// if we are on /ipns/fqdn.tld/ then use hostname from DNSLink
176176
const fqdn = state.currentDnslinkFqdn || state.currentFqdn
177-
if (noRedirectHostnames.includes(fqdn)) {
178-
noRedirectHostnames = noRedirectHostnames.filter(host => !host.endsWith(fqdn))
177+
if (noIntegrationsHostnames.includes(fqdn)) {
178+
noIntegrationsHostnames = noIntegrationsHostnames.filter(host => !host.endsWith(fqdn))
179179
} else {
180-
noRedirectHostnames.push(fqdn)
180+
noIntegrationsHostnames.push(fqdn)
181181
}
182-
// console.dir('toggleSiteRedirect', state)
183-
await browser.storage.local.set({ noRedirectHostnames })
182+
// console.dir('toggleSiteIntegrations', state)
183+
await browser.storage.local.set({ noIntegrationsHostnames })
184184

185+
// TODO: remove below? does it still make sense in "integrations toggle" context?
185186
// Reload the current tab to apply updated redirect preference
186187
if (!state.currentDnslinkFqdn || !IsIpfs.ipnsUrl(state.currentTab.url)) {
187188
// No DNSLink, reload URL as-is
@@ -198,7 +199,7 @@ module.exports = (state, emitter) => {
198199
})
199200
}
200201
} catch (error) {
201-
console.error(`Unable to update redirect state due to ${error}`)
202+
console.error(`Unable to update integrations state due to ${error}`)
202203
emitter.emit('render')
203204
}
204205
})

add-on/src/popup/page-action/page.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ module.exports = function pageActionPage (state, emit) {
1313
const onCopy = (copyAction) => emit('copy', copyAction)
1414
const onPin = () => emit('pin')
1515
const onUnPin = () => emit('unPin')
16-
const onToggleSiteRedirect = () => emit('toggleSiteRedirect')
16+
const onToggleSiteIntegrations = () => emit('toggleSiteIntegrations')
1717

18-
const contextActionsProps = Object.assign({ onViewOnGateway, onCopy, onPin, onUnPin, onToggleSiteRedirect }, state)
18+
const contextActionsProps = Object.assign({ onViewOnGateway, onCopy, onPin, onUnPin, onToggleSiteIntegrations }, state)
1919

2020
// Instant init: page-action is shown only in ipfsContext
2121
contextActionsProps.isIpfsContext = true

0 commit comments

Comments
 (0)