Skip to content

Commit 8bc27a2

Browse files
authored
chore: dependency updates (#731)
Prep for new Beta: - [x] new yarn - [x] new deps - [x] new js-ipfs with HAMT+IPNS patches merged - [x] new js-ipfs-http-client with multipart fixes - [x] new standard - [x] CI fix for MacOS
2 parents 126380c + 95d3613 commit 8bc27a2

20 files changed

+4009
-3565
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ addons:
1515
homebrew:
1616
packages: jq
1717
install:
18+
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew install jq ; fi
1819
- npm run ci:install
1920
script:
2021
- npm run ci:build

add-on/src/contentScripts/ipfs-proxy/page.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ function createWindowIpfs () {
3232
const proxyClient = createProxyClient()
3333

3434
// Add deprecation warning to window.ipfs.<cmd>
35-
for (let cmd in proxyClient) {
36-
let fn = proxyClient[cmd]
35+
for (const cmd in proxyClient) {
36+
const fn = proxyClient[cmd]
3737
proxyClient[cmd] = function () {
3838
console.warn('Calling commands directly on window.ipfs is deprecated and will be removed on 2019-09-01. Use API instance returned by window.ipfs.enable() instead. More: https://github.com/ipfs-shipyard/ipfs-companion/blob/master/docs/window.ipfs.md')
3939
return fn.apply(this, arguments)

add-on/src/contentScripts/linkifyDOM.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* eslint-env browser, webextensions */
33

44
const browser = require('webextension-polyfill')
5-
const PQueue = require('p-queue')
5+
const { default: PQueue } = require('p-queue')
66

77
/*
88
* This content script is responsible for performing the logic of replacing
@@ -65,7 +65,7 @@ const PQueue = require('p-queue')
6565
async function linkifyMutation (mutation, linkifyJobs) {
6666
linkifyJobs = linkifyJobs || new PQueue({ concurrency: 1 })
6767
if (mutation.type === 'childList') {
68-
for (let addedNode of mutation.addedNodes) {
68+
for (const addedNode of mutation.addedNodes) {
6969
if (addedNode.nodeType === Node.TEXT_NODE) {
7070
linkifyJobs.add(async () => linkifyTextNode(addedNode))
7171
} else {

add-on/src/contentScripts/normalizeLinksWithUnhandledProtocols.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
new MutationObserver(function (mutations) {
3939
mutations.forEach(function (mutation) {
4040
if (mutation.type === 'childList') {
41-
for (let addedNode of mutation.addedNodes) {
41+
for (const addedNode of mutation.addedNodes) {
4242
if (addedNode.nodeType === Node.ELEMENT_NODE) {
4343
setTimeout(() => normalizeTree(addedNode), 0)
4444
}

add-on/src/lib/context-menus.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,13 @@ function createContextMenus (getState, runtime, ipfsPathValidator, { onAddFromCo
173173
}
174174
}
175175
const ifApi = getState().peerCount > 0
176-
for (let item of apiMenuItems) {
176+
for (const item of apiMenuItems) {
177177
await browser.contextMenus.update(item, { enabled: ifApi })
178178
}
179-
for (let item of ipfsContextItems) {
179+
for (const item of ipfsContextItems) {
180180
await browser.contextMenus.update(item, { enabled: ipfsContext })
181181
}
182-
for (let item of apiAndIpfsContextItems) {
182+
for (const item of apiAndIpfsContextItems) {
183183
await browser.contextMenus.update(item, { enabled: (ifApi && ipfsContext) })
184184
}
185185
} catch (err) {

add-on/src/lib/dnslink.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ log.error = debug('ipfs-companion:dnslink:error')
77

88
const IsIpfs = require('is-ipfs')
99
const LRU = require('lru-cache')
10-
const PQueue = require('p-queue')
10+
const { default: PQueue } = require('p-queue')
1111
const { offlinePeerCount } = require('./state')
1212
const { pathAtHttpGateway } = require('./ipfs-path')
1313

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

+14-14
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ module.exports = async function init () {
9696
}
9797

9898
function registerListeners () {
99-
let onBeforeSendInfoSpec = ['blocking', 'requestHeaders']
99+
const onBeforeSendInfoSpec = ['blocking', 'requestHeaders']
100100
if (!runtime.isFirefox) {
101101
// Chrome 72+ requires 'extraHeaders' for access to Referer header (used in cors whitelisting of webui)
102102
onBeforeSendInfoSpec.push('extraHeaders')
@@ -230,7 +230,7 @@ module.exports = async function init () {
230230
currentTab: await browser.tabs.query({ active: true, currentWindow: true }).then(tabs => tabs[0])
231231
}
232232
try {
233-
let v = await ipfs.version()
233+
const v = await ipfs.version()
234234
if (v) {
235235
info.gatewayVersion = v.commit ? v.version + '/' + v.commit : v.version
236236
}
@@ -321,7 +321,7 @@ module.exports = async function init () {
321321
notify('notify_uploadErrorTitle', 'notify_uploadTrackingProtectionErrorMsg')
322322
console.warn('IPFS upload often fails because remote file can not be downloaded due to Tracking Protection. See details at: https://github.com/ipfs/ipfs-companion/issues/227')
323323
browser.tabs.create({
324-
'url': 'https://github.com/ipfs/ipfs-companion/issues/227'
324+
url: 'https://github.com/ipfs/ipfs-companion/issues/227'
325325
})
326326
} else {
327327
notify('notify_uploadErrorTitle', 'notify_inlineErrorMsg', `${error.message}`)
@@ -345,15 +345,15 @@ module.exports = async function init () {
345345
}
346346

347347
async function uploadResultHandler ({ result, openRootInNewTab = false }) {
348-
for (let file of result) {
348+
for (const file of result) {
349349
if (file && file.hash) {
350350
const { path, url } = getIpfsPathAndNativeAddress(file.hash)
351351
preloadAtPublicGateway(path)
352352
console.info('[ipfs-companion] successfully stored', file)
353353
// open the wrapping directory (or the CID if wrapping was disabled)
354354
if (openRootInNewTab && (result.length === 1 || file.path === '' || file.path === file.hash)) {
355355
await browser.tabs.create({
356-
'url': url
356+
url: url
357357
})
358358
}
359359
}
@@ -464,7 +464,7 @@ module.exports = async function init () {
464464

465465
async function apiStatusUpdate () {
466466
// update peer count
467-
let oldPeerCount = state.peerCount
467+
const oldPeerCount = state.peerCount
468468
state.peerCount = await getSwarmPeerCount()
469469
updatePeerCountDependentStates(oldPeerCount, state.peerCount)
470470
// trigger pending updates
@@ -535,7 +535,7 @@ module.exports = async function init () {
535535
}
536536

537537
async function setBrowserActionIcon (iconPath) {
538-
let iconDefinition = { path: iconPath }
538+
const iconDefinition = { path: iconPath }
539539
try {
540540
// Try SVG first -- Firefox supports it natively
541541
await browser.browserAction.setIcon(iconDefinition)
@@ -553,17 +553,17 @@ module.exports = async function init () {
553553
// - https://bugs.chromium.org/p/chromium/issues/detail?id=647182
554554
// - https://developer.chrome.com/extensions/manifest/icons
555555
return {
556-
'path': {
557-
'19': rasterIconPath(svgPath, 19),
558-
'38': rasterIconPath(svgPath, 38),
559-
'128': rasterIconPath(svgPath, 128)
556+
path: {
557+
19: rasterIconPath(svgPath, 19),
558+
38: rasterIconPath(svgPath, 38),
559+
128: rasterIconPath(svgPath, 128)
560560
}
561561
}
562562
}
563563

564564
function rasterIconPath (iconPath, size) {
565565
// point at precomputed PNG file
566-
let baseName = /\/icons\/(.+)\.svg/.exec(iconPath)[1]
566+
const baseName = /\/icons\/(.+)\.svg/.exec(iconPath)[1]
567567
return `/icons/png/${baseName}_${size}.png`
568568
}
569569

@@ -602,7 +602,7 @@ module.exports = async function init () {
602602
let shouldRestartIpfsClient = false
603603
let shouldStopIpfsClient = false
604604

605-
for (let key in changes) {
605+
for (const key in changes) {
606606
const change = changes[key]
607607
if (change.oldValue === change.newValue) continue
608608

@@ -729,7 +729,7 @@ module.exports = async function init () {
729729
},
730730

731731
destroy () {
732-
let destroyTasks = []
732+
const destroyTasks = []
733733
clearInterval(apiStatusUpdateInterval)
734734
apiStatusUpdateInterval = null
735735
ipfs = null

add-on/src/lib/ipfs-proxy/access-control.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* eslint-env browser */
33

44
const EventEmitter = require('events')
5-
const PQueue = require('p-queue')
5+
const { default: PQueue } = require('p-queue')
66

77
class AccessControl extends EventEmitter {
88
constructor (storage, storageKeyPrefix = 'ipfsProxyAcl') {

add-on/src/lib/ipfs-proxy/enable-command.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ function createEnableCommand (getIpfs, getState, getScope, accessControl, reques
2121
// Validate and prompt for any missing permissions in bulk
2222
// if a list of needed commands is announced up front
2323
if (opts.commands) {
24-
let missingAcls = []
25-
let deniedAcls = []
26-
for (let command of opts.commands) {
24+
const missingAcls = []
25+
const deniedAcls = []
26+
for (const command of opts.commands) {
2727
// Fail fast if command is not allowed to be proxied at all
2828
if (!inCommandWhitelist(command)) {
2929
throw createCommandWhitelistError(command)
3030
}
3131
// Get the current access flag to decide if it should be added
3232
// to the list of permissions to be prompted about in the next step
33-
let access = await accessControl.getAccess(scope, command)
33+
const access = await accessControl.getAccess(scope, command)
3434
if (!access) {
3535
missingAcls.push(command)
3636
} else if (access.allow !== true) {
@@ -44,7 +44,7 @@ function createEnableCommand (getIpfs, getState, getScope, accessControl, reques
4444
// Display a single prompt with all missing permissions
4545
if (missingAcls.length) {
4646
const { allow, wildcard } = await requestAccess(scope, missingAcls)
47-
let access = await accessControl.setAccess(scope, wildcard ? '*' : missingAcls, allow)
47+
const access = await accessControl.setAccess(scope, wildcard ? '*' : missingAcls, allow)
4848
if (!access.allow) {
4949
throw createProxyAclError(scope, missingAcls)
5050
}

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function createRequestModifier (getState, dnslinkResolver, ipfsPathValidator, ru
4545
// To reconstruct originUrl we read full URL from Referer header in onBeforeSendHeaders
4646
// and cache it for short time
4747
// TODO: when request.originUrl is available in Chrome the `originUrls` cache can be removed
48-
let cachedUrl = originUrls.get(request.requestId)
48+
const cachedUrl = originUrls.get(request.requestId)
4949
if (cachedUrl) return cachedUrl
5050
if (request.requestHeaders) {
5151
const referer = request.requestHeaders.find(h => h.name === 'Referer')
@@ -230,7 +230,7 @@ function createRequestModifier (getState, dnslinkResolver, ipfsPathValidator, ru
230230
let addExpectHeader = true
231231
const expectHeader = { name: 'Expect', value: '100-continue' }
232232
const warningMsg = 'Executing "Expect: 100-continue" workaround for ipfs.add due to https://github.com/ipfs/go-ipfs/issues/5168'
233-
for (let header of request.requestHeaders) {
233+
for (const header of request.requestHeaders) {
234234
// Workaround A: https://github.com/ipfs/go-ipfs/issues/5168#issuecomment-401417420
235235
// (works in Firefox, but Chromium does not expose Connection header)
236236
/* (disabled so we use the workaround B in all browsers)
@@ -335,7 +335,7 @@ function createRequestModifier (getState, dnslinkResolver, ipfsPathValidator, ru
335335
const notActiveGatewayOrApi = !(url.startsWith(state.pubGwURLString) || url.startsWith(state.gwURLString) || url.startsWith(state.apiURLString))
336336
if (state.detectIpfsPathHeader && request.responseHeaders && notActiveGatewayOrApi) {
337337
// console.log('onHeadersReceived.request', request)
338-
for (let header of request.responseHeaders) {
338+
for (const header of request.responseHeaders) {
339339
if (header.name.toLowerCase() === 'x-ipfs-path' && isSafeToRedirect(request, runtime)) {
340340
// console.log('onHeadersReceived.request.responseHeaders', request.responseHeaders.length)
341341
const xIpfsPath = header.value

add-on/src/lib/options.js

+18-9
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
const isFQDN = require('is-fqdn')
44
const { hasChromeSocketsForTcp } = require('./runtime-checks')
55

6-
// Detect Beta Channel on Brave via: chrome.runtime.id === 'hjoieblefckbooibpepigmacodalfndh'
7-
// TODO: enable by default when key blockers are resolved
8-
// - [ ] /ipns/<fqdn>/ load fine
9-
// - [ ] sharded directories (e.g. wikipedia) load fine
6+
// TODO: enable by default when embedded node is performant enough
107
const DEFAULT_TO_EMBEDDED_GATEWAY = false && hasChromeSocketsForTcp()
118

129
exports.optionDefaults = Object.freeze({
@@ -48,7 +45,7 @@ function buildDefaultIpfsNodeType () {
4845
}
4946

5047
function buildDefaultIpfsNodeConfig () {
51-
let config = {
48+
const config = {
5249
config: {
5350
Addresses: {
5451
Swarm: []
@@ -61,8 +58,19 @@ function buildDefaultIpfsNodeConfig () {
6158
// for people already running regular go-ipfs and js-ipfs on standard ports
6259
config.config.Addresses.API = '/ip4/127.0.0.1/tcp/5003'
6360
config.config.Addresses.Gateway = '/ip4/127.0.0.1/tcp/9091'
61+
6462
// Until we have MulticastDNS+DNS, peer discovery is done over ws-star
65-
config.config.Addresses.Swarm.push('/dnsaddr/ws-star.discovery.libp2p.io/tcp/443/wss/p2p-websocket-star')
63+
config.config.Addresses.Swarm = ['/dns4/ws-star1.par.dwebops.pub/tcp/443/wss/p2p-websocket-star']
64+
// Until DHT and p2p transport are ready, delegate + preload
65+
const delegates = [
66+
'/dns4/node0.preload.ipfs.io/tcp/443/https',
67+
'/dns4/node1.preload.ipfs.io/tcp/443/https'
68+
]
69+
// Delegated Content and Peer Routing: https://github.com/ipfs/js-ipfs/pull/2195
70+
// TODO: delegated routing blocked by https://github.com/libp2p/js-libp2p-delegated-content-routing/issues/12
71+
// config.config.Addresses.Delegates = delegates
72+
// TODO: are preloads needed? should Brave have own nodes?
73+
config.preload = { enabled: true, addresses: delegates }
6674
/*
6775
(Sidenote on why we need API for Web UI)
6876
Gateway can run without API port,
@@ -80,11 +88,12 @@ function buildDefaultIpfsNodeConfig () {
8088
exports.storeMissingOptions = async (read, defaults, storage) => {
8189
const requiredKeys = Object.keys(defaults)
8290
const changes = {}
83-
for (let key of requiredKeys) {
91+
const has = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key)
92+
for (const key of requiredKeys) {
8493
// limit work to defaults and missing values, skip values other than defaults
85-
if (!read.hasOwnProperty(key) || read[key] === defaults[key]) {
94+
if (!has(read, key) || read[key] === defaults[key]) {
8695
const data = await storage.get(key)
87-
if (!data.hasOwnProperty(key)) { // detect and fix key without value in storage
96+
if (!has(data, key)) { // detect and fix key without value in storage
8897
changes[key] = defaults[key]
8998
}
9099
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ module.exports = (state, emitter) => {
167167
try {
168168
let noRedirectHostnames = state.noRedirectHostnames
169169
// if we are on /ipns/fqdn.tld/ then use hostname from DNSLink
170-
let fqdn = state.currentDnslinkFqdn || state.currentFqdn
170+
const fqdn = state.currentDnslinkFqdn || state.currentFqdn
171171
if (noRedirectHostnames.includes(fqdn)) {
172172
noRedirectHostnames = noRedirectHostnames.filter(host => !host.endsWith(fqdn))
173173
} else {

add-on/src/popup/quick-upload.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ async function processFiles (state, emitter, files) {
6161
}
6262
const { ipfsCompanion } = await browser.runtime.getBackgroundPage()
6363
const uploadTab = await browser.tabs.getCurrent()
64-
let { streams, totalSize } = files2streams(files)
64+
const { streams, totalSize } = files2streams(files)
6565
progressHandler(0, totalSize, state, emitter)
6666
emitter.emit('render')
6767
const wrapFlag = (state.wrapWithDirectory || streams.length > 1)
@@ -113,7 +113,7 @@ function file2buffer (file) {
113113
function files2streams (files) {
114114
const streams = []
115115
let totalSize = 0
116-
for (let file of files) {
116+
for (const file of files) {
117117
if (!file.type && file.size === 0) {
118118
// UX fail-safe:
119119
// at the moment drag&drop of an empty file without an extension

0 commit comments

Comments
 (0)