Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import filesBundle from './files'
import configBundle from './config'
import configSaveBundle from './config-save'
import navbarBundle from './navbar'
import toursBundle from './tours'
import notifyBundle from './notify'
import connectedBundle from './connected'
import retryInitBundle from './retry-init'
import identityBundle from './identity'
import bundleCache from '../lib/bundle-cache'
import ipfsDesktop from './ipfs-desktop'
import repoStats from './repo-stats'
import createAnalyticsBundle from './analytics'
import experimentsBundle from './experiments'
export default composeBundles(
createCacheBundle({
cacheFn: bundleCache.set
}),
appIdle({ idleTimeout: 5000 }),
ipfsBundle({
tryWindow: false,
ipfsConnectionTest: async (ipfs) => {
// ipfs connection is working if can we fetch the bw stats.
// See: https://github.com/ipfs-shipyard/ipfs-webui/issues/835#issuecomment-466966884
try {
await ipfs.stats.bw()
} catch (err) {
if (!/bandwidth reporter disabled in config/.test(err)) {
throw err
}
}
import configBundle from './config'
import configSaveBundle from './config-save'
import navbarBundle from './navbar'
import toursBundle from './tours'
import notifyBundle from './notify'
import connectedBundle from './connected'
import retryInitBundle from './retry-init'
import identityBundle from './identity'
import bundleCache from '../lib/bundle-cache'
import ipfsDesktop from './ipfs-desktop'
import repoStats from './repo-stats'
import createAnalyticsBundle from './analytics'
import experimentsBundle from './experiments'
export default composeBundles(
createCacheBundle({
cacheFn: bundleCache.set
}),
appIdle({ idleTimeout: 5000 }),
ipfsBundle({
tryWindow: false,
ipfsConnectionTest: async (ipfs) => {
// ipfs connection is working if can we fetch the bw stats.
// See: https://github.com/ipfs-shipyard/ipfs-webui/issues/835#issuecomment-466966884
try {
await ipfs.stats.bw()
} catch (err) {
if (!/bandwidth reporter disabled in config/.test(err)) {
throw err
}
}
const bundle = createAsyncResourceBundle({
name: 'stats',
getPromise: async ({ getIpfs }) => {
const bw = await getIpfs().stats.bw()
return { bw }
},
staleAfter: 3000,
retryAfter: 3000,
persist: false,
checkIfOnline: false
})
bundle.selectStatsLastSuccess = state => state.stats.lastSuccess
// Fetch the config if we don't have it or it's more than `staleAfter` ms old
bundle.reactStatsFetch = createSelector(
'selectStatsShouldUpdate',
'selectIpfsReady',
(shouldUpdate, ipfsReady) => {
if (shouldUpdate && ipfsReady) {
return { actionCreator: 'doFetchStats' }
}
}
)
export default bundle
(config) => getURLFromAddress('API', config) || 'https://ipfs.io'
)
bundle.selectGatewayUrl = createSelector(
'selectConfigObject',
(config) => getURLFromAddress('Gateway', config) || 'https://ipfs.io'
)
bundle.selectBootstrapPeers = createSelector(
'selectConfigObject',
(config) => config && config.Bootstrap
)
// TODO: this is a work-around for IPFS companion blocking the config API
// see: https://github.com/ipfs-shipyard/ipfs-companion/issues/454
bundle.selectIsConfigBlocked = createSelector(
'selectConfigRaw',
({ errorType }) => errorType === 'Access to config.get API is globally blocked for window.ipfs'
)
// Fetch the config if we don't have it or it's more than `staleAfter` ms old
bundle.reactConfigFetch = createSelector(
'selectConfigShouldUpdate',
'selectIpfsReady',
(shouldUpdate, ipfsReady) => {
if (shouldUpdate && ipfsReady) {
return { actionCreator: 'doFetchConfig' }
}
}
)
function getURLFromAddress (name, config) {
return repoStats.repoSize.toString()
}
}
)
bundle.selectRepoNumObjects = createSelector(
'selectRepoStats',
(repoStats) => {
if (repoStats && repoStats.numObjects) {
return repoStats.numObjects.toString()
}
}
)
// Fetch the config if we don't have it or it's more than `staleAfter` ms old
bundle.reactRepoStatsFetch = createSelector(
'selectRepoStatsShouldUpdate',
'selectIpfsReady',
(shouldUpdate, ipfsReady) => {
if (shouldUpdate && ipfsReady) {
return { actionCreator: 'doFetchRepoStats' }
}
}
)
export default bundle
import { createAsyncResourceBundle, createSelector } from 'redux-bundler'
import { resolveIpldPath, quickSplitPath } from '../lib/path'
// Find all the nodes and path boundaries traversed along a given path
const bundle = createAsyncResourceBundle({
name: 'explore',
actionBaseType: 'EXPLORE',
getPromise: async (args) => {
const { store, getIpfs } = args
const hash = store.selectHash()
let path = decodeURIComponent(hash.replace('/explore', ''))
if (!path) return null
const { cidOrFqdn, rest } = quickSplitPath(path)
const { targetNode, canonicalPath, localPath, nodes, pathBoundaries } = await resolveIpldPath(getIpfs, cidOrFqdn, rest)
return {
path,
targetNode,
canonicalPath,
localPath,
nodes,
pathBoundaries
export default function (opts) {
opts = opts || {}
// Max number of locations to retrieve concurrently.
// HTTP API are throttled to max 4-6 at a time by the browser itself.
opts.concurrency = opts.concurrency || 4
// Cache options
opts.cache = opts.cache || {}
const peerLocResolver = new PeerLocationResolver(opts)
const bundle = createAsyncResourceBundle({
name: 'peerLocations',
actionBaseType: 'PEER_LOCATIONS',
getPromise: async ({ store, getIpfs }) => {
const peers = store.selectPeers()
return peerLocResolver.findLocations(peers, getIpfs)
},
staleAfter: UPDATE_EVERY,
retryAfter: UPDATE_EVERY,
persist: false,
checkIfOnline: false
})
bundle.reactPeerLocationsFetch = createSelector(
'selectRouteInfo',
'selectPeerLocationsShouldUpdate',
'selectIpfsConnected',
import { createAsyncResourceBundle, createSelector } from 'redux-bundler'
const bundle = createAsyncResourceBundle({
name: 'identity',
actionBaseType: 'IDENTITY',
getPromise: ({ getIpfs }) => getIpfs().id(),
staleAfter: Infinity,
persist: false,
checkIfOnline: false
})
bundle.selectIdentityLastSuccess = state => state.identity.lastSuccess
// Update identity after we (re)connect with ipfs
bundle.reactIdentityFetch = createSelector(
'selectIpfsConnected',
'selectIdentityIsLoading',
'selectIdentityLastSuccess',
'selectConnectedLastError',
import { createAsyncResourceBundle, createSelector } from 'redux-bundler'
const bundle = createAsyncResourceBundle({
name: 'stats',
getPromise: async ({ getIpfs }) => {
const bw = await getIpfs().stats.bw()
return { bw }
},
staleAfter: 3000,
retryAfter: 3000,
persist: false,
checkIfOnline: false
})
bundle.selectStatsLastSuccess = state => state.stats.lastSuccess
// Fetch the config if we don't have it or it's more than `staleAfter` ms old
bundle.reactStatsFetch = createSelector(
'selectStatsShouldUpdate',
import toUri from 'multiaddr-to-uri'
import { createAsyncResourceBundle, createSelector } from 'redux-bundler'
const bundle = createAsyncResourceBundle({
name: 'config',
getPromise: async ({ getIpfs }) => {
// SEE: https://github.com/ipfs/js-ipfs-api/issues/822
const rawConf = await getIpfs().config.get()
let conf
if (Buffer.isBuffer(rawConf)) {
conf = rawConf.toString()
} else {
conf = JSON.stringify(rawConf, null, '\t')
}
// stringy json for quick compares
return conf
},
staleAfter: 60000,