
Research
/Security News
Trivy Under Attack Again: Widespread GitHub Actions Tag Compromise Exposes CI/CD Secrets
Attackers compromised Trivy GitHub Actions by force-updating tags to deliver malware, exposing CI/CD secrets across affected pipelines.
ipfsd-ctl
Advanced tools
Spawn IPFS daemons using JavaScript!
Version 1.0.0 changed a bit the api and the options methods take so please read the documentation below.
npm install --save ipfsd-ctl
Please ensure your project also has dependencies on ipfs, ipfs-http-client and go-ipfs.
npm install --save ipfs
npm install --save ipfs-http-client
npm install --save go-ipfs
If you are only going to use the go implementation of IPFS, you can skip installing the js implementation and vice versa, though both will require the ipfs-http-client module.
If you are only using the proc type in-process IPFS node, you can skip installing go-ipfs and ipfs-http-client.
You also need to explicitly defined the options
ipfsBin,ipfsModuleandipfsHttpModuleaccording to your needs. Check ControllerOptions and ControllerOptionsOverrides for more information.
createControllerThis is a shorthand for simpler use cases where factory is not needed.
// No need to create a factory when only a single controller is needed.
// Use createController to spawn it instead.
const Ctl = require('ipfsd-ctl')
const ipfsd = await Ctl.createController({
ipfsHttpModule,
ipfsBin: goIpfsModule.path()
})
const id = await ipfsd.api.id()
console.log(id)
await ipfsd.stop()
createFactoryUse a factory to spawn multiple controllers based on some common template.
Spawn an IPFS daemon from Node.js
// Create a factory to spawn two test disposable controllers, get access to an IPFS api
// print node ids and clean all the controllers from the factory.
const Ctl = require('ipfsd-ctl')
const factory = Ctl.createFactory(
{
type: 'js',
test: true,
disposable: true,
ipfsHttpModule,
ipfsModule: (await import('ipfs')) // only if you gonna spawn 'proc' controllers
},
{ // overrides per type
js: {
ipfsBin: ipfsModule.path()
},
go: {
ipfsBin: goIpfsModule.path()
}
}
)
const ipfsd1 = await factory.spawn() // Spawns using options from `createFactory`
const ipfsd2 = await factory.spawn({ type: 'go' }) // Spawns using options from `createFactory` but overrides `type` to spawn a `go` controller
console.log(await ipfsd1.api.id())
console.log(await ipfsd2.api.id())
await factory.clean() // Clean all the controllers created by the factory calling `stop` on all of them.
Spawn an IPFS daemon from the Browser using the provided remote endpoint
// Start a remote disposable node, and get access to the api
// print the node id, and stop the temporary daemon
const Ctl = require('ipfsd-ctl')
const port = 9090
const server = Ctl.createServer(port, {
ipfsModule,
ipfsHttpModule
},
{
js: {
ipfsBin: ipfsModule.path()
},
go: {
ipfsBin: goIpfsModule.path()
},
})
const factory = Ctl.createFactory({
ipfsHttpModule,
remote: true,
endpoint: `http://localhost:${port}` // or you can set process.env.IPFSD_CTL_SERVER to http://localhost:9090
})
await server.start()
const ipfsd = await factory.spawn()
const id = await ipfsd.api.id()
console.log(id)
await ipfsd.stop()
await server.stop()
ipfsd-ctl can spawn disposable and non-disposable nodes.
disposable- Disposable nodes are useful for tests or other temporary use cases, by default they create a temporary repo and automatically initialise and start the node, plus they cleanup everything when stopped.non-disposable - Non disposable nodes will by default attach to any nodes running on the default or the supplied repo. Requires the user to initialize and start the node, as well as stop and cleanup afterwards.createFactory([options], [overrides])Creates a factory that can spawn multiple controllers and pre-define options for them.
options ControllerOptions Controllers options.overrides ControllerOptionsOverrides Pre-defined options overrides per controller type.Returns a Factory
createController([options])Creates a controller.
options ControllerOptions Factory options.Returns Promise<Controller>
createServer([options])Create an Endpoint Server. This server is used by a client node to control a remote node. Example: Spawning a go-ipfs node from a browser.
options [Object] Factory options. Defaults to: { port: 43134 }
port number Port to start the server on.Returns a Server
controllersController[] List of all the controllers spawned.
tmpDir()Create a temporary repo to create controllers manually.
Returns Promise<String> - Path to the repo.
spawn([options])Creates a controller for a IPFS node.
options ControllerOptions Factory options.Returns Promise<Controller>
clean()Cleans all controllers spawned.
Returns Promise<Factory>
Class controller for a IPFS node.
new Controller(options)options ControllerOptionspathString Repo path.
execString Executable path.
envObject ENV object.
initializedBoolean Flag with the current init state.
startedBoolean Flag with the current start state.
cleanBoolean Flag with the current clean state.
apiAddrMultiaddr API address
gatewayAddrMultiaddr Gateway address
apiObject IPFS core interface
init([initOptions])Initialises controlled node
initOptions [Object] IPFS init options https://github.com/ipfs/js-ipfs/blob/master/README.md#optionsinitReturns Promise<Controller>
start()Starts controlled node.
Returns Promise<IPFS>
stop()Stops controlled node.
Returns Promise<Controller>
cleanup()Cleans controlled node, a disposable controller calls this automatically.
Returns Promise<Controller>
pid()Get the pid of the controlled node process if aplicable.
Returns Promise<number>
version()Get the version of the controlled node.
Returns Promise<string>
Type: [Object]
js [ControllerOptions] Pre-defined defaults options for JS controllers these are deep merged with options passed to Factory.spawn(options).go [ControllerOptions] Pre-defined defaults options for Go controllers these are deep merged with options passed to Factory.spawn(options).proc [ControllerOptions] Pre-defined defaults options for Proc controllers these are deep merged with options passed to Factory.spawn(options).Type: [Object]
test [boolean] Flag to activate custom config for tests.remote [boolean] Use remote endpoint to spawn the nodes. Defaults to true when not in node.endpoint [string] Endpoint URL to manage remote Controllers. (Defaults: 'http://localhost:43134').disposable [boolean] A new repo is created and initialized for each invocation, as well as cleaned up automatically once the process exits.type [string] The daemon type, see below the options:
env [Object] Additional environment variables, passed to executing shell. Only applies for Daemon controllers.args [Array] Custom cli args.ipfsHttpModule [Object] Reference to a IPFS HTTP Client object.ipfsModule [Object] Reference to a IPFS API object.ipfsBin [string] Path to a IPFS exectutable.ipfsOptions [IpfsOptions] Options for the IPFS instance same as https://github.com/ipfs/js-ipfs#ipfs-constructor. proc nodes receive these options as is, daemon nodes translate the options as far as possible to cli arguments.forceKill [boolean] - Whether to use SIGKILL to quit a daemon that does not stop after .stop() is called. (default true)forceKillTimeout [Number] - How long to wait before force killing a daemon in ms. (default 5000)In additional to the API described in previous sections, ipfsd-ctl also supports several environment variables. This are often very useful when running in different environments, such as CI or when doing integration/interop testing.
Environment variables precedence order is as follows. Top to bottom, top entry has highest precedence:
Meaning that, environment variables override defaults in the configuration file but are superseded by options to df.spawn({...})
An alternative way of specifying the executable path for the js-ipfs or go-ipfs executable, respectively.
Feel free to join in. All welcome. Open an issue!
This repository falls under the IPFS Code of Conduct.
FAQs
Spawn IPFS Daemons, Kubo or...
The npm package ipfsd-ctl receives a total of 873 weekly downloads. As such, ipfsd-ctl popularity was classified as not popular.
We found that ipfsd-ctl demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Attackers compromised Trivy GitHub Actions by force-updating tags to deliver malware, exposing CI/CD secrets across affected pipelines.

Security News
ENISA’s new package manager advisory outlines the dependency security practices companies will need to demonstrate as the EU’s Cyber Resilience Act begins enforcing software supply chain requirements.

Research
/Security News
We identified over 20 additional malicious extensions, along with over 20 related sleeper extensions, some of which have already been weaponized.