├── .dockerignore ├── .editorconfig ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── config.yml │ └── open_an_issue.md ├── config.yml ├── dependabot.yml └── workflows │ ├── examples.yml │ ├── externals.yml │ ├── stale.yml │ └── test.yml ├── .gitignore ├── .release-please-manifest.json ├── .release-please.json ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── COPYRIGHT ├── Dockerfile.latest ├── Dockerfile.next ├── LICENSE ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md ├── docs ├── ARCHITECTURE.md ├── BROWSERS.md ├── CLI.md ├── CONFIG.md ├── CORS.md ├── DAEMON.md ├── DELEGATE_ROUTERS.md ├── DEVELOPMENT.md ├── DOCKER.md ├── EARLY_TESTERS.md ├── FAQ.md ├── IPLD.md ├── MIGRATION-TO-ASYNC-AWAIT.md ├── MODULE.md ├── MONITORING.md ├── README.md ├── RELEASES.md ├── RELEASE_ISSUE_TEMPLATE.md ├── core-api │ ├── BITSWAP.md │ ├── BLOCK.md │ ├── BOOTSTRAP.md │ ├── CONFIG.md │ ├── DAG.md │ ├── DHT.md │ ├── FILES.md │ ├── KEY.md │ ├── MISCELLANEOUS.md │ ├── NAME.md │ ├── OBJECT.md │ ├── PIN.md │ ├── PUBSUB.md │ ├── README.md │ ├── REFS.md │ ├── REPO.md │ ├── STATS.md │ └── SWARM.md ├── img │ ├── architecture.monopic │ ├── architecture.png │ ├── architecture.txt │ ├── core.monopic │ ├── core.png │ ├── core.txt │ ├── overview.monopic │ ├── overview.png │ └── overview.txt └── upgrading │ ├── v0.62-v0.63.md │ ├── v0.63-v0.64.md │ └── v0.64-v0.65.md ├── package-list.json ├── package.json ├── packages ├── interface-ipfs-core │ ├── .aegir.js │ ├── CHANGELOG.md │ ├── LICENSE │ ├── LICENSE-APACHE │ ├── LICENSE-MIT │ ├── README.md │ ├── img │ │ ├── badge.png │ │ ├── badge.sketch │ │ ├── badge.svg │ │ └── badge@2x.png │ ├── maintainer.json │ ├── package.json │ ├── src │ │ ├── add-all.js │ │ ├── add.js │ │ ├── bitswap │ │ │ ├── index.js │ │ │ ├── stat.js │ │ │ ├── transfer.js │ │ │ ├── unwant.js │ │ │ ├── utils.js │ │ │ ├── wantlist-for-peer.js │ │ │ └── wantlist.js │ │ ├── block │ │ │ ├── get.js │ │ │ ├── index.js │ │ │ ├── put.js │ │ │ ├── rm.js │ │ │ └── stat.js │ │ ├── bootstrap │ │ │ ├── add.js │ │ │ ├── clear.js │ │ │ ├── index.js │ │ │ ├── list.js │ │ │ ├── reset.js │ │ │ └── rm.js │ │ ├── cat.js │ │ ├── config │ │ │ ├── get.js │ │ │ ├── index.js │ │ │ ├── profiles │ │ │ │ ├── apply.js │ │ │ │ ├── index.js │ │ │ │ └── list.js │ │ │ ├── replace.js │ │ │ └── set.js │ │ ├── dag │ │ │ ├── export.js │ │ │ ├── get.js │ │ │ ├── import.js │ │ │ ├── index.js │ │ │ ├── put.js │ │ │ ├── resolve.js │ │ │ └── sharness-t0053-dag.js │ │ ├── dht │ │ │ ├── disabled.js │ │ │ ├── find-peer.js │ │ │ ├── find-provs.js │ │ │ ├── get.js │ │ │ ├── index.js │ │ │ ├── provide.js │ │ │ ├── put.js │ │ │ ├── query.js │ │ │ └── utils.js │ │ ├── files │ │ │ ├── chmod.js │ │ │ ├── cp.js │ │ │ ├── flush.js │ │ │ ├── index.js │ │ │ ├── ls.js │ │ │ ├── mkdir.js │ │ │ ├── mv.js │ │ │ ├── read.js │ │ │ ├── rm.js │ │ │ ├── stat.js │ │ │ ├── touch.js │ │ │ └── write.js │ │ ├── get.js │ │ ├── index.js │ │ ├── key │ │ │ ├── gen.js │ │ │ ├── import.js │ │ │ ├── index.js │ │ │ ├── list.js │ │ │ ├── rename.js │ │ │ └── rm.js │ │ ├── ls.js │ │ ├── miscellaneous │ │ │ ├── dns.js │ │ │ ├── id.js │ │ │ ├── index.js │ │ │ ├── resolve.js │ │ │ ├── stop.js │ │ │ └── version.js │ │ ├── name-pubsub │ │ │ ├── cancel.js │ │ │ ├── index.js │ │ │ ├── pubsub.js │ │ │ ├── state.js │ │ │ └── subs.js │ │ ├── name │ │ │ ├── index.js │ │ │ ├── publish.js │ │ │ ├── resolve.js │ │ │ └── utils.js │ │ ├── object │ │ │ ├── data.js │ │ │ ├── get.js │ │ │ ├── index.js │ │ │ ├── links.js │ │ │ ├── new.js │ │ │ ├── patch │ │ │ │ ├── add-link.js │ │ │ │ ├── append-data.js │ │ │ │ ├── index.js │ │ │ │ ├── rm-link.js │ │ │ │ └── set-data.js │ │ │ ├── put.js │ │ │ └── stat.js │ │ ├── pin │ │ │ ├── add-all.js │ │ │ ├── add.js │ │ │ ├── index.js │ │ │ ├── ls.js │ │ │ ├── remote │ │ │ │ ├── add.js │ │ │ │ ├── index.js │ │ │ │ ├── ls.js │ │ │ │ ├── rm-all.js │ │ │ │ ├── rm.js │ │ │ │ └── service.js │ │ │ ├── rm-all.js │ │ │ ├── rm.js │ │ │ └── utils.js │ │ ├── ping │ │ │ ├── index.js │ │ │ ├── ping.js │ │ │ └── utils.js │ │ ├── pubsub │ │ │ ├── index.js │ │ │ ├── ls.js │ │ │ ├── peers.js │ │ │ ├── publish.js │ │ │ ├── subscribe.js │ │ │ ├── unsubscribe.js │ │ │ └── utils.js │ │ ├── refs-local.js │ │ ├── refs.js │ │ ├── repo │ │ │ ├── gc.js │ │ │ ├── index.js │ │ │ ├── stat.js │ │ │ └── version.js │ │ ├── stats │ │ │ ├── bitswap.js │ │ │ ├── bw.js │ │ │ ├── index.js │ │ │ ├── repo.js │ │ │ └── utils.js │ │ ├── swarm │ │ │ ├── addrs.js │ │ │ ├── connect.js │ │ │ ├── disconnect.js │ │ │ ├── index.js │ │ │ ├── local-addrs.js │ │ │ └── peers.js │ │ └── utils │ │ │ ├── blockstore-adapter.js │ │ │ ├── create-sharded-directory.js │ │ │ ├── create-two-shards.js │ │ │ ├── dump-shard.js │ │ │ ├── index.js │ │ │ ├── ipfs-options-websockets-filter-all.js │ │ │ ├── is-shard-at-path.js │ │ │ ├── mocha.js │ │ │ ├── suite.js │ │ │ ├── test-timeout.js │ │ │ ├── traverse-leaf-nodes.js │ │ │ └── wait-for.js │ ├── test │ │ ├── fixtures │ │ │ ├── .gitattributes │ │ │ ├── car │ │ │ │ ├── combined_naked_roots_genesis_and_128.car │ │ │ │ ├── lotus_devnet_genesis.car │ │ │ │ ├── lotus_devnet_genesis_shuffled_nulroot.car │ │ │ │ ├── lotus_testnet_export_128.car │ │ │ │ └── lotus_testnet_export_256_multiroot.car │ │ │ ├── hidden-files-folder │ │ │ │ ├── .hiddenTest.txt │ │ │ │ ├── alice.txt │ │ │ │ ├── files │ │ │ │ │ ├── hello.txt │ │ │ │ │ └── ipfs.txt │ │ │ │ ├── hello-link │ │ │ │ ├── holmes.txt │ │ │ │ ├── ipfs-add.js │ │ │ │ ├── jungle.txt │ │ │ │ └── pp.txt │ │ │ ├── refs-test │ │ │ │ ├── animals │ │ │ │ │ ├── land │ │ │ │ │ │ ├── african.txt │ │ │ │ │ │ ├── americas.txt │ │ │ │ │ │ └── australian.txt │ │ │ │ │ └── sea │ │ │ │ │ │ ├── atlantic.txt │ │ │ │ │ │ └── indian.txt │ │ │ │ ├── atlantic-animals │ │ │ │ ├── fruits │ │ │ │ │ └── tropical.txt │ │ │ │ └── mushroom.txt │ │ │ ├── ssl │ │ │ │ ├── cert.pem │ │ │ │ └── privkey.pem │ │ │ ├── test-folder │ │ │ │ ├── alice.txt │ │ │ │ ├── files │ │ │ │ │ ├── hello.txt │ │ │ │ │ └── ipfs.txt │ │ │ │ ├── hello-link │ │ │ │ ├── holmes.txt │ │ │ │ ├── ipfs-add.js │ │ │ │ ├── jungle.txt │ │ │ │ └── pp.txt │ │ │ └── weird name folder [v0] │ │ │ │ ├── add │ │ │ │ ├── cat │ │ │ │ ├── files │ │ │ │ ├── hello.txt │ │ │ │ └── ipfs.txt │ │ │ │ ├── hello-link │ │ │ │ ├── ipfs-add │ │ │ │ ├── ls │ │ │ │ └── version │ │ └── interface.spec.js │ └── tsconfig.json ├── ipfs-cli │ ├── CHANGELOG.md │ ├── CODE_OF_CONDUCT.md │ ├── CONTRIBUTING.md │ ├── COPYRIGHT │ ├── LICENSE │ ├── LICENSE-APACHE │ ├── LICENSE-MIT │ ├── README.md │ ├── package.json │ ├── src │ │ ├── command-alias.js │ │ ├── commands │ │ │ ├── add.js │ │ │ ├── bitswap.js │ │ │ ├── bitswap │ │ │ │ ├── index.js │ │ │ │ ├── stat.js │ │ │ │ ├── unwant.js │ │ │ │ └── wantlist.js │ │ │ ├── block.js │ │ │ ├── block │ │ │ │ ├── get.js │ │ │ │ ├── index.js │ │ │ │ ├── put.js │ │ │ │ ├── rm.js │ │ │ │ └── stat.js │ │ │ ├── bootstrap.js │ │ │ ├── bootstrap │ │ │ │ ├── add.js │ │ │ │ ├── index.js │ │ │ │ ├── list.js │ │ │ │ └── rm.js │ │ │ ├── cat.js │ │ │ ├── cid.js │ │ │ ├── cid │ │ │ │ ├── base32.js │ │ │ │ ├── bases.js │ │ │ │ ├── codecs.js │ │ │ │ ├── format.js │ │ │ │ ├── hashes.js │ │ │ │ └── index.js │ │ │ ├── config.js │ │ │ ├── config │ │ │ │ ├── edit.js │ │ │ │ ├── index.js │ │ │ │ ├── profile.js │ │ │ │ ├── profile │ │ │ │ │ ├── apply.js │ │ │ │ │ ├── index.js │ │ │ │ │ └── ls.js │ │ │ │ ├── replace.js │ │ │ │ └── show.js │ │ │ ├── daemon.js │ │ │ ├── dag.js │ │ │ ├── dag │ │ │ │ ├── export.js │ │ │ │ ├── get.js │ │ │ │ ├── import.js │ │ │ │ ├── index.js │ │ │ │ ├── put.js │ │ │ │ └── resolve.js │ │ │ ├── dht.js │ │ │ ├── dht │ │ │ │ ├── find-peer.js │ │ │ │ ├── find-providers.js │ │ │ │ ├── get.js │ │ │ │ ├── index.js │ │ │ │ ├── provide.js │ │ │ │ ├── put.js │ │ │ │ └── query.js │ │ │ ├── dns.js │ │ │ ├── files.js │ │ │ ├── files │ │ │ │ ├── chmod.js │ │ │ │ ├── cp.js │ │ │ │ ├── flush.js │ │ │ │ ├── index.js │ │ │ │ ├── ls.js │ │ │ │ ├── mkdir.js │ │ │ │ ├── mv.js │ │ │ │ ├── read.js │ │ │ │ ├── rm.js │ │ │ │ ├── stat.js │ │ │ │ ├── touch.js │ │ │ │ └── write.js │ │ │ ├── get.js │ │ │ ├── id.js │ │ │ ├── index.js │ │ │ ├── init.js │ │ │ ├── key.js │ │ │ ├── key │ │ │ │ ├── export.js │ │ │ │ ├── gen.js │ │ │ │ ├── import.js │ │ │ │ ├── index.js │ │ │ │ ├── list.js │ │ │ │ ├── rename.js │ │ │ │ └── rm.js │ │ │ ├── ls.js │ │ │ ├── name.js │ │ │ ├── name │ │ │ │ ├── index.js │ │ │ │ ├── publish.js │ │ │ │ ├── pubsub.js │ │ │ │ ├── pubsub │ │ │ │ │ ├── cancel.js │ │ │ │ │ ├── index.js │ │ │ │ │ ├── state.js │ │ │ │ │ └── subs.js │ │ │ │ └── resolve.js │ │ │ ├── object.js │ │ │ ├── object │ │ │ │ ├── data.js │ │ │ │ ├── get.js │ │ │ │ ├── index.js │ │ │ │ ├── links.js │ │ │ │ ├── new.js │ │ │ │ ├── patch.js │ │ │ │ ├── patch │ │ │ │ │ ├── add-link.js │ │ │ │ │ ├── append-data.js │ │ │ │ │ ├── index.js │ │ │ │ │ ├── rm-link.js │ │ │ │ │ └── set-data.js │ │ │ │ ├── put.js │ │ │ │ └── stat.js │ │ │ ├── pin.js │ │ │ ├── pin │ │ │ │ ├── add.js │ │ │ │ ├── index.js │ │ │ │ ├── ls.js │ │ │ │ └── rm.js │ │ │ ├── ping.js │ │ │ ├── pubsub.js │ │ │ ├── pubsub │ │ │ │ ├── index.js │ │ │ │ ├── ls.js │ │ │ │ ├── peers.js │ │ │ │ ├── pub.js │ │ │ │ └── sub.js │ │ │ ├── refs-local.js │ │ │ ├── refs.js │ │ │ ├── repo.js │ │ │ ├── repo │ │ │ │ ├── gc.js │ │ │ │ ├── index.js │ │ │ │ ├── stat.js │ │ │ │ └── version.js │ │ │ ├── resolve.js │ │ │ ├── shutdown.js │ │ │ ├── stats.js │ │ │ ├── stats │ │ │ │ ├── bitswap.js │ │ │ │ ├── bw.js │ │ │ │ ├── index.js │ │ │ │ └── repo.js │ │ │ ├── swarm.js │ │ │ ├── swarm │ │ │ │ ├── addrs.js │ │ │ │ ├── addrs │ │ │ │ │ ├── index.js │ │ │ │ │ └── local.js │ │ │ │ ├── connect.js │ │ │ │ ├── disconnect.js │ │ │ │ ├── index.js │ │ │ │ └── peers.js │ │ │ └── version.js │ │ ├── index.js │ │ ├── parser.js │ │ ├── types.ts │ │ └── utils.js │ ├── test │ │ ├── add.spec.js │ │ ├── bitswap.spec.js │ │ ├── block.spec.js │ │ ├── bootstrap.spec.js │ │ ├── cat.spec.js │ │ ├── cid.spec.js │ │ ├── config.spec.js │ │ ├── daemon.spec.js │ │ ├── dag.spec.js │ │ ├── dht.spec.js │ │ ├── dns.spec.js │ │ ├── files │ │ │ ├── chmod.js │ │ │ ├── cp.js │ │ │ ├── flush.js │ │ │ ├── ls.js │ │ │ ├── mkdir.js │ │ │ ├── mv.js │ │ │ ├── read.js │ │ │ ├── rm.js │ │ │ ├── stat.js │ │ │ ├── touch.js │ │ │ └── write.js │ │ ├── general.spec.js │ │ ├── get.spec.js │ │ ├── id.spec.js │ │ ├── init.spec.js │ │ ├── key.spec.js │ │ ├── ls.spec.js │ │ ├── name-pubsub.spec.js │ │ ├── name.spec.js │ │ ├── object.spec.js │ │ ├── pin.spec.js │ │ ├── ping.spec.js │ │ ├── progress-bar.spec.js │ │ ├── pubsub.spec.js │ │ ├── refs-local.spec.js │ │ ├── refs.spec.js │ │ ├── repo.spec.js │ │ ├── resolve.spec.js │ │ ├── swarm.spec.js │ │ ├── utils │ │ │ ├── clean.js │ │ │ ├── cli.js │ │ │ ├── ipfs-exec.js │ │ │ ├── match-iterable.js │ │ │ ├── match-peer-id.js │ │ │ └── platforms.js │ │ └── version.spec.js │ └── tsconfig.json ├── ipfs-client │ ├── .aegir.js │ ├── CHANGELOG.md │ ├── LICENSE │ ├── LICENSE-APACHE │ ├── LICENSE-MIT │ ├── README.md │ ├── package.json │ ├── src │ │ └── index.js │ └── tsconfig.json ├── ipfs-core-config │ ├── .aegir.js │ ├── CHANGELOG.md │ ├── LICENSE │ ├── LICENSE-APACHE │ ├── LICENSE-MIT │ ├── README.md │ ├── package.json │ ├── src │ │ ├── config.browser.js │ │ ├── config.js │ │ ├── dns.browser.js │ │ ├── dns.js │ │ ├── index.js │ │ ├── init-assets.browser.js │ │ ├── init-assets.js │ │ ├── init-files │ │ │ └── init-docs │ │ │ │ ├── about.js │ │ │ │ ├── contact.js │ │ │ │ ├── docs │ │ │ │ └── index.js │ │ │ │ ├── help.js │ │ │ │ ├── index.js │ │ │ │ ├── quick-start.js │ │ │ │ ├── readme.js │ │ │ │ ├── security-notes.js │ │ │ │ └── tour │ │ │ │ └── 0.0-intro.js │ │ ├── libp2p-pubsub-routers.browser.js │ │ ├── libp2p-pubsub-routers.js │ │ ├── libp2p.browser.js │ │ ├── libp2p.js │ │ ├── preload.browser.js │ │ ├── preload.js │ │ ├── repo.browser.js │ │ ├── repo.js │ │ └── utils │ │ │ ├── lru-datastore.js │ │ │ └── tlru.js │ └── tsconfig.json ├── ipfs-core-types │ ├── CHANGELOG.md │ ├── COPYRIGHT │ ├── LICENSE │ ├── LICENSE-APACHE │ ├── LICENSE-MIT │ ├── README.md │ ├── package.json │ ├── src │ │ ├── bitswap │ │ │ └── index.ts │ │ ├── block │ │ │ └── index.ts │ │ ├── bootstrap │ │ │ └── index.ts │ │ ├── config │ │ │ ├── index.ts │ │ │ └── profiles │ │ │ │ └── index.ts │ │ ├── dag │ │ │ └── index.ts │ │ ├── dht │ │ │ └── index.ts │ │ ├── diag │ │ │ └── index.ts │ │ ├── files │ │ │ └── index.ts │ │ ├── index.ts │ │ ├── key │ │ │ └── index.ts │ │ ├── log │ │ │ └── index.ts │ │ ├── name │ │ │ ├── index.ts │ │ │ └── pubsub │ │ │ │ └── index.ts │ │ ├── object │ │ │ ├── index.ts │ │ │ └── patch │ │ │ │ └── index.ts │ │ ├── pin │ │ │ ├── index.ts │ │ │ └── remote │ │ │ │ ├── index.ts │ │ │ │ └── service │ │ │ │ └── index.ts │ │ ├── pubsub │ │ │ └── index.ts │ │ ├── refs │ │ │ └── index.ts │ │ ├── repo │ │ │ └── index.ts │ │ ├── root.ts │ │ ├── stats │ │ │ └── index.ts │ │ ├── swarm │ │ │ └── index.ts │ │ └── utils.ts │ └── tsconfig.json ├── ipfs-core-utils │ ├── .aegir.js │ ├── CHANGELOG.md │ ├── LICENSE │ ├── LICENSE-APACHE │ ├── LICENSE-MIT │ ├── README.md │ ├── package.json │ ├── src │ │ ├── agent.browser.js │ │ ├── agent.js │ │ ├── errors.js │ │ ├── files │ │ │ ├── format-mode.js │ │ │ ├── format-mtime.js │ │ │ ├── normalise-candidate-multiple.js │ │ │ ├── normalise-candidate-single.js │ │ │ ├── normalise-content.browser.js │ │ │ ├── normalise-content.js │ │ │ ├── normalise-input-multiple.browser.js │ │ │ ├── normalise-input-multiple.js │ │ │ ├── normalise-input-single.browser.js │ │ │ ├── normalise-input-single.js │ │ │ └── utils.js │ │ ├── index.js │ │ ├── mode-to-string.js │ │ ├── multibases.js │ │ ├── multicodecs.js │ │ ├── multihashes.js │ │ ├── multipart-request.browser.js │ │ ├── multipart-request.js │ │ ├── multipart-request.node.js │ │ ├── pins │ │ │ └── normalise-input.js │ │ ├── to-cid-and-path.js │ │ ├── to-url-string.js │ │ ├── types.ts │ │ └── with-timeout-option.js │ ├── test │ │ ├── files │ │ │ ├── format-mode.spec.js │ │ │ ├── format-mtime.spec.js │ │ │ ├── normalise-input-multiple.spec.js │ │ │ └── normalise-input-single.spec.js │ │ ├── fixtures │ │ │ └── file.txt │ │ ├── pins │ │ │ └── normalise-input.spec.js │ │ └── tests.spec.js │ └── tsconfig.json ├── ipfs-core │ ├── .aegir.js │ ├── CHANGELOG.md │ ├── CODE_OF_CONDUCT.md │ ├── CONTRIBUTING.md │ ├── COPYRIGHT │ ├── LICENSE │ ├── LICENSE-APACHE │ ├── LICENSE-MIT │ ├── README.md │ ├── package.json │ ├── scripts │ │ └── update-version.js │ ├── src │ │ ├── block-storage.js │ │ ├── components │ │ │ ├── add-all │ │ │ │ ├── index.js │ │ │ │ └── utils.js │ │ │ ├── add.js │ │ │ ├── bitswap │ │ │ │ ├── index.js │ │ │ │ ├── stat.js │ │ │ │ ├── unwant.js │ │ │ │ ├── wantlist-for-peer.js │ │ │ │ └── wantlist.js │ │ │ ├── block │ │ │ │ ├── get.js │ │ │ │ ├── index.js │ │ │ │ ├── put.js │ │ │ │ ├── rm.js │ │ │ │ ├── stat.js │ │ │ │ └── utils.js │ │ │ ├── bootstrap │ │ │ │ ├── add.js │ │ │ │ ├── clear.js │ │ │ │ ├── index.js │ │ │ │ ├── list.js │ │ │ │ ├── reset.js │ │ │ │ ├── rm.js │ │ │ │ └── utils.js │ │ │ ├── cat.js │ │ │ ├── config │ │ │ │ ├── index.js │ │ │ │ └── profiles.js │ │ │ ├── dag │ │ │ │ ├── export.js │ │ │ │ ├── get.js │ │ │ │ ├── import.js │ │ │ │ ├── index.js │ │ │ │ ├── put.js │ │ │ │ └── resolve.js │ │ │ ├── dht.js │ │ │ ├── dns.js │ │ │ ├── files │ │ │ │ ├── chmod.js │ │ │ │ ├── cp.js │ │ │ │ ├── flush.js │ │ │ │ ├── index.js │ │ │ │ ├── ls.js │ │ │ │ ├── mkdir.js │ │ │ │ ├── mv.js │ │ │ │ ├── read.js │ │ │ │ ├── rm.js │ │ │ │ ├── stat.js │ │ │ │ ├── touch.js │ │ │ │ ├── utils │ │ │ │ │ ├── add-link.js │ │ │ │ │ ├── create-lock.js │ │ │ │ │ ├── create-node.js │ │ │ │ │ ├── dir-sharded.js │ │ │ │ │ ├── hamt-constants.js │ │ │ │ │ ├── hamt-utils.js │ │ │ │ │ ├── persist.js │ │ │ │ │ ├── remove-link.js │ │ │ │ │ ├── to-async-iterator.js │ │ │ │ │ ├── to-mfs-path.js │ │ │ │ │ ├── to-path-components.js │ │ │ │ │ ├── to-trail.js │ │ │ │ │ ├── update-mfs-root.js │ │ │ │ │ ├── update-tree.js │ │ │ │ │ └── with-mfs-root.js │ │ │ │ └── write.js │ │ │ ├── get.js │ │ │ ├── id.js │ │ │ ├── index.js │ │ │ ├── ipns.js │ │ │ ├── is-online.js │ │ │ ├── key │ │ │ │ ├── export.js │ │ │ │ ├── gen.js │ │ │ │ ├── import.js │ │ │ │ ├── index.js │ │ │ │ ├── info.js │ │ │ │ ├── list.js │ │ │ │ ├── rename.js │ │ │ │ └── rm.js │ │ │ ├── libp2p.js │ │ │ ├── ls.js │ │ │ ├── name │ │ │ │ ├── index.js │ │ │ │ ├── publish.js │ │ │ │ ├── pubsub │ │ │ │ │ ├── cancel.js │ │ │ │ │ ├── index.js │ │ │ │ │ ├── state.js │ │ │ │ │ ├── subs.js │ │ │ │ │ └── utils.js │ │ │ │ ├── resolve.js │ │ │ │ └── utils.js │ │ │ ├── network.js │ │ │ ├── object │ │ │ │ ├── data.js │ │ │ │ ├── get.js │ │ │ │ ├── index.js │ │ │ │ ├── links.js │ │ │ │ ├── new.js │ │ │ │ ├── patch │ │ │ │ │ ├── add-link.js │ │ │ │ │ ├── append-data.js │ │ │ │ │ ├── index.js │ │ │ │ │ ├── rm-link.js │ │ │ │ │ └── set-data.js │ │ │ │ ├── put.js │ │ │ │ └── stat.js │ │ │ ├── pin │ │ │ │ ├── add-all.js │ │ │ │ ├── add.js │ │ │ │ ├── index.js │ │ │ │ ├── ls.js │ │ │ │ ├── rm-all.js │ │ │ │ └── rm.js │ │ │ ├── ping.js │ │ │ ├── pubsub.js │ │ │ ├── refs │ │ │ │ ├── index.js │ │ │ │ └── local.js │ │ │ ├── repo │ │ │ │ ├── gc.js │ │ │ │ ├── index.js │ │ │ │ ├── stat.js │ │ │ │ └── version.js │ │ │ ├── resolve.js │ │ │ ├── root.js │ │ │ ├── start.js │ │ │ ├── stats │ │ │ │ ├── bw.js │ │ │ │ └── index.js │ │ │ ├── stop.js │ │ │ ├── storage.js │ │ │ ├── swarm │ │ │ │ ├── addrs.js │ │ │ │ ├── connect.js │ │ │ │ ├── disconnect.js │ │ │ │ ├── index.js │ │ │ │ ├── local-addrs.js │ │ │ │ └── peers.js │ │ │ └── version.js │ │ ├── errors.js │ │ ├── index.js │ │ ├── ipns │ │ │ ├── index.js │ │ │ ├── publisher.js │ │ │ ├── republisher.js │ │ │ ├── resolver.js │ │ │ └── routing │ │ │ │ ├── config.js │ │ │ │ ├── dht-datastore.js │ │ │ │ ├── offline-datastore.js │ │ │ │ └── pubsub-datastore.js │ │ ├── mfs-preload.js │ │ ├── preload.js │ │ ├── types.ts │ │ ├── utils.js │ │ ├── utils │ │ │ ├── service.js │ │ │ └── tlru.js │ │ └── version.js │ ├── test │ │ ├── add-all.spec.js │ │ ├── block-storage.spec.js │ │ ├── bootstrappers.js │ │ ├── config.spec.js │ │ ├── create-node.spec.js │ │ ├── init.spec.js │ │ ├── ipld.spec.js │ │ ├── key-exchange.spec.js │ │ ├── libp2p.spec.js │ │ ├── mfs-preload.spec.js │ │ ├── name.spec.js │ │ ├── preload.spec.js │ │ ├── pubsub.spec.js │ │ ├── utils.spec.js │ │ └── utils │ │ │ ├── clean.js │ │ │ ├── codecs.js │ │ │ ├── create-backend.js │ │ │ ├── create-node.js │ │ │ ├── create-repo.js │ │ │ ├── mock-preload-node-utils.js │ │ │ ├── mock-preload-node.js │ │ │ └── wait-for.js │ └── tsconfig.json ├── ipfs-daemon │ ├── CHANGELOG.md │ ├── CODE_OF_CONDUCT.md │ ├── CONTRIBUTING.md │ ├── COPYRIGHT │ ├── LICENSE │ ├── LICENSE-APACHE │ ├── LICENSE-MIT │ ├── README.md │ ├── package.json │ ├── src │ │ └── index.js │ ├── test │ │ └── index.spec.js │ └── tsconfig.json ├── ipfs-grpc-client │ ├── .aegir.js │ ├── CHANGELOG.md │ ├── LICENSE │ ├── LICENSE-APACHE │ ├── LICENSE-MIT │ ├── README.md │ ├── package.json │ ├── src │ │ ├── core-api │ │ │ ├── add-all.js │ │ │ ├── files │ │ │ │ ├── ls.js │ │ │ │ └── write.js │ │ │ ├── id.js │ │ │ └── pubsub │ │ │ │ ├── subscribe.js │ │ │ │ ├── subscriptions.js │ │ │ │ └── unsubscribe.js │ │ ├── grpc │ │ │ ├── transport.browser.js │ │ │ ├── transport.js │ │ │ └── transport.node.js │ │ ├── index.js │ │ ├── types.ts │ │ └── utils │ │ │ ├── bidi-to-duplex.js │ │ │ ├── client-stream-to-promise.js │ │ │ ├── load-services.js │ │ │ ├── server-stream-to-iterator.js │ │ │ ├── to-headers.js │ │ │ └── unary-to-promise.js │ ├── test │ │ ├── agent.js │ │ ├── node.js │ │ └── utils.spec.js │ └── tsconfig.json ├── ipfs-grpc-protocol │ ├── CHANGELOG.md │ ├── LICENSE │ ├── LICENSE-APACHE │ ├── LICENSE-MIT │ ├── README.md │ ├── package.json │ ├── scripts │ │ └── update-index.js │ ├── src │ │ ├── common.proto │ │ ├── index.js │ │ ├── mfs.proto │ │ ├── pubsub.proto │ │ └── root.proto │ └── tsconfig.json ├── ipfs-grpc-server │ ├── CHANGELOG.md │ ├── LICENSE │ ├── LICENSE-APACHE │ ├── LICENSE-MIT │ ├── README.md │ ├── package.json │ ├── src │ │ ├── endpoints │ │ │ ├── add.js │ │ │ ├── id.js │ │ │ ├── mfs │ │ │ │ ├── ls.js │ │ │ │ └── write.js │ │ │ └── pubsub │ │ │ │ ├── subscribe.js │ │ │ │ ├── subscriptions.js │ │ │ │ └── unsubscribe.js │ │ ├── index.js │ │ ├── types.ts │ │ └── utils │ │ │ ├── encode-mtime.js │ │ │ ├── load-services.js │ │ │ ├── web-socket-message-channel.js │ │ │ └── web-socket-server.js │ ├── test │ │ ├── add.spec.js │ │ ├── id.spec.js │ │ ├── mfs │ │ │ ├── ls.spec.js │ │ │ └── write.spec.js │ │ └── utils │ │ │ ├── channel.js │ │ │ └── server.js │ └── tsconfig.json ├── ipfs-http-client │ ├── .aegir.js │ ├── CHANGELOG.md │ ├── CONTRIBUTING.md │ ├── COPYRIGHT │ ├── LICENSE │ ├── LICENSE-APACHE │ ├── LICENSE-MIT │ ├── README.md │ ├── maintainer.json │ ├── package.json │ ├── src │ │ ├── add-all.js │ │ ├── add.js │ │ ├── bitswap │ │ │ ├── index.js │ │ │ ├── stat.js │ │ │ ├── unwant.js │ │ │ ├── wantlist-for-peer.js │ │ │ └── wantlist.js │ │ ├── block │ │ │ ├── get.js │ │ │ ├── index.js │ │ │ ├── put.js │ │ │ ├── rm.js │ │ │ └── stat.js │ │ ├── bootstrap │ │ │ ├── add.js │ │ │ ├── clear.js │ │ │ ├── index.js │ │ │ ├── list.js │ │ │ ├── reset.js │ │ │ └── rm.js │ │ ├── cat.js │ │ ├── commands.js │ │ ├── config │ │ │ ├── get-all.js │ │ │ ├── get.js │ │ │ ├── index.js │ │ │ ├── profiles │ │ │ │ ├── apply.js │ │ │ │ ├── index.js │ │ │ │ └── list.js │ │ │ ├── replace.js │ │ │ └── set.js │ │ ├── dag │ │ │ ├── export.js │ │ │ ├── get.js │ │ │ ├── import.js │ │ │ ├── index.js │ │ │ ├── put.js │ │ │ └── resolve.js │ │ ├── dht │ │ │ ├── find-peer.js │ │ │ ├── find-provs.js │ │ │ ├── get.js │ │ │ ├── index.js │ │ │ ├── map-event.js │ │ │ ├── provide.js │ │ │ ├── put.js │ │ │ ├── query.js │ │ │ └── response-types.js │ │ ├── diag │ │ │ ├── cmds.js │ │ │ ├── index.js │ │ │ ├── net.js │ │ │ └── sys.js │ │ ├── dns.js │ │ ├── files │ │ │ ├── chmod.js │ │ │ ├── cp.js │ │ │ ├── flush.js │ │ │ ├── index.js │ │ │ ├── ls.js │ │ │ ├── mkdir.js │ │ │ ├── mv.js │ │ │ ├── read.js │ │ │ ├── rm.js │ │ │ ├── stat.js │ │ │ ├── touch.js │ │ │ └── write.js │ │ ├── get-endpoint-config.js │ │ ├── get.js │ │ ├── id.js │ │ ├── index.js │ │ ├── is-online.js │ │ ├── key │ │ │ ├── export.js │ │ │ ├── gen.js │ │ │ ├── import.js │ │ │ ├── index.js │ │ │ ├── info.js │ │ │ ├── list.js │ │ │ ├── rename.js │ │ │ └── rm.js │ │ ├── lib │ │ │ ├── abort-signal.js │ │ │ ├── configure.js │ │ │ ├── core.js │ │ │ ├── http-rpc-wire-format.js │ │ │ ├── mode-to-string.js │ │ │ ├── object-to-camel-with-metadata.js │ │ │ ├── object-to-camel.js │ │ │ ├── parse-mtime.js │ │ │ ├── resolve.js │ │ │ └── to-url-search-params.js │ │ ├── log │ │ │ ├── index.js │ │ │ ├── level.js │ │ │ ├── ls.js │ │ │ └── tail.js │ │ ├── ls.js │ │ ├── mount.js │ │ ├── name │ │ │ ├── index.js │ │ │ ├── publish.js │ │ │ ├── pubsub │ │ │ │ ├── cancel.js │ │ │ │ ├── index.js │ │ │ │ ├── state.js │ │ │ │ └── subs.js │ │ │ └── resolve.js │ │ ├── object │ │ │ ├── data.js │ │ │ ├── get.js │ │ │ ├── index.js │ │ │ ├── links.js │ │ │ ├── new.js │ │ │ ├── patch │ │ │ │ ├── add-link.js │ │ │ │ ├── append-data.js │ │ │ │ ├── index.js │ │ │ │ ├── rm-link.js │ │ │ │ └── set-data.js │ │ │ ├── put.js │ │ │ └── stat.js │ │ ├── pin │ │ │ ├── add-all.js │ │ │ ├── add.js │ │ │ ├── index.js │ │ │ ├── ls.js │ │ │ ├── remote │ │ │ │ ├── add.js │ │ │ │ ├── index.js │ │ │ │ ├── ls.js │ │ │ │ ├── rm-all.js │ │ │ │ ├── rm.js │ │ │ │ ├── service │ │ │ │ │ ├── add.js │ │ │ │ │ ├── index.js │ │ │ │ │ ├── ls.js │ │ │ │ │ ├── rm.js │ │ │ │ │ └── utils.js │ │ │ │ └── utils.js │ │ │ ├── rm-all.js │ │ │ └── rm.js │ │ ├── ping.js │ │ ├── pubsub │ │ │ ├── index.js │ │ │ ├── ls.js │ │ │ ├── peers.js │ │ │ ├── publish.js │ │ │ ├── subscribe.js │ │ │ ├── subscription-tracker.js │ │ │ └── unsubscribe.js │ │ ├── refs │ │ │ ├── index.js │ │ │ └── local.js │ │ ├── repo │ │ │ ├── gc.js │ │ │ ├── index.js │ │ │ ├── stat.js │ │ │ └── version.js │ │ ├── resolve.js │ │ ├── start.js │ │ ├── stats │ │ │ ├── bw.js │ │ │ └── index.js │ │ ├── stop.js │ │ ├── swarm │ │ │ ├── addrs.js │ │ │ ├── connect.js │ │ │ ├── disconnect.js │ │ │ ├── index.js │ │ │ ├── local-addrs.js │ │ │ └── peers.js │ │ ├── types.ts │ │ └── version.js │ ├── test │ │ ├── commands.spec.js │ │ ├── constructor.spec.js │ │ ├── dag.spec.js │ │ ├── diag.spec.js │ │ ├── endpoint-config.spec.js │ │ ├── exports.spec.js │ │ ├── files.spec.js │ │ ├── fixtures │ │ │ ├── .gitattributes │ │ │ ├── 15mb.random │ │ │ ├── r-config.json │ │ │ ├── ssl │ │ │ │ ├── cert.pem │ │ │ │ └── privkey.pem │ │ │ ├── test-folder │ │ │ │ ├── .hiddenTest.txt │ │ │ │ ├── add │ │ │ │ ├── cat │ │ │ │ ├── files │ │ │ │ │ ├── hello.txt │ │ │ │ │ └── ipfs.txt │ │ │ │ ├── hello-link │ │ │ │ ├── ipfs-add │ │ │ │ ├── ls │ │ │ │ └── version │ │ │ ├── testconfig.json │ │ │ └── testfile.txt │ │ ├── key.spec.js │ │ ├── lib.error-handler.spec.js │ │ ├── log.spec.js │ │ ├── node.js │ │ ├── node │ │ │ ├── agent.js │ │ │ ├── custom-headers.js │ │ │ ├── request-api.js │ │ │ └── swarm.js │ │ ├── ping.spec.js │ │ ├── pubsub.spec.js │ │ ├── repo.spec.js │ │ ├── stats.spec.js │ │ └── utils │ │ │ ├── factory.js │ │ │ └── throws-async.js │ └── tsconfig.json ├── ipfs-http-gateway │ ├── CHANGELOG.md │ ├── CODE_OF_CONDUCT.md │ ├── CONTRIBUTING.md │ ├── COPYRIGHT │ ├── LICENSE │ ├── LICENSE-APACHE │ ├── LICENSE-MIT │ ├── README.md │ ├── package.json │ ├── src │ │ ├── index.js │ │ ├── resources │ │ │ ├── gateway.js │ │ │ └── index.js │ │ ├── routes │ │ │ ├── gateway.js │ │ │ └── index.js │ │ ├── types.ts │ │ └── utils │ │ │ └── path.js │ ├── test │ │ ├── fixtures │ │ │ ├── cat-folder │ │ │ │ └── cat.jpg │ │ │ ├── index.html │ │ │ ├── nested-folder │ │ │ │ ├── hello.txt │ │ │ │ ├── ipfs.txt │ │ │ │ └── nested.html │ │ │ └── unsniffable-folder │ │ │ │ ├── hexagons-xml.svg │ │ │ │ └── hexagons.svg │ │ ├── routes.spec.js │ │ └── utils │ │ │ └── http.js │ └── tsconfig.json ├── ipfs-http-response │ ├── CHANGELOG.md │ ├── LICENSE │ ├── LICENSE-APACHE │ ├── LICENSE-MIT │ ├── README.md │ ├── docs │ │ └── ipfs-http-response.png │ ├── package.json │ ├── src │ │ ├── dir-view │ │ │ ├── index.js │ │ │ └── style.js │ │ ├── index.js │ │ ├── resolver.js │ │ └── utils │ │ │ ├── content-type.js │ │ │ └── path.js │ ├── test │ │ ├── fixtures │ │ │ ├── .gitattributes │ │ │ ├── test-folder │ │ │ │ ├── files │ │ │ │ │ └── hello.txt │ │ │ │ ├── hello-link │ │ │ │ ├── holmes.txt │ │ │ │ └── pp.txt │ │ │ ├── test-mime-types │ │ │ │ ├── cat.jpg │ │ │ │ ├── hexagons-xml.svg │ │ │ │ ├── hexagons.svg │ │ │ │ ├── index.html │ │ │ │ └── pp.txt │ │ │ ├── test-site │ │ │ │ ├── holmes.txt │ │ │ │ ├── index.html │ │ │ │ └── pp.txt │ │ │ └── testfile.txt │ │ ├── index.spec.js │ │ ├── resolver.spec.js │ │ └── utils │ │ │ └── web-response-env.js │ └── tsconfig.json ├── ipfs-http-server │ ├── CHANGELOG.md │ ├── CODE_OF_CONDUCT.md │ ├── CONTRIBUTING.md │ ├── COPYRIGHT │ ├── LICENSE │ ├── LICENSE-APACHE │ ├── LICENSE-MIT │ ├── README.md │ ├── package.json │ ├── scripts │ │ └── update-version.js │ ├── src │ │ ├── api │ │ │ ├── resources │ │ │ │ ├── bitswap.js │ │ │ │ ├── block.js │ │ │ │ ├── bootstrap.js │ │ │ │ ├── config.js │ │ │ │ ├── dag.js │ │ │ │ ├── dht.js │ │ │ │ ├── dns.js │ │ │ │ ├── files-regular.js │ │ │ │ ├── files │ │ │ │ │ ├── chmod.js │ │ │ │ │ ├── cp.js │ │ │ │ │ ├── flush.js │ │ │ │ │ ├── ls.js │ │ │ │ │ ├── mkdir.js │ │ │ │ │ ├── mv.js │ │ │ │ │ ├── read.js │ │ │ │ │ ├── rm.js │ │ │ │ │ ├── stat.js │ │ │ │ │ ├── touch.js │ │ │ │ │ ├── utils │ │ │ │ │ │ └── parse-mtime.js │ │ │ │ │ └── write.js │ │ │ │ ├── id.js │ │ │ │ ├── key.js │ │ │ │ ├── name.js │ │ │ │ ├── object.js │ │ │ │ ├── pin.js │ │ │ │ ├── ping.js │ │ │ │ ├── pubsub.js │ │ │ │ ├── repo.js │ │ │ │ ├── resolve.js │ │ │ │ ├── shutdown.js │ │ │ │ ├── stats.js │ │ │ │ ├── swarm.js │ │ │ │ └── version.js │ │ │ └── routes │ │ │ │ ├── bitswap.js │ │ │ │ ├── block.js │ │ │ │ ├── bootstrap.js │ │ │ │ ├── config.js │ │ │ │ ├── dag.js │ │ │ │ ├── debug.js │ │ │ │ ├── dht.js │ │ │ │ ├── dns.js │ │ │ │ ├── files-regular.js │ │ │ │ ├── files.js │ │ │ │ ├── id.js │ │ │ │ ├── index.js │ │ │ │ ├── key.js │ │ │ │ ├── name.js │ │ │ │ ├── object.js │ │ │ │ ├── pin.js │ │ │ │ ├── ping.js │ │ │ │ ├── pubsub.js │ │ │ │ ├── repo.js │ │ │ │ ├── resolve.js │ │ │ │ ├── shutdown.js │ │ │ │ ├── stats.js │ │ │ │ ├── swarm.js │ │ │ │ ├── version.js │ │ │ │ └── webui.js │ │ ├── error-handler.js │ │ ├── index.js │ │ ├── types.ts │ │ ├── utils │ │ │ ├── joi.js │ │ │ ├── multipart-request-parser.js │ │ │ └── stream-response.js │ │ └── version.js │ ├── test │ │ ├── cors.js │ │ ├── fixtures │ │ │ └── test-data │ │ │ │ ├── badconfig │ │ │ │ ├── badnode.json │ │ │ │ └── node.json │ │ ├── inject │ │ │ ├── bitswap.js │ │ │ ├── block.js │ │ │ ├── bootstrap.js │ │ │ ├── browser-headers.js │ │ │ ├── config.js │ │ │ ├── dag.js │ │ │ ├── dht.js │ │ │ ├── dns.js │ │ │ ├── files.js │ │ │ ├── id.js │ │ │ ├── key.js │ │ │ ├── mfs.js │ │ │ ├── mfs │ │ │ │ ├── chmod.js │ │ │ │ ├── cp.js │ │ │ │ ├── flush.js │ │ │ │ ├── ls.js │ │ │ │ ├── mkdir.js │ │ │ │ ├── mv.js │ │ │ │ ├── read.js │ │ │ │ ├── rm.js │ │ │ │ ├── stat.js │ │ │ │ ├── touch.js │ │ │ │ └── write.js │ │ │ ├── name.js │ │ │ ├── object.js │ │ │ ├── pin.js │ │ │ ├── ping.js │ │ │ ├── pubsub.js │ │ │ ├── repo.js │ │ │ ├── resolve.js │ │ │ ├── shutdown.js │ │ │ ├── stats.js │ │ │ ├── swarm.js │ │ │ └── version.js │ │ ├── node.js │ │ ├── routes.js │ │ └── utils │ │ │ ├── all-ndjson.js │ │ │ ├── http.js │ │ │ ├── match-iterable.js │ │ │ └── test-http-method.js │ └── tsconfig.json ├── ipfs-message-port-client │ ├── .aegir.js │ ├── CHANGELOG.md │ ├── CODE_OF_CONDUCT.md │ ├── CONTRIBUTING.md │ ├── COPYRIGHT │ ├── LICENSE │ ├── LICENSE-APACHE │ ├── LICENSE-MIT │ ├── README.md │ ├── package.json │ ├── src │ │ ├── block.js │ │ ├── client.js │ │ ├── client │ │ │ ├── error.js │ │ │ ├── query.js │ │ │ ├── service.js │ │ │ └── transport.js │ │ ├── core.js │ │ ├── dag.js │ │ ├── files.js │ │ ├── index.js │ │ └── interface.ts │ ├── test │ │ ├── interface-message-port-client.js │ │ └── util │ │ │ ├── client.js │ │ │ └── worker.js │ └── tsconfig.json ├── ipfs-message-port-protocol │ ├── .aegir.js │ ├── CHANGELOG.md │ ├── CODE_OF_CONDUCT.md │ ├── CONTRIBUTING.md │ ├── COPYRIGHT │ ├── LICENSE │ ├── LICENSE-APACHE │ ├── LICENSE-MIT │ ├── README.md │ ├── package.json │ ├── src │ │ ├── block.js │ │ ├── cid.js │ │ ├── core.js │ │ ├── dag.js │ │ ├── data.ts │ │ ├── error.js │ │ ├── files.ts │ │ ├── index.js │ │ ├── root.ts │ │ └── rpc.ts │ ├── test │ │ ├── block.browser.js │ │ ├── browser.js │ │ ├── cid.browser.js │ │ ├── cid.spec.js │ │ ├── core.browser.js │ │ ├── dag.browser.js │ │ ├── dag.spec.js │ │ ├── node.js │ │ └── util.js │ └── tsconfig.json ├── ipfs-message-port-server │ ├── .aegir.js │ ├── CHANGELOG.md │ ├── CODE_OF_CONDUCT.md │ ├── CONTRIBUTING.md │ ├── COPYRIGHT │ ├── LICENSE │ ├── LICENSE-APACHE │ ├── LICENSE-MIT │ ├── README.md │ ├── package.json │ ├── src │ │ ├── block.js │ │ ├── core.js │ │ ├── dag.js │ │ ├── files.js │ │ ├── index.js │ │ ├── server.js │ │ └── service.js │ ├── test │ │ ├── basic.spec.js │ │ ├── node.js │ │ └── transfer.spec.js │ └── tsconfig.json └── ipfs │ ├── .aegir.js │ ├── CHANGELOG.md │ ├── CODE_OF_CONDUCT.md │ ├── CONTRIBUTING.md │ ├── COPYRIGHT │ ├── LICENSE │ ├── LICENSE-APACHE │ ├── LICENSE-MIT │ ├── Makefile │ ├── README.md │ ├── init-and-daemon.sh │ ├── maintainer.json │ ├── package.json │ ├── scripts │ └── update-version.js │ ├── src │ ├── cli.js │ ├── index.js │ ├── package.js │ ├── path.browser.js │ └── path.js │ ├── test │ ├── interface-client.js │ ├── interface-core.js │ ├── interface-http-go.js │ ├── interface-http-js.js │ └── utils │ │ ├── factory.js │ │ ├── mock-pinning-service.js │ │ └── mock-preload-node.js │ └── tsconfig.json └── scripts └── node-globals.js /.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | 3 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | indent_style = space 3 | indent_size = 2 4 | trim_trailing_whitespace = true 5 | insert_final_newline = true 6 | end_of_line = lf 7 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | **/test/fixtures/** text eol=lf 3 | **/test/gateway/** text eol=lf 4 | **/src/init-files/** text eol=lf 5 | 6 | *.data binary 7 | *.png binary 8 | *.jpg binary 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Getting Help on IPFS 4 | url: https://ipfs.io/help 5 | about: All information about how and where to get help on IPFS 6 | - name: IPFS Official Forum 7 | url: https://discuss.ipfs.io 8 | about: For general questions, support requests and discussions 9 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | time: "10:00" 8 | open-pull-requests-limit: 0 9 | commit-message: 10 | prefix: "deps" 11 | prefix-development: "deps(dev)" 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | package-lock.json 6 | yarn.lock 7 | tsconfig-types.aegir.json 8 | 9 | # Coverage directory used by tools like istanbul 10 | coverage 11 | .coverage 12 | .nyc_output 13 | tests_output 14 | cache 15 | .cache 16 | .parcel-cache 17 | 18 | # Dependency directory 19 | node_modules 20 | 21 | # Build artefacts 22 | dist 23 | build 24 | bundle.js 25 | tsconfig-types.aegir.json 26 | tsconfig-check.aegir.json 27 | .tsbuildinfo 28 | 29 | # Deployment files 30 | .npmrc 31 | 32 | # Editor files 33 | .vscode 34 | 35 | # Operating system files 36 | .DS_Store 37 | types -------------------------------------------------------------------------------- /.release-please-manifest.json: -------------------------------------------------------------------------------- 1 | {"packages/interface-ipfs-core":"0.158.1","packages/ipfs":"0.66.1","packages/ipfs-cli":"0.16.1","packages/ipfs-client":"0.10.1","packages/ipfs-core":"0.18.1","packages/ipfs-core-config":"0.7.1","packages/ipfs-core-types":"0.14.1","packages/ipfs-core-utils":"0.18.1","packages/ipfs-daemon":"0.16.1","packages/ipfs-grpc-client":"0.13.1","packages/ipfs-grpc-protocol":"0.8.1","packages/ipfs-grpc-server":"0.12.1","packages/ipfs-http-client":"60.0.1","packages/ipfs-http-gateway":"0.13.1","packages/ipfs-http-response":"6.0.1","packages/ipfs-http-server":"0.15.1","packages/ipfs-message-port-client":"0.15.1","packages/ipfs-message-port-protocol":"0.15.1","packages/ipfs-message-port-server":"0.15.1"} -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | The `js-ipfs` project follows the [`IPFS Community Code of Conduct`](https://github.com/ipfs/community/blob/master/code-of-conduct.md) 4 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing guidelines 2 | 3 | IPFS as a project, including js-ipfs and all of its modules, follows the [standard IPFS Community contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md). 4 | 5 | We also adhere to the [IPFS JavaScript Community contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) which provide additional information of how to collaborate and contribute in the JavaScript implementation of IPFS. 6 | 7 | We appreciate your time and attention for going over these. Please open an issue on [ipfs/community](https://github.com/ipfs/community) if you have any question. 8 | 9 | Thank you. 10 | -------------------------------------------------------------------------------- /COPYRIGHT: -------------------------------------------------------------------------------- 1 | This project is transitioning from an MIT-only license to a dual MIT/Apache-2.0 license. 2 | Unless otherwise noted, all code contributed prior to 2019-11-21 and not contributed by 3 | a user listed in [this signoff issue](https://github.com/ipfs/js-ipfs/issues/2624) is 4 | licensed under MIT-only. All new contributions (and past contributions since 2019-11-21) 5 | are licensed under a dual MIT/Apache-2.0 license. 6 | -------------------------------------------------------------------------------- /Dockerfile.latest: -------------------------------------------------------------------------------- 1 | FROM node:16-alpine 2 | 3 | ENV IPFS_VERSION=latest 4 | ENV IPFS_MONITORING=1 5 | ENV IPFS_PATH=/root/.jsipfs 6 | ENV BUILD_DEPS='libnspr4 libnspr4-dev libnss3' 7 | 8 | RUN apk add --no-cache git python3 build-base 9 | 10 | # Hopefully remove when https://github.com/node-webrtc/node-webrtc/pull/694 is merged 11 | RUN npm install -g ipfs@"$IPFS_VERSION" 12 | 13 | # Make the image a bit smaller 14 | RUN npm cache clear --force 15 | RUN apk del build-base python3 git 16 | 17 | # Configure jsipfs 18 | RUN jsipfs init 19 | 20 | RUN jsipfs version 21 | 22 | # Allow connections from any host 23 | RUN sed -i.bak "s/127.0.0.1/0.0.0.0/g" $IPFS_PATH/config 24 | 25 | EXPOSE 4002 26 | EXPOSE 4003 27 | EXPOSE 5002 28 | EXPOSE 9090 29 | 30 | CMD jsipfs daemon 31 | -------------------------------------------------------------------------------- /Dockerfile.next: -------------------------------------------------------------------------------- 1 | FROM node:16-alpine 2 | 3 | ENV IPFS_VERSION=next 4 | ENV IPFS_MONITORING=1 5 | ENV IPFS_PATH=/root/.jsipfs 6 | ENV BUILD_DEPS='libnspr4 libnspr4-dev libnss3' 7 | 8 | RUN apk add --no-cache git python3 build-base 9 | 10 | # Hopefully remove when https://github.com/node-webrtc/node-webrtc/pull/694 is merged 11 | RUN npm install -g ipfs@"$IPFS_VERSION" 12 | 13 | # Make the image a bit smaller 14 | RUN npm cache clear --force 15 | RUN apk del build-base python3 git 16 | 17 | # Configure jsipfs 18 | RUN jsipfs init 19 | 20 | RUN jsipfs version 21 | 22 | # Allow connections from any host 23 | RUN sed -i.bak "s/127.0.0.1/0.0.0.0/g" $IPFS_PATH/config 24 | 25 | EXPOSE 4002 26 | EXPOSE 4003 27 | EXPOSE 5002 28 | EXPOSE 9090 29 | 30 | CMD jsipfs daemon 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This project is dual licensed under MIT and Apache-2.0. 2 | 3 | MIT: https://www.opensource.org/licenses/mit 4 | Apache-2.0: https://www.apache.org/licenses/license-2.0 5 | -------------------------------------------------------------------------------- /LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 2 | 3 | http://www.apache.org/licenses/LICENSE-2.0 4 | 5 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 6 | -------------------------------------------------------------------------------- /docs/MONITORING.md: -------------------------------------------------------------------------------- 1 | # Monitoring 2 | 3 | The HTTP API exposed with js-ipfs can also be used for exposing metrics about the running js-ipfs node and other Node.js metrics. 4 | 5 | To enable it, you need to set the environment variable `IPFS_MONITORING` (any value). E.g. 6 | 7 | ```console 8 | $ IPFS_MONITORING=true jsipfs daemon 9 | ``` 10 | 11 | Once the environment variable is set and the js-ipfs daemon is running, you can get the metrics (in prometheus format) by making a GET request to the following endpoint: 12 | 13 | ``` 14 | http://localhost:5002/debug/metrics/prometheus 15 | ``` 16 | -------------------------------------------------------------------------------- /docs/img/architecture.monopic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipfs/js-ipfs/bf1bc8b18d750d5591bdd575a6d0f4c067d61d0a/docs/img/architecture.monopic -------------------------------------------------------------------------------- /docs/img/architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipfs/js-ipfs/bf1bc8b18d750d5591bdd575a6d0f4c067d61d0a/docs/img/architecture.png -------------------------------------------------------------------------------- /docs/img/core.monopic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipfs/js-ipfs/bf1bc8b18d750d5591bdd575a6d0f4c067d61d0a/docs/img/core.monopic -------------------------------------------------------------------------------- /docs/img/core.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipfs/js-ipfs/bf1bc8b18d750d5591bdd575a6d0f4c067d61d0a/docs/img/core.png -------------------------------------------------------------------------------- /docs/img/overview.monopic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipfs/js-ipfs/bf1bc8b18d750d5591bdd575a6d0f4c067d61d0a/docs/img/overview.monopic -------------------------------------------------------------------------------- /docs/img/overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipfs/js-ipfs/bf1bc8b18d750d5591bdd575a6d0f4c067d61d0a/docs/img/overview.png -------------------------------------------------------------------------------- /docs/upgrading/v0.63-v0.64.md: -------------------------------------------------------------------------------- 1 | 2 | # Migrating to ipfs@0.64 and ipfs-core@0.16 3 | 4 | > A migration guide for refactoring your application code from `ipfs@0.63.x` to `ipfs@0.64.x` 5 | 6 | ## Table of Contents 7 | 8 | - [libp2p](#libp2p) 9 | 10 | ## libp2p 11 | 12 | The upgrade to `ipfs@0.64.x` incorporates an update to `libp2p@0.38.x` but no API changes. 13 | 14 | If your application uses only the default libp2p config there is nothing to do. 15 | 16 | If you supply a custom `libp2p` instance to the `ipfs` factory function you should consult the [`libp2p@0.38.x` upgrade guide](https://github.com/libp2p/js-libp2p/blob/master/doc/migrations/v0.37-v0.38.md) for any changes you need to make. 17 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/.aegir.js: -------------------------------------------------------------------------------- 1 | 2 | /** @type {import('aegir').PartialOptions} */ 3 | export default { 4 | build: { 5 | bundlesizeMax: '338kB' 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/LICENSE: -------------------------------------------------------------------------------- 1 | This project is dual licensed under MIT and Apache-2.0. 2 | 3 | MIT: https://www.opensource.org/licenses/mit 4 | Apache-2.0: https://www.apache.org/licenses/license-2.0 5 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 2 | 3 | http://www.apache.org/licenses/LICENSE-2.0 4 | 5 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 6 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/img/badge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipfs/js-ipfs/bf1bc8b18d750d5591bdd575a6d0f4c067d61d0a/packages/interface-ipfs-core/img/badge.png -------------------------------------------------------------------------------- /packages/interface-ipfs-core/img/badge.sketch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipfs/js-ipfs/bf1bc8b18d750d5591bdd575a6d0f4c067d61d0a/packages/interface-ipfs-core/img/badge.sketch -------------------------------------------------------------------------------- /packages/interface-ipfs-core/img/badge@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipfs/js-ipfs/bf1bc8b18d750d5591bdd575a6d0f4c067d61d0a/packages/interface-ipfs-core/img/badge@2x.png -------------------------------------------------------------------------------- /packages/interface-ipfs-core/maintainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "repoLeadMaintainer": { 3 | "name": "Alan Shaw", 4 | "email": "alan.shaw@protocol.ai", 5 | "username": "alanshaw" 6 | }, 7 | "workingGroup": { 8 | "name": "JS IPFS", 9 | "entryPoint": "https://github.com/ipfs/js-core" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/src/bitswap/index.js: -------------------------------------------------------------------------------- 1 | import { createSuite } from '../utils/suite.js' 2 | import { testStat } from './stat.js' 3 | import { testWantlist } from './wantlist.js' 4 | import { testWantlistForPeer } from './wantlist-for-peer.js' 5 | import { testTransfer } from './transfer.js' 6 | import { testUnwant } from './unwant.js' 7 | 8 | const tests = { 9 | stat: testStat, 10 | wantlist: testWantlist, 11 | wantlistForPeer: testWantlistForPeer, 12 | transfer: testTransfer, 13 | unwant: testUnwant 14 | } 15 | 16 | export default createSuite(tests) 17 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/src/block/index.js: -------------------------------------------------------------------------------- 1 | import { createSuite } from '../utils/suite.js' 2 | import { testGet } from './get.js' 3 | import { testPut } from './put.js' 4 | import { testRm } from './rm.js' 5 | import { testStat } from './stat.js' 6 | 7 | const tests = { 8 | get: testGet, 9 | put: testPut, 10 | rm: testRm, 11 | stat: testStat 12 | } 13 | 14 | export default createSuite(tests) 15 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/src/bootstrap/index.js: -------------------------------------------------------------------------------- 1 | import { createSuite } from '../utils/suite.js' 2 | import { testAdd } from './add.js' 3 | import { testClear } from './clear.js' 4 | import { testList } from './list.js' 5 | import { testReset } from './reset.js' 6 | import { testRm } from './rm.js' 7 | 8 | const tests = { 9 | add: testAdd, 10 | clear: testClear, 11 | list: testList, 12 | reset: testReset, 13 | rm: testRm 14 | } 15 | 16 | export default createSuite(tests) 17 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/src/config/index.js: -------------------------------------------------------------------------------- 1 | import { createSuite } from '../utils/suite.js' 2 | import { testGet } from './get.js' 3 | import { testSet } from './set.js' 4 | import { testReplace } from './replace.js' 5 | import profiles from './profiles/index.js' 6 | 7 | const tests = { 8 | get: testGet, 9 | set: testSet, 10 | replace: testReplace, 11 | profiles 12 | } 13 | 14 | export default createSuite(tests) 15 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/src/config/profiles/index.js: -------------------------------------------------------------------------------- 1 | import { createSuite } from '../../utils/suite.js' 2 | import { testApply } from './apply.js' 3 | import { testList } from './list.js' 4 | 5 | const tests = { 6 | apply: testApply, 7 | list: testList 8 | } 9 | 10 | export default createSuite(tests, 'config') 11 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/src/dag/index.js: -------------------------------------------------------------------------------- 1 | 2 | import { createSuite } from '../utils/suite.js' 3 | import { testExport } from './export.js' 4 | import { testGet } from './get.js' 5 | import { testPut } from './put.js' 6 | import { testImport } from './import.js' 7 | import { testResolve } from './resolve.js' 8 | import { testDagSharnessT0053 } from './sharness-t0053-dag.js' 9 | 10 | const tests = { 11 | export: testExport, 12 | get: testGet, 13 | put: testPut, 14 | import: testImport, 15 | resolve: testResolve, 16 | dagSharnessT0053: testDagSharnessT0053 17 | } 18 | 19 | export default createSuite(tests) 20 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/src/dht/index.js: -------------------------------------------------------------------------------- 1 | import { createSuite } from '../utils/suite.js' 2 | import { testPut } from './put.js' 3 | import { testGet } from './get.js' 4 | import { testFindPeer } from './find-peer.js' 5 | import { testProvide } from './provide.js' 6 | import { testFindProvs } from './find-provs.js' 7 | import { testQuery } from './query.js' 8 | import { testDisabled } from './disabled.js' 9 | 10 | const tests = { 11 | put: testPut, 12 | get: testGet, 13 | findPeer: testFindPeer, 14 | provide: testProvide, 15 | findProvs: testFindProvs, 16 | query: testQuery, 17 | disabled: testDisabled 18 | } 19 | 20 | export default createSuite(tests) 21 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/src/key/index.js: -------------------------------------------------------------------------------- 1 | 2 | import { createSuite } from '../utils/suite.js' 3 | import { testGen } from './gen.js' 4 | import { testList } from './list.js' 5 | import { testRename } from './rename.js' 6 | import { testRm } from './rm.js' 7 | import { testImport } from './import.js' 8 | 9 | const tests = { 10 | gen: testGen, 11 | list: testList, 12 | rename: testRename, 13 | rm: testRm, 14 | import: testImport 15 | } 16 | 17 | export default createSuite(tests) 18 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/src/miscellaneous/index.js: -------------------------------------------------------------------------------- 1 | import { createSuite } from '../utils/suite.js' 2 | import { testId } from './id.js' 3 | import { testVersion } from './version.js' 4 | import { testStop } from './stop.js' 5 | import { testResolve } from './resolve.js' 6 | import { testDns } from './dns.js' 7 | 8 | const tests = { 9 | id: testId, 10 | version: testVersion, 11 | dns: testDns, 12 | stop: testStop, 13 | resolve: testResolve 14 | } 15 | 16 | export default createSuite(tests) 17 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/src/name-pubsub/index.js: -------------------------------------------------------------------------------- 1 | import { createSuite } from '../utils/suite.js' 2 | import { testCancel } from './cancel.js' 3 | import { testState } from './state.js' 4 | import { testSubs } from './subs.js' 5 | import { testPubsub } from './pubsub.js' 6 | 7 | const tests = { 8 | cancel: testCancel, 9 | state: testState, 10 | subs: testSubs, 11 | pubsub: testPubsub 12 | } 13 | 14 | export default createSuite(tests) 15 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/src/name/index.js: -------------------------------------------------------------------------------- 1 | import { createSuite } from '../utils/suite.js' 2 | import { testPublish } from './publish.js' 3 | import { testResolve } from './resolve.js' 4 | 5 | const tests = { 6 | publish: testPublish, 7 | resolve: testResolve 8 | } 9 | 10 | export default createSuite(tests) 11 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/src/name/utils.js: -------------------------------------------------------------------------------- 1 | import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' 2 | 3 | export const fixture = Object.freeze({ 4 | cid: 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', 5 | data: uint8ArrayFromString('Plz add me!\n') 6 | }) 7 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/src/object/index.js: -------------------------------------------------------------------------------- 1 | import { createSuite } from '../utils/suite.js' 2 | import { testNew } from './new.js' 3 | import { testPut } from './put.js' 4 | import { testGet } from './get.js' 5 | import { testData } from './data.js' 6 | import { testLinks } from './links.js' 7 | import { testStat } from './stat.js' 8 | import testPatch from './patch/index.js' 9 | 10 | const tests = { 11 | new: testNew, 12 | put: testPut, 13 | get: testGet, 14 | data: testData, 15 | links: testLinks, 16 | stat: testStat, 17 | patch: testPatch 18 | } 19 | 20 | export default createSuite(tests) 21 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/src/object/patch/index.js: -------------------------------------------------------------------------------- 1 | import { createSuite } from '../../utils/suite.js' 2 | import { testAddLink } from './add-link.js' 3 | import { testRmLink } from './rm-link.js' 4 | import { testAppendData } from './append-data.js' 5 | import { testSetData } from './set-data.js' 6 | 7 | const tests = { 8 | addLink: testAddLink, 9 | rmLink: testRmLink, 10 | appendData: testAppendData, 11 | setData: testSetData 12 | } 13 | 14 | export default createSuite(tests, 'patch') 15 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/src/pin/index.js: -------------------------------------------------------------------------------- 1 | import { createSuite } from '../utils/suite.js' 2 | import { testAdd } from './add.js' 3 | import { testAddAll } from './add-all.js' 4 | import { testLs } from './ls.js' 5 | import { testRm } from './rm.js' 6 | import { testRmAll } from './rm-all.js' 7 | import testRemote from './remote/index.js' 8 | 9 | const tests = { 10 | add: testAdd, 11 | addAll: testAddAll, 12 | ls: testLs, 13 | rm: testRm, 14 | rmAll: testRmAll, 15 | remote: testRemote 16 | } 17 | 18 | export default createSuite(tests) 19 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/src/pin/remote/index.js: -------------------------------------------------------------------------------- 1 | import { createSuite } from '../../utils/suite.js' 2 | import { testService } from './service.js' 3 | import { testAdd } from './add.js' 4 | import { testLs } from './ls.js' 5 | import { testRm } from './rm.js' 6 | import { testRmAll } from './rm-all.js' 7 | 8 | const tests = { 9 | service: testService, 10 | add: testAdd, 11 | ls: testLs, 12 | rm: testRm, 13 | rmAll: testRmAll 14 | } 15 | 16 | export default createSuite(tests, 'pin') 17 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/src/ping/index.js: -------------------------------------------------------------------------------- 1 | import { createSuite } from '../utils/suite.js' 2 | import { testPing } from './ping.js' 3 | 4 | const tests = { 5 | ping: testPing 6 | } 7 | 8 | export default createSuite(tests) 9 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/src/ping/utils.js: -------------------------------------------------------------------------------- 1 | import { expect } from 'aegir/chai' 2 | 3 | /** 4 | * @param {*} obj 5 | */ 6 | export function expectIsPingResponse (obj) { 7 | expect(obj).to.have.a.property('success') 8 | expect(obj).to.have.a.property('time') 9 | expect(obj).to.have.a.property('text') 10 | expect(obj.success).to.be.a('boolean') 11 | expect(obj.time).to.be.a('number') 12 | expect(obj.text).to.be.a('string') 13 | } 14 | 15 | /** 16 | * Determine if a ping response object is a pong, or something else, like a status message 17 | * 18 | * @param {*} pingResponse 19 | */ 20 | export function isPong (pingResponse) { 21 | return Boolean(pingResponse && pingResponse.success && !pingResponse.text) 22 | } 23 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/src/pubsub/index.js: -------------------------------------------------------------------------------- 1 | import { createSuite } from '../utils/suite.js' 2 | import { testPublish } from './publish.js' 3 | import { testSubscribe } from './subscribe.js' 4 | import { testUnsubscribe } from './unsubscribe.js' 5 | import { testPeers } from './peers.js' 6 | import { testLs } from './ls.js' 7 | 8 | const tests = { 9 | publish: testPublish, 10 | subscribe: testSubscribe, 11 | unsubscribe: testUnsubscribe, 12 | peers: testPeers, 13 | ls: testLs 14 | } 15 | 16 | export default createSuite(tests) 17 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/src/repo/index.js: -------------------------------------------------------------------------------- 1 | import { createSuite } from '../utils/suite.js' 2 | import { testVersion } from './version.js' 3 | import { testStat } from './stat.js' 4 | import { testGc } from './gc.js' 5 | 6 | const tests = { 7 | version: testVersion, 8 | stat: testStat, 9 | gc: testGc 10 | } 11 | 12 | export default createSuite(tests) 13 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/src/stats/index.js: -------------------------------------------------------------------------------- 1 | import { createSuite } from '../utils/suite.js' 2 | import { testBitswap } from './bitswap.js' 3 | import { testBw } from './bw.js' 4 | import { testRepo } from './repo.js' 5 | 6 | const tests = { 7 | bitswap: testBitswap, 8 | bw: testBw, 9 | repo: testRepo 10 | } 11 | 12 | export default createSuite(tests) 13 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/src/swarm/index.js: -------------------------------------------------------------------------------- 1 | import { createSuite } from '../utils/suite.js' 2 | import { testConnect } from './connect.js' 3 | import { testPeers } from './peers.js' 4 | import { testAddrs } from './addrs.js' 5 | import { testLocalAddrs } from './local-addrs.js' 6 | import { testDisconnect } from './disconnect.js' 7 | 8 | const tests = { 9 | connect: testConnect, 10 | peers: testPeers, 11 | addrs: testAddrs, 12 | localAddrs: testLocalAddrs, 13 | disconnect: testDisconnect 14 | } 15 | 16 | export default createSuite(tests) 17 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/src/utils/ipfs-options-websockets-filter-all.js: -------------------------------------------------------------------------------- 1 | import { webSockets } from '@libp2p/websockets' 2 | import { all } from '@libp2p/websockets/filters' 3 | 4 | export function ipfsOptionsWebsocketsFilterAll () { 5 | return { 6 | libp2p: { 7 | config: { 8 | transports: [ 9 | webSockets({ 10 | filter: all 11 | }) 12 | ] 13 | } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/src/utils/is-shard-at-path.js: -------------------------------------------------------------------------------- 1 | import { UnixFS } from 'ipfs-unixfs' 2 | 3 | /** 4 | * @param {string} path 5 | * @param {import('ipfs-core-types').IPFS} ipfs 6 | */ 7 | export default async function isShardAtPath (path, ipfs) { 8 | const stats = await ipfs.files.stat(path) 9 | const { value: node } = await ipfs.dag.get(stats.cid) 10 | const entry = UnixFS.unmarshal(node.Data) 11 | 12 | return entry.type === 'hamt-sharded-directory' 13 | } 14 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/.gitattributes: -------------------------------------------------------------------------------- 1 | * -text 2 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/car/combined_naked_roots_genesis_and_128.car: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipfs/js-ipfs/bf1bc8b18d750d5591bdd575a6d0f4c067d61d0a/packages/interface-ipfs-core/test/fixtures/car/combined_naked_roots_genesis_and_128.car -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/car/lotus_devnet_genesis.car: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipfs/js-ipfs/bf1bc8b18d750d5591bdd575a6d0f4c067d61d0a/packages/interface-ipfs-core/test/fixtures/car/lotus_devnet_genesis.car -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/car/lotus_devnet_genesis_shuffled_nulroot.car: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipfs/js-ipfs/bf1bc8b18d750d5591bdd575a6d0f4c067d61d0a/packages/interface-ipfs-core/test/fixtures/car/lotus_devnet_genesis_shuffled_nulroot.car -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/car/lotus_testnet_export_128.car: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipfs/js-ipfs/bf1bc8b18d750d5591bdd575a6d0f4c067d61d0a/packages/interface-ipfs-core/test/fixtures/car/lotus_testnet_export_128.car -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/car/lotus_testnet_export_256_multiroot.car: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipfs/js-ipfs/bf1bc8b18d750d5591bdd575a6d0f4c067d61d0a/packages/interface-ipfs-core/test/fixtures/car/lotus_testnet_export_256_multiroot.car -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/hidden-files-folder/.hiddenTest.txt: -------------------------------------------------------------------------------- 1 | Aha! You found me! 2 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/hidden-files-folder/files/hello.txt: -------------------------------------------------------------------------------- 1 | Hello 2 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/hidden-files-folder/files/ipfs.txt: -------------------------------------------------------------------------------- 1 | IPFS 2 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/hidden-files-folder/hello-link: -------------------------------------------------------------------------------- 1 | Hello 2 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/hidden-files-folder/ipfs-add.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const ipfs = require('../src')('localhost', 5001) 4 | const files = process.argv.slice(2) 5 | 6 | ipfs.add(files, { recursive: true }, function (err, res) { 7 | if (err || !res) return console.log(err) 8 | 9 | for (let i = 0; i < res.length; i++) { 10 | console.log('added', res[i].Hash, res[i].Name) 11 | } 12 | }) 13 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/refs-test/animals/land/african.txt: -------------------------------------------------------------------------------- 1 | elephant 2 | rhinocerous -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/refs-test/animals/land/americas.txt: -------------------------------------------------------------------------------- 1 | ñandu 2 | tapir -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/refs-test/animals/land/australian.txt: -------------------------------------------------------------------------------- 1 | emu 2 | kangaroo -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/refs-test/animals/sea/atlantic.txt: -------------------------------------------------------------------------------- 1 | dolphin 2 | whale -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/refs-test/animals/sea/indian.txt: -------------------------------------------------------------------------------- 1 | cuttlefish 2 | octopus -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/refs-test/atlantic-animals: -------------------------------------------------------------------------------- 1 | dolphin 2 | whale -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/refs-test/fruits/tropical.txt: -------------------------------------------------------------------------------- 1 | banana 2 | pineapple -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/refs-test/mushroom.txt: -------------------------------------------------------------------------------- 1 | mushroom -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/test-folder/files/hello.txt: -------------------------------------------------------------------------------- 1 | Hello 2 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/test-folder/files/ipfs.txt: -------------------------------------------------------------------------------- 1 | IPFS 2 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/test-folder/hello-link: -------------------------------------------------------------------------------- 1 | files/hello.txt -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/test-folder/ipfs-add.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | 'use strict' 4 | 5 | const ipfs = require('../src')('localhost', 5001) 6 | const files = process.argv.slice(2) 7 | 8 | ipfs.add(files, { recursive: true }, function (err, res) { 9 | if (err || !res) return console.log(err) 10 | 11 | for (let i = 0; i < res.length; i++) { 12 | console.log('added', res[i].Hash, res[i].Name) 13 | } 14 | }) 15 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/weird name folder [v0]/add: -------------------------------------------------------------------------------- 1 | 2 | 3 | const ipfs = require('../src')('localhost', 5001) 4 | 5 | const f1 = 'Hello' 6 | const f2 = 'World' 7 | 8 | ipfs.add([Uint8Array.from(f1), Uint8Array,from(f2)], function (err, res) { 9 | if (err || !res) return console.log(err) 10 | 11 | for (let i = 0; i < res.length; i++) { 12 | console.log(res[i]) 13 | } 14 | }) 15 | 16 | ipfs.add(['./files/hello.txt', './files/ipfs.txt'], function (err, res) { 17 | if (err || !res) return console.log(err) 18 | 19 | for (let i = 0; i < res.length; i++) { 20 | console.log(res[i]) 21 | } 22 | }) 23 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/weird name folder [v0]/cat: -------------------------------------------------------------------------------- 1 | 2 | 3 | const ipfs = require('../src')('localhost', 5001) 4 | 5 | const hash = [ 6 | 'QmdFyxZXsFiP4csgfM5uPu99AvFiKH62CSPDw5TP92nr7w', 7 | 'QmY9cxiHqTFoWamkQVkpmmqzBrY3hCBEL2XNu3NtX74Fuu' 8 | ] 9 | 10 | ipfs.cat(hash, function (err, res) { 11 | if (err || !res) return console.log(err) 12 | 13 | if (res.readable) { 14 | res.pipe(process.stdout) 15 | } else { 16 | console.log(res) 17 | } 18 | }) 19 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/weird name folder [v0]/files/hello.txt: -------------------------------------------------------------------------------- 1 | Hello 2 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/weird name folder [v0]/files/ipfs.txt: -------------------------------------------------------------------------------- 1 | IPFS 2 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/weird name folder [v0]/hello-link: -------------------------------------------------------------------------------- 1 | Hello 2 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/weird name folder [v0]/ipfs-add: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | 4 | 5 | const ipfs = require('../src')('localhost', 5001) 6 | const files = process.argv.slice(2) 7 | 8 | ipfs.add(files, {recursive: true}, function (err, res) { 9 | if (err || !res) return console.log(err) 10 | 11 | for (let i = 0; i < res.length; i++) { 12 | console.log('added', res[i].Hash, res[i].Name) 13 | } 14 | }) 15 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/weird name folder [v0]/ls: -------------------------------------------------------------------------------- 1 | 2 | 3 | const ipfs = require('../src')('localhost', 5001) 4 | 5 | const hash = ['QmdbHK6gMiecyjjSoPnfJg6iKMF7v6E2NkoBgGpmyCoevh'] 6 | 7 | ipfs.ls(hash, function (err, res) { 8 | if (err || !res) return console.log(err) 9 | 10 | res.Objects.forEach(function (node) { 11 | console.log(node.Hash) 12 | 13 | console.log('Links [%d]', node.Links.length) 14 | node.Links.forEach(function (link, i) { 15 | console.log('[%d]', i, link) 16 | }) 17 | }) 18 | }) 19 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/fixtures/weird name folder [v0]/version: -------------------------------------------------------------------------------- 1 | 2 | 3 | const ipfs = require('../src')('localhost', 5001) 4 | 5 | ipfs.commands(function (err, res) { 6 | if (err) throw err 7 | console.log(res) 8 | }) 9 | -------------------------------------------------------------------------------- /packages/interface-ipfs-core/test/interface.spec.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipfs/js-ipfs/bf1bc8b18d750d5591bdd575a6d0f4c067d61d0a/packages/interface-ipfs-core/test/interface.spec.js -------------------------------------------------------------------------------- /packages/interface-ipfs-core/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "aegir/src/config/tsconfig.aegir.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "emitDeclarationOnly": true 6 | }, 7 | "include": [ 8 | "src", 9 | "test" 10 | ], 11 | "exclude": [ 12 | "test/fixtures/*" 13 | ], 14 | "references": [ 15 | { 16 | "path": "../ipfs-core-types" 17 | } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /packages/ipfs-cli/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | The `js-ipfs` project follows the [`IPFS Community Code of Conduct`](https://github.com/ipfs/community/blob/master/code-of-conduct.md) 4 | -------------------------------------------------------------------------------- /packages/ipfs-cli/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing guidelines 2 | 3 | IPFS as a project, including js-ipfs and all of its modules, follows the [standard IPFS Community contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md). 4 | 5 | We also adhere to the [IPFS JavaScript Community contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) which provide additional information of how to collaborate and contribute in the JavaScript implementation of IPFS. 6 | 7 | We appreciate your time and attention for going over these. Please open an issue on [ipfs/community](https://github.com/ipfs/community) if you have any question. 8 | 9 | Thank you. 10 | -------------------------------------------------------------------------------- /packages/ipfs-cli/COPYRIGHT: -------------------------------------------------------------------------------- 1 | This project is transitioning from an MIT-only license to a dual MIT/Apache-2.0 license. 2 | Unless otherwise noted, all code contributed prior to 2019-11-21 and not contributed by 3 | a user listed in [this signoff issue](https://github.com/ipfs/js-ipfs/issues/2624) is 4 | licensed under MIT-only. All new contributions (and past contributions since 2019-11-21) 5 | are licensed under a dual MIT/Apache-2.0 license. 6 | -------------------------------------------------------------------------------- /packages/ipfs-cli/LICENSE: -------------------------------------------------------------------------------- 1 | This project is dual licensed under MIT and Apache-2.0. 2 | 3 | MIT: https://www.opensource.org/licenses/mit 4 | Apache-2.0: https://www.apache.org/licenses/license-2.0 5 | -------------------------------------------------------------------------------- /packages/ipfs-cli/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 2 | 3 | http://www.apache.org/licenses/LICENSE-2.0 4 | 5 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 6 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/bitswap.js: -------------------------------------------------------------------------------- 1 | import { commands } from './bitswap/index.js' 2 | 3 | /** @type {import('yargs').CommandModule} */ 4 | const command = { 5 | command: 'bitswap ', 6 | 7 | describe: 'Interact with the bitswap agent', 8 | 9 | builder (yargs) { 10 | commands.forEach(command => { 11 | yargs.command(command) 12 | }) 13 | 14 | return yargs 15 | }, 16 | 17 | handler () { 18 | 19 | } 20 | } 21 | 22 | export default command 23 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/bitswap/index.js: -------------------------------------------------------------------------------- 1 | import bitswapStat from './stat.js' 2 | import bitswapUnwant from './unwant.js' 3 | import bitswapWantlist from './wantlist.js' 4 | 5 | /** @type {import('yargs').CommandModule[]} */ 6 | export const commands = [ 7 | bitswapStat, 8 | bitswapUnwant, 9 | bitswapWantlist 10 | ] 11 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/block.js: -------------------------------------------------------------------------------- 1 | import { commands } from './block/index.js' 2 | 3 | /** @type {import('yargs').CommandModule} */ 4 | const command = { 5 | command: 'block ', 6 | 7 | describe: 'Manipulate raw IPFS blocks', 8 | 9 | builder (yargs) { 10 | commands.forEach(command => { 11 | yargs.command(command) 12 | }) 13 | 14 | return yargs 15 | }, 16 | 17 | handler () { 18 | 19 | } 20 | } 21 | 22 | export default command 23 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/block/index.js: -------------------------------------------------------------------------------- 1 | import blockGet from './get.js' 2 | import blockPut from './put.js' 3 | import blockRm from './rm.js' 4 | import blockStat from './stat.js' 5 | 6 | /** @type {import('yargs').CommandModule[]} */ 7 | export const commands = [ 8 | blockGet, 9 | blockPut, 10 | blockRm, 11 | blockStat 12 | ] 13 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/bootstrap.js: -------------------------------------------------------------------------------- 1 | import { commands } from './bootstrap/index.js' 2 | 3 | /** @type {import('yargs').CommandModule} */ 4 | const command = { 5 | command: 'bootstrap ', 6 | 7 | describe: 'Show or edit the list of bootstrap peers', 8 | 9 | builder (yargs) { 10 | commands.forEach(command => { 11 | yargs.command(command) 12 | }) 13 | 14 | return yargs 15 | }, 16 | 17 | handler () { 18 | 19 | } 20 | } 21 | 22 | export default command 23 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/bootstrap/index.js: -------------------------------------------------------------------------------- 1 | import bootstrapAdd from './add.js' 2 | import bootstrapList from './list.js' 3 | import bootstrapRm from './rm.js' 4 | 5 | /** @type {import('yargs').CommandModule[]} */ 6 | export const commands = [ 7 | bootstrapAdd, 8 | bootstrapList, 9 | bootstrapRm 10 | ] 11 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/bootstrap/list.js: -------------------------------------------------------------------------------- 1 | import parseDuration from 'parse-duration' 2 | 3 | /** 4 | * @typedef {object} Argv 5 | * @property {import('../../types').Context} Argv.ctx 6 | * @property {number} Argv.timeout 7 | */ 8 | 9 | /** @type {import('yargs').CommandModule} */ 10 | const command = { 11 | command: 'list', 12 | 13 | describe: 'Show peers in the bootstrap list', 14 | 15 | builder: { 16 | timeout: { 17 | string: true, 18 | coerce: parseDuration 19 | } 20 | }, 21 | 22 | async handler ({ ctx: { ipfs, print }, timeout }) { 23 | const list = await ipfs.bootstrap.list({ 24 | timeout 25 | }) 26 | list.Peers.forEach((node) => print(node.toString())) 27 | } 28 | } 29 | 30 | export default command 31 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/cid.js: -------------------------------------------------------------------------------- 1 | import { commands } from './cid/index.js' 2 | 3 | /** @type {import('yargs').CommandModule} */ 4 | const command = { 5 | command: 'cid ', 6 | 7 | describe: 'Convert, format and discover properties of CIDs', 8 | 9 | builder (yargs) { 10 | commands.forEach(command => { 11 | yargs.command(command) 12 | }) 13 | 14 | return yargs 15 | }, 16 | 17 | handler () { 18 | 19 | } 20 | } 21 | 22 | export default command 23 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/cid/index.js: -------------------------------------------------------------------------------- 1 | import cidBase32 from './base32.js' 2 | import cidBases from './bases.js' 3 | import cidCodecs from './codecs.js' 4 | import cidFormat from './format.js' 5 | import cidHashes from './hashes.js' 6 | 7 | /** @type {import('yargs').CommandModule[]} */ 8 | export const commands = [ 9 | cidBase32, 10 | cidBases, 11 | cidCodecs, 12 | cidFormat, 13 | cidHashes 14 | ] 15 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/config/edit.js: -------------------------------------------------------------------------------- 1 | import path from 'path' 2 | import { execa } from 'execa' 3 | 4 | /** 5 | * @typedef {object} Argv 6 | * @property {import('../../types').Context} Argv.ctx 7 | */ 8 | 9 | /** @type {import('yargs').CommandModule} */ 10 | const command = { 11 | command: 'edit', 12 | 13 | describe: 'Opens the config file for editing in $EDITOR', 14 | 15 | async handler ({ ctx: { repoPath } }) { 16 | const editor = process.env.EDITOR 17 | 18 | if (!editor) { 19 | throw new Error('ENV variable $EDITOR not set') 20 | } 21 | 22 | await execa(editor, [path.join(repoPath, 'config')]) 23 | } 24 | } 25 | 26 | export default command 27 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/config/index.js: -------------------------------------------------------------------------------- 1 | import configEdit from './edit.js' 2 | import configProfile from './profile.js' 3 | import configReplace from './replace.js' 4 | import configShow from './show.js' 5 | 6 | /** @type {import('yargs').CommandModule[]} */ 7 | export const commands = [ 8 | configEdit, 9 | configProfile, 10 | configReplace, 11 | configShow 12 | ] 13 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/config/profile.js: -------------------------------------------------------------------------------- 1 | import { commands } from './profile/index.js' 2 | 3 | /** 4 | * @typedef {import('yargs').Argv<{}>} Argv 5 | */ 6 | 7 | /** @type {import('yargs').CommandModule} */ 8 | const command = { 9 | command: 'profile ', 10 | 11 | describe: 'Interact with config profiles', 12 | 13 | builder (yargs) { 14 | return yargs 15 | .command(commands) 16 | }, 17 | 18 | handler () { 19 | 20 | } 21 | } 22 | 23 | export default command 24 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/config/profile/index.js: -------------------------------------------------------------------------------- 1 | import configProfileApply from './apply.js' 2 | import configProfileLs from './ls.js' 3 | 4 | /** @type {import('yargs').CommandModule[]} */ 5 | export const commands = [ 6 | configProfileApply, 7 | configProfileLs 8 | ] 9 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/config/show.js: -------------------------------------------------------------------------------- 1 | import parseDuration from 'parse-duration' 2 | 3 | /** 4 | * @typedef {object} Argv 5 | * @property {import('../../types').Context} Argv.ctx 6 | * @property {number} Argv.timeout 7 | */ 8 | 9 | /** @type {import('yargs').CommandModule} */ 10 | const command = { 11 | command: 'show', 12 | 13 | describe: 'Outputs the content of the config file', 14 | 15 | builder: { 16 | timeout: { 17 | string: true, 18 | coerce: parseDuration 19 | } 20 | }, 21 | 22 | async handler ({ ctx: { ipfs, print }, timeout }) { 23 | const config = await ipfs.config.getAll({ 24 | timeout 25 | }) 26 | print(JSON.stringify(config, null, 2)) 27 | } 28 | } 29 | 30 | export default command 31 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/dag.js: -------------------------------------------------------------------------------- 1 | import { commands } from './dag/index.js' 2 | 3 | /** @type {import('yargs').CommandModule} */ 4 | const command = { 5 | command: 'dag ', 6 | 7 | describe: 'Interact with ipld dag objects', 8 | 9 | builder (yargs) { 10 | commands.forEach(command => { 11 | yargs.command(command) 12 | }) 13 | 14 | return yargs 15 | }, 16 | 17 | handler () { 18 | 19 | } 20 | } 21 | 22 | export default command 23 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/dag/index.js: -------------------------------------------------------------------------------- 1 | import dagExport from './export.js' 2 | import dagGet from './get.js' 3 | import dagImport from './import.js' 4 | import dagPut from './put.js' 5 | import dagResolve from './resolve.js' 6 | 7 | /** @type {import('yargs').CommandModule[]} */ 8 | export const commands = [ 9 | dagExport, 10 | dagGet, 11 | dagImport, 12 | dagPut, 13 | dagResolve 14 | ] 15 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/dht.js: -------------------------------------------------------------------------------- 1 | import { commands } from './dht/index.js' 2 | 3 | /** @type {import('yargs').CommandModule} */ 4 | const command = { 5 | command: 'dht ', 6 | 7 | describe: 'Issue commands directly through the DHT', 8 | 9 | builder (yargs) { 10 | commands.forEach(command => { 11 | yargs.command(command) 12 | }) 13 | 14 | return yargs 15 | }, 16 | 17 | handler () { 18 | 19 | } 20 | } 21 | 22 | export default command 23 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/dht/index.js: -------------------------------------------------------------------------------- 1 | import dhtFindPeer from './find-peer.js' 2 | import dhtFindProviders from './find-providers.js' 3 | import dhtGet from './get.js' 4 | import dhtProvide from './provide.js' 5 | import dhtPut from './put.js' 6 | import dhtQuery from './query.js' 7 | 8 | /** @type {import('yargs').CommandModule[]} */ 9 | export const commands = [ 10 | dhtFindPeer, 11 | dhtFindProviders, 12 | dhtGet, 13 | dhtProvide, 14 | dhtPut, 15 | dhtQuery 16 | ] 17 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/files.js: -------------------------------------------------------------------------------- 1 | import { commands } from './files/index.js' 2 | 3 | /** @type {import('yargs').CommandModule} */ 4 | const command = { 5 | command: 'files ', 6 | 7 | describe: 'Operations over mfs files (ls, mkdir, rm, etc)', 8 | 9 | builder (yargs) { 10 | commands.forEach(command => { 11 | yargs.command(command) 12 | }) 13 | 14 | return yargs 15 | }, 16 | 17 | handler ({ ctx: { print } }) { 18 | print('Type `jsipfs files --help` for more instructions') 19 | } 20 | } 21 | 22 | export default command 23 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/files/index.js: -------------------------------------------------------------------------------- 1 | import filesChmod from './chmod.js' 2 | import filesCp from './cp.js' 3 | import filesFlush from './flush.js' 4 | import filesLs from './ls.js' 5 | import filesMkdir from './mkdir.js' 6 | import filesMv from './mv.js' 7 | import filesRead from './read.js' 8 | import filesRm from './rm.js' 9 | import filesStat from './stat.js' 10 | import filesTouch from './touch.js' 11 | import filesWrite from './write.js' 12 | 13 | /** @type {import('yargs').CommandModule[]} */ 14 | export const commands = [ 15 | filesChmod, 16 | filesCp, 17 | filesFlush, 18 | filesLs, 19 | filesMkdir, 20 | filesMv, 21 | filesRead, 22 | filesRm, 23 | filesStat, 24 | filesTouch, 25 | filesWrite 26 | ] 27 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/key.js: -------------------------------------------------------------------------------- 1 | import { commands } from './key/index.js' 2 | 3 | /** @type {import('yargs').CommandModule} */ 4 | const command = { 5 | command: 'key ', 6 | 7 | describe: 'Manage your keys', 8 | 9 | builder (yargs) { 10 | commands.forEach(command => { 11 | yargs.command(command) 12 | }) 13 | 14 | return yargs 15 | }, 16 | 17 | handler () { 18 | 19 | } 20 | } 21 | 22 | export default command 23 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/key/index.js: -------------------------------------------------------------------------------- 1 | import keyExport from './export.js' 2 | import keyGen from './gen.js' 3 | import keyImport from './import.js' 4 | import keyList from './list.js' 5 | import keyRename from './rename.js' 6 | import keyRm from './rm.js' 7 | 8 | /** @type {import('yargs').CommandModule[]} */ 9 | export const commands = [ 10 | keyExport, 11 | keyGen, 12 | keyImport, 13 | keyList, 14 | keyRename, 15 | keyRm 16 | ] 17 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/name.js: -------------------------------------------------------------------------------- 1 | import { commands } from './name/index.js' 2 | 3 | /* 4 | IPNS is a PKI namespace, where names are the hashes of public keys, and 5 | the private key enables publishing new (signed) values. In both publish 6 | and resolve, the default name used is the node's own PeerID, 7 | which is the hash of its public key. 8 | */ 9 | /** @type {import('yargs').CommandModule} */ 10 | const command = { 11 | command: 'name ', 12 | 13 | describe: 'Publish and resolve IPNS names', 14 | 15 | builder (yargs) { 16 | commands.forEach(command => { 17 | yargs.command(command) 18 | }) 19 | 20 | return yargs 21 | }, 22 | 23 | handler () { 24 | 25 | } 26 | } 27 | 28 | export default command 29 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/name/index.js: -------------------------------------------------------------------------------- 1 | import namePublish from './publish.js' 2 | import namePubsub from './pubsub.js' 3 | import nameResolve from './resolve.js' 4 | 5 | /** @type {import('yargs').CommandModule[]} */ 6 | export const commands = [ 7 | namePublish, 8 | namePubsub, 9 | nameResolve 10 | ] 11 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/name/pubsub.js: -------------------------------------------------------------------------------- 1 | import { commands } from './pubsub/index.js' 2 | 3 | /** 4 | * @typedef {import('yargs').Argv} Argv 5 | */ 6 | 7 | /* 8 | Manage and inspect the state of the IPNS pubsub resolver. 9 | Note: this command is experimental and subject to change as the system is refined. 10 | */ 11 | /** @type {import('yargs').CommandModule} */ 12 | const command = { 13 | command: 'pubsub', 14 | 15 | describe: 'IPNS pubsub management', 16 | 17 | builder (yargs) { 18 | commands.forEach(command => { 19 | yargs.command(command) 20 | }) 21 | 22 | return yargs 23 | }, 24 | 25 | handler () { 26 | 27 | } 28 | } 29 | 30 | export default command 31 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/name/pubsub/index.js: -------------------------------------------------------------------------------- 1 | import namePubsubCancel from './cancel.js' 2 | import namePubsubState from './state.js' 3 | import namePubsubSubs from './subs.js' 4 | 5 | /** @type {import('yargs').CommandModule[]} */ 6 | export const commands = [ 7 | namePubsubCancel, 8 | namePubsubState, 9 | namePubsubSubs 10 | ] 11 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/name/pubsub/state.js: -------------------------------------------------------------------------------- 1 | import parseDuration from 'parse-duration' 2 | 3 | /** 4 | * @typedef {object} Argv 5 | * @property {import('../../../types').Context} Argv.ctx 6 | * @property {number} Argv.timeout 7 | */ 8 | 9 | /** @type {import('yargs').CommandModule} */ 10 | const command = { 11 | command: 'state', 12 | 13 | describe: 'Query the state of IPNS pubsub', 14 | 15 | builder: { 16 | timeout: { 17 | string: true, 18 | coerce: parseDuration 19 | } 20 | }, 21 | 22 | async handler ({ ctx: { ipfs, print }, timeout }) { 23 | const result = await ipfs.name.pubsub.state({ 24 | timeout 25 | }) 26 | print(result.enabled ? 'enabled' : 'disabled') 27 | } 28 | } 29 | 30 | export default command 31 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/object.js: -------------------------------------------------------------------------------- 1 | import { commands } from './object/index.js' 2 | 3 | /** @type {import('yargs').CommandModule} */ 4 | const command = { 5 | command: 'object ', 6 | 7 | describe: 'Interact with ipfs objects', 8 | 9 | builder (yargs) { 10 | commands.forEach(command => { 11 | yargs.command(command) 12 | }) 13 | 14 | return yargs 15 | }, 16 | 17 | handler () { 18 | 19 | } 20 | } 21 | 22 | export default command 23 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/object/index.js: -------------------------------------------------------------------------------- 1 | import objectData from './data.js' 2 | import objectGet from './get.js' 3 | import objectLinks from './links.js' 4 | import objectNew from './new.js' 5 | import objectPatch from './patch.js' 6 | import objectPut from './put.js' 7 | import objectStat from './stat.js' 8 | 9 | /** @type {import('yargs').CommandModule[]} */ 10 | export const commands = [ 11 | objectData, 12 | objectGet, 13 | objectLinks, 14 | objectNew, 15 | objectPatch, 16 | objectPut, 17 | objectStat 18 | ] 19 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/object/patch.js: -------------------------------------------------------------------------------- 1 | import { commands } from './patch/index.js' 2 | 3 | /** 4 | * @typedef {import('yargs').Argv} Argv 5 | */ 6 | 7 | /** @type {import('yargs').CommandModule} */ 8 | const command = { 9 | command: 'patch', 10 | 11 | describe: 'Create a new merkledag object based on an existing one', 12 | 13 | builder (yargs) { 14 | commands.forEach(command => { 15 | yargs.command(command) 16 | }) 17 | 18 | return yargs 19 | }, 20 | 21 | handler () { 22 | 23 | } 24 | } 25 | 26 | export default command 27 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/object/patch/index.js: -------------------------------------------------------------------------------- 1 | import objectPatchAddLink from './add-link.js' 2 | import objectPatchAppendData from './append-data.js' 3 | import objectPatchRmLink from './rm-link.js' 4 | import objectPatchSetData from './set-data.js' 5 | 6 | /** @type {import('yargs').CommandModule[]} */ 7 | export const commands = [ 8 | objectPatchAddLink, 9 | objectPatchAppendData, 10 | objectPatchRmLink, 11 | objectPatchSetData 12 | ] 13 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/pin.js: -------------------------------------------------------------------------------- 1 | import { commands } from './pin/index.js' 2 | 3 | /** @type {import('yargs').CommandModule} */ 4 | const command = { 5 | command: 'pin ', 6 | 7 | describe: 'Pin and unpin objects to local storage', 8 | 9 | builder (yargs) { 10 | commands.forEach(command => { 11 | yargs.command(command) 12 | }) 13 | 14 | return yargs 15 | }, 16 | 17 | handler () { 18 | 19 | } 20 | } 21 | 22 | export default command 23 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/pin/index.js: -------------------------------------------------------------------------------- 1 | import pinAdd from './add.js' 2 | import pinLs from './ls.js' 3 | import pinRm from './rm.js' 4 | 5 | /** @type {import('yargs').CommandModule[]} */ 6 | export const commands = [ 7 | pinAdd, 8 | pinLs, 9 | pinRm 10 | ] 11 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/pubsub.js: -------------------------------------------------------------------------------- 1 | import { commands } from './pubsub/index.js' 2 | 3 | /** @type {import('yargs').CommandModule} */ 4 | const command = { 5 | command: 'pubsub ', 6 | 7 | describe: 'pubsub commands', 8 | 9 | builder (yargs) { 10 | commands.forEach(command => { 11 | yargs.command(command) 12 | }) 13 | 14 | return yargs 15 | }, 16 | 17 | handler () { 18 | 19 | } 20 | } 21 | 22 | export default command 23 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/pubsub/index.js: -------------------------------------------------------------------------------- 1 | import pubsubLs from './ls.js' 2 | import pubsubPeers from './peers.js' 3 | import pubsubPub from './pub.js' 4 | import pubsubSub from './sub.js' 5 | 6 | /** @type {import('yargs').CommandModule[]} */ 7 | export const commands = [ 8 | pubsubLs, 9 | pubsubPeers, 10 | pubsubPub, 11 | pubsubSub 12 | ] 13 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/repo.js: -------------------------------------------------------------------------------- 1 | import { commands } from './repo/index.js' 2 | 3 | /** @type {import('yargs').CommandModule} */ 4 | const command = { 5 | command: 'repo ', 6 | 7 | describe: 'Manipulate the IPFS repo', 8 | 9 | builder (yargs) { 10 | commands.forEach(command => { 11 | yargs.command(command) 12 | }) 13 | 14 | return yargs 15 | }, 16 | 17 | handler () { 18 | 19 | } 20 | } 21 | 22 | export default command 23 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/repo/index.js: -------------------------------------------------------------------------------- 1 | import repoGc from './gc.js' 2 | import repoStat from './stat.js' 3 | import repoVersion from './version.js' 4 | 5 | /** @type {import('yargs').CommandModule[]} */ 6 | export const commands = [ 7 | repoGc, 8 | repoStat, 9 | repoVersion 10 | ] 11 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/repo/version.js: -------------------------------------------------------------------------------- 1 | import parseDuration from 'parse-duration' 2 | 3 | /** 4 | * @typedef {object} Argv 5 | * @property {import('../../types').Context} Argv.ctx 6 | * @property {number} Argv.timeout 7 | */ 8 | 9 | /** @type {import('yargs').CommandModule} */ 10 | const command = { 11 | command: 'version', 12 | 13 | describe: 'Shows IPFS repo version information', 14 | 15 | builder: { 16 | timeout: { 17 | string: true, 18 | coerce: parseDuration 19 | } 20 | }, 21 | 22 | async handler ({ ctx: { ipfs, print }, timeout }) { 23 | const version = await ipfs.repo.version({ 24 | timeout 25 | }) 26 | print(`${version}`) 27 | } 28 | } 29 | 30 | export default command 31 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/shutdown.js: -------------------------------------------------------------------------------- 1 | import parseDuration from 'parse-duration' 2 | 3 | /** 4 | * @typedef {object} Argv 5 | * @property {import('../types').Context} Argv.ctx 6 | * @property {number} Argv.timeout 7 | */ 8 | 9 | /** @type {import('yargs').CommandModule} */ 10 | const command = { 11 | command: 'shutdown', 12 | 13 | describe: 'Shut down the ipfs daemon', 14 | 15 | builder: { 16 | timeout: { 17 | string: true, 18 | coerce: parseDuration 19 | } 20 | }, 21 | 22 | handler ({ ctx: { ipfs }, timeout }) { 23 | // @ts-expect-error not part of the core api 24 | return ipfs.shutdown({ 25 | timeout 26 | }) 27 | } 28 | } 29 | 30 | export default command 31 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/stats.js: -------------------------------------------------------------------------------- 1 | import { commands } from './stats/index.js' 2 | 3 | /** @type {import('yargs').CommandModule} */ 4 | const command = { 5 | command: 'stats ', 6 | 7 | describe: 'Query IPFS statistics', 8 | 9 | builder (yargs) { 10 | commands.forEach(command => { 11 | yargs.command(command) 12 | }) 13 | 14 | return yargs 15 | }, 16 | 17 | handler () { 18 | 19 | } 20 | } 21 | 22 | export default command 23 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/stats/bitswap.js: -------------------------------------------------------------------------------- 1 | import bitswapStat from '../bitswap/stat.js' 2 | 3 | // This is an alias for `bitswap stat`. 4 | /** @type {bitswapStat} */ 5 | const command = { 6 | ...bitswapStat, 7 | // The command needs to be renamed, else it would be `stats stat` instead of 8 | // `stats bitswap` 9 | command: 'bitswap' 10 | } 11 | 12 | export default command 13 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/stats/index.js: -------------------------------------------------------------------------------- 1 | import statsBitswap from './bitswap.js' 2 | import statsBw from './bw.js' 3 | import statsRepo from './repo.js' 4 | 5 | /** @type {import('yargs').CommandModule[]} */ 6 | export const commands = [ 7 | statsBitswap, 8 | statsBw, 9 | statsRepo 10 | ] 11 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/stats/repo.js: -------------------------------------------------------------------------------- 1 | 2 | // This is an alias for `repo stat`. 3 | import repoStats from '../repo/stat.js' 4 | 5 | /** @type {repoStats} */ 6 | const command = { 7 | ...repoStats, 8 | 9 | // The command needs to be renamed, else it would be `stats stat` instead of 10 | // `stats repo` 11 | command: 'repo' 12 | } 13 | 14 | export default command 15 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/swarm.js: -------------------------------------------------------------------------------- 1 | import { commands } from './swarm/index.js' 2 | 3 | /** @type {import('yargs').CommandModule} */ 4 | const command = { 5 | command: 'swarm ', 6 | 7 | describe: 'Swarm inspection tool', 8 | 9 | builder (yargs) { 10 | commands.forEach(command => { 11 | yargs.command(command) 12 | }) 13 | 14 | return yargs 15 | }, 16 | 17 | handler () { 18 | 19 | } 20 | } 21 | 22 | export default command 23 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/swarm/addrs/index.js: -------------------------------------------------------------------------------- 1 | import swarmAddrsLocal from './local.js' 2 | 3 | /** @type {import('yargs').CommandModule[]} */ 4 | export const commands = [ 5 | swarmAddrsLocal 6 | ] 7 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/commands/swarm/index.js: -------------------------------------------------------------------------------- 1 | import swarmAddrs from './addrs.js' 2 | import swarmConnect from './connect.js' 3 | import swarmDisconnect from './disconnect.js' 4 | import swarmPeers from './peers.js' 5 | 6 | /** @type {import('yargs').CommandModule[]} */ 7 | export const commands = [ 8 | swarmAddrs, 9 | swarmConnect, 10 | swarmDisconnect, 11 | swarmPeers 12 | ] 13 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/index.js: -------------------------------------------------------------------------------- 1 | import parser from './parser.js' 2 | import commandAlias from './command-alias.js' 3 | 4 | /** 5 | * @param {string[]} command 6 | * @param {import('yargs').MiddlewareFunction} ctxMiddleware 7 | */ 8 | export async function cli (command, ctxMiddleware) { 9 | // Apply command aliasing (eg `refs local` -> `refs-local`) 10 | command = commandAlias(command) 11 | 12 | await parser() 13 | .middleware(ctxMiddleware) 14 | .parse(command) 15 | } 16 | -------------------------------------------------------------------------------- /packages/ipfs-cli/src/types.ts: -------------------------------------------------------------------------------- 1 | import type { IPFS } from 'ipfs-core-types' 2 | import type { Multiaddr } from '@multiformats/multiaddr' 3 | 4 | declare module '@hapi/hapi' { 5 | interface ServerInfo { 6 | ma: Multiaddr 7 | } 8 | } 9 | 10 | export interface Context { 11 | ipfs: IPFS 12 | print: Print 13 | isDaemon: boolean 14 | getStdin: () => AsyncIterable 15 | repoPath: string 16 | } 17 | 18 | export interface Print { 19 | (msg: string | Uint8Array, includeNewline?: boolean, isError?: boolean): void 20 | clearLine: () => void 21 | cursorTo: (pos: number) => void 22 | write: (data: any) => void 23 | error: (msg: string, includeNewline?: boolean) => void 24 | isTTY: boolean 25 | columns: any 26 | } 27 | -------------------------------------------------------------------------------- /packages/ipfs-cli/test/progress-bar.spec.js: -------------------------------------------------------------------------------- 1 | /* eslint-env mocha */ 2 | 3 | import { expect } from 'aegir/chai' 4 | import { createProgressBar } from '../src/utils.js' 5 | 6 | describe('progress bar', () => { 7 | it('created with the correct properties', () => { 8 | const total = 1000 9 | 10 | const bar = createProgressBar(total) 11 | expect(bar.total).to.eql(total) 12 | expect(typeof bar.tick).to.eql('function') 13 | }) 14 | }) 15 | -------------------------------------------------------------------------------- /packages/ipfs-cli/test/utils/clean.js: -------------------------------------------------------------------------------- 1 | 2 | import rimraf from 'rimraf' 3 | import fs from 'fs/promises' 4 | import { promisify } from 'util' 5 | 6 | /** 7 | * @param {string} dir 8 | */ 9 | export async function clean (dir) { 10 | try { 11 | await fs.access(dir) 12 | } catch (/** @type {any} */ err) { 13 | // Does not exist so all good 14 | return 15 | } 16 | 17 | return promisify(rimraf)(dir) 18 | } 19 | -------------------------------------------------------------------------------- /packages/ipfs-cli/test/utils/match-iterable.js: -------------------------------------------------------------------------------- 1 | 2 | import sinon from 'sinon' 3 | 4 | export function matchIterable () { 5 | return sinon.match((thing) => Boolean(thing[Symbol.asyncIterator]) || Boolean(thing[Symbol.iterator])) 6 | } 7 | -------------------------------------------------------------------------------- /packages/ipfs-cli/test/utils/match-peer-id.js: -------------------------------------------------------------------------------- 1 | import sinon from 'sinon' 2 | 3 | /** 4 | * @param {import('@libp2p/interface-peer-id').PeerId} peerId 5 | * @returns {import('sinon').SinonMatcher} 6 | */ 7 | export function matchPeerId (peerId) { 8 | return sinon.match((value) => { 9 | return peerId.toString() === value.toString() 10 | }) 11 | } 12 | -------------------------------------------------------------------------------- /packages/ipfs-cli/test/utils/platforms.js: -------------------------------------------------------------------------------- 1 | 2 | import os from 'os' 3 | 4 | const current = os.platform() 5 | 6 | export const isWindows = current === 'win32' 7 | export const isMacOS = current === 'darwin' 8 | export const isLinux = current === 'linux' 9 | -------------------------------------------------------------------------------- /packages/ipfs-cli/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "aegir/src/config/tsconfig.aegir.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "emitDeclarationOnly": true 6 | }, 7 | "include": [ 8 | "src", 9 | "package.json" 10 | ], 11 | "references": [ 12 | { 13 | "path": "../ipfs-core" 14 | }, 15 | { 16 | "path": "../ipfs-core-types" 17 | }, 18 | { 19 | "path": "../ipfs-core-utils" 20 | }, 21 | { 22 | "path": "../ipfs-daemon" 23 | }, 24 | { 25 | "path": "../ipfs-http-client" 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /packages/ipfs-client/.aegir.js: -------------------------------------------------------------------------------- 1 | 2 | /** @type {import('aegir').PartialOptions} */ 3 | export default { 4 | build: { 5 | bundlesizeMax: '98kB' 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/ipfs-client/LICENSE: -------------------------------------------------------------------------------- 1 | This project is dual licensed under MIT and Apache-2.0. 2 | 3 | MIT: https://www.opensource.org/licenses/mit 4 | Apache-2.0: https://www.apache.org/licenses/license-2.0 5 | -------------------------------------------------------------------------------- /packages/ipfs-client/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 2 | 3 | http://www.apache.org/licenses/LICENSE-2.0 4 | 5 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 6 | -------------------------------------------------------------------------------- /packages/ipfs-client/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "aegir/src/config/tsconfig.aegir.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "emitDeclarationOnly": true 6 | }, 7 | "include": [ 8 | "src" 9 | ], 10 | "references": [ 11 | { 12 | "path": "../ipfs-grpc-client" 13 | }, 14 | { 15 | "path": "../ipfs-http-client" 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /packages/ipfs-core-config/.aegir.js: -------------------------------------------------------------------------------- 1 | 2 | /** @type {import('aegir').PartialOptions} */ 3 | export default { 4 | build: { 5 | bundlesizeMax: '540B' 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/ipfs-core-config/LICENSE: -------------------------------------------------------------------------------- 1 | This project is dual licensed under MIT and Apache-2.0. 2 | 3 | MIT: https://www.opensource.org/licenses/mit 4 | Apache-2.0: https://www.apache.org/licenses/license-2.0 5 | -------------------------------------------------------------------------------- /packages/ipfs-core-config/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 2 | 3 | http://www.apache.org/licenses/LICENSE-2.0 4 | 5 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 6 | -------------------------------------------------------------------------------- /packages/ipfs-core-config/src/index.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipfs/js-ipfs/bf1bc8b18d750d5591bdd575a6d0f4c067d61d0a/packages/ipfs-core-config/src/index.js -------------------------------------------------------------------------------- /packages/ipfs-core-config/src/init-assets.browser.js: -------------------------------------------------------------------------------- 1 | 2 | export function initAssets () {} 3 | -------------------------------------------------------------------------------- /packages/ipfs-core-config/src/init-assets.js: -------------------------------------------------------------------------------- 1 | import all from 'it-all' 2 | import assets from './init-files/init-docs/index.js' 3 | 4 | /** 5 | * Add the default assets to the repo. 6 | * 7 | * @param {object} arg 8 | * @param {import('ipfs-core-types/src/root').API<{}>["addAll"]} arg.addAll 9 | * @param {(msg: string) => void} arg.print 10 | */ 11 | export async function initAssets ({ addAll, print }) { 12 | const results = await all(addAll(assets, { preload: false })) 13 | const dir = results.filter(file => file.path === 'init-docs').pop() 14 | 15 | if (!dir) { 16 | return 17 | } 18 | 19 | print('to get started, enter:\n') 20 | print(`\tjsipfs cat /ipfs/${dir.cid}/readme\n`) 21 | } 22 | -------------------------------------------------------------------------------- /packages/ipfs-core-config/src/init-files/init-docs/contact.js: -------------------------------------------------------------------------------- 1 | export default `Come hang out in our IRC chat room if you have any questions. 2 | 3 | Contact the ipfs dev team: 4 | - Bugs: https://github.com/ipfs/go-ipfs/issues 5 | - Help: irc.freenode.org/#ipfs 6 | - Email: dev@ipfs.io 7 | ` 8 | -------------------------------------------------------------------------------- /packages/ipfs-core-config/src/init-files/init-docs/docs/index.js: -------------------------------------------------------------------------------- 1 | export default `Index 2 | ` 3 | -------------------------------------------------------------------------------- /packages/ipfs-core-config/src/init-files/init-docs/help.js: -------------------------------------------------------------------------------- 1 | export default `Some helpful resources for finding your way around ipfs: 2 | 3 | - quick-start: a quick show of various ipfs features. 4 | - ipfs commands: a list of all commands 5 | - ipfs --help: every command describes itself 6 | - https://github.com/ipfs/go-ipfs -- the src repository 7 | - #ipfs on irc.freenode.org -- the community irc channel 8 | ` 9 | -------------------------------------------------------------------------------- /packages/ipfs-core-config/src/libp2p-pubsub-routers.browser.js: -------------------------------------------------------------------------------- 1 | import { gossipsub } from '@chainsafe/libp2p-gossipsub' 2 | 3 | /** @typedef {import('@libp2p/interface-pubsub').PubSub} PubSub */ 4 | 5 | /** @type {() => Record PubSub>}>} */ 6 | export const routers = () => ({ 7 | gossipsub: gossipsub({ 8 | fallbackToFloodsub: true, 9 | emitSelf: true, 10 | maxInboundStreams: 64, 11 | maxOutboundStreams: 128 12 | }) 13 | }) 14 | -------------------------------------------------------------------------------- /packages/ipfs-core-config/src/libp2p-pubsub-routers.js: -------------------------------------------------------------------------------- 1 | import { gossipsub } from '@chainsafe/libp2p-gossipsub' 2 | import { floodsub } from '@libp2p/floodsub' 3 | 4 | /** @typedef {import('@libp2p/interface-pubsub').PubSub} PubSub */ 5 | 6 | /** @type {() => Record PubSub>}>} */ 7 | export const routers = () => ({ 8 | gossipsub: gossipsub({ 9 | fallbackToFloodsub: true, 10 | emitSelf: true, 11 | maxInboundStreams: 64, 12 | maxOutboundStreams: 128 13 | }), 14 | floodsub: floodsub({ 15 | emitSelf: true 16 | }) 17 | }) 18 | -------------------------------------------------------------------------------- /packages/ipfs-core-config/src/libp2p.browser.js: -------------------------------------------------------------------------------- 1 | import { webRTCStar } from '@libp2p/webrtc-star' 2 | 3 | export function libp2pConfig () { 4 | const webRtcStar = webRTCStar() 5 | 6 | /** @type {import('libp2p').Libp2pOptions} */ 7 | const options = { 8 | transports: [ 9 | webRtcStar.transport 10 | ], 11 | peerDiscovery: [ 12 | webRtcStar.discovery 13 | ], 14 | connectionManager: { 15 | maxParallelDials: 150, // 150 total parallel multiaddr dials 16 | maxDialsPerPeer: 4, // Allow 4 multiaddrs to be dialed per peer in parallel 17 | dialTimeout: 10e3, // 10 second dial timeout per peer dial 18 | autoDial: true 19 | }, 20 | nat: { 21 | enabled: false 22 | } 23 | } 24 | 25 | return options 26 | } 27 | -------------------------------------------------------------------------------- /packages/ipfs-core-config/src/preload.js: -------------------------------------------------------------------------------- 1 | import HTTP from 'ipfs-utils/src/http.js' 2 | import { logger } from '@libp2p/logger' 3 | import drain from 'it-drain' 4 | 5 | const log = logger('ipfs:preload') 6 | 7 | /** 8 | * @param {string} url 9 | * @param {import('ipfs-core-types/src/utils').AbortOptions} options 10 | */ 11 | export async function preload (url, options = {}) { 12 | log(url) 13 | 14 | const res = await HTTP.post(url, { signal: options.signal }) 15 | 16 | if (res.body) { 17 | // Read to completion but do not cache 18 | // @ts-expect-error 19 | await drain(res.body) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/ipfs-core-config/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "aegir/src/config/tsconfig.aegir.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "emitDeclarationOnly": true 6 | }, 7 | "include": [ 8 | "src", 9 | "test" 10 | ], 11 | "references": [ 12 | { 13 | "path": "../ipfs-core-utils" 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /packages/ipfs-core-types/COPYRIGHT: -------------------------------------------------------------------------------- 1 | This project is transitioning from an MIT-only license to a dual MIT/Apache-2.0 license. 2 | Unless otherwise noted, all code contributed prior to 2019-11-21 and not contributed by 3 | a user listed in [this signoff issue](https://github.com/ipfs/js-ipfs/issues/2624) is 4 | licensed under MIT-only. All new contributions (and past contributions since 2019-11-21) 5 | are licensed under a dual MIT/Apache-2.0 license. 6 | -------------------------------------------------------------------------------- /packages/ipfs-core-types/LICENSE: -------------------------------------------------------------------------------- 1 | This project is dual licensed under MIT and Apache-2.0. 2 | 3 | MIT: https://www.opensource.org/licenses/mit 4 | Apache-2.0: https://www.apache.org/licenses/license-2.0 5 | -------------------------------------------------------------------------------- /packages/ipfs-core-types/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 2 | 3 | http://www.apache.org/licenses/LICENSE-2.0 4 | 5 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 6 | -------------------------------------------------------------------------------- /packages/ipfs-core-types/src/diag/index.ts: -------------------------------------------------------------------------------- 1 | import type { AbortOptions } from '../utils' 2 | 3 | export interface API { 4 | cmds: (options?: AbortOptions & OptionExtension) => Promise 5 | net: (options?: AbortOptions & OptionExtension) => Promise 6 | sys: (options?: AbortOptions & OptionExtension) => Promise 7 | } 8 | 9 | export interface CmdsResult { 10 | active: boolean 11 | args: string[] 12 | endTime: Date 13 | id: string 14 | options: Record 15 | startTime: Date 16 | } 17 | -------------------------------------------------------------------------------- /packages/ipfs-core-types/src/log/index.ts: -------------------------------------------------------------------------------- 1 | import type { AbortOptions } from '../utils' 2 | 3 | export interface API { 4 | level: (subsystem: string, level: string, options?: AbortOptions & OptionExtension) => Promise 5 | ls: (options?: AbortOptions & OptionExtension) => Promise 6 | tail: (options?: AbortOptions & OptionExtension) => AsyncIterable 7 | } 8 | -------------------------------------------------------------------------------- /packages/ipfs-core-types/src/object/patch/index.ts: -------------------------------------------------------------------------------- 1 | import type { CID } from 'multiformats/cid' 2 | import type { AbortOptions } from '../../utils' 3 | import type { PBLink as DAGLink } from '@ipld/dag-pb' 4 | 5 | export interface API { 6 | addLink: (cid: CID, link: DAGLink, options?: AbortOptions & OptionExtension) => Promise 7 | rmLink: (cid: CID, link: DAGLink | string, options?: AbortOptions & OptionExtension) => Promise 8 | appendData: (cid: CID, data: Uint8Array, options?: AbortOptions & OptionExtension) => Promise 9 | setData: (cid: CID, data: Uint8Array, options?: AbortOptions & OptionExtension) => Promise 10 | } 11 | -------------------------------------------------------------------------------- /packages/ipfs-core-types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "aegir/src/config/tsconfig.aegir.json", 3 | "compilerOptions": { 4 | "outDir": "dist" 5 | }, 6 | "include": [ 7 | "src" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /packages/ipfs-core-utils/.aegir.js: -------------------------------------------------------------------------------- 1 | 2 | /** @type {import('aegir').PartialOptions} */ 3 | export default { 4 | build: { 5 | bundlesizeMax: '540B' 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/ipfs-core-utils/LICENSE: -------------------------------------------------------------------------------- 1 | This project is dual licensed under MIT and Apache-2.0. 2 | 3 | MIT: https://www.opensource.org/licenses/mit 4 | Apache-2.0: https://www.apache.org/licenses/license-2.0 5 | -------------------------------------------------------------------------------- /packages/ipfs-core-utils/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 2 | 3 | http://www.apache.org/licenses/LICENSE-2.0 4 | 5 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 6 | -------------------------------------------------------------------------------- /packages/ipfs-core-utils/src/agent.browser.js: -------------------------------------------------------------------------------- 1 | 2 | export default () => {} 3 | -------------------------------------------------------------------------------- /packages/ipfs-core-utils/src/agent.js: -------------------------------------------------------------------------------- 1 | import http from 'http' 2 | import https from 'https' 3 | 4 | /** 5 | * @param {URL} [url] 6 | */ 7 | export default (url) => { 8 | if (!url) { 9 | throw new Error('URL required') 10 | } 11 | 12 | return url.protocol.startsWith('https') ? https.Agent : http.Agent 13 | } 14 | -------------------------------------------------------------------------------- /packages/ipfs-core-utils/src/errors.js: -------------------------------------------------------------------------------- 1 | 2 | export class TimeoutError extends Error { 3 | constructor (message = 'request timed out') { 4 | super(message) 5 | this.name = 'TimeoutError' 6 | this.code = TimeoutError.code 7 | } 8 | } 9 | 10 | TimeoutError.code = 'ERR_TIMEOUT' 11 | -------------------------------------------------------------------------------- /packages/ipfs-core-utils/src/files/format-mtime.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {import('ipfs-unixfs').Mtime | null} [mtime] 3 | * @returns {string} 4 | */ 5 | export function formatMtime (mtime) { 6 | if (mtime == null) { 7 | return '-' 8 | } 9 | 10 | const date = new Date((mtime.secs * 1000) + Math.round((mtime.nsecs || 0) / 1000)) 11 | 12 | return date.toLocaleDateString(Intl.DateTimeFormat().resolvedOptions().locale, { 13 | year: 'numeric', 14 | month: 'short', 15 | day: 'numeric', 16 | hour: '2-digit', 17 | minute: '2-digit', 18 | second: '2-digit', 19 | timeZoneName: 'short' 20 | }) 21 | } 22 | -------------------------------------------------------------------------------- /packages/ipfs-core-utils/src/files/normalise-input-single.js: -------------------------------------------------------------------------------- 1 | import { normaliseContent } from './normalise-content.js' 2 | import { normaliseCandidateSingle } from './normalise-candidate-single.js' 3 | 4 | /** 5 | * @typedef {import('ipfs-core-types/src/utils').ImportCandidate} ImportCandidate 6 | */ 7 | 8 | /** 9 | * Transforms any of the `ipfs.add` input types into 10 | * 11 | * ``` 12 | * AsyncIterable<{ path, mode, mtime, content: AsyncIterable }> 13 | * ``` 14 | * 15 | * See https://github.com/ipfs/js-ipfs/blob/master/docs/core-api/FILES.md#ipfsadddata-options 16 | * 17 | * @param {ImportCandidate} input 18 | */ 19 | export function normaliseInput (input) { 20 | return normaliseCandidateSingle(input, normaliseContent) 21 | } 22 | -------------------------------------------------------------------------------- /packages/ipfs-core-utils/src/index.js: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /packages/ipfs-core-utils/src/mode-to-string.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * @param {number | string | undefined} mode 4 | */ 5 | export function modeToString (mode) { 6 | if (mode == null) { 7 | return undefined 8 | } 9 | 10 | if (typeof mode === 'string') { 11 | return mode 12 | } 13 | 14 | return mode.toString(8).padStart(4, '0') 15 | } 16 | -------------------------------------------------------------------------------- /packages/ipfs-core-utils/src/to-url-string.js: -------------------------------------------------------------------------------- 1 | import { multiaddr } from '@multiformats/multiaddr' 2 | import { multiaddrToUri } from '@multiformats/multiaddr-to-uri' 3 | 4 | /** 5 | * @typedef {import('@multiformats/multiaddr').Multiaddr} Multiaddr 6 | */ 7 | 8 | /** 9 | * @param {string|Multiaddr|URL} url - A string, multiaddr or URL to convert to a url string 10 | * @returns {string} 11 | */ 12 | export function toUrlString (url) { 13 | try { 14 | // @ts-expect-error 15 | url = multiaddrToUri(multiaddr(url)) 16 | } catch (/** @type {any} */ err) { } 17 | 18 | url = url.toString() 19 | 20 | return url 21 | } 22 | -------------------------------------------------------------------------------- /packages/ipfs-core-utils/src/types.ts: -------------------------------------------------------------------------------- 1 | import type { MultibaseCodec } from 'multiformats/bases/interface' 2 | import type { BlockCodec } from 'multiformats/codecs/interface' 3 | import type { MultihashHasher } from 'multiformats/hashes/interface' 4 | 5 | export interface LoadBaseFn { (codeOrName: string): Promise> } 6 | export interface LoadCodecFn { (codeOrName: number | string): Promise> } 7 | export interface LoadHasherFn { (codeOrName: number | string): Promise } 8 | -------------------------------------------------------------------------------- /packages/ipfs-core-utils/test/files/format-mtime.spec.js: -------------------------------------------------------------------------------- 1 | /* eslint-env mocha */ 2 | 3 | import { expect } from 'aegir/chai' 4 | import { formatMtime } from '../../src/files/format-mtime.js' 5 | 6 | describe('format-mtime', function () { 7 | it('formats mtime', function () { 8 | expect(formatMtime({ secs: 15768000, nsecs: 0 })).to.include('1970') 9 | }) 10 | 11 | it('formats empty mtime', function () { 12 | expect(formatMtime()).to.equal('-') 13 | }) 14 | }) 15 | -------------------------------------------------------------------------------- /packages/ipfs-core-utils/test/fixtures/file.txt: -------------------------------------------------------------------------------- 1 | hello world -------------------------------------------------------------------------------- /packages/ipfs-core-utils/test/tests.spec.js: -------------------------------------------------------------------------------- 1 | 2 | import './files/format-mode.spec.js' 3 | import './files/format-mtime.spec.js' 4 | import './files/normalise-input-multiple.spec.js' 5 | import './files/normalise-input-single.spec.js' 6 | import './pins/normalise-input.spec.js' 7 | -------------------------------------------------------------------------------- /packages/ipfs-core-utils/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "aegir/src/config/tsconfig.aegir.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "emitDeclarationOnly": true 6 | }, 7 | "include": [ 8 | "src", 9 | "test" 10 | ], 11 | "references": [ 12 | { 13 | "path": "../ipfs-core-types" 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /packages/ipfs-core/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | The `js-ipfs` project follows the [`IPFS Community Code of Conduct`](https://github.com/ipfs/community/blob/master/code-of-conduct.md) 4 | -------------------------------------------------------------------------------- /packages/ipfs-core/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing guidelines 2 | 3 | IPFS as a project, including js-ipfs and all of its modules, follows the [standard IPFS Community contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md). 4 | 5 | We also adhere to the [IPFS JavaScript Community contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) which provide additional information of how to collaborate and contribute in the JavaScript implementation of IPFS. 6 | 7 | We appreciate your time and attention for going over these. Please open an issue on [ipfs/community](https://github.com/ipfs/community) if you have any question. 8 | 9 | Thank you. 10 | -------------------------------------------------------------------------------- /packages/ipfs-core/COPYRIGHT: -------------------------------------------------------------------------------- 1 | This project is transitioning from an MIT-only license to a dual MIT/Apache-2.0 license. 2 | Unless otherwise noted, all code contributed prior to 2019-11-21 and not contributed by 3 | a user listed in [this signoff issue](https://github.com/ipfs/js-ipfs/issues/2624) is 4 | licensed under MIT-only. All new contributions (and past contributions since 2019-11-21) 5 | are licensed under a dual MIT/Apache-2.0 license. 6 | -------------------------------------------------------------------------------- /packages/ipfs-core/LICENSE: -------------------------------------------------------------------------------- 1 | This project is dual licensed under MIT and Apache-2.0. 2 | 3 | MIT: https://www.opensource.org/licenses/mit 4 | Apache-2.0: https://www.apache.org/licenses/license-2.0 5 | -------------------------------------------------------------------------------- /packages/ipfs-core/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 2 | 3 | http://www.apache.org/licenses/LICENSE-2.0 4 | 5 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 6 | -------------------------------------------------------------------------------- /packages/ipfs-core/scripts/update-version.js: -------------------------------------------------------------------------------- 1 | import { readFile, writeFile } from 'fs/promises' 2 | 3 | const pkg = JSON.parse( 4 | await readFile( 5 | new URL('../package.json', import.meta.url) 6 | ) 7 | ) 8 | 9 | await writeFile( 10 | new URL('../src/version.js', import.meta.url), 11 | ` 12 | export const ipfsCore = '${pkg.version}' 13 | export const commit = '${pkg.gitHead || ''}' 14 | export const interfaceIpfsCore = '${pkg.devDependencies['interface-ipfs-core']}' 15 | ` 16 | ) 17 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/components/bitswap/unwant.js: -------------------------------------------------------------------------------- 1 | import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' 2 | 3 | /** 4 | * @param {object} config 5 | * @param {import('../../types').NetworkService} config.network 6 | */ 7 | export function createUnwant ({ network }) { 8 | /** 9 | * @type {import('ipfs-core-types/src/bitswap').API<{}>["unwant"]} 10 | */ 11 | async function unwant (cids, options = {}) { 12 | const { bitswap } = await network.use(options) 13 | 14 | if (!Array.isArray(cids)) { 15 | cids = [cids] 16 | } 17 | 18 | return bitswap.unwant(cids) 19 | } 20 | 21 | return withTimeoutOption(unwant) 22 | } 23 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/components/bitswap/wantlist-for-peer.js: -------------------------------------------------------------------------------- 1 | import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' 2 | 3 | /** 4 | * @param {object} config 5 | * @param {import('../../types').NetworkService} config.network 6 | */ 7 | export function createWantlistForPeer ({ network }) { 8 | /** 9 | * @type {import('ipfs-core-types/src/bitswap').API<{}>["wantlistForPeer"]} 10 | */ 11 | async function wantlistForPeer (peerId, options = {}) { 12 | const { bitswap } = await network.use(options) 13 | const list = bitswap.wantlistForPeer(peerId) 14 | 15 | return Array.from(list).map(e => e[1].cid) 16 | } 17 | 18 | return withTimeoutOption(wantlistForPeer) 19 | } 20 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/components/bitswap/wantlist.js: -------------------------------------------------------------------------------- 1 | import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' 2 | 3 | /** 4 | * @param {object} config 5 | * @param {import('../../types').NetworkService} config.network 6 | */ 7 | export function createWantlist ({ network }) { 8 | /** 9 | * @type {import('ipfs-core-types/src/bitswap').API<{}>["wantlist"]} 10 | */ 11 | async function wantlist (options = {}) { 12 | const { bitswap } = await network.use(options) 13 | const list = bitswap.getWantlist() 14 | 15 | return Array.from(list).map(e => e[1].cid) 16 | } 17 | 18 | return withTimeoutOption(wantlist) 19 | } 20 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/components/block/get.js: -------------------------------------------------------------------------------- 1 | import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' 2 | 3 | /** 4 | * @param {object} config 5 | * @param {import('../../types').Preload} config.preload 6 | * @param {import('ipfs-repo').IPFSRepo} config.repo 7 | */ 8 | export function createGet ({ preload, repo }) { 9 | /** 10 | * @type {import('ipfs-core-types/src/block').API<{}>["get"]} 11 | */ 12 | async function get (cid, options = {}) { // eslint-disable-line require-await 13 | if (options.preload !== false) { 14 | preload(cid) 15 | } 16 | 17 | return repo.blocks.get(cid, options) 18 | } 19 | 20 | return withTimeoutOption(get) 21 | } 22 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/components/block/utils.js: -------------------------------------------------------------------------------- 1 | import { CID } from 'multiformats/cid' 2 | 3 | /** 4 | * @param {string|Uint8Array|CID} cid 5 | */ 6 | export function cleanCid (cid) { 7 | if (cid instanceof Uint8Array) { 8 | return CID.decode(cid) 9 | } 10 | 11 | return CID.parse(cid.toString()) 12 | } 13 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/components/bootstrap/clear.js: -------------------------------------------------------------------------------- 1 | import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' 2 | import { multiaddr } from '@multiformats/multiaddr' 3 | 4 | /** 5 | * @param {object} config 6 | * @param {import('ipfs-repo').IPFSRepo} config.repo 7 | */ 8 | export function createClear ({ repo }) { 9 | /** 10 | * @type {import('ipfs-core-types/src/bootstrap').API<{}>["clear"]} 11 | */ 12 | async function clear (options = {}) { 13 | const config = await repo.config.getAll(options) 14 | const removed = config.Bootstrap || [] 15 | config.Bootstrap = [] 16 | 17 | await repo.config.replace(config) 18 | 19 | return { Peers: removed.map(ma => multiaddr(ma)) } 20 | } 21 | 22 | return withTimeoutOption(clear) 23 | } 24 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/components/bootstrap/index.js: -------------------------------------------------------------------------------- 1 | import { createAdd } from './add.js' 2 | import { createClear } from './clear.js' 3 | import { createList } from './list.js' 4 | import { createReset } from './reset.js' 5 | import { createRm } from './rm.js' 6 | export class BootstrapAPI { 7 | /** 8 | * @param {object} config 9 | * @param {import('ipfs-repo').IPFSRepo} config.repo 10 | */ 11 | constructor ({ repo }) { 12 | this.add = createAdd({ repo }) 13 | this.list = createList({ repo }) 14 | this.rm = createRm({ repo }) 15 | this.clear = createClear({ repo }) 16 | this.reset = createReset({ repo }) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/components/bootstrap/list.js: -------------------------------------------------------------------------------- 1 | import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' 2 | import { multiaddr } from '@multiformats/multiaddr' 3 | 4 | /** 5 | * @param {object} config 6 | * @param {import('ipfs-repo').IPFSRepo} config.repo 7 | */ 8 | export function createList ({ repo }) { 9 | /** 10 | * @type {import('ipfs-core-types/src/bootstrap').API<{}>["list"]} 11 | */ 12 | async function list (options = {}) { 13 | /** @type {string[]|null} */ 14 | const peers = (await repo.config.get('Bootstrap', options)) 15 | return { Peers: (peers || []).map(ma => multiaddr(ma)) } 16 | } 17 | 18 | return withTimeoutOption(list) 19 | } 20 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/components/bootstrap/utils.js: -------------------------------------------------------------------------------- 1 | import { IPFS } from '@multiformats/mafmt' 2 | 3 | /** 4 | * @param {any} ma 5 | */ 6 | export function isValidMultiaddr (ma) { 7 | try { 8 | return IPFS.matches(ma) 9 | } catch (/** @type {any} */ err) { 10 | return false 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/components/files/utils/hamt-constants.js: -------------------------------------------------------------------------------- 1 | import { murmur3128 } from '@multiformats/murmur3' 2 | 3 | export const hamtHashCode = murmur3128.code 4 | export const hamtBucketBits = 8 5 | 6 | /** 7 | * @param {Uint8Array} buf 8 | */ 9 | export async function hamtHashFn (buf) { 10 | return (await murmur3128.encode(buf)) 11 | // Murmur3 outputs 128 bit but, accidentally, IPFS Go's 12 | // implementation only uses the first 64, so we must do the same 13 | // for parity.. 14 | .subarray(0, 8) 15 | // Invert buffer because that's how Go impl does it 16 | .reverse() 17 | } 18 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/components/files/utils/to-path-components.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * @param {string} [path] 4 | */ 5 | export function toPathComponents (path = '') { 6 | // split on / unless escaped with \ 7 | return (path 8 | .trim() 9 | .match(/([^\\^/]|\\\/)+/g) || []) 10 | .filter(Boolean) 11 | } 12 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/components/is-online.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * @param {object} config 4 | * @param {import('../types').NetworkService} config.network 5 | */ 6 | export function createIsOnline ({ network }) { 7 | /** 8 | * @returns {boolean} 9 | */ 10 | return () => { 11 | const net = network.try() 12 | return net != null && Boolean(net.libp2p.isStarted()) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/components/key/export.js: -------------------------------------------------------------------------------- 1 | import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' 2 | 3 | /** 4 | * @param {object} config 5 | * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain 6 | */ 7 | export function createExport ({ keychain }) { 8 | /** 9 | * @type {import('ipfs-core-types/src/key').API<{}>["export"]} 10 | */ 11 | const exportKey = (name, password) => 12 | keychain.exportKey(name, password) 13 | 14 | return withTimeoutOption(exportKey) 15 | } 16 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/components/key/gen.js: -------------------------------------------------------------------------------- 1 | import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' 2 | 3 | const DEFAULT_KEY_TYPE = 'Ed25519' 4 | const DEFAULT_KEY_SIZE = 2048 5 | 6 | /** 7 | * @param {object} config 8 | * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain 9 | */ 10 | export function createGen ({ keychain }) { 11 | /** 12 | * @type {import('ipfs-core-types/src/key').API<{}>["gen"]} 13 | */ 14 | const gen = (name, options = { type: DEFAULT_KEY_TYPE, size: DEFAULT_KEY_SIZE }) => { 15 | return keychain.createKey(name, options.type || DEFAULT_KEY_TYPE, options.size || DEFAULT_KEY_SIZE) 16 | } 17 | 18 | return withTimeoutOption(gen) 19 | } 20 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/components/key/import.js: -------------------------------------------------------------------------------- 1 | import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' 2 | 3 | /** 4 | * @param {object} config 5 | * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain 6 | */ 7 | export function createImport ({ keychain }) { 8 | /** 9 | * @type {import('ipfs-core-types/src/key').API<{}>["import"]} 10 | */ 11 | const importKey = (name, pem, password) => { 12 | return keychain.importKey(name, pem, password) 13 | } 14 | 15 | return withTimeoutOption(importKey) 16 | } 17 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/components/key/info.js: -------------------------------------------------------------------------------- 1 | import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' 2 | 3 | /** 4 | * @param {object} config 5 | * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain 6 | */ 7 | export function createInfo ({ keychain }) { 8 | /** 9 | * @type {import('ipfs-core-types/src/key').API<{}>["info"]} 10 | */ 11 | const info = (name) => keychain.findKeyByName(name) 12 | 13 | return withTimeoutOption(info) 14 | } 15 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/components/key/list.js: -------------------------------------------------------------------------------- 1 | import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' 2 | 3 | /** 4 | * @param {object} config 5 | * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain 6 | */ 7 | export function createList ({ keychain }) { 8 | /** 9 | * @type {import('ipfs-core-types/src/key').API<{}>["list"]} 10 | */ 11 | const list = () => keychain.listKeys() 12 | 13 | return withTimeoutOption(list) 14 | } 15 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/components/key/rename.js: -------------------------------------------------------------------------------- 1 | import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' 2 | 3 | /** 4 | * @param {object} config 5 | * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain 6 | */ 7 | export function createRename ({ keychain }) { 8 | /** 9 | * @type {import('ipfs-core-types/src/key').API<{}>["rename"]} 10 | */ 11 | const rename = async (oldName, newName) => { 12 | const key = await keychain.renameKey(oldName, newName) 13 | 14 | return { 15 | was: oldName, 16 | now: key.name, 17 | id: key.id, 18 | overwrite: false 19 | } 20 | } 21 | 22 | return withTimeoutOption(rename) 23 | } 24 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/components/key/rm.js: -------------------------------------------------------------------------------- 1 | import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' 2 | 3 | /** 4 | * @param {object} config 5 | * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain 6 | */ 7 | export function createRm ({ keychain }) { 8 | /** 9 | * @type {import('ipfs-core-types/src/key').API<{}>["rm"]} 10 | */ 11 | const rm = (name) => keychain.removeKey(name) 12 | 13 | return withTimeoutOption(rm) 14 | } 15 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/components/name/pubsub/index.js: -------------------------------------------------------------------------------- 1 | import { createCancel } from './cancel.js' 2 | import { createState } from './state.js' 3 | import { createSubs } from './subs.js' 4 | 5 | export class PubSubAPI { 6 | /** 7 | * @param {object} config 8 | * @param {import('../../ipns').IPNSAPI} config.ipns 9 | * @param {import('../../../types').Options} config.options 10 | */ 11 | constructor ({ ipns, options }) { 12 | this.cancel = createCancel({ ipns, options }) 13 | this.state = createState({ ipns, options }) 14 | this.subs = createSubs({ ipns, options }) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/components/object/data.js: -------------------------------------------------------------------------------- 1 | import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' 2 | import { createGet } from './get.js' 3 | 4 | /** 5 | * @param {object} config 6 | * @param {import('ipfs-repo').IPFSRepo} config.repo 7 | * @param {import('../../types').Preload} config.preload 8 | */ 9 | export function createData ({ repo, preload }) { 10 | const get = createGet({ repo, preload }) 11 | 12 | /** 13 | * @type {import('ipfs-core-types/src/object').API<{}>["data"]} 14 | */ 15 | async function data (multihash, options = {}) { 16 | const node = await get(multihash, options) 17 | return node.Data || new Uint8Array(0) 18 | } 19 | 20 | return withTimeoutOption(data) 21 | } 22 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/components/pin/rm.js: -------------------------------------------------------------------------------- 1 | import last from 'it-last' 2 | 3 | /** 4 | * @param {object} config 5 | * @param {import('ipfs-core-types/src/pin').API<{}>["rmAll"]} config.rmAll 6 | */ 7 | export function createRm ({ rmAll }) { 8 | /** 9 | * @type {import('ipfs-core-types/src/pin').API<{}>["rm"]} 10 | */ 11 | async function rm (path, options = {}) { 12 | // @ts-expect-error return value of last can be undefined 13 | const cid = await last(rmAll([{ path, ...options }], options)) 14 | 15 | if (!cid) { 16 | throw new Error('CID expected') 17 | } 18 | 19 | return cid 20 | } 21 | 22 | return rm 23 | } 24 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/components/refs/local.js: -------------------------------------------------------------------------------- 1 | import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' 2 | 3 | /** 4 | * @param {object} config 5 | * @param {import('ipfs-repo').IPFSRepo} config.repo 6 | */ 7 | export function createLocal ({ repo }) { 8 | /** 9 | * @type {import('ipfs-core-types/src/refs').API<{}>["local"]} 10 | */ 11 | async function * refsLocal (options = {}) { 12 | for await (const cid of repo.blocks.queryKeys({}, { signal: options.signal })) { 13 | yield { ref: cid.toString() } 14 | } 15 | } 16 | 17 | return withTimeoutOption(refsLocal) 18 | } 19 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/components/repo/stat.js: -------------------------------------------------------------------------------- 1 | import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' 2 | 3 | /** 4 | * @param {object} config 5 | * @param {import('ipfs-repo').IPFSRepo} config.repo 6 | */ 7 | export function createStat ({ repo }) { 8 | /** 9 | * @type {import('ipfs-core-types/src/repo').API<{}>["stat"]} 10 | */ 11 | async function stat (options = {}) { 12 | const stats = await repo.stat() 13 | 14 | return { 15 | numObjects: BigInt(stats.numObjects.toString()), 16 | repoSize: BigInt(stats.repoSize.toString()), 17 | repoPath: stats.repoPath, 18 | version: `${stats.version}`, 19 | storageMax: BigInt(stats.storageMax.toString()) 20 | } 21 | } 22 | 23 | return withTimeoutOption(stat) 24 | } 25 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/components/stats/index.js: -------------------------------------------------------------------------------- 1 | import { createBw } from './bw.js' 2 | import { createStat as createRepo } from '../repo/stat.js' 3 | import { createStat as createBitswap } from '../bitswap/stat.js' 4 | 5 | export class StatsAPI { 6 | /** 7 | * @param {object} config 8 | * @param {import('ipfs-repo').IPFSRepo} config.repo 9 | * @param {import('../../types').NetworkService} config.network 10 | */ 11 | constructor ({ repo, network }) { 12 | this.repo = createRepo({ repo }) 13 | this.bw = createBw({ network }) 14 | this.bitswap = createBitswap({ network }) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/components/swarm/connect.js: -------------------------------------------------------------------------------- 1 | import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' 2 | 3 | /** 4 | * @param {object} config 5 | * @param {import('../../types').NetworkService} config.network 6 | */ 7 | export function createConnect ({ network }) { 8 | /** 9 | * @type {import('ipfs-core-types/src/swarm').API<{}>["connect"]} 10 | */ 11 | async function connect (multiaddrOrPeerId, options = {}) { 12 | const { libp2p } = await network.use(options) 13 | await libp2p.dial(multiaddrOrPeerId, options) 14 | } 15 | 16 | return withTimeoutOption(connect) 17 | } 18 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/components/swarm/disconnect.js: -------------------------------------------------------------------------------- 1 | import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' 2 | 3 | /** 4 | * @param {object} config 5 | * @param {import('../../types').NetworkService} config.network 6 | */ 7 | export function createDisconnect ({ network }) { 8 | /** 9 | * @type {import('ipfs-core-types/src/swarm').API<{}>["disconnect"]} 10 | */ 11 | async function disconnect (addr, options = {}) { 12 | const { libp2p } = await network.use(options) 13 | await libp2p.hangUp(addr) 14 | } 15 | 16 | return withTimeoutOption(disconnect) 17 | } 18 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/components/swarm/index.js: -------------------------------------------------------------------------------- 1 | import { createAddrs } from './addrs.js' 2 | import { createConnect } from './connect.js' 3 | import { createDisconnect } from './disconnect.js' 4 | import { createLocalAddrs } from './local-addrs.js' 5 | import { createPeers } from './peers.js' 6 | 7 | export class SwarmAPI { 8 | /** 9 | * @param {object} config 10 | * @param {import('../../types').NetworkService} config.network 11 | */ 12 | constructor ({ network }) { 13 | this.addrs = createAddrs({ network }) 14 | this.connect = createConnect({ network }) 15 | this.disconnect = createDisconnect({ network }) 16 | this.localAddrs = createLocalAddrs({ network }) 17 | this.peers = createPeers({ network }) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/components/swarm/local-addrs.js: -------------------------------------------------------------------------------- 1 | import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' 2 | 3 | /** 4 | * @param {object} config 5 | * @param {import('../../types').NetworkService} config.network 6 | */ 7 | export function createLocalAddrs ({ network }) { 8 | /** 9 | * @type {import('ipfs-core-types/src/swarm').API<{}>["localAddrs"]} 10 | */ 11 | async function localAddrs (options = {}) { 12 | const { libp2p } = await network.use(options) 13 | return libp2p.getMultiaddrs() 14 | } 15 | 16 | return withTimeoutOption(localAddrs) 17 | } 18 | -------------------------------------------------------------------------------- /packages/ipfs-core/src/version.js: -------------------------------------------------------------------------------- 1 | 2 | export const ipfsCore = '' 3 | export const commit = '' 4 | export const interfaceIpfsCore = '' 5 | -------------------------------------------------------------------------------- /packages/ipfs-core/test/utils/clean.js: -------------------------------------------------------------------------------- 1 | 2 | import rimraf from 'rimraf' 3 | import { promises as fs } from 'fs' 4 | import { promisify } from 'util' 5 | 6 | /** 7 | * @param {string} dir 8 | */ 9 | export async function clean (dir) { 10 | try { 11 | await fs.access(dir) 12 | } catch (/** @type {any} */ err) { 13 | // Does not exist so all good 14 | return 15 | } 16 | 17 | return promisify(rimraf)(dir) 18 | } 19 | -------------------------------------------------------------------------------- /packages/ipfs-core/test/utils/codecs.js: -------------------------------------------------------------------------------- 1 | /* eslint-env mocha */ 2 | 3 | import { Multicodecs } from 'ipfs-core-utils/multicodecs' 4 | import * as dagPB from '@ipld/dag-pb' 5 | import * as dagCBOR from '@ipld/dag-cbor' 6 | import * as dagJSON from '@ipld/dag-json' 7 | import * as raw from 'multiformats/codecs/raw' 8 | 9 | export const codecs = new Multicodecs({ 10 | codecs: [dagPB, dagCBOR, dagJSON, raw], 11 | loadCodec: () => Promise.reject(new Error('No extra codecs configured')) 12 | }) 13 | -------------------------------------------------------------------------------- /packages/ipfs-core/test/utils/create-backend.js: -------------------------------------------------------------------------------- 1 | import { MemoryDatastore } from 'datastore-core/memory' 2 | import { BlockstoreDatastoreAdapter } from 'blockstore-datastore-adapter' 3 | 4 | export function createBackend (overrides = {}) { 5 | return { 6 | datastore: new MemoryDatastore(), 7 | blocks: new BlockstoreDatastoreAdapter( 8 | new MemoryDatastore() 9 | ), 10 | pins: new MemoryDatastore(), 11 | keys: new MemoryDatastore(), 12 | root: new MemoryDatastore(), 13 | ...overrides 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/ipfs-core/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "aegir/src/config/tsconfig.aegir.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "emitDeclarationOnly": true 6 | }, 7 | "include": [ 8 | "src", 9 | "test", 10 | "package.json" 11 | ], 12 | "references": [ 13 | { 14 | "path": "../interface-ipfs-core" 15 | }, 16 | { 17 | "path": "../ipfs-core-config" 18 | }, 19 | { 20 | "path": "../ipfs-core-types" 21 | }, 22 | { 23 | "path": "../ipfs-core-utils" 24 | }, 25 | { 26 | "path": "../ipfs-http-client" 27 | } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /packages/ipfs-daemon/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | The `js-ipfs` project follows the [`IPFS Community Code of Conduct`](https://github.com/ipfs/community/blob/master/code-of-conduct.md) 4 | -------------------------------------------------------------------------------- /packages/ipfs-daemon/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing guidelines 2 | 3 | IPFS as a project, including js-ipfs and all of its modules, follows the [standard IPFS Community contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md). 4 | 5 | We also adhere to the [IPFS JavaScript Community contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) which provide additional information of how to collaborate and contribute in the JavaScript implementation of IPFS. 6 | 7 | We appreciate your time and attention for going over these. Please open an issue on [ipfs/community](https://github.com/ipfs/community) if you have any question. 8 | 9 | Thank you. 10 | -------------------------------------------------------------------------------- /packages/ipfs-daemon/COPYRIGHT: -------------------------------------------------------------------------------- 1 | This project is transitioning from an MIT-only license to a dual MIT/Apache-2.0 license. 2 | Unless otherwise noted, all code contributed prior to 2019-11-21 and not contributed by 3 | a user listed in [this signoff issue](https://github.com/ipfs/js-ipfs/issues/2624) is 4 | licensed under MIT-only. All new contributions (and past contributions since 2019-11-21) 5 | are licensed under a dual MIT/Apache-2.0 license. 6 | -------------------------------------------------------------------------------- /packages/ipfs-daemon/LICENSE: -------------------------------------------------------------------------------- 1 | This project is dual licensed under MIT and Apache-2.0. 2 | 3 | MIT: https://www.opensource.org/licenses/mit 4 | Apache-2.0: https://www.apache.org/licenses/license-2.0 5 | -------------------------------------------------------------------------------- /packages/ipfs-daemon/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 2 | 3 | http://www.apache.org/licenses/LICENSE-2.0 4 | 5 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 6 | -------------------------------------------------------------------------------- /packages/ipfs-daemon/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "aegir/src/config/tsconfig.aegir.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "emitDeclarationOnly": true 6 | }, 7 | "include": [ 8 | "src" 9 | ], 10 | "references": [ 11 | { 12 | "path": "../ipfs-core" 13 | }, 14 | { 15 | "path": "../ipfs-core-types" 16 | }, 17 | { 18 | "path": "../ipfs-grpc-server" 19 | }, 20 | { 21 | "path": "../ipfs-http-gateway" 22 | }, 23 | { 24 | "path": "../ipfs-http-server" 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /packages/ipfs-grpc-client/.aegir.js: -------------------------------------------------------------------------------- 1 | 2 | /** @type {import('aegir').PartialOptions} */ 3 | export default { 4 | build: { 5 | bundlesizeMax: '53KB' 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/ipfs-grpc-client/LICENSE: -------------------------------------------------------------------------------- 1 | This project is dual licensed under MIT and Apache-2.0. 2 | 3 | MIT: https://www.opensource.org/licenses/mit 4 | Apache-2.0: https://www.apache.org/licenses/license-2.0 5 | -------------------------------------------------------------------------------- /packages/ipfs-grpc-client/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 2 | 3 | http://www.apache.org/licenses/LICENSE-2.0 4 | 5 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 6 | -------------------------------------------------------------------------------- /packages/ipfs-grpc-client/src/core-api/pubsub/subscriptions.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * @typedef {import('@libp2p/interface-pubsub').Message} Message 4 | * @typedef {import('@libp2p/interfaces/events').EventHandler} Subscription 5 | */ 6 | 7 | /** @type {Map>} */ 8 | export const subscriptions = new Map() 9 | -------------------------------------------------------------------------------- /packages/ipfs-grpc-client/src/grpc/transport.browser.js: -------------------------------------------------------------------------------- 1 | import grpcWeb from '@improbable-eng/grpc-web' 2 | 3 | export const transport = () => grpcWeb.grpc.WebsocketTransport 4 | -------------------------------------------------------------------------------- /packages/ipfs-grpc-client/src/grpc/transport.js: -------------------------------------------------------------------------------- 1 | import { isElectronRenderer, isBrowser } from 'wherearewe' 2 | import { transport as nodeTransport } from './transport.node.js' 3 | import { transport as browserTransport } from './transport.browser.js' 4 | 5 | export function transport () { 6 | // In electron-renderer we use the browser transport 7 | if (isElectronRenderer || isBrowser) { 8 | return browserTransport() 9 | } else { 10 | return nodeTransport() 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/ipfs-grpc-client/src/types.ts: -------------------------------------------------------------------------------- 1 | import type { Agent as HttpAgent } from 'http' 2 | import type { Agent as HttpsAgent } from 'https' 3 | import type { Multiaddr } from '@multiformats/multiaddr' 4 | 5 | export interface Options { 6 | url: string | URL | Multiaddr 7 | agent?: HttpAgent | HttpsAgent 8 | } 9 | 10 | export interface RPCOptions { 11 | host: string | URL | Multiaddr 12 | debug?: boolean 13 | metadata: Metadata 14 | agent?: HttpAgent | HttpsAgent 15 | } 16 | -------------------------------------------------------------------------------- /packages/ipfs-grpc-client/src/utils/to-headers.js: -------------------------------------------------------------------------------- 1 | import { paramCase } from 'change-case' 2 | 3 | /** 4 | * @param {Record} [object] - key/value pairs to turn into HTTP headers 5 | */ 6 | export function toHeaders (object = {}) { 7 | /** @type {Record} */ 8 | const output = {} 9 | 10 | Object.keys(object || {}).forEach(key => { 11 | if (typeof object[key] === 'function') { 12 | return 13 | } 14 | 15 | output[paramCase(key)] = object[key].toString() 16 | }) 17 | 18 | return output 19 | } 20 | -------------------------------------------------------------------------------- /packages/ipfs-grpc-client/test/node.js: -------------------------------------------------------------------------------- 1 | 2 | import './agent.js' 3 | -------------------------------------------------------------------------------- /packages/ipfs-grpc-client/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "aegir/src/config/tsconfig.aegir.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "emitDeclarationOnly": true 6 | }, 7 | "include": [ 8 | "src" 9 | ], 10 | "references": [ 11 | { 12 | "path": "../ipfs-core-types" 13 | }, 14 | { 15 | "path": "../ipfs-core-utils" 16 | }, 17 | { 18 | "path": "../ipfs-grpc-protocol" 19 | } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /packages/ipfs-grpc-protocol/LICENSE: -------------------------------------------------------------------------------- 1 | This project is dual licensed under MIT and Apache-2.0. 2 | 3 | MIT: https://www.opensource.org/licenses/mit 4 | Apache-2.0: https://www.apache.org/licenses/license-2.0 5 | -------------------------------------------------------------------------------- /packages/ipfs-grpc-protocol/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 2 | 3 | http://www.apache.org/licenses/LICENSE-2.0 4 | 5 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 6 | -------------------------------------------------------------------------------- /packages/ipfs-grpc-protocol/scripts/update-index.js: -------------------------------------------------------------------------------- 1 | import { readFile, writeFile } from 'fs/promises' 2 | 3 | const ipfs = JSON.parse( 4 | await readFile( 5 | new URL('../dist/ipfs.json', import.meta.url) 6 | ) 7 | ) 8 | 9 | await writeFile( 10 | new URL('../src/index.js', import.meta.url), 11 | ` 12 | export default ${JSON.stringify(ipfs, null, 2)} 13 | ` 14 | ) 15 | -------------------------------------------------------------------------------- /packages/ipfs-grpc-protocol/src/common.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package ipfs; 4 | 5 | enum FileType { 6 | DIRECTORY = 0; 7 | FILE = 1; 8 | } 9 | -------------------------------------------------------------------------------- /packages/ipfs-grpc-protocol/src/mfs.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | import "common.proto"; 4 | 5 | package ipfs; 6 | 7 | service MFS { 8 | rpc ls (LsRequest) returns (stream LsResponse) {} 9 | rpc write (stream WriteRequest) returns (WriteResponse) {} 10 | } 11 | 12 | message LsRequest { 13 | string path = 1; 14 | } 15 | 16 | message LsResponse { 17 | string name = 1; 18 | FileType type = 2; 19 | uint32 size = 3; 20 | string cid = 4; 21 | uint32 mode = 5; 22 | int32 mtime = 6; 23 | uint32 mtime_nsecs = 7; 24 | } 25 | 26 | message WriteRequest { 27 | string path = 1; 28 | bytes content = 2; 29 | } 30 | 31 | message WriteResponse { 32 | 33 | } 34 | -------------------------------------------------------------------------------- /packages/ipfs-grpc-protocol/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "aegir/src/config/tsconfig.aegir.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "emitDeclarationOnly": true 6 | }, 7 | "include": [ 8 | "src" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /packages/ipfs-grpc-server/LICENSE: -------------------------------------------------------------------------------- 1 | This project is dual licensed under MIT and Apache-2.0. 2 | 3 | MIT: https://www.opensource.org/licenses/mit 4 | Apache-2.0: https://www.apache.org/licenses/license-2.0 5 | -------------------------------------------------------------------------------- /packages/ipfs-grpc-server/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 2 | 3 | http://www.apache.org/licenses/LICENSE-2.0 4 | 5 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 6 | -------------------------------------------------------------------------------- /packages/ipfs-grpc-server/src/endpoints/pubsub/subscriptions.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @typedef {import('@libp2p/interface-pubsub').Message} Message 3 | * @typedef {object} Subscription 4 | * @property {import('@libp2p/interfaces/events').EventHandler} onMessage 5 | * @property {() => void} onUnsubscribe 6 | */ 7 | 8 | /** @type {Map} */ 9 | export const subscriptions = new Map() 10 | -------------------------------------------------------------------------------- /packages/ipfs-grpc-server/src/utils/encode-mtime.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * @param {import('ipfs-unixfs').Mtime} [mtime] 4 | */ 5 | export function encodeMtime (mtime) { 6 | const output = {} 7 | 8 | if (!mtime) { 9 | return output 10 | } 11 | 12 | const { 13 | secs, 14 | nsecs 15 | } = mtime 16 | 17 | if (secs != null) { 18 | output.mtime = secs 19 | 20 | if (nsecs != null) { 21 | output.mtime_nsecs = nsecs 22 | } 23 | } 24 | 25 | return output 26 | } 27 | -------------------------------------------------------------------------------- /packages/ipfs-grpc-server/test/utils/server.js: -------------------------------------------------------------------------------- 1 | 2 | import { createServer } from '../../src/index.js' 3 | import { EventEmitter } from 'events' 4 | import { createChannel } from './channel.js' 5 | 6 | export function server ({ ipfs, options }) { 7 | const socket = new EventEmitter() 8 | 9 | createServer(ipfs, { 10 | socket 11 | }) 12 | 13 | return { 14 | send: (path, metadata) => { 15 | const channel = createChannel() 16 | 17 | socket.emit('data', { path, metadata, channel }) 18 | 19 | return channel 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /packages/ipfs-grpc-server/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "aegir/src/config/tsconfig.aegir.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "emitDeclarationOnly": true 6 | }, 7 | "include": [ 8 | "src" 9 | ], 10 | "references": [ 11 | { 12 | "path": "../ipfs-core" 13 | }, 14 | { 15 | "path": "../ipfs-core-types" 16 | }, 17 | { 18 | "path": "../ipfs-grpc-protocol" 19 | } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/COPYRIGHT: -------------------------------------------------------------------------------- 1 | This project is transitioning from an MIT-only license to a dual MIT/Apache-2.0 license. 2 | Unless otherwise noted, all code contributed prior to 2019-11-26 and not contributed by 3 | a user listed in [this signoff issue](https://github.com/ipfs/js-ipfs-http-client/issues/1189) is 4 | licensed under MIT-only. All new contributions (and past contributions since 2019-11-29) 5 | are licensed under a dual MIT/Apache-2.0 license. 6 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/LICENSE: -------------------------------------------------------------------------------- 1 | This project is dual licensed under MIT and Apache-2.0. 2 | 3 | MIT: https://www.opensource.org/licenses/mit 4 | Apache-2.0: https://www.apache.org/licenses/license-2.0 5 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 2 | 3 | http://www.apache.org/licenses/LICENSE-2.0 4 | 5 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 6 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/maintainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "repoLeadMaintainer": { 3 | "name": "Alan Shaw", 4 | "email": "alan.shaw@protocol.ai", 5 | "username": "alanshaw" 6 | }, 7 | "workingGroup": { 8 | "name": "JS IPFS", 9 | "entryPoint": "https://github.com/ipfs/js-core" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/bitswap/index.js: -------------------------------------------------------------------------------- 1 | import { createWantlist } from './wantlist.js' 2 | import { createWantlistForPeer } from './wantlist-for-peer.js' 3 | import { createStat } from './stat.js' 4 | import { createUnwant } from './unwant.js' 5 | 6 | /** 7 | * @param {import('../types').Options} config 8 | */ 9 | export function createBitswap (config) { 10 | return { 11 | wantlist: createWantlist(config), 12 | wantlistForPeer: createWantlistForPeer(config), 13 | unwant: createUnwant(config), 14 | stat: createStat(config) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/block/index.js: -------------------------------------------------------------------------------- 1 | import { createGet } from './get.js' 2 | import { createPut } from './put.js' 3 | import { createRm } from './rm.js' 4 | import { createStat } from './stat.js' 5 | 6 | /** 7 | * @param {import('../types').Options} config 8 | */ 9 | export function createBlock (config) { 10 | return { 11 | get: createGet(config), 12 | put: createPut(config), 13 | rm: createRm(config), 14 | stat: createStat(config) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/bootstrap/index.js: -------------------------------------------------------------------------------- 1 | import { createAdd } from './add.js' 2 | import { createClear } from './clear.js' 3 | import { createList } from './list.js' 4 | import { createReset } from './reset.js' 5 | import { createRm } from './rm.js' 6 | 7 | /** 8 | * @param {import('../types').Options} config 9 | */ 10 | export function createBootstrap (config) { 11 | return { 12 | add: createAdd(config), 13 | clear: createClear(config), 14 | list: createList(config), 15 | reset: createReset(config), 16 | rm: createRm(config) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/commands.js: -------------------------------------------------------------------------------- 1 | import { configure } from './lib/configure.js' 2 | import { toUrlSearchParams } from './lib/to-url-search-params.js' 3 | 4 | /** 5 | * @typedef {import('./types').HTTPClientExtraOptions} HTTPClientExtraOptions 6 | * @typedef {import('ipfs-core-types/src/root').API} RootAPI 7 | */ 8 | 9 | export const createCommands = configure(api => { 10 | /** 11 | * @type {RootAPI["commands"]} 12 | */ 13 | const commands = async (options = {}) => { 14 | const res = await api.post('commands', { 15 | signal: options.signal, 16 | searchParams: toUrlSearchParams(options), 17 | headers: options.headers 18 | }) 19 | 20 | return res.json() 21 | } 22 | return commands 23 | }) 24 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/config/index.js: -------------------------------------------------------------------------------- 1 | import { createProfiles } from './profiles/index.js' 2 | import { createGet } from './get.js' 3 | import { createGetAll } from './get-all.js' 4 | import { createReplace } from './replace.js' 5 | import { createSet } from './set.js' 6 | 7 | /** 8 | * @param {import('../types').Options} config 9 | */ 10 | export function createConfig (config) { 11 | return { 12 | getAll: createGetAll(config), 13 | get: createGet(config), 14 | set: createSet(config), 15 | replace: createReplace(config), 16 | profiles: createProfiles(config) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/config/profiles/index.js: -------------------------------------------------------------------------------- 1 | import { createApply } from './apply.js' 2 | import { createList } from './list.js' 3 | 4 | /** 5 | * @param {import('../../types').Options} config 6 | */ 7 | export function createProfiles (config) { 8 | return { 9 | apply: createApply(config), 10 | list: createList(config) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/dag/index.js: -------------------------------------------------------------------------------- 1 | import { createExport } from './export.js' 2 | import { createGet } from './get.js' 3 | import { createImport } from './import.js' 4 | import { createPut } from './put.js' 5 | import { createResolve } from './resolve.js' 6 | 7 | /** 8 | * @param {import('ipfs-core-utils/multicodecs').Multicodecs} codecs 9 | * @param {import('../types').Options} config 10 | */ 11 | export function createDag (codecs, config) { 12 | return { 13 | export: createExport(config), 14 | get: createGet(codecs, config), 15 | import: createImport(config), 16 | put: createPut(codecs, config), 17 | resolve: createResolve(config) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/dht/index.js: -------------------------------------------------------------------------------- 1 | import { createFindPeer } from './find-peer.js' 2 | import { createFindProvs } from './find-provs.js' 3 | import { createGet } from './get.js' 4 | import { createProvide } from './provide.js' 5 | import { createPut } from './put.js' 6 | import { createQuery } from './query.js' 7 | 8 | /** 9 | * @param {import('../types').Options} config 10 | */ 11 | export function createDht (config) { 12 | return { 13 | findPeer: createFindPeer(config), 14 | findProvs: createFindProvs(config), 15 | get: createGet(config), 16 | provide: createProvide(config), 17 | put: createPut(config), 18 | query: createQuery(config) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/dht/response-types.js: -------------------------------------------------------------------------------- 1 | 2 | // Response types are defined here = 3 | // https://github.com/libp2p/go-libp2p-core/blob/6e566d10f4a5447317a66d64c7459954b969bdab/routing/query.go#L15-L24 4 | export const SendingQuery = 0 5 | export const PeerResponse = 1 6 | export const FinalPeer = 2 7 | export const QueryError = 3 8 | export const Provider = 4 9 | export const Value = 5 10 | export const AddingPeer = 6 11 | export const DialingPeer = 7 12 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/diag/cmds.js: -------------------------------------------------------------------------------- 1 | import { configure } from '../lib/configure.js' 2 | import { toUrlSearchParams } from '../lib/to-url-search-params.js' 3 | 4 | /** 5 | * @typedef {import('../types').HTTPClientExtraOptions} HTTPClientExtraOptions 6 | * @typedef {import('ipfs-core-types/src/diag').API} DiagAPI 7 | */ 8 | 9 | export const createCmds = configure(api => { 10 | /** 11 | * @type {DiagAPI["cmds"]} 12 | */ 13 | async function cmds (options = {}) { 14 | const res = await api.post('diag/cmds', { 15 | signal: options.signal, 16 | searchParams: toUrlSearchParams(options), 17 | headers: options.headers 18 | }) 19 | 20 | return res.json() 21 | } 22 | return cmds 23 | }) 24 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/diag/index.js: -------------------------------------------------------------------------------- 1 | import { createCmds } from './cmds.js' 2 | import { createNet } from './net.js' 3 | import { createSys } from './sys.js' 4 | 5 | /** 6 | * @param {import('../types').Options} config 7 | */ 8 | export function createDiag (config) { 9 | return { 10 | cmds: createCmds(config), 11 | net: createNet(config), 12 | sys: createSys(config) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/diag/net.js: -------------------------------------------------------------------------------- 1 | import { configure } from '../lib/configure.js' 2 | import { toUrlSearchParams } from '../lib/to-url-search-params.js' 3 | 4 | /** 5 | * @typedef {import('../types').HTTPClientExtraOptions} HTTPClientExtraOptions 6 | * @typedef {import('ipfs-core-types/src/diag').API} DiagAPI 7 | */ 8 | 9 | export const createNet = configure(api => { 10 | /** 11 | * @type {DiagAPI["net"]} 12 | */ 13 | async function net (options = {}) { 14 | const res = await api.post('diag/net', { 15 | signal: options.signal, 16 | searchParams: toUrlSearchParams(options), 17 | headers: options.headers 18 | }) 19 | return res.json() 20 | } 21 | return net 22 | }) 23 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/diag/sys.js: -------------------------------------------------------------------------------- 1 | import { configure } from '../lib/configure.js' 2 | import { toUrlSearchParams } from '../lib/to-url-search-params.js' 3 | 4 | /** 5 | * @typedef {import('../types').HTTPClientExtraOptions} HTTPClientExtraOptions 6 | * @typedef {import('ipfs-core-types/src/diag').API} DiagAPI 7 | */ 8 | 9 | export const createSys = configure(api => { 10 | /** 11 | * @type {DiagAPI["sys"]} 12 | */ 13 | async function sys (options = {}) { 14 | const res = await api.post('diag/sys', { 15 | signal: options.signal, 16 | searchParams: toUrlSearchParams(options), 17 | headers: options.headers 18 | }) 19 | 20 | return res.json() 21 | } 22 | return sys 23 | }) 24 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/get-endpoint-config.js: -------------------------------------------------------------------------------- 1 | import { configure } from './lib/configure.js' 2 | 3 | export const createGetEndpointConfig = configure(api => { 4 | return () => { 5 | const url = new URL(api.opts.base || '') 6 | return { 7 | host: url.hostname, 8 | port: url.port, 9 | protocol: url.protocol, 10 | pathname: url.pathname, 11 | 'api-path': url.pathname 12 | } 13 | } 14 | }) 15 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/is-online.js: -------------------------------------------------------------------------------- 1 | import { createId } from './id.js' 2 | 3 | /** 4 | * @typedef {import('./types').HTTPClientExtraOptions} HTTPClientExtraOptions 5 | * @typedef {import('ipfs-core-types/src/root').API} RootAPI 6 | */ 7 | 8 | /** 9 | * @param {import('./types').Options} options 10 | */ 11 | export const createIsOnline = options => { 12 | const id = createId(options) 13 | 14 | /** 15 | * @type {RootAPI["isOnline"]} 16 | */ 17 | async function isOnline (options = {}) { 18 | const res = await id(options) 19 | 20 | return Boolean(res && res.addresses && res.addresses.length) 21 | } 22 | return isOnline 23 | } 24 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/key/export.js: -------------------------------------------------------------------------------- 1 | import { configure } from '../lib/configure.js' 2 | import errCode from 'err-code' 3 | 4 | /** 5 | * @typedef {import('../types').HTTPClientExtraOptions} HTTPClientExtraOptions 6 | * @typedef {import('ipfs-core-types/src/key').API} KeyAPI 7 | */ 8 | 9 | export const createExport = configure(api => { 10 | /** 11 | * @type {KeyAPI["export"]} 12 | */ 13 | const exportKey = async (name, password, options = {}) => { 14 | throw errCode(new Error('Not implemented'), 'ERR_NOT_IMPLEMENTED') 15 | } 16 | 17 | return exportKey 18 | }) 19 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/key/index.js: -------------------------------------------------------------------------------- 1 | import { createExport } from './export.js' 2 | import { createGen } from './gen.js' 3 | import { createImport } from './import.js' 4 | import { createInfo } from './info.js' 5 | import { createList } from './list.js' 6 | import { createRename } from './rename.js' 7 | import { createRm } from './rm.js' 8 | 9 | /** 10 | * @param {import('../types').Options} config 11 | */ 12 | export function createKey (config) { 13 | return { 14 | export: createExport(config), 15 | gen: createGen(config), 16 | import: createImport(config), 17 | info: createInfo(config), 18 | list: createList(config), 19 | rename: createRename(config), 20 | rm: createRm(config) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/key/info.js: -------------------------------------------------------------------------------- 1 | import { configure } from '../lib/configure.js' 2 | import errCode from 'err-code' 3 | 4 | /** 5 | * @typedef {import('../types').HTTPClientExtraOptions} HTTPClientExtraOptions 6 | * @typedef {import('ipfs-core-types/src/key').API} KeyAPI 7 | */ 8 | 9 | export const createInfo = configure(api => { 10 | /** 11 | * @type {KeyAPI["info"]} 12 | */ 13 | const info = async (name, options = {}) => { 14 | throw errCode(new Error('Not implemented'), 'ERR_NOT_IMPLEMENTED') 15 | } 16 | 17 | return info 18 | }) 19 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/lib/abort-signal.js: -------------------------------------------------------------------------------- 1 | import { anySignal } from 'any-signal' 2 | 3 | /** 4 | * @param {any[]} signals 5 | * @returns {AbortSignal[]} 6 | */ 7 | function filter (signals) { 8 | return signals.filter(Boolean) 9 | } 10 | 11 | /** 12 | * @param {...AbortSignal|undefined} signals 13 | */ 14 | export function abortSignal (...signals) { 15 | return anySignal(filter(signals)) 16 | } 17 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/lib/configure.js: -------------------------------------------------------------------------------- 1 | 2 | /* eslint-env browser */ 3 | 4 | import { Client } from './core.js' 5 | 6 | // Set default configuration and call create function with them 7 | /** 8 | * @typedef { import("../types").Options } Options 9 | */ 10 | 11 | /** 12 | * @template T 13 | * @typedef {(client: Client, clientOptions: Options) => T} Fn 14 | */ 15 | 16 | /** 17 | * @template T 18 | * @typedef {(clientOptions: Options) => T} Factory 19 | */ 20 | 21 | /** 22 | * @template T 23 | * @param {Fn} fn 24 | * @returns {Factory} 25 | */ 26 | export const configure = (fn) => { 27 | return (options) => { 28 | return fn(new Client(options), options) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/lib/mode-to-string.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * @param {number | string | undefined} mode 4 | */ 5 | export function modeToString (mode) { 6 | if (mode == null) { 7 | return undefined 8 | } 9 | 10 | if (typeof mode === 'string') { 11 | return mode 12 | } 13 | 14 | return mode.toString(8).padStart(4, '0') 15 | } 16 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/lib/object-to-camel-with-metadata.js: -------------------------------------------------------------------------------- 1 | import { objectToCamel } from './object-to-camel.js' 2 | 3 | /** 4 | * @param {Record} entry 5 | */ 6 | export function objectToCamelWithMetadata (entry) { 7 | const file = objectToCamel(entry) 8 | 9 | if (Object.prototype.hasOwnProperty.call(file, 'mode')) { 10 | file.mode = parseInt(file.mode, 8) 11 | } 12 | 13 | if (Object.prototype.hasOwnProperty.call(file, 'mtime')) { 14 | file.mtime = { 15 | secs: file.mtime, 16 | nsecs: file.mtimeNsecs || 0 17 | } 18 | 19 | delete file.mtimeNsecs 20 | } 21 | 22 | return file 23 | } 24 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/log/index.js: -------------------------------------------------------------------------------- 1 | import { createLevel } from './level.js' 2 | import { createLs } from './ls.js' 3 | import { createTail } from './tail.js' 4 | 5 | /** 6 | * @param {import('../types').Options} config 7 | */ 8 | export function createLog (config) { 9 | return { 10 | level: createLevel(config), 11 | ls: createLs(config), 12 | tail: createTail(config) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/log/ls.js: -------------------------------------------------------------------------------- 1 | import { configure } from '../lib/configure.js' 2 | import { toUrlSearchParams } from '../lib/to-url-search-params.js' 3 | 4 | /** 5 | * @typedef {import('../types').HTTPClientExtraOptions} HTTPClientExtraOptions 6 | * @typedef {import('ipfs-core-types/src/log').API} LogAPI 7 | */ 8 | 9 | export const createLs = configure(api => { 10 | /** 11 | * @type {LogAPI["ls"]} 12 | */ 13 | async function ls (options = {}) { 14 | const res = await api.post('log/ls', { 15 | signal: options.signal, 16 | searchParams: toUrlSearchParams(options), 17 | headers: options.headers 18 | }) 19 | 20 | const data = await res.json() 21 | return data.Strings 22 | } 23 | return ls 24 | }) 25 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/log/tail.js: -------------------------------------------------------------------------------- 1 | import { configure } from '../lib/configure.js' 2 | import { toUrlSearchParams } from '../lib/to-url-search-params.js' 3 | 4 | /** 5 | * @typedef {import('../types').HTTPClientExtraOptions} HTTPClientExtraOptions 6 | * @typedef {import('ipfs-core-types/src/log').API} LogAPI 7 | */ 8 | 9 | export const createTail = configure(api => { 10 | /** 11 | * @type {LogAPI["tail"]} 12 | */ 13 | async function * tail (options = {}) { 14 | const res = await api.post('log/tail', { 15 | signal: options.signal, 16 | searchParams: toUrlSearchParams(options), 17 | headers: options.headers 18 | }) 19 | 20 | yield * res.ndjson() 21 | } 22 | return tail 23 | }) 24 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/name/index.js: -------------------------------------------------------------------------------- 1 | import { createPublish } from './publish.js' 2 | import { createResolve } from './resolve.js' 3 | import { createPubsub } from './pubsub/index.js' 4 | 5 | /** 6 | * @param {import('../types').Options} config 7 | */ 8 | export function createName (config) { 9 | return { 10 | publish: createPublish(config), 11 | resolve: createResolve(config), 12 | pubsub: createPubsub(config) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/name/pubsub/index.js: -------------------------------------------------------------------------------- 1 | import { createCancel } from './cancel.js' 2 | import { createState } from './state.js' 3 | import { createSubs } from './subs.js' 4 | 5 | /** 6 | * @param {import('../../types').Options} config 7 | */ 8 | export function createPubsub (config) { 9 | return { 10 | cancel: createCancel(config), 11 | state: createState(config), 12 | subs: createSubs(config) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/object/patch/index.js: -------------------------------------------------------------------------------- 1 | import { createAddLink } from './add-link.js' 2 | import { createAppendData } from './append-data.js' 3 | import { createRmLink } from './rm-link.js' 4 | import { createSetData } from './set-data.js' 5 | 6 | /** 7 | * @param {import('../../types').Options} config 8 | */ 9 | export function createPatch (config) { 10 | return { 11 | addLink: createAddLink(config), 12 | appendData: createAppendData(config), 13 | rmLink: createRmLink(config), 14 | setData: createSetData(config) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/pin/index.js: -------------------------------------------------------------------------------- 1 | import { createAddAll } from './add-all.js' 2 | import { createAdd } from './add.js' 3 | import { createLs } from './ls.js' 4 | import { createRmAll } from './rm-all.js' 5 | import { createRm } from './rm.js' 6 | import { createRemote } from './remote/index.js' 7 | 8 | /** 9 | * @param {import('../types').Options} config 10 | */ 11 | export function createPin (config) { 12 | return { 13 | addAll: createAddAll(config), 14 | add: createAdd(config), 15 | ls: createLs(config), 16 | rmAll: createRmAll(config), 17 | rm: createRm(config), 18 | remote: createRemote(config) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/pin/remote/index.js: -------------------------------------------------------------------------------- 1 | import { Client } from '../../lib/core.js' 2 | import { createAdd } from './add.js' 3 | import { createLs } from './ls.js' 4 | import { createRm } from './rm.js' 5 | import { createRmAll } from './rm-all.js' 6 | import { createService } from './service/index.js' 7 | 8 | /** 9 | * @param {import('../../types').Options} config 10 | */ 11 | export function createRemote (config) { 12 | const client = new Client(config) 13 | 14 | return { 15 | add: createAdd(client), 16 | ls: createLs(client), 17 | rm: createRm(client), 18 | rmAll: createRmAll(client), 19 | service: createService(config) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/pin/remote/service/index.js: -------------------------------------------------------------------------------- 1 | import { Client } from '../../../lib/core.js' 2 | import { createAdd } from './add.js' 3 | import { createLs } from './ls.js' 4 | import { createRm } from './rm.js' 5 | 6 | /** 7 | * @param {import('../../../types').Options} config 8 | */ 9 | export function createService (config) { 10 | const client = new Client(config) 11 | 12 | return { 13 | add: createAdd(client), 14 | ls: createLs(client), 15 | rm: createRm(client) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/pubsub/unsubscribe.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * @typedef {import('../types').HTTPClientExtraOptions} HTTPClientExtraOptions 4 | * @typedef {import('ipfs-core-types/src/pubsub').API} PubsubAPI 5 | * @typedef {import('../types').Options} Options 6 | */ 7 | 8 | /** 9 | * @param {Options} options 10 | * @param {import('./subscription-tracker').SubscriptionTracker} subsTracker 11 | */ 12 | export const createUnsubscribe = (options, subsTracker) => { 13 | /** 14 | * @type {PubsubAPI["unsubscribe"]} 15 | */ 16 | async function unsubscribe (topic, handler) { 17 | subsTracker.unsubscribe(topic, handler) 18 | } 19 | return unsubscribe 20 | } 21 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/repo/index.js: -------------------------------------------------------------------------------- 1 | import { createGc } from './gc.js' 2 | import { createStat } from './stat.js' 3 | import { createVersion } from './version.js' 4 | 5 | /** 6 | * @param {import('../types').Options} config 7 | */ 8 | export function createRepo (config) { 9 | return { 10 | gc: createGc(config), 11 | stat: createStat(config), 12 | version: createVersion(config) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/start.js: -------------------------------------------------------------------------------- 1 | import { configure } from './lib/configure.js' 2 | import errCode from 'err-code' 3 | 4 | /** 5 | * @typedef {import('./types').HTTPClientExtraOptions} HTTPClientExtraOptions 6 | * @typedef {import('ipfs-core-types/src/root').API} RootAPI 7 | */ 8 | 9 | export const createStart = configure(api => { 10 | /** 11 | * @type {RootAPI["start"]} 12 | */ 13 | const start = async (options = {}) => { 14 | throw errCode(new Error('Not implemented'), 'ERR_NOT_IMPLEMENTED') 15 | } 16 | 17 | return start 18 | }) 19 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/stats/index.js: -------------------------------------------------------------------------------- 1 | import { createStat as createBitswap } from '../bitswap/stat.js' 2 | import { createStat as createRepo } from '../repo/stat.js' 3 | import { createBw } from './bw.js' 4 | 5 | /** 6 | * @param {import('../types').Options} config 7 | */ 8 | export function createStats (config) { 9 | return { 10 | bitswap: createBitswap(config), 11 | repo: createRepo(config), 12 | bw: createBw(config) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/stop.js: -------------------------------------------------------------------------------- 1 | import { configure } from './lib/configure.js' 2 | import { toUrlSearchParams } from './lib/to-url-search-params.js' 3 | 4 | /** 5 | * @typedef {import('./types').HTTPClientExtraOptions} HTTPClientExtraOptions 6 | * @typedef {import('ipfs-core-types/src/root').API} RootAPI 7 | */ 8 | 9 | export const createStop = configure(api => { 10 | /** 11 | * @type {RootAPI["stop"]} 12 | */ 13 | async function stop (options = {}) { 14 | const res = await api.post('shutdown', { 15 | signal: options.signal, 16 | searchParams: toUrlSearchParams(options), 17 | headers: options.headers 18 | }) 19 | 20 | await res.text() 21 | } 22 | return stop 23 | }) 24 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/src/swarm/index.js: -------------------------------------------------------------------------------- 1 | import { createAddrs } from './addrs.js' 2 | import { createConnect } from './connect.js' 3 | import { createDisconnect } from './disconnect.js' 4 | import { createLocalAddrs } from './local-addrs.js' 5 | import { createPeers } from './peers.js' 6 | 7 | /** 8 | * @param {import('../types').Options} config 9 | */ 10 | export function createSwarm (config) { 11 | return { 12 | addrs: createAddrs(config), 13 | connect: createConnect(config), 14 | disconnect: createDisconnect(config), 15 | localAddrs: createLocalAddrs(config), 16 | peers: createPeers(config) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/test/commands.spec.js: -------------------------------------------------------------------------------- 1 | /* eslint-env mocha */ 2 | 3 | import { expect } from 'aegir/chai' 4 | import { factory } from './utils/factory.js' 5 | const f = factory() 6 | 7 | describe('.commands', function () { 8 | this.timeout(60 * 1000) 9 | 10 | /** @type {import('ipfs-core-types').IPFS} */ 11 | let ipfs 12 | 13 | before(async () => { 14 | ipfs = (await f.spawn()).api 15 | }) 16 | 17 | after(() => f.clean()) 18 | 19 | it('lists commands', async () => { 20 | const res = await ipfs.commands() 21 | 22 | expect(res).to.exist() 23 | }) 24 | }) 25 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/test/endpoint-config.spec.js: -------------------------------------------------------------------------------- 1 | /* eslint-env mocha */ 2 | /* eslint max-nested-callbacks: ["error", 8] */ 3 | 4 | import { expect } from 'aegir/chai' 5 | import { create as httpClient } from '../src/index.js' 6 | 7 | describe('.getEndpointConfig', () => { 8 | it('should return the endpoint configuration', function () { 9 | const ipfs = httpClient('https://127.0.0.1:5501/ipfs/api/') 10 | const endpoint = ipfs.getEndpointConfig() 11 | 12 | expect(endpoint.host).to.equal('127.0.0.1') 13 | expect(endpoint.protocol).to.equal('https:') 14 | expect(endpoint.pathname).to.equal('/ipfs/api/') 15 | expect(endpoint.port).to.equal('5501') 16 | }) 17 | }) 18 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/test/exports.spec.js: -------------------------------------------------------------------------------- 1 | /* eslint-env mocha, browser */ 2 | 3 | import { CID } from 'multiformats/cid' 4 | import { multiaddr } from '@multiformats/multiaddr' 5 | import { expect } from 'aegir/chai' 6 | import * as IpfsHttpClient from '../src/index.js' 7 | 8 | describe('exports', () => { 9 | it('should export the expected types and utilities', () => { 10 | expect(IpfsHttpClient.CID).to.equal(CID) 11 | expect(IpfsHttpClient.multiaddr).to.equal(multiaddr) 12 | }) 13 | }) 14 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/test/fixtures/.gitattributes: -------------------------------------------------------------------------------- 1 | * -text 2 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/test/fixtures/15mb.random: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipfs/js-ipfs/bf1bc8b18d750d5591bdd575a6d0f4c067d61d0a/packages/ipfs-http-client/test/fixtures/15mb.random -------------------------------------------------------------------------------- /packages/ipfs-http-client/test/fixtures/r-config.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/test/fixtures/test-folder/.hiddenTest.txt: -------------------------------------------------------------------------------- 1 | Aha! You found me! 2 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/test/fixtures/test-folder/add: -------------------------------------------------------------------------------- 1 | 2 | 3 | const { Buffer } = require('buffer') 4 | const ipfs = require('../src')('localhost', 5001) 5 | 6 | const f1 = 'Hello' 7 | const f2 = 'World' 8 | 9 | ipfs.add([new Buffer(f1), new Buffer(f2)], function (err, res) { 10 | if (err || !res) return console.log(err) 11 | 12 | for (let i = 0; i < res.length; i++) { 13 | console.log(res[i]) 14 | } 15 | }) 16 | 17 | ipfs.add(['./files/hello.txt', './files/ipfs.txt'], function (err, res) { 18 | if (err || !res) return console.log(err) 19 | 20 | for (let i = 0; i < res.length; i++) { 21 | console.log(res[i]) 22 | } 23 | }) 24 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/test/fixtures/test-folder/cat: -------------------------------------------------------------------------------- 1 | 2 | 3 | const ipfs = require('../src')('localhost', 5001) 4 | 5 | const hash = [ 6 | 'QmdFyxZXsFiP4csgfM5uPu99AvFiKH62CSPDw5TP92nr7w', 7 | 'QmY9cxiHqTFoWamkQVkpmmqzBrY3hCBEL2XNu3NtX74Fuu' 8 | ] 9 | 10 | ipfs.cat(hash, function (err, res) { 11 | if (err || !res) return console.log(err) 12 | 13 | if (res.readable) { 14 | res.pipe(process.stdout) 15 | } else { 16 | console.log(res) 17 | } 18 | }) 19 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/test/fixtures/test-folder/files/hello.txt: -------------------------------------------------------------------------------- 1 | Hello 2 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/test/fixtures/test-folder/files/ipfs.txt: -------------------------------------------------------------------------------- 1 | IPFS 2 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/test/fixtures/test-folder/hello-link: -------------------------------------------------------------------------------- 1 | files/hello.txt -------------------------------------------------------------------------------- /packages/ipfs-http-client/test/fixtures/test-folder/ipfs-add: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | 4 | 5 | const ipfs = require('../src')('localhost', 5001) 6 | const files = process.argv.slice(2) 7 | 8 | ipfs.add(files, {recursive: true}, function (err, res) { 9 | if (err || !res) return console.log(err) 10 | 11 | for (let i = 0; i < res.length; i++) { 12 | console.log('added', res[i].Hash, res[i].Name) 13 | } 14 | }) 15 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/test/fixtures/test-folder/ls: -------------------------------------------------------------------------------- 1 | 2 | 3 | const ipfs = require('../src')('localhost', 5001) 4 | 5 | const hash = ['QmdbHK6gMiecyjjSoPnfJg6iKMF7v6E2NkoBgGpmyCoevh'] 6 | 7 | ipfs.ls(hash, function (err, res) { 8 | if (err || !res) return console.log(err) 9 | 10 | res.Objects.forEach(function (node) { 11 | console.log(node.Hash) 12 | 13 | console.log('Links [%d]', node.Links.length) 14 | node.Links.forEach(function (link, i) { 15 | console.log('[%d]', i, link) 16 | }) 17 | }) 18 | }) 19 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/test/fixtures/test-folder/version: -------------------------------------------------------------------------------- 1 | 2 | 3 | const ipfs = require('../src')('localhost', 5001) 4 | 5 | ipfs.commands(function (err, res) { 6 | if (err) throw err 7 | console.log(res) 8 | }) 9 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/test/fixtures/testfile.txt: -------------------------------------------------------------------------------- 1 | Plz add me! 2 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/test/node.js: -------------------------------------------------------------------------------- 1 | 2 | import './node/agent.js' 3 | import './node/swarm.js' 4 | import './node/request-api.js' 5 | import './node/custom-headers.js' 6 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/test/utils/throws-async.js: -------------------------------------------------------------------------------- 1 | 2 | export async function throwsAsync (fnOrPromise) { 3 | try { 4 | await (fnOrPromise.then ? fnOrPromise : fnOrPromise()) 5 | } catch (/** @type {any} */ err) { 6 | return err 7 | } 8 | throw new Error('did not throw') 9 | } 10 | -------------------------------------------------------------------------------- /packages/ipfs-http-client/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "aegir/src/config/tsconfig.aegir.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "emitDeclarationOnly": true 6 | }, 7 | "include": [ 8 | "src", 9 | "test/utils/factory.js", 10 | "test/pubsub.spec.js" 11 | ], 12 | "references": [ 13 | { 14 | "path": "../ipfs-core-types" 15 | }, 16 | { 17 | "path": "../ipfs-core-utils" 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /packages/ipfs-http-gateway/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | The `js-ipfs` project follows the [`IPFS Community Code of Conduct`](https://github.com/ipfs/community/blob/master/code-of-conduct.md) 4 | -------------------------------------------------------------------------------- /packages/ipfs-http-gateway/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing guidelines 2 | 3 | IPFS as a project, including js-ipfs and all of its modules, follows the [standard IPFS Community contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md). 4 | 5 | We also adhere to the [IPFS JavaScript Community contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) which provide additional information of how to collaborate and contribute in the JavaScript implementation of IPFS. 6 | 7 | We appreciate your time and attention for going over these. Please open an issue on [ipfs/community](https://github.com/ipfs/community) if you have any question. 8 | 9 | Thank you. 10 | -------------------------------------------------------------------------------- /packages/ipfs-http-gateway/COPYRIGHT: -------------------------------------------------------------------------------- 1 | This project is transitioning from an MIT-only license to a dual MIT/Apache-2.0 license. 2 | Unless otherwise noted, all code contributed prior to 2019-11-21 and not contributed by 3 | a user listed in [this signoff issue](https://github.com/ipfs/js-ipfs/issues/2624) is 4 | licensed under MIT-only. All new contributions (and past contributions since 2019-11-21) 5 | are licensed under a dual MIT/Apache-2.0 license. 6 | -------------------------------------------------------------------------------- /packages/ipfs-http-gateway/LICENSE: -------------------------------------------------------------------------------- 1 | This project is dual licensed under MIT and Apache-2.0. 2 | 3 | MIT: https://www.opensource.org/licenses/mit 4 | Apache-2.0: https://www.apache.org/licenses/license-2.0 5 | -------------------------------------------------------------------------------- /packages/ipfs-http-gateway/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 2 | 3 | http://www.apache.org/licenses/LICENSE-2.0 4 | 5 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 6 | -------------------------------------------------------------------------------- /packages/ipfs-http-gateway/src/resources/index.js: -------------------------------------------------------------------------------- 1 | import { Gateway } from './gateway.js' 2 | 3 | export default { 4 | gateway: Gateway 5 | } 6 | -------------------------------------------------------------------------------- /packages/ipfs-http-gateway/src/routes/index.js: -------------------------------------------------------------------------------- 1 | import Gateway from './gateway.js' 2 | 3 | export default { 4 | gateway: Gateway 5 | } 6 | -------------------------------------------------------------------------------- /packages/ipfs-http-gateway/src/types.ts: -------------------------------------------------------------------------------- 1 | import type { IPFS } from 'ipfs-core-types' 2 | import type { Request, Server } from '@hapi/hapi' 3 | import type { Multiaddr } from '@multiformats/multiaddr' 4 | 5 | declare module '@hapi/hapi' { 6 | interface ServerApplicationState { 7 | ipfs: IPFS 8 | } 9 | interface ServerInfo { 10 | ma: Multiaddr 11 | } 12 | } 13 | 14 | export type { Request, Server } 15 | -------------------------------------------------------------------------------- /packages/ipfs-http-gateway/test/fixtures/cat-folder/cat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipfs/js-ipfs/bf1bc8b18d750d5591bdd575a6d0f4c067d61d0a/packages/ipfs-http-gateway/test/fixtures/cat-folder/cat.jpg -------------------------------------------------------------------------------- /packages/ipfs-http-gateway/test/fixtures/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IPFS test index.html 6 | 7 | 8 | index.html 9 | 10 | 11 | -------------------------------------------------------------------------------- /packages/ipfs-http-gateway/test/fixtures/nested-folder/hello.txt: -------------------------------------------------------------------------------- 1 | Hello 2 | -------------------------------------------------------------------------------- /packages/ipfs-http-gateway/test/fixtures/nested-folder/ipfs.txt: -------------------------------------------------------------------------------- 1 | IPFS 2 | -------------------------------------------------------------------------------- /packages/ipfs-http-gateway/test/fixtures/nested-folder/nested.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IPFS test nested.html 6 | 7 | 8 | nested.html 9 | 10 | 11 | -------------------------------------------------------------------------------- /packages/ipfs-http-gateway/test/utils/http.js: -------------------------------------------------------------------------------- 1 | 2 | import { HttpGateway } from '../../src/index.js' 3 | 4 | export async function http (request, { ipfs } = {}) { 5 | const api = new HttpGateway(ipfs) 6 | const server = await api._createGatewayServer('127.0.0.1', 8080, ipfs) 7 | 8 | return server.inject(request) 9 | } 10 | -------------------------------------------------------------------------------- /packages/ipfs-http-gateway/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "aegir/src/config/tsconfig.aegir.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "emitDeclarationOnly": true 6 | }, 7 | "include": [ 8 | "src" 9 | ], 10 | "references": [ 11 | { 12 | "path": "../ipfs-core-types" 13 | }, 14 | { 15 | "path": "../ipfs-http-response" 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /packages/ipfs-http-response/LICENSE: -------------------------------------------------------------------------------- 1 | This project is dual licensed under MIT and Apache-2.0. 2 | 3 | MIT: https://www.opensource.org/licenses/mit 4 | Apache-2.0: https://www.apache.org/licenses/license-2.0 5 | -------------------------------------------------------------------------------- /packages/ipfs-http-response/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 2 | 3 | http://www.apache.org/licenses/LICENSE-2.0 4 | 5 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 6 | -------------------------------------------------------------------------------- /packages/ipfs-http-response/docs/ipfs-http-response.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipfs/js-ipfs/bf1bc8b18d750d5591bdd575a6d0f4c067d61d0a/packages/ipfs-http-response/docs/ipfs-http-response.png -------------------------------------------------------------------------------- /packages/ipfs-http-response/test/fixtures/.gitattributes: -------------------------------------------------------------------------------- 1 | # Make sure fixtures have correct line endings on windows 2 | 3 | *.txt text eol=lf 4 | *.svg text eol=lf 5 | *.html text eol=lf 6 | -------------------------------------------------------------------------------- /packages/ipfs-http-response/test/fixtures/test-folder/files/hello.txt: -------------------------------------------------------------------------------- 1 | hello world -------------------------------------------------------------------------------- /packages/ipfs-http-response/test/fixtures/test-folder/hello-link: -------------------------------------------------------------------------------- 1 | files/hello.txt -------------------------------------------------------------------------------- /packages/ipfs-http-response/test/fixtures/test-mime-types/cat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipfs/js-ipfs/bf1bc8b18d750d5591bdd575a6d0f4c067d61d0a/packages/ipfs-http-response/test/fixtures/test-mime-types/cat.jpg -------------------------------------------------------------------------------- /packages/ipfs-http-response/test/fixtures/test-mime-types/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Website 4 | 5 | 6 | -------------------------------------------------------------------------------- /packages/ipfs-http-response/test/fixtures/test-site/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Website 4 | 5 | 6 | -------------------------------------------------------------------------------- /packages/ipfs-http-response/test/fixtures/testfile.txt: -------------------------------------------------------------------------------- 1 | Plz add me! 2 | -------------------------------------------------------------------------------- /packages/ipfs-http-response/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "aegir/src/config/tsconfig.aegir.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "emitDeclarationOnly": true 6 | }, 7 | "include": [ 8 | "src", 9 | "test" 10 | ], 11 | "exclude": [ 12 | "dist", 13 | "node_modules" 14 | ], 15 | "references": [ 16 | { 17 | "path": "../ipfs-core" 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | The `js-ipfs` project follows the [`IPFS Community Code of Conduct`](https://github.com/ipfs/community/blob/master/code-of-conduct.md) 4 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing guidelines 2 | 3 | IPFS as a project, including js-ipfs and all of its modules, follows the [standard IPFS Community contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md). 4 | 5 | We also adhere to the [IPFS JavaScript Community contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) which provide additional information of how to collaborate and contribute in the JavaScript implementation of IPFS. 6 | 7 | We appreciate your time and attention for going over these. Please open an issue on [ipfs/community](https://github.com/ipfs/community) if you have any question. 8 | 9 | Thank you. 10 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/COPYRIGHT: -------------------------------------------------------------------------------- 1 | This project is transitioning from an MIT-only license to a dual MIT/Apache-2.0 license. 2 | Unless otherwise noted, all code contributed prior to 2019-11-21 and not contributed by 3 | a user listed in [this signoff issue](https://github.com/ipfs/js-ipfs/issues/2624) is 4 | licensed under MIT-only. All new contributions (and past contributions since 2019-11-21) 5 | are licensed under a dual MIT/Apache-2.0 license. 6 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/LICENSE: -------------------------------------------------------------------------------- 1 | This project is dual licensed under MIT and Apache-2.0. 2 | 3 | MIT: https://www.opensource.org/licenses/mit 4 | Apache-2.0: https://www.apache.org/licenses/license-2.0 5 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 2 | 3 | http://www.apache.org/licenses/LICENSE-2.0 4 | 5 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 6 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/scripts/update-version.js: -------------------------------------------------------------------------------- 1 | import { readFile, writeFile } from 'fs/promises' 2 | 3 | const pkg = JSON.parse( 4 | await readFile( 5 | new URL('../package.json', import.meta.url) 6 | ) 7 | ) 8 | 9 | await writeFile( 10 | new URL('../src/version.js', import.meta.url), 11 | ` 12 | export const ipfsHttpClient = '${pkg.devDependencies['ipfs-http-client']}' 13 | ` 14 | ) 15 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/src/api/resources/files/utils/parse-mtime.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * @param {number | undefined} secs 4 | * @param {number | undefined} nsecs 5 | */ 6 | export function parseMtime (secs, nsecs) { 7 | if (secs == null && nsecs == null) { 8 | return 9 | } 10 | 11 | const mtime = {} 12 | 13 | if (nsecs || nsecs === 0) { 14 | mtime.secs = 0 15 | mtime.nsecs = nsecs 16 | } 17 | 18 | if (secs || secs === 0) { 19 | mtime.secs = secs 20 | } 21 | 22 | return mtime 23 | } 24 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/src/api/resources/shutdown.js: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Stop the daemon. 4 | * 5 | * Returns an empty response to the caller then 6 | * on the next 'tick' emits SIGTERM. 7 | */ 8 | export const shutdownResource = { 9 | /** 10 | * @param {import('../../types').Request} _request 11 | * @param {import('@hapi/hapi').ResponseToolkit} h 12 | */ 13 | handler: (_request, h) => { 14 | setImmediate(() => process.emit('SIGTERM', 'SIGTERM')) 15 | return h.response() 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/src/api/routes/bitswap.js: -------------------------------------------------------------------------------- 1 | import { 2 | wantlistResource, 3 | statResource, 4 | unwantResource 5 | } from '../resources/bitswap.js' 6 | 7 | export default [ 8 | { 9 | method: 'POST', 10 | path: '/api/v0/bitswap/wantlist', 11 | ...wantlistResource 12 | }, 13 | { 14 | method: 'POST', 15 | path: '/api/v0/bitswap/stat', 16 | ...statResource 17 | }, 18 | { 19 | method: 'POST', 20 | path: '/api/v0/bitswap/unwant', 21 | ...unwantResource 22 | } 23 | ] 24 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/src/api/routes/block.js: -------------------------------------------------------------------------------- 1 | import { 2 | getResource, 3 | putResource, 4 | rmResource, 5 | statResource 6 | } from '../resources/block.js' 7 | 8 | export default [ 9 | { 10 | method: 'POST', 11 | path: '/api/v0/block/get', 12 | ...getResource 13 | }, 14 | { 15 | method: 'POST', 16 | path: '/api/v0/block/put', 17 | ...putResource 18 | }, 19 | { 20 | method: 'POST', 21 | path: '/api/v0/block/rm', 22 | ...rmResource 23 | }, 24 | { 25 | method: 'POST', 26 | path: '/api/v0/block/stat', 27 | ...statResource 28 | } 29 | ] 30 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/src/api/routes/dag.js: -------------------------------------------------------------------------------- 1 | import { 2 | exportResource, 3 | getResource, 4 | importResource, 5 | putResource, 6 | resolveResource 7 | } from '../resources/dag.js' 8 | 9 | export default [ 10 | { 11 | method: 'POST', 12 | path: '/api/v0/dag/export', 13 | ...exportResource 14 | }, 15 | { 16 | method: 'POST', 17 | path: '/api/v0/dag/get', 18 | ...getResource 19 | }, 20 | { 21 | method: 'POST', 22 | path: '/api/v0/dag/import', 23 | ...importResource 24 | }, 25 | { 26 | method: 'POST', 27 | path: '/api/v0/dag/put', 28 | ...putResource 29 | }, 30 | { 31 | method: 'POST', 32 | path: '/api/v0/dag/resolve', 33 | ...resolveResource 34 | } 35 | ] 36 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/src/api/routes/dns.js: -------------------------------------------------------------------------------- 1 | import { 2 | dnsResource 3 | } from '../resources/dns.js' 4 | 5 | export default [{ 6 | method: 'POST', 7 | path: '/api/v0/dns', 8 | ...dnsResource 9 | }] 10 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/src/api/routes/id.js: -------------------------------------------------------------------------------- 1 | import { 2 | idResource 3 | } from '../resources/id.js' 4 | 5 | export default [{ 6 | method: 'POST', 7 | path: '/api/v0/id', 8 | ...idResource 9 | }] 10 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/src/api/routes/key.js: -------------------------------------------------------------------------------- 1 | import { 2 | listResource, 3 | genResource, 4 | rmResource, 5 | renameResource, 6 | importResource 7 | } from '../resources/key.js' 8 | 9 | export default [ 10 | { 11 | method: 'POST', 12 | path: '/api/v0/key/list', 13 | ...listResource 14 | }, 15 | { 16 | method: 'POST', 17 | path: '/api/v0/key/gen', 18 | ...genResource 19 | }, 20 | { 21 | method: 'POST', 22 | path: '/api/v0/key/rm', 23 | ...rmResource 24 | }, 25 | { 26 | method: 'POST', 27 | path: '/api/v0/key/rename', 28 | ...renameResource 29 | }, 30 | { 31 | method: 'POST', 32 | path: '/api/v0/key/import', 33 | ...importResource 34 | } 35 | ] 36 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/src/api/routes/pin.js: -------------------------------------------------------------------------------- 1 | import { 2 | addResource, 3 | rmResource, 4 | lsResource 5 | } from '../resources/pin.js' 6 | 7 | export default [ 8 | { 9 | method: 'POST', 10 | path: '/api/v0/pin/add', 11 | ...addResource 12 | }, 13 | { 14 | method: 'POST', 15 | path: '/api/v0/pin/rm', 16 | ...rmResource 17 | }, 18 | { 19 | method: 'POST', 20 | path: '/api/v0/pin/ls', 21 | ...lsResource 22 | } 23 | ] 24 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/src/api/routes/ping.js: -------------------------------------------------------------------------------- 1 | import { 2 | pingResource 3 | } from '../resources/ping.js' 4 | 5 | export default [{ 6 | method: 'POST', 7 | path: '/api/v0/ping', 8 | ...pingResource 9 | }] 10 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/src/api/routes/pubsub.js: -------------------------------------------------------------------------------- 1 | import { 2 | subscribeResource, 3 | publishResource, 4 | lsResource, 5 | peersResource 6 | } from '../resources/pubsub.js' 7 | 8 | export default [ 9 | { 10 | method: 'POST', 11 | path: '/api/v0/pubsub/sub', 12 | ...subscribeResource 13 | }, 14 | { 15 | method: 'POST', 16 | path: '/api/v0/pubsub/pub', 17 | ...publishResource 18 | }, 19 | { 20 | method: 'POST', 21 | path: '/api/v0/pubsub/ls', 22 | ...lsResource 23 | }, 24 | { 25 | method: 'POST', 26 | path: '/api/v0/pubsub/peers', 27 | ...peersResource 28 | } 29 | ] 30 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/src/api/routes/repo.js: -------------------------------------------------------------------------------- 1 | import { 2 | versionResource, 3 | statResource, 4 | gcResource 5 | } from '../resources/repo.js' 6 | 7 | export default [ 8 | { 9 | method: 'POST', 10 | path: '/api/v0/repo/version', 11 | ...versionResource 12 | }, 13 | { 14 | method: 'POST', 15 | path: '/api/v0/repo/stat', 16 | ...statResource 17 | }, 18 | { 19 | method: 'POST', 20 | path: '/api/v0/repo/gc', 21 | ...gcResource 22 | } 23 | ] 24 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/src/api/routes/resolve.js: -------------------------------------------------------------------------------- 1 | import { 2 | resolveResource 3 | } from '../resources/resolve.js' 4 | 5 | export default [{ 6 | method: 'POST', 7 | path: '/api/v0/resolve', 8 | ...resolveResource 9 | }] 10 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/src/api/routes/shutdown.js: -------------------------------------------------------------------------------- 1 | import { 2 | shutdownResource 3 | } from '../resources/shutdown.js' 4 | 5 | export default [{ 6 | method: 'POST', 7 | path: '/api/v0/shutdown', 8 | ...shutdownResource 9 | }] 10 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/src/api/routes/stats.js: -------------------------------------------------------------------------------- 1 | import { 2 | bitswapResource, 3 | repoResource, 4 | bwResource 5 | } from '../resources/stats.js' 6 | 7 | export default [ 8 | { 9 | method: 'POST', 10 | path: '/api/v0/stats/bitswap', 11 | ...bitswapResource 12 | }, 13 | { 14 | method: 'POST', 15 | path: '/api/v0/stats/repo', 16 | ...repoResource 17 | }, 18 | { 19 | method: 'POST', 20 | path: '/api/v0/stats/bw', 21 | ...bwResource 22 | } 23 | ] 24 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/src/api/routes/version.js: -------------------------------------------------------------------------------- 1 | import { versionResource } from '../resources/version.js' 2 | 3 | export default [{ 4 | method: 'POST', 5 | path: '/api/v0/version', 6 | ...versionResource 7 | }] 8 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/src/version.js: -------------------------------------------------------------------------------- 1 | 2 | export const ipfsHttpClient = '' 3 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/test/fixtures/test-data/badconfig: -------------------------------------------------------------------------------- 1 | { 2 | bad config 3 | } 4 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/test/fixtures/test-data/badnode.json: -------------------------------------------------------------------------------- 1 | { 2 | bad config 3 | } 4 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/test/fixtures/test-data/node.json: -------------------------------------------------------------------------------- 1 | { "Data": "another", "Links": [ { "Name": "some link", "Hash": "QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39V", "Size": 8 } ] } 2 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/test/inject/mfs.js: -------------------------------------------------------------------------------- 1 | /* eslint-env mocha */ 2 | 3 | import './mfs/chmod.js' 4 | import './mfs/cp.js' 5 | import './mfs/flush.js' 6 | import './mfs/ls.js' 7 | import './mfs/mkdir.js' 8 | import './mfs/mv.js' 9 | import './mfs/read.js' 10 | import './mfs/rm.js' 11 | import './mfs/stat.js' 12 | import './mfs/touch.js' 13 | import './mfs/write.js' 14 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/test/inject/shutdown.js: -------------------------------------------------------------------------------- 1 | /* eslint-env mocha */ 2 | 3 | import { testHttpMethod } from '../utils/test-http-method.js' 4 | import { http } from '../utils/http.js' 5 | 6 | describe('/shutdown', () => { 7 | let ipfs 8 | 9 | beforeEach(() => { 10 | ipfs = {} 11 | }) 12 | 13 | it('only accepts POST', () => { 14 | return testHttpMethod('/api/v0/shutdown') 15 | }) 16 | 17 | it('should shut down', (done) => { 18 | const listener = () => { 19 | done() 20 | 21 | process.removeListener('SIGTERM', listener) 22 | } 23 | 24 | process.on('SIGTERM', listener) 25 | 26 | http({ 27 | method: 'POST', 28 | url: '/api/v0/shutdown' 29 | }, { ipfs }) 30 | .then(() => {}, err => done(err)) 31 | }) 32 | }) 33 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/test/node.js: -------------------------------------------------------------------------------- 1 | import './routes.js' 2 | import './cors.js' 3 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/test/utils/all-ndjson.js: -------------------------------------------------------------------------------- 1 | 2 | export function allNdjson (res) { 3 | return res.result 4 | .split('\n') 5 | .map(line => line.trim()) 6 | .filter(line => Boolean(line)) 7 | .map(line => JSON.parse(line)) 8 | } 9 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/test/utils/http.js: -------------------------------------------------------------------------------- 1 | import { HttpApi } from '../../src/index.js' 2 | 3 | export async function http (request, { ipfs, cors } = {}) { 4 | const api = new HttpApi(ipfs) 5 | const server = await api._createApiServer('127.0.0.1', 8080, ipfs, cors) 6 | 7 | return server.inject(request) 8 | } 9 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/test/utils/match-iterable.js: -------------------------------------------------------------------------------- 1 | 2 | import sinon from 'sinon' 3 | 4 | export function matchIterable () { 5 | return sinon.match((thing) => Boolean(thing[Symbol.asyncIterator]) || Boolean(thing[Symbol.iterator])) 6 | } 7 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/test/utils/test-http-method.js: -------------------------------------------------------------------------------- 1 | 2 | import { expect } from 'aegir/chai' 3 | import { http } from './http.js' 4 | 5 | const METHODS = [ 6 | 'GET', 7 | 'PUT', 8 | 'PATCH', 9 | 'DELETE', 10 | 'HEAD' 11 | ] 12 | 13 | export async function testHttpMethod (url, ipfs) { 14 | for (let i = 0; i < METHODS.length; i++) { 15 | const res = await http({ 16 | method: METHODS[i], 17 | url 18 | }, { ipfs }) 19 | 20 | expect(res).to.have.property('statusCode', 405) 21 | expect(res).to.have.nested.property('headers.allow', 'OPTIONS, POST') 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/ipfs-http-server/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "aegir/src/config/tsconfig.aegir.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "emitDeclarationOnly": true 6 | }, 7 | "include": [ 8 | "src", 9 | "package.json" 10 | ], 11 | "references": [ 12 | { 13 | "path": "../ipfs-core-types" 14 | }, 15 | { 16 | "path": "../ipfs-core-utils" 17 | }, 18 | { 19 | "path": "../ipfs-http-client" 20 | }, 21 | { 22 | "path": "../ipfs-http-gateway" 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-client/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | The `js-ipfs` project follows the [`IPFS Community Code of Conduct`](https://github.com/ipfs/community/blob/master/code-of-conduct.md) 4 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-client/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing guidelines 2 | 3 | IPFS as a project, including js-ipfs and all of its modules, follows the [standard IPFS Community contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md). 4 | 5 | We also adhere to the [IPFS JavaScript Community contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) which provide additional information of how to collaborate and contribute in the JavaScript implementation of IPFS. 6 | 7 | We appreciate your time and attention for going over these. Please open an issue on [ipfs/community](https://github.com/ipfs/community) if you have any question. 8 | 9 | Thank you. 10 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-client/COPYRIGHT: -------------------------------------------------------------------------------- 1 | This project is transitioning from an MIT-only license to a dual MIT/Apache-2.0 license. 2 | Unless otherwise noted, all code contributed prior to 2019-11-21 and not contributed by 3 | a user listed in [this signoff issue](https://github.com/ipfs/js-ipfs/issues/2624) is 4 | licensed under MIT-only. All new contributions (and past contributions since 2019-11-21) 5 | are licensed under a dual MIT/Apache-2.0 license. 6 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-client/LICENSE: -------------------------------------------------------------------------------- 1 | This project is dual licensed under MIT and Apache-2.0. 2 | 3 | MIT: https://www.opensource.org/licenses/mit 4 | Apache-2.0: https://www.apache.org/licenses/license-2.0 5 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-client/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 2 | 3 | http://www.apache.org/licenses/LICENSE-2.0 4 | 5 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 6 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-client/src/client/error.js: -------------------------------------------------------------------------------- 1 | 2 | export class TimeoutError extends Error { 3 | get name () { 4 | return this.constructor.name 5 | } 6 | } 7 | 8 | export class AbortError extends Error { 9 | get name () { 10 | return this.constructor.name 11 | } 12 | } 13 | 14 | export class DisconnectError extends Error { 15 | get name () { 16 | return this.constructor.name 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-client/src/interface.ts: -------------------------------------------------------------------------------- 1 | // This file contains some utility types that either can't be expressed in 2 | // JSDoc syntax or that result in a different behaviour when typed in JSDoc. 3 | 4 | export interface MessagePortClientOptions { 5 | transfer?: Set 6 | } 7 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-client/test/util/client.js: -------------------------------------------------------------------------------- 1 | /* eslint-env browser */ 2 | 3 | import { IPFSClient } from '../../src/index.js' 4 | 5 | export const activate = () => { 6 | const worker = new SharedWorker(process.env.IPFS_WORKER_URL, 'IPFSService') 7 | const client = IPFSClient.from(worker.port) 8 | return client 9 | } 10 | 11 | export const detached = () => { 12 | const client = IPFSClient.detached() 13 | return client 14 | } 15 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-client/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "aegir/src/config/tsconfig.aegir.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "emitDeclarationOnly": true 6 | }, 7 | "include": [ 8 | "src" 9 | ], 10 | "references": [ 11 | { 12 | "path": "../interface-ipfs-core" 13 | }, 14 | { 15 | "path": "../ipfs-core" 16 | }, 17 | { 18 | "path": "../ipfs-core-types" 19 | }, 20 | { 21 | "path": "../ipfs-message-port-protocol" 22 | }, 23 | { 24 | "path": "../ipfs-message-port-server" 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-protocol/.aegir.js: -------------------------------------------------------------------------------- 1 | 2 | /** @type {import('aegir').PartialOptions} */ 3 | export default { 4 | build: { 5 | bundlesizeMax: '547B' 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-protocol/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | The `js-ipfs` project follows the [`IPFS Community Code of Conduct`](https://github.com/ipfs/community/blob/master/code-of-conduct.md) 4 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-protocol/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing guidelines 2 | 3 | IPFS as a project, including js-ipfs and all of its modules, follows the [standard IPFS Community contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md). 4 | 5 | We also adhere to the [IPFS JavaScript Community contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) which provide additional information of how to collaborate and contribute in the JavaScript implementation of IPFS. 6 | 7 | We appreciate your time and attention for going over these. Please open an issue on [ipfs/community](https://github.com/ipfs/community) if you have any question. 8 | 9 | Thank you. 10 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-protocol/COPYRIGHT: -------------------------------------------------------------------------------- 1 | This project is transitioning from an MIT-only license to a dual MIT/Apache-2.0 license. 2 | Unless otherwise noted, all code contributed prior to 2019-11-21 and not contributed by 3 | a user listed in [this signoff issue](https://github.com/ipfs/js-ipfs/issues/2624) is 4 | licensed under MIT-only. All new contributions (and past contributions since 2019-11-21) 5 | are licensed under a dual MIT/Apache-2.0 license. 6 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-protocol/LICENSE: -------------------------------------------------------------------------------- 1 | This project is dual licensed under MIT and Apache-2.0. 2 | 3 | MIT: https://www.opensource.org/licenses/mit 4 | Apache-2.0: https://www.apache.org/licenses/license-2.0 5 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-protocol/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 2 | 3 | http://www.apache.org/licenses/LICENSE-2.0 4 | 5 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 6 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-protocol/src/data.ts: -------------------------------------------------------------------------------- 1 | export interface JSONObject { [key: string]: JSONValue } 2 | export type JSONArray = JSONValue[] 3 | export type JSONValue = 4 | | null 5 | | boolean 6 | | number 7 | | string 8 | | JSONArray 9 | | JSONObject 10 | 11 | export type Encoded<_Data, Representation> = Representation // eslint-disable-line @typescript-eslint/no-unused-vars 12 | export type StringEncoded = Encoded 13 | 14 | export type Result = { ok: true, value: T } | { ok: false, error: X } 15 | 16 | export interface EncodedError { 17 | message: string 18 | name: string 19 | stack: string 20 | } 21 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-protocol/src/files.ts: -------------------------------------------------------------------------------- 1 | import type { Mtime } from 'ipfs-unixfs' 2 | import type { EncodedCID } from './cid' 3 | 4 | export interface EncodedStat { 5 | cid: EncodedCID 6 | size: number 7 | cumulativeSize: number 8 | type: 'directory' | 'file' 9 | blocks: number 10 | withLocality: boolean 11 | local?: boolean 12 | sizeLocal?: number 13 | mode?: number 14 | mtime?: Mtime 15 | } 16 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-protocol/src/index.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ipfs/js-ipfs/bf1bc8b18d750d5591bdd575a6d0f4c067d61d0a/packages/ipfs-message-port-protocol/src/index.js -------------------------------------------------------------------------------- /packages/ipfs-message-port-protocol/test/browser.js: -------------------------------------------------------------------------------- 1 | 2 | import './cid.browser.js' 3 | import './block.browser.js' 4 | import './dag.browser.js' 5 | import './core.browser.js' 6 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-protocol/test/node.js: -------------------------------------------------------------------------------- 1 | 2 | import './cid.spec.js' 3 | import './dag.spec.js' 4 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-protocol/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "aegir/src/config/tsconfig.aegir.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "emitDeclarationOnly": true 6 | }, 7 | "include": [ 8 | "src" 9 | ], 10 | "references": [ 11 | { 12 | "path": "../ipfs-core-types" 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-server/.aegir.js: -------------------------------------------------------------------------------- 1 | 2 | /** @type {import('aegir').PartialOptions} */ 3 | export default { 4 | build: { 5 | bundlesizeMax: '8KB' 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-server/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | The `js-ipfs` project follows the [`IPFS Community Code of Conduct`](https://github.com/ipfs/community/blob/master/code-of-conduct.md) 4 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-server/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing guidelines 2 | 3 | IPFS as a project, including js-ipfs and all of its modules, follows the [standard IPFS Community contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md). 4 | 5 | We also adhere to the [IPFS JavaScript Community contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) which provide additional information of how to collaborate and contribute in the JavaScript implementation of IPFS. 6 | 7 | We appreciate your time and attention for going over these. Please open an issue on [ipfs/community](https://github.com/ipfs/community) if you have any question. 8 | 9 | Thank you. 10 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-server/COPYRIGHT: -------------------------------------------------------------------------------- 1 | This project is transitioning from an MIT-only license to a dual MIT/Apache-2.0 license. 2 | Unless otherwise noted, all code contributed prior to 2019-11-21 and not contributed by 3 | a user listed in [this signoff issue](https://github.com/ipfs/js-ipfs/issues/2624) is 4 | licensed under MIT-only. All new contributions (and past contributions since 2019-11-21) 5 | are licensed under a dual MIT/Apache-2.0 license. 6 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-server/LICENSE: -------------------------------------------------------------------------------- 1 | This project is dual licensed under MIT and Apache-2.0. 2 | 3 | MIT: https://www.opensource.org/licenses/mit 4 | Apache-2.0: https://www.apache.org/licenses/license-2.0 5 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-server/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 2 | 3 | http://www.apache.org/licenses/LICENSE-2.0 4 | 5 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 6 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-server/src/index.js: -------------------------------------------------------------------------------- 1 | 2 | /* eslint-env browser */ 3 | 4 | export { DAGService } from './dag.js' 5 | export { CoreService } from './core.js' 6 | export { FilesService } from './files.js' 7 | export { BlockService } from './block.js' 8 | export { IPFSService } from './service.js' 9 | export { Server } from './server.js' 10 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-server/src/service.js: -------------------------------------------------------------------------------- 1 | 2 | /* eslint-env browser */ 3 | 4 | import { DAGService } from './dag.js' 5 | import { CoreService } from './core.js' 6 | import { FilesService } from './files.js' 7 | import { BlockService } from './block.js' 8 | 9 | /** 10 | * @typedef {import('ipfs-core-types').IPFS} IPFS 11 | */ 12 | 13 | export class IPFSService { 14 | /** 15 | * @param {IPFS} ipfs 16 | */ 17 | constructor (ipfs) { 18 | this.dag = new DAGService(ipfs) 19 | this.core = new CoreService(ipfs) 20 | this.files = new FilesService(ipfs) 21 | this.block = new BlockService(ipfs) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-server/test/node.js: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /packages/ipfs-message-port-server/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "aegir/src/config/tsconfig.aegir.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "emitDeclarationOnly": true 6 | }, 7 | "include": [ 8 | "src" 9 | ], 10 | "references": [ 11 | { 12 | "path": "../ipfs-core-types" 13 | }, 14 | { 15 | "path": "../ipfs-message-port-protocol" 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /packages/ipfs/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | The `js-ipfs` project follows the [`IPFS Community Code of Conduct`](https://github.com/ipfs/community/blob/master/code-of-conduct.md) 4 | -------------------------------------------------------------------------------- /packages/ipfs/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing guidelines 2 | 3 | IPFS as a project, including js-ipfs and all of its modules, follows the [standard IPFS Community contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md). 4 | 5 | We also adhere to the [IPFS JavaScript Community contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) which provide additional information of how to collaborate and contribute in the JavaScript implementation of IPFS. 6 | 7 | We appreciate your time and attention for going over these. Please open an issue on [ipfs/community](https://github.com/ipfs/community) if you have any question. 8 | 9 | Thank you. 10 | -------------------------------------------------------------------------------- /packages/ipfs/COPYRIGHT: -------------------------------------------------------------------------------- 1 | This project is transitioning from an MIT-only license to a dual MIT/Apache-2.0 license. 2 | Unless otherwise noted, all code contributed prior to 2019-11-21 and not contributed by 3 | a user listed in [this signoff issue](https://github.com/ipfs/js-ipfs/issues/2624) is 4 | licensed under MIT-only. All new contributions (and past contributions since 2019-11-21) 5 | are licensed under a dual MIT/Apache-2.0 license. 6 | -------------------------------------------------------------------------------- /packages/ipfs/LICENSE: -------------------------------------------------------------------------------- 1 | This project is dual licensed under MIT and Apache-2.0. 2 | 3 | MIT: https://www.opensource.org/licenses/mit 4 | Apache-2.0: https://www.apache.org/licenses/license-2.0 5 | -------------------------------------------------------------------------------- /packages/ipfs/LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 2 | 3 | http://www.apache.org/licenses/LICENSE-2.0 4 | 5 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 6 | -------------------------------------------------------------------------------- /packages/ipfs/Makefile: -------------------------------------------------------------------------------- 1 | all: help 2 | 3 | test: test_expensive 4 | 5 | test_short: test_sharness_short 6 | 7 | test_expensive: test_sharness_expensive 8 | 9 | test_sharness_short: 10 | $(MAKE) -j1 -C test/sharness/ 11 | 12 | test_sharness_expensive: 13 | TEST_EXPENSIVE=1 $(MAKE) -j1 -C test/sharness/ 14 | 15 | help: 16 | @echo 'TESTING TARGETS:' 17 | @echo '' 18 | @echo ' test - Run expensive tests' 19 | @echo ' test_short - Run short tests and sharness tests' 20 | @echo ' test_expensive - Run a few extras' 21 | @echo ' test_sharness_short' 22 | @echo ' test_sharness_expensive' 23 | @echo '' 24 | -------------------------------------------------------------------------------- /packages/ipfs/init-and-daemon.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | 3 | set -e 4 | 5 | if [ -n "$IPFS_PATH" ]; then 6 | echo "Using $IPFS_PATH as IPFS repository" 7 | else 8 | echo "You need to set IPFS_PATH environment variable to use this script" 9 | exit 1 10 | fi 11 | 12 | # Initialize the repo but ignore if error if it already exists 13 | # This can be the case when we restart a container without stopping/removing it 14 | node src/cli.js init || true 15 | 16 | if [ -n "$IPFS_API_HOST" ]; then 17 | sed -i.bak "s/127.0.0.1/$IPFS_API_HOST/g" $IPFS_PATH/config 18 | fi 19 | 20 | node src/cli.js daemon 21 | -------------------------------------------------------------------------------- /packages/ipfs/maintainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "repoLeadMaintainer": { 3 | "name": "Alan Shaw", 4 | "email": "alan.shaw@protocol.ai", 5 | "username": "alanshaw" 6 | }, 7 | "workingGroup": { 8 | "name": "JS IPFS", 9 | "entryPoint": "https://github.com/ipfs/js-core" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/ipfs/scripts/update-version.js: -------------------------------------------------------------------------------- 1 | import { readFile, writeFile } from 'fs/promises' 2 | 3 | const pkg = JSON.parse( 4 | await readFile( 5 | new URL('../package.json', import.meta.url) 6 | ) 7 | ) 8 | 9 | await writeFile( 10 | new URL('../src/package.js', import.meta.url), 11 | ` 12 | export const name = '${pkg.name}' 13 | export const version = '${pkg.version}' 14 | export const node = '${pkg.engines.node}' 15 | ` 16 | ) 17 | -------------------------------------------------------------------------------- /packages/ipfs/src/index.js: -------------------------------------------------------------------------------- 1 | import { 2 | create as createImport, 3 | globSource as globSourceImport, 4 | urlSource as urlSourceImport 5 | } from 'ipfs-core' 6 | import { 7 | path as pathImport 8 | } from './path.js' 9 | 10 | /** 11 | * @typedef {import('ipfs-core-types').IPFS} IPFS 12 | */ 13 | 14 | export const create = createImport 15 | export const globSource = globSourceImport 16 | export const urlSource = urlSourceImport 17 | export const path = pathImport 18 | -------------------------------------------------------------------------------- /packages/ipfs/src/package.js: -------------------------------------------------------------------------------- 1 | 2 | export const name = 'ipfs' 3 | export const version = '0.62.2' 4 | export const node = '>=15.0.0' 5 | -------------------------------------------------------------------------------- /packages/ipfs/src/path.browser.js: -------------------------------------------------------------------------------- 1 | 2 | export function path () { 3 | throw new Error('Not supported in browsers') 4 | } 5 | -------------------------------------------------------------------------------- /packages/ipfs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "aegir/src/config/tsconfig.aegir.json", 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "emitDeclarationOnly": true 6 | }, 7 | "include": [ 8 | "src", 9 | "test", 10 | "package.json" 11 | ], 12 | "references": [ 13 | { 14 | "path": "../interface-ipfs-core" 15 | }, 16 | { 17 | "path": "../ipfs-cli" 18 | }, 19 | { 20 | "path": "../ipfs-client" 21 | }, 22 | { 23 | "path": "../ipfs-core" 24 | }, 25 | { 26 | "path": "../ipfs-core-types" 27 | }, 28 | { 29 | "path": "../ipfs-http-client" 30 | } 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /scripts/node-globals.js: -------------------------------------------------------------------------------- 1 | // @ts-nocheck 2 | export const { Buffer } = require('buffer') 3 | export const process = require('process/browser') 4 | --------------------------------------------------------------------------------