├── ci
├── jenkins
└── Dockerfile
├── test
├── .gitignore
├── fixtures
│ ├── go-ipfs-repo
│ │ ├── datastore
│ │ │ ├── LOCK
│ │ │ ├── CURRENT
│ │ │ ├── 000002.ldb
│ │ │ ├── 000005.ldb
│ │ │ ├── 000010.ldb
│ │ │ ├── MANIFEST-000014
│ │ │ ├── LOG.old
│ │ │ └── LOG
│ │ ├── version
│ │ └── blocks
│ │ │ ├── 75
│ │ │ └── CIQMB7DLJFKD267QJ2B5FJNHZPTSVA7IB6OHXSQ2XSVEEKMKK6RT75I.data
│ │ │ ├── SHARDING
│ │ │ ├── QV
│ │ │ └── CIQOHMGEIKMPYHAUTL57JSEZN64SIJ5OIHSGJG4TJSSJLGI3PBJLQVI.data
│ │ │ ├── X3
│ │ │ └── CIQFTFEEHEDF6KLBT32BFAGLXEZL4UWFNWM4LFTLMXQBCERZ6CMLX3Y.data
│ │ │ ├── YD
│ │ │ └── CIQENVCICS44LLYUDQ5KVN6ALXC6QRHK2X4R6EUFRMBB5OSFO2FUYDQ.data
│ │ │ ├── 2F
│ │ │ └── CIQEUWUVLBXVFYSYCHHSCRTXCYHGIOBXKWUMKFR3UPAFHQ5WK5362FQ.data
│ │ │ ├── 5V
│ │ │ └── CIQFFRR4O52TS2Z7QLDDTF32OIR4FWLKT5YLL7MLDVIT7DC3NHOK5VA.data
│ │ │ ├── 5X
│ │ │ └── CIQJ23BL4UHXA2KTI6NLTXZM4PW4VEFWQBJ4ACZQAS37BLGL4HUO5XY.data
│ │ │ ├── 7J
│ │ │ └── CIQKKLBWAIBQZOIS5X7E32LQAL6236OUKZTMHPQSFIXPWXNZHQOV7JQ.data
│ │ │ ├── AE
│ │ │ └── CIQONICFQZH7QVU6IPSIM3AK7AD554D3BWZPAGEAQYQOWMFZQDUUAEI.data
│ │ │ ├── AP
│ │ │ └── CIQHAKDLTL5GMIFGN5YVY4BA22FPHUIODJEXS4LCTQDWA275XAJDAPI.data
│ │ │ ├── C4
│ │ │ └── CIQDDZ5EDQK5AP7LRTLZHQZUR2R3GECRFV3WPKNL7PL2SKFIL2LXC4Y.data
│ │ │ ├── CY
│ │ │ └── CIQDMKFEUGKSLXMEXO774EZOYCYNHPRVFD53ZSAU7237F67XDSQGCYQ.data
│ │ │ ├── DU
│ │ │ └── CIQLBK52T5EHVHZY5URTG5JS3JCUJDQM2DRB5RVF33DCUUOFJNGVDUI.data
│ │ │ ├── DX
│ │ │ └── CIQPDQJBGYDZNMOAGGYNRNMP2VDKWBWGAEDDEJDACM3SGG3VIANDDXI.data
│ │ │ ├── FN
│ │ │ └── CIQIXBZMUTXFC5QIGMLJNXLLHZOPGSL2PBC65D4UIVWM6TI5F5TAFNI.data
│ │ │ ├── GQ
│ │ │ └── CIQH7OEYWXL34RWYL7VXLWEU4FWPVGT24VJT7DUZPTNLF25N25IGGQA.data
│ │ │ ├── HD
│ │ │ └── CIQDDVW2EZIJF4NQH7WJNESD7XHQSXA5EGJVNTPVHD7444C2KLKXHDI.data
│ │ │ ├── IL
│ │ │ └── CIQJFGRQHQ45VCQLM7AJNF2GF5UHUAGGHC6LLAH6VYDEKLQMD4QLILY.data
│ │ │ ├── IR
│ │ │ └── CIQERMRAAFXUAUOX3V2DCW7R77FRIVHQ3V5OIPPS3XQBX34KRPNOIRQ.data
│ │ │ ├── LG
│ │ │ └── CIQJBQD2O6K4CGJVCCTJNUP57QHR4SKHZ74OIITBBGLOMCO3ZOLWLGA.data
│ │ │ ├── M4
│ │ │ └── CIQOLBQZSZAODJGGH6RYYVBUXHTS3SM5EORZDU63LYPEFUAFE4SBM4I.data
│ │ │ ├── O6
│ │ │ └── CIQOYW2THIZBRGI7IN33ROGCKOFZLXJJ2MPKYZBTV4H3N7GYHXMAO6A.data
│ │ │ ├── QF
│ │ │ └── CIQGPALRQ24P6NS4OWHTQ7R247ZI7KJWP3QWPQYS43LFULQC5ANLQFI.data
│ │ │ ├── R3
│ │ │ └── CIQBED3K6YA5I3QQWLJOCHWXDRK5EXZQILBCKAPEDUJENZ5B5HJ5R3A.data
│ │ │ ├── S5
│ │ │ └── CIQHBGZNZRPWVEFNMTLP4OS5EAVHFMCX2HD7FZUC2B3WUU3D4LGKS5A.data
│ │ │ ├── SW
│ │ │ └── CIQHPUVCWD6JA6AFUVD6VA64TGWP67KYA3AIMBUMVWGZ5AQN2L2HSWQ.data
│ │ │ ├── TW
│ │ │ └── CIQFEAGMNNXXTYKYQSANT6IBNTFN7WR5RPD5F6GN6MBKUUO25DNOTWQ.data
│ │ │ ├── UN
│ │ │ └── CIQOMBKARLB7PAITVSNH7VEGIQJRPL6J7FT2XYVKAXT4MQPXXPUYUNY.data
│ │ │ ├── UW
│ │ │ └── CIQDVKITASFS55MC2TXCX5XMZLMGTYVODWPEDIW7JYEG7YXBIA7IUWY.data
│ │ │ ├── VO
│ │ │ └── CIQGFTQ7FSI2COUXWWLOQ45VUM2GUZCGAXLWCTOKKPGTUWPXHBNIVOY.data
│ │ │ ├── XO
│ │ │ └── CIQJGO2B2N75IUEM372FSMG76VV256I4PXBULZZ5ASNLK4FL4EG7XOI.data
│ │ │ ├── ZF
│ │ │ └── CIQLBS5HG4PRCRQ7O4EBXFD5QN6MTI5YBYMCVQJDXPKCOVR6RMLHZFQ.data
│ │ │ └── _README
│ └── test-data
│ │ ├── hello
│ │ ├── recursive-get-dir
│ │ ├── datastore
│ │ │ ├── LOCK
│ │ │ ├── CURRENT
│ │ │ ├── 000002.ldb
│ │ │ ├── 000005.ldb
│ │ │ ├── 000010.ldb
│ │ │ ├── MANIFEST-000014
│ │ │ ├── LOG.old
│ │ │ └── LOG
│ │ ├── version
│ │ ├── init-docs
│ │ │ ├── docs
│ │ │ │ └── index
│ │ │ ├── contact
│ │ │ ├── help
│ │ │ ├── readme
│ │ │ ├── tour
│ │ │ │ └── 0.0-intro
│ │ │ └── security-notes
│ │ └── blocks
│ │ │ ├── CIQOH
│ │ │ └── CIQOHMGEIKMPYHAUTL57JSEZN64SIJ5OIHSGJG4TJSSJLGI3PBJLQVI.data
│ │ │ ├── CIQFT
│ │ │ └── CIQFTFEEHEDF6KLBT32BFAGLXEZL4UWFNWM4LFTLMXQBCERZ6CMLX3Y.data
│ │ │ ├── CIQEN
│ │ │ └── CIQENVCICS44LLYUDQ5KVN6ALXC6QRHK2X4R6EUFRMBB5OSFO2FUYDQ.data
│ │ │ ├── CIQEU
│ │ │ └── CIQEUWUVLBXVFYSYCHHSCRTXCYHGIOBXKWUMKFR3UPAFHQ5WK5362FQ.data
│ │ │ ├── CIQBE
│ │ │ └── CIQBED3K6YA5I3QQWLJOCHWXDRK5EXZQILBCKAPEDUJENZ5B5HJ5R3A.data
│ │ │ ├── CIQDD
│ │ │ ├── CIQDDVW2EZIJF4NQH7WJNESD7XHQSXA5EGJVNTPVHD7444C2KLKXHDI.data
│ │ │ └── CIQDDZ5EDQK5AP7LRTLZHQZUR2R3GECRFV3WPKNL7PL2SKFIL2LXC4Y.data
│ │ │ ├── CIQDM
│ │ │ └── CIQDMKFEUGKSLXMEXO774EZOYCYNHPRVFD53ZSAU7237F67XDSQGCYQ.data
│ │ │ ├── CIQDV
│ │ │ └── CIQDVKITASFS55MC2TXCX5XMZLMGTYVODWPEDIW7JYEG7YXBIA7IUWY.data
│ │ │ ├── CIQER
│ │ │ └── CIQERMRAAFXUAUOX3V2DCW7R77FRIVHQ3V5OIPPS3XQBX34KRPNOIRQ.data
│ │ │ ├── CIQFE
│ │ │ └── CIQFEAGMNNXXTYKYQSANT6IBNTFN7WR5RPD5F6GN6MBKUUO25DNOTWQ.data
│ │ │ ├── CIQFF
│ │ │ └── CIQFFRR4O52TS2Z7QLDDTF32OIR4FWLKT5YLL7MLDVIT7DC3NHOK5VA.data
│ │ │ ├── CIQGF
│ │ │ └── CIQGFTQ7FSI2COUXWWLOQ45VUM2GUZCGAXLWCTOKKPGTUWPXHBNIVOY.data
│ │ │ ├── CIQGP
│ │ │ └── CIQGPALRQ24P6NS4OWHTQ7R247ZI7KJWP3QWPQYS43LFULQC5ANLQFI.data
│ │ │ ├── CIQH7
│ │ │ └── CIQH7OEYWXL34RWYL7VXLWEU4FWPVGT24VJT7DUZPTNLF25N25IGGQA.data
│ │ │ ├── CIQHA
│ │ │ └── CIQHAKDLTL5GMIFGN5YVY4BA22FPHUIODJEXS4LCTQDWA275XAJDAPI.data
│ │ │ ├── CIQHB
│ │ │ └── CIQHBGZNZRPWVEFNMTLP4OS5EAVHFMCX2HD7FZUC2B3WUU3D4LGKS5A.data
│ │ │ ├── CIQHP
│ │ │ └── CIQHPUVCWD6JA6AFUVD6VA64TGWP67KYA3AIMBUMVWGZ5AQN2L2HSWQ.data
│ │ │ ├── CIQIX
│ │ │ └── CIQIXBZMUTXFC5QIGMLJNXLLHZOPGSL2PBC65D4UIVWM6TI5F5TAFNI.data
│ │ │ ├── CIQJ2
│ │ │ └── CIQJ23BL4UHXA2KTI6NLTXZM4PW4VEFWQBJ4ACZQAS37BLGL4HUO5XY.data
│ │ │ ├── CIQJB
│ │ │ └── CIQJBQD2O6K4CGJVCCTJNUP57QHR4SKHZ74OIITBBGLOMCO3ZOLWLGA.data
│ │ │ ├── CIQJF
│ │ │ └── CIQJFGRQHQ45VCQLM7AJNF2GF5UHUAGGHC6LLAH6VYDEKLQMD4QLILY.data
│ │ │ ├── CIQJG
│ │ │ └── CIQJGO2B2N75IUEM372FSMG76VV256I4PXBULZZ5ASNLK4FL4EG7XOI.data
│ │ │ ├── CIQKK
│ │ │ └── CIQKKLBWAIBQZOIS5X7E32LQAL6236OUKZTMHPQSFIXPWXNZHQOV7JQ.data
│ │ │ ├── CIQLB
│ │ │ ├── CIQLBK52T5EHVHZY5URTG5JS3JCUJDQM2DRB5RVF33DCUUOFJNGVDUI.data
│ │ │ └── CIQLBS5HG4PRCRQ7O4EBXFD5QN6MTI5YBYMCVQJDXPKCOVR6RMLHZFQ.data
│ │ │ ├── CIQMB
│ │ │ └── CIQMB7DLJFKD267QJ2B5FJNHZPTSVA7IB6OHXSQ2XSVEEKMKK6RT75I.data
│ │ │ ├── CIQOL
│ │ │ └── CIQOLBQZSZAODJGGH6RYYVBUXHTS3SM5EORZDU63LYPEFUAFE4SBM4I.data
│ │ │ ├── CIQOM
│ │ │ └── CIQOMBKARLB7PAITVSNH7VEGIQJRPL6J7FT2XYVKAXT4MQPXXPUYUNY.data
│ │ │ ├── CIQON
│ │ │ └── CIQONICFQZH7QVU6IPSIM3AK7AD554D3BWZPAGEAQYQOWMFZQDUUAEI.data
│ │ │ ├── CIQOY
│ │ │ └── CIQOYW2THIZBRGI7IN33ROGCKOFZLXJJ2MPKYZBTV4H3N7GYHXMAO6A.data
│ │ │ └── CIQPD
│ │ │ └── CIQPDQJBGYDZNMOAGGYNRNMP2VDKWBWGAEDDEJDACM3SGG3VIANDDXI.data
│ │ ├── badconfig
│ │ ├── badnode.json
│ │ ├── no-newline
│ │ ├── eth-block
│ │ └── node.json
├── gateway
│ └── test-folder
│ │ ├── nested-folder
│ │ ├── hello.txt
│ │ ├── ipfs.txt
│ │ └── nested.html
│ │ ├── cat-folder
│ │ └── cat.jpg
│ │ └── index.html
├── sharness
│ ├── .gitignore
│ ├── lib
│ │ ├── test-lib-hashes.sh
│ │ └── iptb-lib.sh
│ ├── t0000-sharness.sh
│ ├── t0022-init-default.sh
│ ├── Makefile
│ └── t0020-init.sh
├── interop
│ ├── node.js
│ └── browser.js
├── cli
│ ├── index.js
│ ├── general.js
│ ├── progress-bar.js
│ ├── commands.js
│ ├── version.js
│ ├── id.js
│ ├── dag.js
│ ├── bitswap.js
│ └── file.js
├── utils
│ ├── clean.js
│ ├── interop-daemon-spawner
│ │ └── util.js
│ ├── create-repo-browser.js
│ ├── create-repo-nodejs.js
│ ├── ipfs-factory-instance
│ │ ├── default-config.json
│ │ └── index.js
│ └── ipfs-factory-daemon
│ │ └── default-config.json
├── core
│ └── interface
│ │ ├── block.js
│ │ ├── dag.js
│ │ ├── files.js
│ │ ├── pubsub.js
│ │ ├── config.js
│ │ ├── object.js
│ │ ├── swarm.js
│ │ ├── generic.js
│ │ ├── interface.spec.js
│ │ └── dht.js
├── http-api
│ ├── interface
│ │ ├── block.js
│ │ ├── files.js
│ │ ├── swarm.js
│ │ ├── config.js
│ │ ├── object.js
│ │ └── pubsub.js
│ ├── over-ipfs-api
│ │ ├── version.js
│ │ └── id.js
│ ├── spec
│ │ ├── version.js
│ │ ├── bitswap.js
│ │ ├── id.js
│ │ └── files.js
│ └── index.js
└── bootstrapers.js
├── .dockerignore
├── examples
├── run-in-electron
│ ├── renderer.js
│ ├── index.html
│ ├── README.md
│ ├── package.json
│ ├── build.sh
│ └── main.js
├── browser-browserify
│ ├── .gitignore
│ ├── img
│ │ ├── 1.png
│ │ └── 2.png
│ ├── README.md
│ ├── package.json
│ ├── public
│ │ └── index.html
│ └── src
│ │ └── index.js
├── exchange-files-in-browser
│ ├── .gitignore
│ ├── img
│ │ ├── final.png
│ │ ├── connect-1.png
│ │ ├── connect-2.png
│ │ ├── diagram.monopic
│ │ ├── fetch-files-1.png
│ │ ├── fetch-files-2.png
│ │ └── diagram.txt
│ ├── public
│ │ └── favicon.ico
│ └── package.json
├── browser-webpack
│ ├── .gitignore
│ ├── .babelrc
│ ├── img
│ │ └── 1.png
│ ├── index.html
│ ├── src
│ │ └── components
│ │ │ └── index.js
│ ├── .eslintrc
│ ├── server.js
│ ├── README.md
│ ├── package.json
│ └── webpack.config.js
├── ipfs-101
│ ├── hello.txt
│ ├── package.json
│ └── 1.js
├── traverse-ipld-graphs
│ ├── git-objects
│ │ ├── 177bf18bc707d82b21cdefd0b43b38fc8c5c13fe
│ │ ├── 23cc25f631cb076d5de5036c87678ea713cbaa6a
│ │ ├── ee71cef5001b84b0314438f76cf0acd338a2fd21
│ │ ├── 4e425dba7745a781f0712c9a01455899e8c0c249
│ │ ├── a5095353cd62a178663dd26efc2d61f4f61bccbe
│ │ ├── dc9bd15e8b81b6565d3736f9c308bd1bba60f33a
│ │ ├── ee62b3d206cb23f939208898f32d8708c0e3fa3c
│ │ ├── 6850c7be7136e6be00976ddbae80671b945c3e9d
│ │ ├── 0f328c91df28c5c01b9e9f9f7e663191fa156593
│ │ └── e68e6f6e31857877a79fd6b3956898436bb5a76f
│ ├── eth-blocks
│ │ ├── block_302515
│ │ ├── block_302516
│ │ └── block_302517
│ ├── create-node.js
│ ├── put.js
│ ├── get.js
│ ├── get-path.js
│ ├── README.md
│ ├── tree.js
│ ├── get-path-accross-formats.js
│ └── eth.js
├── explore-ethereum-blockchain
│ ├── eth-stuffs
│ │ ├── block_302515
│ │ ├── block_302516
│ │ ├── block_302517
│ │ ├── state_0_302516
│ │ ├── state_r_302516
│ │ ├── state_000_302516
│ │ ├── state_00_302516
│ │ ├── state_000017_302516
│ │ ├── state_00001_302516
│ │ └── state_0000_302516
│ ├── load-eth-stuffs.sh
│ └── README.md
├── ipfs-cli-fun
│ └── README.md
├── browser-script-tag
│ └── README.md
└── browser-video-streaming
│ ├── index.html
│ └── streaming.js
├── src
├── http
│ ├── api
│ │ ├── resources
│ │ │ ├── repo.js
│ │ │ ├── version.js
│ │ │ ├── id.js
│ │ │ ├── index.js
│ │ │ └── bitswap.js
│ │ └── routes
│ │ │ ├── id.js
│ │ │ ├── repo.js
│ │ │ ├── version.js
│ │ │ ├── file.js
│ │ │ ├── index.js
│ │ │ ├── bitswap.js
│ │ │ ├── pubsub.js
│ │ │ ├── config.js
│ │ │ ├── debug.js
│ │ │ ├── block.js
│ │ │ ├── bootstrap.js
│ │ │ ├── files.js
│ │ │ └── swarm.js
│ ├── gateway
│ │ ├── resources
│ │ │ └── index.js
│ │ ├── routes
│ │ │ ├── index.js
│ │ │ └── gateway.js
│ │ └── utils
│ │ │ └── path.js
│ └── error-handler.js
├── init-files
│ └── init-docs
│ │ ├── docs
│ │ └── index
│ │ ├── contact
│ │ ├── help
│ │ ├── readme
│ │ ├── tour
│ │ └── 0.0-intro
│ │ └── security-notes
├── index.js
├── core
│ ├── utils.js
│ ├── runtime
│ │ ├── repo-browser.js
│ │ ├── repo-nodejs.js
│ │ ├── libp2p-browser.js
│ │ ├── config-browser.json
│ │ ├── config-nodejs.json
│ │ └── libp2p-nodejs.js
│ ├── components
│ │ ├── is-online.js
│ │ ├── ping.js
│ │ ├── repo.js
│ │ ├── version.js
│ │ ├── config.js
│ │ ├── id.js
│ │ ├── index.js
│ │ ├── bitswap.js
│ │ ├── stop.js
│ │ ├── pre-start.js
│ │ ├── init-assets.js
│ │ └── start.js
│ └── state.js
└── cli
│ └── commands
│ ├── repo
│ ├── gc.js
│ ├── init.js
│ └── version.js
│ ├── bitswap
│ ├── unwant.js
│ ├── wantlist.js
│ └── stat.js
│ ├── pubsub.js
│ ├── repo.js
│ ├── swarm.js
│ ├── block.js
│ ├── dag.js
│ ├── object.js
│ ├── bootstrap.js
│ ├── file.js
│ ├── object
│ ├── patch.js
│ ├── data.js
│ ├── new.js
│ ├── links.js
│ ├── stat.js
│ ├── patch
│ │ ├── add-link.js
│ │ ├── rm-link.js
│ │ ├── set-data.js
│ │ └── append-data.js
│ ├── get.js
│ └── put.js
│ ├── bitswap.js
│ ├── files.js
│ ├── pubsub
│ ├── pub.js
│ ├── peers.js
│ ├── ls.js
│ └── sub.js
│ ├── bootstrap
│ ├── list.js
│ ├── add.js
│ └── rm.js
│ ├── block
│ ├── get.js
│ ├── stat.js
│ └── rm.js
│ ├── id.js
│ ├── files
│ └── cat.js
│ ├── file
│ └── ls.js
│ ├── config
│ ├── show.js
│ └── replace.js
│ ├── swarm
│ ├── connect.js
│ ├── disconnect.js
│ ├── addrs.js
│ ├── addrs
│ │ └── local.js
│ └── peers.js
│ ├── version.js
│ ├── commands.js
│ ├── init.js
│ ├── daemon.js
│ ├── dag
│ └── get.js
│ ├── ls.js
│ └── config.js
├── img
├── core.png
├── core.monopic
├── overview.png
├── overview.monopic
└── overview.txt
├── init-and-daemon.sh
├── CODE_OF_CONDUCT.md
├── appveyor.yml
├── Dockerfile
├── .travis.yml
├── Makefile
├── RELEASE.md
├── .npmignore
├── CONTRIBUTING.md
├── .gitignore
├── circle.yml
└── LICENSE
/ci/jenkins:
--------------------------------------------------------------------------------
1 | javascript
2 |
--------------------------------------------------------------------------------
/test/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 |
--------------------------------------------------------------------------------
/.dockerignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 |
--------------------------------------------------------------------------------
/examples/run-in-electron/renderer.js:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/datastore/LOCK:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/version:
--------------------------------------------------------------------------------
1 | 5
2 |
--------------------------------------------------------------------------------
/examples/browser-browserify/.gitignore:
--------------------------------------------------------------------------------
1 | bundle.js
--------------------------------------------------------------------------------
/src/http/api/resources/repo.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
--------------------------------------------------------------------------------
/src/init-files/init-docs/docs/index:
--------------------------------------------------------------------------------
1 | Index
2 |
--------------------------------------------------------------------------------
/test/fixtures/test-data/hello:
--------------------------------------------------------------------------------
1 | hello world
2 |
--------------------------------------------------------------------------------
/ci/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM quay.io/ipfs/js-base:6.9.4
2 |
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/datastore/LOCK:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/version:
--------------------------------------------------------------------------------
1 | 4
2 |
--------------------------------------------------------------------------------
/test/gateway/test-folder/nested-folder/hello.txt:
--------------------------------------------------------------------------------
1 | Hello
2 |
--------------------------------------------------------------------------------
/test/gateway/test-folder/nested-folder/ipfs.txt:
--------------------------------------------------------------------------------
1 | IPFS
2 |
--------------------------------------------------------------------------------
/test/fixtures/test-data/badconfig:
--------------------------------------------------------------------------------
1 | {
2 | bad config
3 | }
4 |
--------------------------------------------------------------------------------
/examples/exchange-files-in-browser/.gitignore:
--------------------------------------------------------------------------------
1 | public/js/ipfs.js
2 |
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/datastore/CURRENT:
--------------------------------------------------------------------------------
1 | MANIFEST-000014
2 |
--------------------------------------------------------------------------------
/test/fixtures/test-data/badnode.json:
--------------------------------------------------------------------------------
1 | {
2 | bad config
3 | }
4 |
--------------------------------------------------------------------------------
/test/fixtures/test-data/no-newline:
--------------------------------------------------------------------------------
1 | there is no newline at end of this file
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/init-docs/docs/index:
--------------------------------------------------------------------------------
1 | Index
2 |
--------------------------------------------------------------------------------
/img/core.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/img/core.png
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/SHARDING:
--------------------------------------------------------------------------------
1 | /repo/flatfs/shard/v1/next-to-last/2
2 |
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/datastore/CURRENT:
--------------------------------------------------------------------------------
1 | MANIFEST-000014
2 |
--------------------------------------------------------------------------------
/img/core.monopic:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/img/core.monopic
--------------------------------------------------------------------------------
/img/overview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/img/overview.png
--------------------------------------------------------------------------------
/examples/browser-webpack/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | npm-debug.log
3 | .DS_Store
4 | dist
5 |
--------------------------------------------------------------------------------
/examples/ipfs-101/hello.txt:
--------------------------------------------------------------------------------
1 | Hello, how are you today? Welcome to the Distributed Web!
2 |
--------------------------------------------------------------------------------
/img/overview.monopic:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/img/overview.monopic
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/QV/CIQOHMGEIKMPYHAUTL57JSEZN64SIJ5OIHSGJG4TJSSJLGI3PBJLQVI.data:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/sharness/.gitignore:
--------------------------------------------------------------------------------
1 | !/lib/
2 | lib/sharness/
3 | test-results/
4 | trash directory.*.sh/
5 |
--------------------------------------------------------------------------------
/examples/browser-webpack/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | "stage-0",
4 | "react"
5 | ]
6 | }
7 |
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/git-objects/177bf18bc707d82b21cdefd0b43b38fc8c5c13fe:
--------------------------------------------------------------------------------
1 | blob 14 Git IPLD demo
2 |
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/X3/CIQFTFEEHEDF6KLBT32BFAGLXEZL4UWFNWM4LFTLMXQBCERZ6CMLX3Y.data:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const IPFS = require('./core')
4 |
5 | exports = module.exports = IPFS
6 |
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/git-objects/23cc25f631cb076d5de5036c87678ea713cbaa6a:
--------------------------------------------------------------------------------
1 | blob 21 echo 'Hello, World!'
2 |
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/git-objects/ee71cef5001b84b0314438f76cf0acd338a2fd21:
--------------------------------------------------------------------------------
1 | blob 20 echo 'hello world!'
2 |
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQOH/CIQOHMGEIKMPYHAUTL57JSEZN64SIJ5OIHSGJG4TJSSJLGI3PBJLQVI.data:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/examples/browser-webpack/img/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/examples/browser-webpack/img/1.png
--------------------------------------------------------------------------------
/src/http/gateway/resources/index.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = {
4 | gateway: require('./gateway')
5 | }
6 |
--------------------------------------------------------------------------------
/test/fixtures/test-data/eth-block:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/eth-block
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQFT/CIQFTFEEHEDF6KLBT32BFAGLXEZL4UWFNWM4LFTLMXQBCERZ6CMLX3Y.data:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/examples/browser-browserify/img/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/examples/browser-browserify/img/1.png
--------------------------------------------------------------------------------
/examples/browser-browserify/img/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/examples/browser-browserify/img/2.png
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/YD/CIQENVCICS44LLYUDQ5KVN6ALXC6QRHK2X4R6EUFRMBB5OSFO2FUYDQ.data:
--------------------------------------------------------------------------------
1 |
2 | hello world
3 |
--------------------------------------------------------------------------------
/src/http/gateway/routes/index.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = (server) => {
4 | require('./gateway')(server)
5 | }
6 |
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQEN/CIQENVCICS44LLYUDQ5KVN6ALXC6QRHK2X4R6EUFRMBB5OSFO2FUYDQ.data:
--------------------------------------------------------------------------------
1 |
2 | hello world
3 |
--------------------------------------------------------------------------------
/test/gateway/test-folder/cat-folder/cat.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/gateway/test-folder/cat-folder/cat.jpg
--------------------------------------------------------------------------------
/src/core/utils.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | exports.OFFLINE_ERROR = 'This command must be run in online mode. Try running \'ipfs daemon\' first.'
4 |
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/datastore/000002.ldb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/datastore/000002.ldb
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/datastore/000005.ldb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/datastore/000005.ldb
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/datastore/000010.ldb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/datastore/000010.ldb
--------------------------------------------------------------------------------
/examples/exchange-files-in-browser/img/final.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/examples/exchange-files-in-browser/img/final.png
--------------------------------------------------------------------------------
/examples/exchange-files-in-browser/img/connect-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/examples/exchange-files-in-browser/img/connect-1.png
--------------------------------------------------------------------------------
/examples/exchange-files-in-browser/img/connect-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/examples/exchange-files-in-browser/img/connect-2.png
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/datastore/MANIFEST-000014:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/datastore/MANIFEST-000014
--------------------------------------------------------------------------------
/examples/exchange-files-in-browser/img/diagram.monopic:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/examples/exchange-files-in-browser/img/diagram.monopic
--------------------------------------------------------------------------------
/examples/exchange-files-in-browser/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/examples/exchange-files-in-browser/public/favicon.ico
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/eth-blocks/block_302515:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/examples/traverse-ipld-graphs/eth-blocks/block_302515
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/eth-blocks/block_302516:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/examples/traverse-ipld-graphs/eth-blocks/block_302516
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/eth-blocks/block_302517:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/examples/traverse-ipld-graphs/eth-blocks/block_302517
--------------------------------------------------------------------------------
/init-and-daemon.sh:
--------------------------------------------------------------------------------
1 | #! /bin/sh -e
2 | node src/cli/bin.js init
3 |
4 | sed -i.bak 's/127.0.0.1/0.0.0.0/g' $IPFS_PATH/config
5 |
6 | node src/cli/bin.js daemon
7 |
--------------------------------------------------------------------------------
/examples/exchange-files-in-browser/img/fetch-files-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/examples/exchange-files-in-browser/img/fetch-files-1.png
--------------------------------------------------------------------------------
/examples/exchange-files-in-browser/img/fetch-files-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/examples/exchange-files-in-browser/img/fetch-files-2.png
--------------------------------------------------------------------------------
/test/fixtures/test-data/node.json:
--------------------------------------------------------------------------------
1 | { "Data": "another", "Links": [ { "Name": "some link", "Hash": "QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39V", "Size": 8 } ] }
2 |
--------------------------------------------------------------------------------
/examples/explore-ethereum-blockchain/eth-stuffs/block_302515:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/examples/explore-ethereum-blockchain/eth-stuffs/block_302515
--------------------------------------------------------------------------------
/examples/explore-ethereum-blockchain/eth-stuffs/block_302516:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/examples/explore-ethereum-blockchain/eth-stuffs/block_302516
--------------------------------------------------------------------------------
/examples/explore-ethereum-blockchain/eth-stuffs/block_302517:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/examples/explore-ethereum-blockchain/eth-stuffs/block_302517
--------------------------------------------------------------------------------
/examples/explore-ethereum-blockchain/eth-stuffs/state_0_302516:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/examples/explore-ethereum-blockchain/eth-stuffs/state_0_302516
--------------------------------------------------------------------------------
/examples/explore-ethereum-blockchain/eth-stuffs/state_r_302516:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/examples/explore-ethereum-blockchain/eth-stuffs/state_r_302516
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/datastore/000002.ldb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/datastore/000002.ldb
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/datastore/000005.ldb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/datastore/000005.ldb
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/datastore/000010.ldb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/datastore/000010.ldb
--------------------------------------------------------------------------------
/examples/explore-ethereum-blockchain/eth-stuffs/state_000_302516:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/examples/explore-ethereum-blockchain/eth-stuffs/state_000_302516
--------------------------------------------------------------------------------
/examples/explore-ethereum-blockchain/eth-stuffs/state_00_302516:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/examples/explore-ethereum-blockchain/eth-stuffs/state_00_302516
--------------------------------------------------------------------------------
/examples/explore-ethereum-blockchain/eth-stuffs/state_000017_302516:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/examples/explore-ethereum-blockchain/eth-stuffs/state_000017_302516
--------------------------------------------------------------------------------
/examples/explore-ethereum-blockchain/eth-stuffs/state_00001_302516:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/examples/explore-ethereum-blockchain/eth-stuffs/state_00001_302516
--------------------------------------------------------------------------------
/examples/explore-ethereum-blockchain/eth-stuffs/state_0000_302516:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/examples/explore-ethereum-blockchain/eth-stuffs/state_0000_302516
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/datastore/MANIFEST-000014:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/datastore/MANIFEST-000014
--------------------------------------------------------------------------------
/examples/ipfs-cli-fun/README.md:
--------------------------------------------------------------------------------
1 | # Interact with IPFS directly from your Terminal
2 |
3 | 
4 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/src/cli/commands/repo/gc.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = {
4 | command: 'gc',
5 |
6 | describe: '',
7 |
8 | builder: {},
9 |
10 | handler (argv) {
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/cli/commands/repo/init.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = {
4 | command: 'init',
5 |
6 | describe: '',
7 |
8 | builder: {},
9 |
10 | handler (argv) {
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/test/interop/node.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | require('./repo')
5 | require('./exchange-files')
6 | require('./circuit-relay')
7 | require('./kad-dht')
8 | require('./pubsub')
9 |
--------------------------------------------------------------------------------
/src/core/runtime/repo-browser.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const IPFSRepo = require('ipfs-repo')
4 |
5 | module.exports = (dir) => {
6 | const repoPath = dir || 'ipfs'
7 | return new IPFSRepo(repoPath)
8 | }
9 |
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/git-objects/4e425dba7745a781f0712c9a01455899e8c0c249:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/examples/traverse-ipld-graphs/git-objects/4e425dba7745a781f0712c9a01455899e8c0c249
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/git-objects/a5095353cd62a178663dd26efc2d61f4f61bccbe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/examples/traverse-ipld-graphs/git-objects/a5095353cd62a178663dd26efc2d61f4f61bccbe
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/git-objects/dc9bd15e8b81b6565d3736f9c308bd1bba60f33a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/examples/traverse-ipld-graphs/git-objects/dc9bd15e8b81b6565d3736f9c308bd1bba60f33a
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/git-objects/ee62b3d206cb23f939208898f32d8708c0e3fa3c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/examples/traverse-ipld-graphs/git-objects/ee62b3d206cb23f939208898f32d8708c0e3fa3c
--------------------------------------------------------------------------------
/test/gateway/test-folder/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IPFS test index.html
6 |
7 |
8 | index.html
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/core/components/is-online.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = function isOnline (self) {
4 | return () => {
5 | return Boolean(self._bitswap && self._libp2pNode && self._libp2pNode.isStarted())
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/2F/CIQEUWUVLBXVFYSYCHHSCRTXCYHGIOBXKWUMKFR3UPAFHQ5WK5362FQ.data:
--------------------------------------------------------------------------------
1 |
2 | ys# js-ipfs-repo
3 | Implementation of the IPFS repo spec (https://github.com/ipfs/specs/tree/master/repo) in JavaScript
4 | s
--------------------------------------------------------------------------------
/examples/browser-webpack/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Sample App
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/test/gateway/test-folder/nested-folder/nested.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IPFS test nested.html
6 |
7 |
8 | nested.html
9 |
10 |
11 |
--------------------------------------------------------------------------------
/examples/browser-webpack/src/components/index.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const React = require('react')
4 | const ReactDOM = require('react-dom')
5 | const App = require('./app')
6 |
7 | ReactDOM.render(, document.getElementById('root'))
8 |
--------------------------------------------------------------------------------
/src/init-files/init-docs/contact:
--------------------------------------------------------------------------------
1 | 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 |
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/5V/CIQFFRR4O52TS2Z7QLDDTF32OIR4FWLKT5YLL7MLDVIT7DC3NHOK5VA.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/blocks/5V/CIQFFRR4O52TS2Z7QLDDTF32OIR4FWLKT5YLL7MLDVIT7DC3NHOK5VA.data
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/5X/CIQJ23BL4UHXA2KTI6NLTXZM4PW4VEFWQBJ4ACZQAS37BLGL4HUO5XY.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/blocks/5X/CIQJ23BL4UHXA2KTI6NLTXZM4PW4VEFWQBJ4ACZQAS37BLGL4HUO5XY.data
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/75/CIQMB7DLJFKD267QJ2B5FJNHZPTSVA7IB6OHXSQ2XSVEEKMKK6RT75I.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/blocks/75/CIQMB7DLJFKD267QJ2B5FJNHZPTSVA7IB6OHXSQ2XSVEEKMKK6RT75I.data
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/7J/CIQKKLBWAIBQZOIS5X7E32LQAL6236OUKZTMHPQSFIXPWXNZHQOV7JQ.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/blocks/7J/CIQKKLBWAIBQZOIS5X7E32LQAL6236OUKZTMHPQSFIXPWXNZHQOV7JQ.data
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/AE/CIQONICFQZH7QVU6IPSIM3AK7AD554D3BWZPAGEAQYQOWMFZQDUUAEI.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/blocks/AE/CIQONICFQZH7QVU6IPSIM3AK7AD554D3BWZPAGEAQYQOWMFZQDUUAEI.data
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/AP/CIQHAKDLTL5GMIFGN5YVY4BA22FPHUIODJEXS4LCTQDWA275XAJDAPI.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/blocks/AP/CIQHAKDLTL5GMIFGN5YVY4BA22FPHUIODJEXS4LCTQDWA275XAJDAPI.data
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/C4/CIQDDZ5EDQK5AP7LRTLZHQZUR2R3GECRFV3WPKNL7PL2SKFIL2LXC4Y.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/blocks/C4/CIQDDZ5EDQK5AP7LRTLZHQZUR2R3GECRFV3WPKNL7PL2SKFIL2LXC4Y.data
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/CY/CIQDMKFEUGKSLXMEXO774EZOYCYNHPRVFD53ZSAU7237F67XDSQGCYQ.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/blocks/CY/CIQDMKFEUGKSLXMEXO774EZOYCYNHPRVFD53ZSAU7237F67XDSQGCYQ.data
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/DU/CIQLBK52T5EHVHZY5URTG5JS3JCUJDQM2DRB5RVF33DCUUOFJNGVDUI.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/blocks/DU/CIQLBK52T5EHVHZY5URTG5JS3JCUJDQM2DRB5RVF33DCUUOFJNGVDUI.data
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/DX/CIQPDQJBGYDZNMOAGGYNRNMP2VDKWBWGAEDDEJDACM3SGG3VIANDDXI.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/blocks/DX/CIQPDQJBGYDZNMOAGGYNRNMP2VDKWBWGAEDDEJDACM3SGG3VIANDDXI.data
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/FN/CIQIXBZMUTXFC5QIGMLJNXLLHZOPGSL2PBC65D4UIVWM6TI5F5TAFNI.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/blocks/FN/CIQIXBZMUTXFC5QIGMLJNXLLHZOPGSL2PBC65D4UIVWM6TI5F5TAFNI.data
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/GQ/CIQH7OEYWXL34RWYL7VXLWEU4FWPVGT24VJT7DUZPTNLF25N25IGGQA.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/blocks/GQ/CIQH7OEYWXL34RWYL7VXLWEU4FWPVGT24VJT7DUZPTNLF25N25IGGQA.data
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/HD/CIQDDVW2EZIJF4NQH7WJNESD7XHQSXA5EGJVNTPVHD7444C2KLKXHDI.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/blocks/HD/CIQDDVW2EZIJF4NQH7WJNESD7XHQSXA5EGJVNTPVHD7444C2KLKXHDI.data
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/IL/CIQJFGRQHQ45VCQLM7AJNF2GF5UHUAGGHC6LLAH6VYDEKLQMD4QLILY.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/blocks/IL/CIQJFGRQHQ45VCQLM7AJNF2GF5UHUAGGHC6LLAH6VYDEKLQMD4QLILY.data
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/IR/CIQERMRAAFXUAUOX3V2DCW7R77FRIVHQ3V5OIPPS3XQBX34KRPNOIRQ.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/blocks/IR/CIQERMRAAFXUAUOX3V2DCW7R77FRIVHQ3V5OIPPS3XQBX34KRPNOIRQ.data
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/LG/CIQJBQD2O6K4CGJVCCTJNUP57QHR4SKHZ74OIITBBGLOMCO3ZOLWLGA.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/blocks/LG/CIQJBQD2O6K4CGJVCCTJNUP57QHR4SKHZ74OIITBBGLOMCO3ZOLWLGA.data
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/M4/CIQOLBQZSZAODJGGH6RYYVBUXHTS3SM5EORZDU63LYPEFUAFE4SBM4I.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/blocks/M4/CIQOLBQZSZAODJGGH6RYYVBUXHTS3SM5EORZDU63LYPEFUAFE4SBM4I.data
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/O6/CIQOYW2THIZBRGI7IN33ROGCKOFZLXJJ2MPKYZBTV4H3N7GYHXMAO6A.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/blocks/O6/CIQOYW2THIZBRGI7IN33ROGCKOFZLXJJ2MPKYZBTV4H3N7GYHXMAO6A.data
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/QF/CIQGPALRQ24P6NS4OWHTQ7R247ZI7KJWP3QWPQYS43LFULQC5ANLQFI.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/blocks/QF/CIQGPALRQ24P6NS4OWHTQ7R247ZI7KJWP3QWPQYS43LFULQC5ANLQFI.data
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/R3/CIQBED3K6YA5I3QQWLJOCHWXDRK5EXZQILBCKAPEDUJENZ5B5HJ5R3A.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/blocks/R3/CIQBED3K6YA5I3QQWLJOCHWXDRK5EXZQILBCKAPEDUJENZ5B5HJ5R3A.data
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/S5/CIQHBGZNZRPWVEFNMTLP4OS5EAVHFMCX2HD7FZUC2B3WUU3D4LGKS5A.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/blocks/S5/CIQHBGZNZRPWVEFNMTLP4OS5EAVHFMCX2HD7FZUC2B3WUU3D4LGKS5A.data
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/SW/CIQHPUVCWD6JA6AFUVD6VA64TGWP67KYA3AIMBUMVWGZ5AQN2L2HSWQ.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/blocks/SW/CIQHPUVCWD6JA6AFUVD6VA64TGWP67KYA3AIMBUMVWGZ5AQN2L2HSWQ.data
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/TW/CIQFEAGMNNXXTYKYQSANT6IBNTFN7WR5RPD5F6GN6MBKUUO25DNOTWQ.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/blocks/TW/CIQFEAGMNNXXTYKYQSANT6IBNTFN7WR5RPD5F6GN6MBKUUO25DNOTWQ.data
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/UN/CIQOMBKARLB7PAITVSNH7VEGIQJRPL6J7FT2XYVKAXT4MQPXXPUYUNY.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/blocks/UN/CIQOMBKARLB7PAITVSNH7VEGIQJRPL6J7FT2XYVKAXT4MQPXXPUYUNY.data
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/UW/CIQDVKITASFS55MC2TXCX5XMZLMGTYVODWPEDIW7JYEG7YXBIA7IUWY.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/blocks/UW/CIQDVKITASFS55MC2TXCX5XMZLMGTYVODWPEDIW7JYEG7YXBIA7IUWY.data
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/VO/CIQGFTQ7FSI2COUXWWLOQ45VUM2GUZCGAXLWCTOKKPGTUWPXHBNIVOY.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/blocks/VO/CIQGFTQ7FSI2COUXWWLOQ45VUM2GUZCGAXLWCTOKKPGTUWPXHBNIVOY.data
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/XO/CIQJGO2B2N75IUEM372FSMG76VV256I4PXBULZZ5ASNLK4FL4EG7XOI.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/blocks/XO/CIQJGO2B2N75IUEM372FSMG76VV256I4PXBULZZ5ASNLK4FL4EG7XOI.data
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/ZF/CIQLBS5HG4PRCRQ7O4EBXFD5QN6MTI5YBYMCVQJDXPKCOVR6RMLHZFQ.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/go-ipfs-repo/blocks/ZF/CIQLBS5HG4PRCRQ7O4EBXFD5QN6MTI5YBYMCVQJDXPKCOVR6RMLHZFQ.data
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQEU/CIQEUWUVLBXVFYSYCHHSCRTXCYHGIOBXKWUMKFR3UPAFHQ5WK5362FQ.data:
--------------------------------------------------------------------------------
1 |
2 | ys# js-ipfs-repo
3 | Implementation of the IPFS repo spec (https://github.com/ipfs/specs/tree/master/repo) in JavaScript
4 | s
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/git-objects/6850c7be7136e6be00976ddbae80671b945c3e9d:
--------------------------------------------------------------------------------
1 | tag 142 object e68e6f6e31857877a79fd6b3956898436bb5a76f
2 | type commit
3 | tag v1.0.0
4 | tagger John Doe 1504620173 +0200
5 |
6 | Release v1.0.0
7 |
--------------------------------------------------------------------------------
/src/core/components/ping.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const promisify = require('promisify-es6')
4 |
5 | module.exports = function ping (self) {
6 | return promisify((callback) => {
7 | callback(new Error('Not implemented'))
8 | })
9 | }
10 |
--------------------------------------------------------------------------------
/examples/browser-webpack/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "standard",
3 | "rules": {
4 | "react/jsx-uses-react": 2,
5 | "react/jsx-uses-vars": 2,
6 | "react/react-in-jsx-scope": 2
7 | },
8 | "plugins": [
9 | "react"
10 | ]
11 | }
12 |
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/init-docs/contact:
--------------------------------------------------------------------------------
1 | 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 |
--------------------------------------------------------------------------------
/src/cli/commands/bitswap/unwant.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = {
4 | command: 'unwant ',
5 |
6 | describe: 'Remove a given block from your wantlist.',
7 |
8 | handler (argv) {
9 | throw new Error('Not implemented yet')
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/test/cli/index.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | const fs = require('fs')
5 |
6 | describe('cli', () => {
7 | fs.readdirSync(__dirname)
8 | .filter((file) => file !== 'index.js')
9 | .forEach((file) => require('./' + file))
10 | })
11 |
--------------------------------------------------------------------------------
/src/cli/commands/pubsub.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = {
4 | command: 'pubsub',
5 |
6 | description: 'pubsub commands',
7 |
8 | builder (yargs) {
9 | return yargs
10 | .commandDir('pubsub')
11 | },
12 |
13 | handler (argv) {}
14 | }
15 |
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/git-objects/0f328c91df28c5c01b9e9f9f7e663191fa156593:
--------------------------------------------------------------------------------
1 | commit 175 tree dc9bd15e8b81b6565d3736f9c308bd1bba60f33a
2 | author John Doe 1504619620 +0200
3 | committer John Doe 1504619620 +0200
4 |
5 | Initial commit
6 |
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQBE/CIQBED3K6YA5I3QQWLJOCHWXDRK5EXZQILBCKAPEDUJENZ5B5HJ5R3A.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/blocks/CIQBE/CIQBED3K6YA5I3QQWLJOCHWXDRK5EXZQILBCKAPEDUJENZ5B5HJ5R3A.data
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQDD/CIQDDVW2EZIJF4NQH7WJNESD7XHQSXA5EGJVNTPVHD7444C2KLKXHDI.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/blocks/CIQDD/CIQDDVW2EZIJF4NQH7WJNESD7XHQSXA5EGJVNTPVHD7444C2KLKXHDI.data
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQDD/CIQDDZ5EDQK5AP7LRTLZHQZUR2R3GECRFV3WPKNL7PL2SKFIL2LXC4Y.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/blocks/CIQDD/CIQDDZ5EDQK5AP7LRTLZHQZUR2R3GECRFV3WPKNL7PL2SKFIL2LXC4Y.data
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQDM/CIQDMKFEUGKSLXMEXO774EZOYCYNHPRVFD53ZSAU7237F67XDSQGCYQ.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/blocks/CIQDM/CIQDMKFEUGKSLXMEXO774EZOYCYNHPRVFD53ZSAU7237F67XDSQGCYQ.data
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQDV/CIQDVKITASFS55MC2TXCX5XMZLMGTYVODWPEDIW7JYEG7YXBIA7IUWY.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/blocks/CIQDV/CIQDVKITASFS55MC2TXCX5XMZLMGTYVODWPEDIW7JYEG7YXBIA7IUWY.data
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQER/CIQERMRAAFXUAUOX3V2DCW7R77FRIVHQ3V5OIPPS3XQBX34KRPNOIRQ.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/blocks/CIQER/CIQERMRAAFXUAUOX3V2DCW7R77FRIVHQ3V5OIPPS3XQBX34KRPNOIRQ.data
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQFE/CIQFEAGMNNXXTYKYQSANT6IBNTFN7WR5RPD5F6GN6MBKUUO25DNOTWQ.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/blocks/CIQFE/CIQFEAGMNNXXTYKYQSANT6IBNTFN7WR5RPD5F6GN6MBKUUO25DNOTWQ.data
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQFF/CIQFFRR4O52TS2Z7QLDDTF32OIR4FWLKT5YLL7MLDVIT7DC3NHOK5VA.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/blocks/CIQFF/CIQFFRR4O52TS2Z7QLDDTF32OIR4FWLKT5YLL7MLDVIT7DC3NHOK5VA.data
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQGF/CIQGFTQ7FSI2COUXWWLOQ45VUM2GUZCGAXLWCTOKKPGTUWPXHBNIVOY.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/blocks/CIQGF/CIQGFTQ7FSI2COUXWWLOQ45VUM2GUZCGAXLWCTOKKPGTUWPXHBNIVOY.data
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQGP/CIQGPALRQ24P6NS4OWHTQ7R247ZI7KJWP3QWPQYS43LFULQC5ANLQFI.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/blocks/CIQGP/CIQGPALRQ24P6NS4OWHTQ7R247ZI7KJWP3QWPQYS43LFULQC5ANLQFI.data
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQH7/CIQH7OEYWXL34RWYL7VXLWEU4FWPVGT24VJT7DUZPTNLF25N25IGGQA.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/blocks/CIQH7/CIQH7OEYWXL34RWYL7VXLWEU4FWPVGT24VJT7DUZPTNLF25N25IGGQA.data
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQHA/CIQHAKDLTL5GMIFGN5YVY4BA22FPHUIODJEXS4LCTQDWA275XAJDAPI.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/blocks/CIQHA/CIQHAKDLTL5GMIFGN5YVY4BA22FPHUIODJEXS4LCTQDWA275XAJDAPI.data
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQHB/CIQHBGZNZRPWVEFNMTLP4OS5EAVHFMCX2HD7FZUC2B3WUU3D4LGKS5A.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/blocks/CIQHB/CIQHBGZNZRPWVEFNMTLP4OS5EAVHFMCX2HD7FZUC2B3WUU3D4LGKS5A.data
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQHP/CIQHPUVCWD6JA6AFUVD6VA64TGWP67KYA3AIMBUMVWGZ5AQN2L2HSWQ.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/blocks/CIQHP/CIQHPUVCWD6JA6AFUVD6VA64TGWP67KYA3AIMBUMVWGZ5AQN2L2HSWQ.data
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQIX/CIQIXBZMUTXFC5QIGMLJNXLLHZOPGSL2PBC65D4UIVWM6TI5F5TAFNI.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/blocks/CIQIX/CIQIXBZMUTXFC5QIGMLJNXLLHZOPGSL2PBC65D4UIVWM6TI5F5TAFNI.data
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQJ2/CIQJ23BL4UHXA2KTI6NLTXZM4PW4VEFWQBJ4ACZQAS37BLGL4HUO5XY.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/blocks/CIQJ2/CIQJ23BL4UHXA2KTI6NLTXZM4PW4VEFWQBJ4ACZQAS37BLGL4HUO5XY.data
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQJB/CIQJBQD2O6K4CGJVCCTJNUP57QHR4SKHZ74OIITBBGLOMCO3ZOLWLGA.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/blocks/CIQJB/CIQJBQD2O6K4CGJVCCTJNUP57QHR4SKHZ74OIITBBGLOMCO3ZOLWLGA.data
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQJF/CIQJFGRQHQ45VCQLM7AJNF2GF5UHUAGGHC6LLAH6VYDEKLQMD4QLILY.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/blocks/CIQJF/CIQJFGRQHQ45VCQLM7AJNF2GF5UHUAGGHC6LLAH6VYDEKLQMD4QLILY.data
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQJG/CIQJGO2B2N75IUEM372FSMG76VV256I4PXBULZZ5ASNLK4FL4EG7XOI.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/blocks/CIQJG/CIQJGO2B2N75IUEM372FSMG76VV256I4PXBULZZ5ASNLK4FL4EG7XOI.data
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQKK/CIQKKLBWAIBQZOIS5X7E32LQAL6236OUKZTMHPQSFIXPWXNZHQOV7JQ.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/blocks/CIQKK/CIQKKLBWAIBQZOIS5X7E32LQAL6236OUKZTMHPQSFIXPWXNZHQOV7JQ.data
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQLB/CIQLBK52T5EHVHZY5URTG5JS3JCUJDQM2DRB5RVF33DCUUOFJNGVDUI.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/blocks/CIQLB/CIQLBK52T5EHVHZY5URTG5JS3JCUJDQM2DRB5RVF33DCUUOFJNGVDUI.data
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQLB/CIQLBS5HG4PRCRQ7O4EBXFD5QN6MTI5YBYMCVQJDXPKCOVR6RMLHZFQ.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/blocks/CIQLB/CIQLBS5HG4PRCRQ7O4EBXFD5QN6MTI5YBYMCVQJDXPKCOVR6RMLHZFQ.data
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQMB/CIQMB7DLJFKD267QJ2B5FJNHZPTSVA7IB6OHXSQ2XSVEEKMKK6RT75I.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/blocks/CIQMB/CIQMB7DLJFKD267QJ2B5FJNHZPTSVA7IB6OHXSQ2XSVEEKMKK6RT75I.data
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQOL/CIQOLBQZSZAODJGGH6RYYVBUXHTS3SM5EORZDU63LYPEFUAFE4SBM4I.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/blocks/CIQOL/CIQOLBQZSZAODJGGH6RYYVBUXHTS3SM5EORZDU63LYPEFUAFE4SBM4I.data
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQOM/CIQOMBKARLB7PAITVSNH7VEGIQJRPL6J7FT2XYVKAXT4MQPXXPUYUNY.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/blocks/CIQOM/CIQOMBKARLB7PAITVSNH7VEGIQJRPL6J7FT2XYVKAXT4MQPXXPUYUNY.data
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQON/CIQONICFQZH7QVU6IPSIM3AK7AD554D3BWZPAGEAQYQOWMFZQDUUAEI.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/blocks/CIQON/CIQONICFQZH7QVU6IPSIM3AK7AD554D3BWZPAGEAQYQOWMFZQDUUAEI.data
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQOY/CIQOYW2THIZBRGI7IN33ROGCKOFZLXJJ2MPKYZBTV4H3N7GYHXMAO6A.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/blocks/CIQOY/CIQOYW2THIZBRGI7IN33ROGCKOFZLXJJ2MPKYZBTV4H3N7GYHXMAO6A.data
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/blocks/CIQPD/CIQPDQJBGYDZNMOAGGYNRNMP2VDKWBWGAEDDEJDACM3SGG3VIANDDXI.data:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TarekJor/js-ipfs/master/test/fixtures/test-data/recursive-get-dir/blocks/CIQPD/CIQPDQJBGYDZNMOAGGYNRNMP2VDKWBWGAEDDEJDACM3SGG3VIANDDXI.data
--------------------------------------------------------------------------------
/src/cli/commands/repo.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = {
4 | command: 'repo',
5 |
6 | description: 'Manipulate the IPFS repo.',
7 |
8 | builder (yargs) {
9 | return yargs
10 | .commandDir('repo')
11 | },
12 |
13 | handler (argv) {
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/cli/commands/swarm.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = {
4 | command: 'swarm',
5 |
6 | description: 'Swarm inspection tool.',
7 |
8 | builder (yargs) {
9 | return yargs
10 | .commandDir('swarm')
11 | },
12 |
13 | handler (argv) {
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/test/interop/browser.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | describe('browser interop tests', () => {
5 | it('need to get written', function (done) {
6 | this.timeout(10 * 1000)
7 | // for teardown time
8 | setTimeout(done, 5 * 1000)
9 | })
10 | })
11 |
--------------------------------------------------------------------------------
/src/cli/commands/block.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = {
4 | command: 'block',
5 |
6 | description: 'Manipulate raw IPFS blocks.',
7 |
8 | builder (yargs) {
9 | return yargs
10 | .commandDir('block')
11 | },
12 |
13 | handler (argv) {
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/cli/commands/dag.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = {
4 | command: 'dag',
5 |
6 | description: 'Interact with ipld dag objects.',
7 |
8 | builder (yargs) {
9 | return yargs
10 | .commandDir('dag')
11 | },
12 |
13 | handler (argv) {
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/cli/commands/object.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = {
4 | command: 'object',
5 |
6 | description: 'Interact with ipfs objects.',
7 |
8 | builder (yargs) {
9 | return yargs
10 | .commandDir('object')
11 | },
12 |
13 | handler (argv) {
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/http/api/routes/id.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const resources = require('./../resources')
4 |
5 | module.exports = (server) => {
6 | const api = server.select('API')
7 |
8 | api.route({
9 | method: '*',
10 | path: '/api/v0/id',
11 | handler: resources.id.get
12 | })
13 | }
14 |
--------------------------------------------------------------------------------
/src/core/runtime/repo-nodejs.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const os = require('os')
4 | const IPFSRepo = require('ipfs-repo')
5 | const path = require('path')
6 |
7 | module.exports = (dir) => {
8 | const repoPath = dir || path.join(os.homedir(), '.jsipfs')
9 |
10 | return new IPFSRepo(repoPath)
11 | }
12 |
--------------------------------------------------------------------------------
/test/utils/clean.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const rimraf = require('rimraf')
4 | const fs = require('fs')
5 |
6 | module.exports = (dir) => {
7 | try {
8 | fs.accessSync(dir)
9 | } catch (err) {
10 | // Does not exist so all good
11 | return
12 | }
13 |
14 | rimraf.sync(dir)
15 | }
16 |
--------------------------------------------------------------------------------
/src/cli/commands/bootstrap.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = {
4 | command: 'bootstrap',
5 |
6 | description: 'Show or edit the list of bootstrap peers.',
7 |
8 | builder (yargs) {
9 | return yargs
10 | .commandDir('bootstrap')
11 | },
12 |
13 | handler (argv) {
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/cli/commands/file.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = {
4 | command: 'file',
5 |
6 | description: 'Interact with IPFS objects representing Unix filesystems.',
7 |
8 | builder (yargs) {
9 | return yargs
10 | .commandDir('file')
11 | },
12 |
13 | handler (argv) {
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/http/api/routes/repo.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const resources = require('./../resources')
4 |
5 | // TODO
6 | module.exports = (server) => {
7 | const api = server.select('API')
8 |
9 | api.route({
10 | method: '*',
11 | path: '/api/v0/repo',
12 | handler: resources.repo
13 | })
14 | }
15 |
--------------------------------------------------------------------------------
/src/http/api/routes/version.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const resources = require('./../resources')
4 |
5 | module.exports = (server) => {
6 | const api = server.select('API')
7 |
8 | api.route({
9 | method: '*',
10 | path: '/api/v0/version',
11 | handler: resources.version.get
12 | })
13 | }
14 |
--------------------------------------------------------------------------------
/examples/run-in-electron/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IPFS
6 |
7 |
8 | IPFS in electron!
9 | now check your console
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/cli/commands/object/patch.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = {
4 | command: 'patch',
5 |
6 | description: 'Create a new merkledag object based on an existing one.',
7 |
8 | builder (yargs) {
9 | return yargs
10 | .commandDir('patch')
11 | },
12 |
13 | handler (argv) {
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/git-objects/e68e6f6e31857877a79fd6b3956898436bb5a76f:
--------------------------------------------------------------------------------
1 | commit 222 tree 4e425dba7745a781f0712c9a01455899e8c0c249
2 | parent 0f328c91df28c5c01b9e9f9f7e663191fa156593
3 | author John Doe 1504620164 +0200
4 | committer John Doe 1504620164 +0200
5 |
6 | Improve hello
7 |
--------------------------------------------------------------------------------
/test/utils/interop-daemon-spawner/util.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const os = require('os')
4 | const crypto = require('libp2p-crypto')
5 | const path = require('path')
6 |
7 | exports.tmpDir = (prefix) => {
8 | return path.join(
9 | os.tmpdir(),
10 | prefix || 'tmp',
11 | crypto.randomBytes(32).toString('hex')
12 | )
13 | }
14 |
--------------------------------------------------------------------------------
/src/init-files/init-docs/help:
--------------------------------------------------------------------------------
1 | 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 |
--------------------------------------------------------------------------------
/src/cli/commands/bitswap.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = {
4 | command: 'bitswap',
5 |
6 | description: 'Interact with the bitswap agent.',
7 |
8 | builder (yargs) {
9 | return yargs.commandDir('bitswap')
10 | },
11 |
12 | handler (argv) {
13 | console.log('Type `jsipfs bitswap --help` for more information about this command')
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/cli/commands/files.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = {
4 | command: 'files',
5 |
6 | description: 'Operations over files (add, cat, get, ls, etc)',
7 |
8 | builder (yargs) {
9 | return yargs
10 | .commandDir('files')
11 | },
12 |
13 | handler (argv) {
14 | console.log('Type `jsipfs bitswap --help` for more instructions')
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/init-docs/help:
--------------------------------------------------------------------------------
1 | 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 |
--------------------------------------------------------------------------------
/src/core/components/repo.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = function repo (self) {
4 | return {
5 | init: (bits, empty, callback) => {
6 | // 1. check if repo already exists
7 | },
8 |
9 | version: (callback) => {
10 | self._repo.version.get(callback)
11 | },
12 |
13 | gc: function () {},
14 |
15 | path: () => self._repo.path
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/examples/browser-script-tag/README.md:
--------------------------------------------------------------------------------
1 | # Use IPFS in the browser with `
7 | ```
8 |
9 | This exposes a global `Ipfs`; you can get a node by making a `new Ipfs()`.
10 |
11 | See `index.html` for a working example.
12 |
--------------------------------------------------------------------------------
/examples/browser-video-streaming/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/test/cli/general.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | const expect = require('chai').expect
5 | const runOnAndOff = require('../utils/on-and-off')
6 |
7 | describe('general cli options', () => runOnAndOff.off((thing) => {
8 | it('should handle --silent flag', () => {
9 | return thing.ipfs('help --silent').then((out) => {
10 | expect(out).to.be.empty()
11 | })
12 | })
13 | }))
14 |
--------------------------------------------------------------------------------
/src/cli/commands/pubsub/pub.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = {
4 | command: 'pub ',
5 |
6 | describe: 'Publish data to a topic',
7 |
8 | builder: {},
9 |
10 | handler (argv) {
11 | const data = Buffer.from(String(argv.data))
12 |
13 | argv.ipfs.pubsub.publish(argv.topic, data, (err) => {
14 | if (err) {
15 | throw err
16 | }
17 | })
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/cli/commands/repo/version.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const print = require('../../utils').print
4 |
5 | module.exports = {
6 | command: 'version',
7 |
8 | describe: 'Shows IPFS repo version information',
9 |
10 | builder: {},
11 |
12 | handler (argv) {
13 | argv.ipfs.repo.version(function (err, version) {
14 | if (err) {
15 | throw err
16 | }
17 | print(version)
18 | })
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/test/sharness/lib/test-lib-hashes.sh:
--------------------------------------------------------------------------------
1 | # this file defines several useful hashes used across the test codebase.
2 | # thus they can be defined + changed in one place
3 |
4 | HASH_WELCOME_DOCS="QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG"
5 | HASH_GATEWAY_ASSETS="QmXB7PLRWH6bCiwrGh2MrBBjNkLv3mY3JdYXCikYZSwLED"
6 | HASH_HELP_PAGE="QmY5heUM5qgRubMDD1og9fhCPA6QdkMp3QCwd4s7gJsyE7"
7 | HASH_EMPTY_DIR="QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn"
8 |
--------------------------------------------------------------------------------
/test/core/interface/block.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | const test = require('interface-ipfs-core')
5 | const IPFSFactory = require('../../utils/ipfs-factory-instance')
6 |
7 | let factory
8 |
9 | const common = {
10 | setup: function (cb) {
11 | factory = new IPFSFactory()
12 | cb(null, factory)
13 | },
14 | teardown: function (cb) {
15 | factory.dismantle(cb)
16 | }
17 | }
18 |
19 | test.block(common)
20 |
--------------------------------------------------------------------------------
/test/core/interface/dag.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 |
3 | 'use strict'
4 |
5 | const test = require('interface-ipfs-core')
6 | const IPFSFactory = require('../../utils/ipfs-factory-instance')
7 |
8 | let factory
9 |
10 | const common = {
11 | setup: function (cb) {
12 | factory = new IPFSFactory()
13 | cb(null, factory)
14 | },
15 | teardown: function (cb) {
16 | factory.dismantle(cb)
17 | }
18 | }
19 |
20 | test.dag(common)
21 |
--------------------------------------------------------------------------------
/test/core/interface/files.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | const test = require('interface-ipfs-core')
5 | const IPFSFactory = require('../../utils/ipfs-factory-instance')
6 |
7 | let factory
8 |
9 | const common = {
10 | setup: function (cb) {
11 | factory = new IPFSFactory()
12 | cb(null, factory)
13 | },
14 | teardown: function (cb) {
15 | factory.dismantle(cb)
16 | }
17 | }
18 |
19 | test.files(common)
20 |
--------------------------------------------------------------------------------
/test/core/interface/pubsub.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | const test = require('interface-ipfs-core')
5 | const IPFSFactory = require('../../utils/ipfs-factory-instance')
6 |
7 | let factory
8 |
9 | const common = {
10 | setup: function (cb) {
11 | factory = new IPFSFactory()
12 | cb(null, factory)
13 | },
14 | teardown: function (cb) {
15 | factory.dismantle(cb)
16 | }
17 | }
18 |
19 | test.pubsub(common)
20 |
--------------------------------------------------------------------------------
/src/cli/commands/bootstrap/list.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const print = require('../../utils').print
4 |
5 | module.exports = {
6 | command: 'list',
7 |
8 | describe: 'Show peers in the bootstrap list',
9 |
10 | builder: {},
11 |
12 | handler (argv) {
13 | argv.ipfs.bootstrap.list((err, list) => {
14 | if (err) {
15 | throw err
16 | }
17 |
18 | list.Peers.forEach((node) => print(node))
19 | })
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/http/gateway/routes/gateway.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const resources = require('../resources')
4 |
5 | module.exports = (server) => {
6 | const gateway = server.select('Gateway')
7 |
8 | gateway.route({
9 | method: '*',
10 | path: '/ipfs/{cid*}',
11 | config: {
12 | pre: [
13 | { method: resources.gateway.checkCID, assign: 'args' }
14 | ],
15 | handler: resources.gateway.handler
16 | }
17 | })
18 | }
19 |
--------------------------------------------------------------------------------
/test/core/interface/config.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 |
3 | 'use strict'
4 |
5 | const test = require('interface-ipfs-core')
6 | const IPFSFactory = require('../../utils/ipfs-factory-instance')
7 |
8 | let factory
9 |
10 | const common = {
11 | setup: function (cb) {
12 | factory = new IPFSFactory()
13 | cb(null, factory)
14 | },
15 | teardown: function (cb) {
16 | factory.dismantle(cb)
17 | }
18 | }
19 |
20 | test.config(common)
21 |
--------------------------------------------------------------------------------
/test/core/interface/object.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 |
3 | 'use strict'
4 |
5 | const test = require('interface-ipfs-core')
6 | const IPFSFactory = require('../../utils/ipfs-factory-instance')
7 |
8 | let factory
9 |
10 | const common = {
11 | setup: function (cb) {
12 | factory = new IPFSFactory()
13 | cb(null, factory)
14 | },
15 | teardown: function (cb) {
16 | factory.dismantle(cb)
17 | }
18 | }
19 |
20 | test.object(common)
21 |
--------------------------------------------------------------------------------
/test/core/interface/swarm.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 |
3 | 'use strict'
4 |
5 | const test = require('interface-ipfs-core')
6 | const IPFSFactory = require('../../utils/ipfs-factory-instance')
7 |
8 | let factory
9 |
10 | const common = {
11 | setup: function (cb) {
12 | factory = new IPFSFactory()
13 | cb(null, factory)
14 | },
15 | teardown: function (cb) {
16 | factory.dismantle(cb)
17 | }
18 | }
19 |
20 | test.swarm(common)
21 |
--------------------------------------------------------------------------------
/test/core/interface/generic.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 |
3 | 'use strict'
4 |
5 | const test = require('interface-ipfs-core')
6 | const IPFSFactory = require('../../utils/ipfs-factory-instance')
7 |
8 | let factory
9 |
10 | const common = {
11 | setup: function (cb) {
12 | factory = new IPFSFactory()
13 | cb(null, factory)
14 | },
15 | teardown: function (cb) {
16 | factory.dismantle(cb)
17 | }
18 | }
19 |
20 | test.generic(common)
21 |
--------------------------------------------------------------------------------
/test/core/interface/interface.spec.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 |
3 | 'use strict'
4 |
5 | const isNode = require('detect-node')
6 |
7 | describe('interface-ipfs-core tests', () => {
8 | require('./block')
9 | require('./config')
10 | require('./files')
11 | require('./generic')
12 | require('./object')
13 | require('./dag')
14 | if (isNode) {
15 | require('./swarm')
16 | require('./pubsub')
17 | require('./dht')
18 | }
19 | })
20 |
--------------------------------------------------------------------------------
/src/cli/commands/block/get.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const CID = require('cids')
4 |
5 | module.exports = {
6 | command: 'get ',
7 |
8 | describe: 'Get a raw IPFS block',
9 |
10 | builder: {},
11 |
12 | handler (argv) {
13 | const cid = new CID(argv.key)
14 |
15 | argv.ipfs.block.get(cid, (err, block) => {
16 | if (err) {
17 | throw err
18 | }
19 |
20 | process.stdout.write(block.data)
21 | })
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/test/http-api/interface/block.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 |
3 | 'use strict'
4 |
5 | const test = require('interface-ipfs-core')
6 | const FactoryClient = require('./../../utils/ipfs-factory-daemon')
7 |
8 | let fc
9 |
10 | const common = {
11 | setup: function (callback) {
12 | fc = new FactoryClient()
13 | callback(null, fc)
14 | },
15 | teardown: function (callback) {
16 | fc.dismantle(callback)
17 | }
18 | }
19 |
20 | test.block(common)
21 |
--------------------------------------------------------------------------------
/test/http-api/interface/files.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 |
3 | 'use strict'
4 |
5 | const test = require('interface-ipfs-core')
6 | const FactoryClient = require('./../../utils/ipfs-factory-daemon')
7 |
8 | let fc
9 |
10 | const common = {
11 | setup: function (callback) {
12 | fc = new FactoryClient()
13 | callback(null, fc)
14 | },
15 | teardown: function (callback) {
16 | fc.dismantle(callback)
17 | }
18 | }
19 |
20 | test.files(common)
21 |
--------------------------------------------------------------------------------
/test/http-api/interface/swarm.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 |
3 | 'use strict'
4 |
5 | const test = require('interface-ipfs-core')
6 | const FactoryClient = require('./../../utils/ipfs-factory-daemon')
7 |
8 | let fc
9 |
10 | const common = {
11 | setup: function (callback) {
12 | fc = new FactoryClient()
13 | callback(null, fc)
14 | },
15 | teardown: function (callback) {
16 | fc.dismantle(callback)
17 | }
18 | }
19 |
20 | test.swarm(common)
21 |
--------------------------------------------------------------------------------
/src/cli/commands/pubsub/peers.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const print = require('../../utils').print
4 |
5 | module.exports = {
6 | command: 'peers ',
7 |
8 | describe: 'Get all peers subscribed to a topic',
9 |
10 | builder: {},
11 |
12 | handler (argv) {
13 | argv.ipfs.pubsub.peers(argv.topic, (err, peers) => {
14 | if (err) {
15 | throw err
16 | }
17 |
18 | peers.forEach((peer) => print(peer))
19 | })
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/http/api/routes/file.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const resources = require('./../resources')
4 |
5 | module.exports = (server) => {
6 | const api = server.select('API')
7 |
8 | api.route({
9 | // TODO fix method
10 | method: '*',
11 | path: '/api/v0/file/ls',
12 | config: {
13 | pre: [
14 | { method: resources.file.ls.parseArgs, assign: 'args' }
15 | ],
16 | handler: resources.file.ls.handler
17 | }
18 | })
19 | }
20 |
--------------------------------------------------------------------------------
/test/http-api/interface/config.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 |
3 | 'use strict'
4 |
5 | const test = require('interface-ipfs-core')
6 | const FactoryClient = require('./../../utils/ipfs-factory-daemon')
7 |
8 | let fc
9 |
10 | const common = {
11 | setup: function (callback) {
12 | fc = new FactoryClient()
13 | callback(null, fc)
14 | },
15 | teardown: function (callback) {
16 | fc.dismantle(callback)
17 | }
18 | }
19 |
20 | test.config(common)
21 |
--------------------------------------------------------------------------------
/test/http-api/interface/object.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 |
3 | 'use strict'
4 |
5 | const test = require('interface-ipfs-core')
6 | const FactoryClient = require('./../../utils/ipfs-factory-daemon')
7 |
8 | let fc
9 |
10 | const common = {
11 | setup: function (callback) {
12 | fc = new FactoryClient()
13 | callback(null, fc)
14 | },
15 | teardown: function (callback) {
16 | fc.dismantle(callback)
17 | }
18 | }
19 |
20 | test.object(common)
21 |
--------------------------------------------------------------------------------
/src/core/components/version.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const pkg = require('../../../package.json')
4 | const promisify = require('promisify-es6')
5 |
6 | module.exports = function version (self) {
7 | return promisify((opts, callback) => {
8 | if (typeof opts === 'function') {
9 | callback = opts
10 | opts = {}
11 | }
12 |
13 | callback(null, {
14 | version: pkg.version,
15 | repo: '',
16 | commit: ''
17 | })
18 | })
19 | }
20 |
--------------------------------------------------------------------------------
/test/cli/progress-bar.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | const expect = require('chai').expect
5 | const createProgressBar = require('../../src/cli/utils').createProgressBar
6 |
7 | describe('progress bar', () => {
8 | it('created with the correct properties', () => {
9 | const total = 1000
10 |
11 | const bar = createProgressBar(total)
12 | expect(bar.total).to.eql(total)
13 | expect(typeof bar.tick).to.eql('function')
14 | })
15 | })
16 |
--------------------------------------------------------------------------------
/src/cli/commands/pubsub/ls.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const print = require('../../utils').print
4 |
5 | module.exports = {
6 | command: 'ls',
7 |
8 | describe: 'Get your list of subscriptions',
9 |
10 | builder: {},
11 |
12 | handler (argv) {
13 | argv.ipfs.pubsub.ls((err, subscriptions) => {
14 | if (err) {
15 | throw err
16 | }
17 |
18 | subscriptions.forEach((sub) => {
19 | print(sub)
20 | })
21 | })
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/http/api/resources/version.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const boom = require('boom')
4 |
5 | exports = module.exports
6 |
7 | exports.get = (request, reply) => {
8 | const ipfs = request.server.app.ipfs
9 |
10 | ipfs.version((err, version) => {
11 | if (err) {
12 | return reply(boom.badRequest(err))
13 | }
14 |
15 | reply({
16 | Version: version.version,
17 | Commit: version.commit,
18 | Repo: version.repo
19 | })
20 | })
21 | }
22 |
--------------------------------------------------------------------------------
/test/core/interface/dht.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 |
3 | 'use strict'
4 |
5 | /*
6 | const test = require('interface-ipfs-core')
7 | const IPFSFactory = require('../../utils/ipfs-factory-instance')
8 |
9 | let factory
10 |
11 | const common = {
12 | setup: function (callback) {
13 | factory = new IPFSFactory()
14 | callback(null, factory)
15 | },
16 | teardown: function (callback) {
17 | factory.dismantle(callback)
18 | }
19 | }
20 |
21 | test.dht(common)
22 | */
23 |
--------------------------------------------------------------------------------
/src/cli/commands/object/data.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const print = require('../../utils').print
4 |
5 | module.exports = {
6 | command: 'data ',
7 |
8 | describe: 'Outputs the raw bytes in an IPFS object',
9 |
10 | builder: {},
11 |
12 | handler (argv) {
13 | argv.ipfs.object.data(argv.key, {
14 | enc: 'base58'
15 | }, (err, data) => {
16 | if (err) {
17 | throw err
18 | }
19 |
20 | print(data.toString())
21 | })
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/cli/commands/pubsub/sub.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const print = require('../../utils').print
4 |
5 | module.exports = {
6 | command: 'sub ',
7 |
8 | describe: 'Subscribe to a topic',
9 |
10 | builder: {},
11 |
12 | handler (argv) {
13 | const handler = (msg) => {
14 | print(msg.data.toString())
15 | }
16 |
17 | argv.ipfs.pubsub.subscribe(argv.topic, handler, (err) => {
18 | if (err) {
19 | throw err
20 | }
21 | })
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/examples/ipfs-101/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ipfs-101",
3 | "version": "0.0.0",
4 | "description": "this package.json needs to exist because of new npm config https://github.com/ipfs/js-ipfs/issues/977#issuecomment-326741092",
5 | "main": "1.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "David Dias ",
10 | "license": "MIT",
11 | "dependencies": {
12 | "async": "^2.5.0",
13 | "ipfs": "^0.25.4"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/http/api/resources/id.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const boom = require('boom')
4 |
5 | exports = module.exports
6 |
7 | exports.get = (request, reply) => {
8 | request.server.app.ipfs.id((err, id) => {
9 | if (err) {
10 | return reply(boom.badRequest(err))
11 | }
12 |
13 | return reply({
14 | ID: id.id,
15 | PublicKey: id.publicKey,
16 | Addresses: id.addresses,
17 | AgentVersion: id.agentVersion,
18 | ProtocolVersion: id.protocolVersion
19 | })
20 | })
21 | }
22 |
--------------------------------------------------------------------------------
/examples/browser-webpack/server.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const webpack = require('webpack')
4 | const WebpackDevServer = require('webpack-dev-server')
5 | const config = require('./webpack.config')
6 |
7 | const wds = new WebpackDevServer(webpack(config), {
8 | publicPath: config.output.publicPath,
9 | hot: true,
10 | historyApiFallback: true
11 | })
12 |
13 | wds.listen(3000, 'localhost', (err, result) => {
14 | if (err) {
15 | throw err
16 | }
17 |
18 | console.log('Listening at localhost:3000')
19 | })
20 |
--------------------------------------------------------------------------------
/examples/exchange-files-in-browser/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "exchange-files-browser",
3 | "version": "0.0.0",
4 | "scripts": {
5 | "bundle": "browserify public/js/app.js > public/js/bundle.js",
6 | "serve": "http-server -c-1 -p 12345 public",
7 | "start": "npm run bundle && npm run serve"
8 | },
9 | "license": "MIT",
10 | "devDependencies": {
11 | "browserify": "^14.4.0",
12 | "http-server": "^0.10.0"
13 | },
14 | "dependencies": {
15 | "stream-buffers": "^3.0.1"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/cli/commands/id.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | const print = require('../utils').print
3 |
4 | module.exports = {
5 | command: 'id',
6 |
7 | describe: 'Shows IPFS Node ID info',
8 |
9 | builder: {
10 | format: {
11 | alias: 'f',
12 | type: 'string'
13 | }
14 | },
15 |
16 | handler (argv) {
17 | // TODO: handle argv.format
18 | argv.ipfs.id((err, id) => {
19 | if (err) {
20 | throw err
21 | }
22 |
23 | print(JSON.stringify(id, '', 2))
24 | })
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/http/api/resources/index.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | exports.version = require('./version')
4 | exports.id = require('./id')
5 | exports.bootstrap = require('./bootstrap')
6 | exports.repo = require('./repo')
7 | exports.object = require('./object')
8 | exports.config = require('./config')
9 | exports.block = require('./block')
10 | exports.swarm = require('./swarm')
11 | exports.bitswap = require('./bitswap')
12 | exports.file = require('./file')
13 | exports.files = require('./files')
14 | exports.pubsub = require('./pubsub')
15 |
--------------------------------------------------------------------------------
/src/http/api/routes/index.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = (server) => {
4 | require('./version')(server)
5 | require('./id')(server)
6 | require('./bootstrap')(server)
7 | require('./block')(server)
8 | require('./object')(server)
9 | // require('./repo')(server)
10 | require('./config')(server)
11 | require('./swarm')(server)
12 | require('./bitswap')(server)
13 | require('./file')(server)
14 | require('./files')(server)
15 | require('./pubsub')(server)
16 | require('./debug')(server)
17 | }
18 |
--------------------------------------------------------------------------------
/src/cli/commands/block/stat.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const CID = require('cids')
4 | const print = require('../../utils').print
5 |
6 | module.exports = {
7 | command: 'stat ',
8 |
9 | describe: 'Print information of a raw IPFS block',
10 |
11 | builder: {},
12 |
13 | handler (argv) {
14 | argv.ipfs.block.stat(new CID(argv.key), (err, stats) => {
15 | if (err) {
16 | throw err
17 | }
18 |
19 | print('Key: ' + stats.key)
20 | print('Size: ' + stats.size)
21 | })
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/cli/commands/files/cat.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = {
4 | command: 'cat ',
5 |
6 | describe: 'Fetch and cat an IPFS path referencing a file',
7 |
8 | builder: {},
9 |
10 | handler (argv) {
11 | let path = argv['ipfs-path']
12 | if (path.indexOf('/ipfs/') !== 1) {
13 | path = path.replace('/ipfs/', '')
14 | }
15 |
16 | argv.ipfs.files.cat(path, (err, file) => {
17 | if (err) {
18 | throw err
19 | }
20 |
21 | file.pipe(process.stdout)
22 | })
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/test/http-api/interface/pubsub.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 |
3 | 'use strict'
4 |
5 | // TODO needs: https://github.com/ipfs/js-ipfs-api/pull/493
6 | /*
7 | const test = require('interface-ipfs-core')
8 | const FactoryClient = require('./../../utils/ipfs-factory-daemon')
9 |
10 | let fc
11 |
12 | const common = {
13 | setup: function (callback) {
14 | fc = new FactoryClient()
15 | callback(null, fc)
16 | },
17 | teardown: function (callback) {
18 | fc.dismantle(callback)
19 | }
20 | }
21 |
22 | test.pubsub(common)
23 | */
24 |
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 | version: "{build}"
2 |
3 | environment:
4 | matrix:
5 | - nodejs_version: "6"
6 | - nodejs_version: "8"
7 |
8 | matrix:
9 | fast_finish: true
10 |
11 | install:
12 | # Install Node.js
13 | - ps: Install-Product node $env:nodejs_version
14 |
15 | # Upgrade npm
16 | - npm install -g npm
17 |
18 | # Output our current versions for debugging
19 | - node --version
20 | - npm --version
21 |
22 | # Install our package dependencies
23 | - npm install
24 |
25 | test_script:
26 | - npm run test:node
27 |
28 | build: off
29 |
--------------------------------------------------------------------------------
/test/cli/commands.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | const expect = require('chai').expect
5 | const runOnAndOff = require('../utils/on-and-off')
6 |
7 | const commandCount = 58
8 |
9 | describe('commands', () => runOnAndOff((thing) => {
10 | let ipfs
11 |
12 | before(function () {
13 | this.timeout(30 * 1000)
14 | ipfs = thing.ipfs
15 | })
16 |
17 | it('list the commands', () => {
18 | return ipfs('commands').then((out) => {
19 | expect(out.split('\n')).to.have.length(commandCount + 1)
20 | })
21 | })
22 | }))
23 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM node:6
2 |
3 | RUN apt-get update
4 | RUN apt-get install --yes python2.7 git-all pkg-config libncurses5-dev libssl-dev libnss3-dev libexpat-dev libc6
5 |
6 | WORKDIR /usr/src/app
7 |
8 | COPY package.json /usr/src/app/package.json
9 |
10 | RUN npm install
11 | RUN npm install wrtc
12 |
13 | COPY . /usr/src/app
14 |
15 | ENV IPFS_WRTC_LINUX_WINDOWS=1
16 | ENV IPFS_BOOTSTRAP=1
17 | ENV IPFS_MONITORING=1
18 | ENV IPFS_PATH=/root/.jsipfs
19 |
20 | EXPOSE 4002
21 | EXPOSE 4003
22 | EXPOSE 5002
23 | EXPOSE 9090
24 |
25 | CMD ./init-and-daemon.sh
26 |
--------------------------------------------------------------------------------
/examples/run-in-electron/README.md:
--------------------------------------------------------------------------------
1 | # js-ipfs in Electron
2 |
3 | > This example is heavily inspired by [electron-quick-start](https://github.com/electron/electron-quick-start).
4 |
5 | **DISCLAIMER:** This example is still a work in progress, it currently doesn't work due to the usage of native dependencies that Electron is not supporting.
6 |
7 | To try it by yourself, do:
8 |
9 | ```
10 | > npm install
11 | > ./node_modules/.bin/electron-rebuild
12 | # or
13 | > ./build.sh
14 | #
15 | # You can also try to use `npm start` to see where electron errors
16 | ```
17 |
--------------------------------------------------------------------------------
/test/cli/version.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | const expect = require('chai').expect
5 | const pkgversion = require('../../package.json').version
6 | const runOnAndOff = require('../utils/on-and-off')
7 |
8 | describe('version', () => runOnAndOff((thing) => {
9 | let ipfs
10 |
11 | before(() => {
12 | ipfs = thing.ipfs
13 | })
14 |
15 | it('get the version', () => {
16 | return ipfs('version').then((out) => {
17 | expect(out).to.eql(
18 | `js-ipfs version: ${pkgversion}\n`
19 | )
20 | })
21 | })
22 | }))
23 |
--------------------------------------------------------------------------------
/examples/browser-webpack/README.md:
--------------------------------------------------------------------------------
1 | # Bundle js-ipfs with Webpack!
2 |
3 | > In this example, you will find a boilerplate you can use to guide yourself into bundling js-ipfs with webpack, so that you can use it in your own web app!
4 |
5 | ## Run this example
6 |
7 | Once the daemon is on, run the following commands within this folder:
8 |
9 | ```bash
10 | > npm install
11 | > npm start
12 | ```
13 |
14 | Now open your browser at `http://localhost:3000`
15 |
16 | You should see the following:
17 |
18 | 
19 |
--------------------------------------------------------------------------------
/examples/browser-browserify/README.md:
--------------------------------------------------------------------------------
1 | # Bundle js-ipfs with Browserify!
2 |
3 | > In this example, you will find a boilerplate you can use to guide yourself into bundling js-ipfs with browserify, so that you can use it in your own web app!
4 |
5 | ## Run this example
6 |
7 | ```bash
8 | > npm install
9 | > npm start
10 | ```
11 |
12 | Now open your browser at `http://localhost:8888`
13 |
14 | You should see the following:
15 |
16 | 
17 | 
18 |
--------------------------------------------------------------------------------
/examples/run-in-electron/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "js-ipfs-in-electron",
3 | "version": "0.0.0",
4 | "description": "A minimal Electron application with js-ipfs",
5 | "main": "main.js",
6 | "scripts": {
7 | "start": "electron .",
8 | "postinstall": "electron-rebuild"
9 | },
10 | "keywords": [
11 | "Electron",
12 | "IPFS",
13 | "Example"
14 | ],
15 | "author": "David Dias ",
16 | "license": "MIT",
17 | "devDependencies": {
18 | "electron": "~1.6.11",
19 | "electron-rebuild": "^1.5.11",
20 | "ipfs": "ipfs/js-ipfs"
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/examples/browser-browserify/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bundle-browserify",
3 | "version": "1.0.0",
4 | "description": "Bundle js-ipfs with Browserify",
5 | "main": "index.js",
6 | "scripts": {
7 | "bundle": "browserify src/index.js > public/bundle.js",
8 | "serve": "http-server public -a 127.0.0.1 -p 8888",
9 | "start": "npm run bundle && npm run serve"
10 | },
11 | "keywords": [],
12 | "license": "MIT",
13 | "devDependencies": {
14 | "browserify": "^14.0.0",
15 | "concat-stream": "^1.6.0",
16 | "http-server": "^0.9.0"
17 | },
18 | "dependencies": {}
19 | }
20 |
--------------------------------------------------------------------------------
/src/cli/commands/object/new.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const debug = require('debug')
4 | const log = debug('cli:object')
5 | log.error = debug('cli:object:error')
6 | const print = require('../../utils').print
7 |
8 | module.exports = {
9 | command: 'new []',
10 |
11 | describe: 'Create new ipfs objects',
12 |
13 | builder: {},
14 |
15 | handler (argv) {
16 | argv.ipfs.object.new(argv.template, (err, node) => {
17 | if (err) {
18 | throw err
19 | }
20 |
21 | const nodeJSON = node.toJSON()
22 |
23 | print(nodeJSON.multihash)
24 | })
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/create-node.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const IPFS = require('../../src/core')
4 | // In your project, replace by the following line and install IPFS as a dep
5 | // const IPFS = require('ipfs')
6 |
7 | function createNode (options, callback) {
8 | if (typeof options === 'function') {
9 | callback = options
10 | options = {}
11 | }
12 |
13 | options.path = options.path || '/tmp/ipfs' + Math.random()
14 |
15 | const node = new IPFS({
16 | repo: options.path
17 | })
18 |
19 | node.on('start', () => callback(null, node))
20 | }
21 |
22 | module.exports = createNode
23 |
--------------------------------------------------------------------------------
/examples/run-in-electron/build.sh:
--------------------------------------------------------------------------------
1 | # Electron's version.
2 | export npm_config_target=1.6.11
3 | # The architecture of Electron, can be ia32 or x64.
4 | export npm_config_arch=x64
5 | export npm_config_target_arch=x64
6 | # Download headers for Electron.
7 | export npm_config_disturl=https://atom.io/download/electron
8 | # Tell node-pre-gyp that we are building for Electron.
9 | export npm_config_runtime=electron
10 | # Tell node-pre-gyp to build module from source code.
11 | export npm_config_build_from_source=true
12 | # Install all dependencies, and store cache to ~/.electron-gyp.
13 | HOME=~/.electron-gyp npm install
14 |
--------------------------------------------------------------------------------
/test/cli/id.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | const expect = require('chai').expect
5 | const runOnAndOff = require('../utils/on-and-off')
6 |
7 | describe('id', () => runOnAndOff((thing) => {
8 | let ipfs
9 |
10 | before(function () {
11 | this.timeout(30 * 1000)
12 | ipfs = thing.ipfs
13 | })
14 |
15 | it('get the id', () => {
16 | return ipfs('id').then((res) => {
17 | const id = JSON.parse(res)
18 | expect(id).to.have.property('id')
19 | expect(id).to.have.property('publicKey')
20 | expect(id).to.have.property('addresses')
21 | })
22 | })
23 | }))
24 |
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/datastore/LOG.old:
--------------------------------------------------------------------------------
1 | =============== Dec 10, 2015 (PST) ===============
2 | 07:50:02.056578 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed
3 | 07:50:02.057231 db@open opening
4 | 07:50:02.057312 journal@recovery F·1
5 | 07:50:02.057514 journal@recovery recovering @3
6 | 07:50:02.058921 mem@flush created L0@5 N·4 S·1KiB "/ip..\xf6\xe4\xa9,v5":"/pk..\xf6\xe4\xa9,v6"
7 | 07:50:02.059983 db@janitor F·4 G·0
8 | 07:50:02.060001 db@open done T·2.755926ms
9 | 07:50:02.073183 db@close closing
10 | 07:50:02.073285 db@close done T·97.522µs
11 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: node_js
3 |
4 | matrix:
5 | include:
6 | - node_js: 6
7 | env: CXX=g++-4.8
8 | - node_js: 8
9 | env: CXX=g++-4.8
10 | # - node_js: stable
11 | # env: CXX=g++-4.8
12 |
13 | script:
14 | - npm run lint
15 | - npm run test
16 | - npm run coverage
17 | - make test
18 |
19 | before_script:
20 | - export DISPLAY=:99.0
21 | - sh -e /etc/init.d/xvfb start
22 |
23 | after_success:
24 | - npm run coverage-publish
25 |
26 | addons:
27 | firefox: 'latest'
28 | apt:
29 | sources:
30 | - ubuntu-toolchain-r-test
31 | packages:
32 | - g++-4.8
33 |
--------------------------------------------------------------------------------
/src/cli/commands/file/ls.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const print = require('../../utils').print
4 |
5 | module.exports = {
6 | command: 'ls ',
7 |
8 | describe: 'List directory contents for Unix filesystem objects.',
9 |
10 | builder: {},
11 |
12 | handler (argv) {
13 | let path = argv.key
14 | argv.ipfs.ls(path, (err, links) => {
15 | if (err) {
16 | throw err
17 | }
18 |
19 | // Single file? Then print its hash
20 | if (links.length === 0) {
21 | links = [{hash: path}]
22 | }
23 |
24 | links.forEach((file) => print(file.hash))
25 | })
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/cli/commands/object/links.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const print = require('../../utils').print
4 |
5 | module.exports = {
6 | command: 'links ',
7 |
8 | describe: 'Outputs the links pointed to by the specified object',
9 |
10 | builder: {},
11 |
12 | handler (argv) {
13 | argv.ipfs.object.links(argv.key, {
14 | enc: 'base58'
15 | }, (err, links) => {
16 | if (err) {
17 | throw err
18 | }
19 |
20 | links.forEach((link) => {
21 | link = link.toJSON()
22 |
23 | print(`${link.multihash} ${link.size} ${link.name}`)
24 | })
25 | })
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/cli/commands/object/stat.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const print = require('../../utils').print
4 |
5 | module.exports = {
6 | command: 'stat ',
7 |
8 | describe: 'Get stats for the DAG node named by ',
9 |
10 | builder: {},
11 |
12 | handler (argv) {
13 | argv.ipfs.object.stat(argv.key, {
14 | enc: 'base58'
15 | }, (err, stats) => {
16 | if (err) {
17 | throw err
18 | }
19 |
20 | delete stats.Hash // only for js-ipfs-api output
21 |
22 | Object.keys(stats).forEach((key) => {
23 | print(`${key}: ${stats[key]}`)
24 | })
25 | })
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/cli/commands/config/show.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const debug = require('debug')
4 | const log = debug('cli:config')
5 | log.error = debug('cli:config:error')
6 | const print = require('../../utils').print
7 |
8 | module.exports = {
9 | command: 'show',
10 |
11 | describe: 'Outputs the content of the config file',
12 |
13 | builder: {},
14 |
15 | handler (argv) {
16 | if (argv._handled) return
17 | argv._handled = true
18 |
19 | argv.ipfs.config.get((err, config) => {
20 | if (err) {
21 | throw err
22 | }
23 |
24 | print(JSON.stringify(config, null, 4))
25 | })
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/core/components/config.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const promisify = require('promisify-es6')
4 |
5 | module.exports = function config (self) {
6 | return {
7 | get: promisify((key, callback) => {
8 | if (typeof key === 'function') {
9 | callback = key
10 | key = undefined
11 | }
12 |
13 | return self._repo.config.get(key, callback)
14 | }),
15 | set: promisify((key, value, callback) => {
16 | self._repo.config.set(key, value, callback)
17 | }),
18 | replace: promisify((config, callback) => {
19 | self._repo.config.set(config, callback)
20 | })
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/src/cli/commands/swarm/connect.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const utils = require('../../utils')
4 | const print = utils.print
5 |
6 | module.exports = {
7 | command: 'connect ',
8 |
9 | describe: 'Open connection to a given address',
10 |
11 | builder: {},
12 |
13 | handler (argv) {
14 | if (!utils.isDaemonOn()) {
15 | throw new Error('This command must be run in online mode. Try running \'ipfs daemon\' first.')
16 | }
17 |
18 | argv.ipfs.swarm.connect(argv.address, (err, res) => {
19 | if (err) {
20 | throw err
21 | }
22 |
23 | print(res.Strings[0])
24 | })
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/datastore/LOG.old:
--------------------------------------------------------------------------------
1 | =============== Dec 10, 2015 (PST) ===============
2 | 07:50:02.056578 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed
3 | 07:50:02.057231 db@open opening
4 | 07:50:02.057312 journal@recovery F·1
5 | 07:50:02.057514 journal@recovery recovering @3
6 | 07:50:02.058921 mem@flush created L0@5 N·4 S·1KiB "/ip..\xf6\xe4\xa9,v5":"/pk..\xf6\xe4\xa9,v6"
7 | 07:50:02.059983 db@janitor F·4 G·0
8 | 07:50:02.060001 db@open done T·2.755926ms
9 | 07:50:02.073183 db@close closing
10 | 07:50:02.073285 db@close done T·97.522µs
11 |
--------------------------------------------------------------------------------
/test/http-api/over-ipfs-api/version.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | const chai = require('chai')
5 | const dirtyChai = require('dirty-chai')
6 | const expect = chai.expect
7 | chai.use(dirtyChai)
8 |
9 | module.exports = (ctl) => {
10 | describe('.version', () => {
11 | it('get the version', (done) => {
12 | ctl.version((err, result) => {
13 | expect(err).to.not.exist()
14 | expect(result).to.have.a.property('version')
15 | expect(result).to.have.a.property('commit')
16 | expect(result).to.have.a.property('repo')
17 | done()
18 | })
19 | })
20 | })
21 | }
22 |
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/put.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const createNode = require('./create-node.js')
4 |
5 | createNode((err, ipfs) => {
6 | if (err) {
7 | throw err
8 | }
9 |
10 | console.log('\nStart of the example:')
11 |
12 | const myData = {
13 | name: 'David',
14 | likes: ['js-ipfs', 'icecream', 'steak']
15 | }
16 |
17 | ipfs.dag.put(myData, { format: 'dag-cbor', hashAlg: 'sha2-256' }, (err, cid) => {
18 | if (err) {
19 | throw err
20 | }
21 | console.log(cid.toBaseEncodedString())
22 | // should print:
23 | // zdpuAzZSktMhXjJu5zneSFrg9ue5rLXKAMC9KLigqhQ7Q7vRm
24 | })
25 | })
26 |
--------------------------------------------------------------------------------
/src/cli/commands/bootstrap/add.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const print = require('../../utils').print
4 |
5 | module.exports = {
6 | command: 'add []',
7 |
8 | describe: 'Add peers to the bootstrap list',
9 |
10 | builder: {
11 | default: {
12 | describe: 'Add default bootstrap nodes.',
13 | type: 'boolean',
14 | default: false
15 | }
16 | },
17 |
18 | handler (argv) {
19 | argv.ipfs.bootstrap.add(argv.peer, {
20 | default: argv.default
21 | }, (err, list) => {
22 | if (err) {
23 | throw err
24 | }
25 |
26 | list.Peers.forEach((peer) => print(peer))
27 | })
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/RELEASE.md:
--------------------------------------------------------------------------------
1 | # Release checklist
2 |
3 | > List of actions to perform before issuing a new js-ipfs release
4 |
5 | - Robustness and quality
6 | - [ ] Ensure that all tests are passing, this includes:
7 | - [ ] unit
8 | - [ ] interop
9 | - [ ] sharness
10 | - [ ] Run tests of the following projects with the new release:
11 | - n/a
12 | - Documentation
13 | - [ ] Ensure that README.md is up to date
14 | - [ ] Ensure that all the examples run
15 | - Communication
16 | - [ ] Create the release issue
17 | - [ ] Announcements (both pre-release and post-release)
18 | - [ ] Twitter
19 | - [ ] IRC
20 | - [ ] Reddit
21 | - [ ] Blog post
22 |
--------------------------------------------------------------------------------
/src/cli/commands/swarm/disconnect.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const utils = require('../../utils')
4 | const print = require('../../utils').print
5 |
6 | module.exports = {
7 | command: 'disconnect ',
8 |
9 | describe: 'Close connection to a given address',
10 |
11 | builder: {},
12 |
13 | handler (argv) {
14 | if (!utils.isDaemonOn()) {
15 | throw new Error('This command must be run in online mode. Try running \'ipfs daemon\' first.')
16 | }
17 |
18 | argv.ipfs.swarm.disconnect(argv.address, (err, res) => {
19 | if (err) {
20 | throw err
21 | }
22 |
23 | print(res.Strings[0])
24 | })
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | **/node_modules/
2 | **/*.log
3 | test/repo-tests*
4 |
5 | # Logs
6 | logs
7 | *.log
8 |
9 | coverage
10 |
11 | # Runtime data
12 | pids
13 | *.pid
14 | *.seed
15 |
16 | # Directory for instrumented libs generated by jscoverage/JSCover
17 | lib-cov
18 |
19 | # Coverage directory used by tools like istanbul
20 | coverage
21 |
22 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
23 | .grunt
24 |
25 | # node-waf configuration
26 | .lock-wscript
27 |
28 | build
29 |
30 | # Dependency directory
31 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
32 | node_modules
33 |
34 | test
35 |
--------------------------------------------------------------------------------
/test/utils/create-repo-browser.js:
--------------------------------------------------------------------------------
1 | /* global self */
2 | 'use strict'
3 |
4 | const IPFSRepo = require('ipfs-repo')
5 | const hat = require('hat')
6 |
7 | const idb = self.indexedDB ||
8 | self.mozIndexedDB ||
9 | self.webkitIndexedDB ||
10 | self.msIndexedDB
11 |
12 | function createTempRepo (repoPath) {
13 | repoPath = repoPath || '/ipfs-' + hat()
14 |
15 | const repo = new IPFSRepo(repoPath)
16 |
17 | repo.teardown = (done) => {
18 | repo.close(() => {
19 | idb.deleteDatabase(repoPath)
20 | idb.deleteDatabase(repoPath + '/blocks')
21 | done()
22 | })
23 | }
24 |
25 | return repo
26 | }
27 |
28 | module.exports = createTempRepo
29 |
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/get.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const createNode = require('./create-node.js')
4 |
5 | createNode((err, ipfs) => {
6 | if (err) {
7 | throw err
8 | }
9 |
10 | console.log('\nStart of the example:')
11 |
12 | const myData = {
13 | name: 'David',
14 | likes: ['js-ipfs', 'icecream', 'steak']
15 | }
16 |
17 | ipfs.dag.put(myData, { format: 'dag-cbor', hashAlg: 'sha2-256' }, (err, cid) => {
18 | if (err) {
19 | throw err
20 | }
21 |
22 | ipfs.dag.get(cid, (err, result) => {
23 | if (err) {
24 | throw err
25 | }
26 |
27 | console.log(JSON.stringify(result.value))
28 | })
29 | })
30 | })
31 |
--------------------------------------------------------------------------------
/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/contribution-guidelines.md).
4 |
5 | We also adhere to the [IPFS JavaScript Community contributing guidelines](https://github.com/ipfs/community/blob/master/js-project-guidelines.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 |
--------------------------------------------------------------------------------
/src/cli/commands/block/rm.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const utils = require('../../utils')
4 | const mh = require('multihashes')
5 | const print = utils.print
6 |
7 | module.exports = {
8 | command: 'rm ',
9 |
10 | describe: 'Remove a raw IPFS block',
11 |
12 | builder: {},
13 |
14 | handler (argv) {
15 | if (utils.isDaemonOn()) {
16 | // TODO implement this once `js-ipfs-api` supports it
17 | throw new Error('rm block with daemon running is not yet implemented')
18 | }
19 |
20 | argv.ipfs.block.del(mh.fromB58String(argv.key), (err) => {
21 | if (err) {
22 | throw err
23 | }
24 |
25 | print('removed ' + argv.key)
26 | })
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/cli/commands/bitswap/wantlist.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const print = require('../../utils').print
4 |
5 | module.exports = {
6 | command: 'wantlist',
7 |
8 | describe: 'Print out all blocks currently on the bitswap wantlist for the local peer.',
9 |
10 | builder: {
11 | peer: {
12 | alias: 'p',
13 | describe: 'Specify which peer to show wantlist for.',
14 | type: 'string'
15 | }
16 | },
17 |
18 | handler (argv) {
19 | // TODO: handle argv.peer
20 | argv.ipfs.bitswap.wantlist((err, res) => {
21 | if (err) {
22 | throw err
23 | }
24 | res.Keys.forEach((cidStr) => {
25 | print(cidStr)
26 | })
27 | })
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/examples/browser-webpack/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bundle-webpack",
3 | "version": "1.0.0",
4 | "description": "Bundle js-ipfs with WebPack",
5 | "scripts": {
6 | "start": "node server.js"
7 | },
8 | "license": "MIT",
9 | "keywords": [],
10 | "devDependencies": {
11 | "babel-core": "^6.24.1",
12 | "babel-loader": "^7.0.0",
13 | "babel-preset-react": "^6.24.1",
14 | "babel-preset-stage-0": "^6.24.1",
15 | "json-loader": "^0.5.4",
16 | "react": "^15.5.4",
17 | "react-dom": "^15.6.1",
18 | "react-hot-loader": "^1.3.1",
19 | "webpack": "^2.5.1",
20 | "webpack-dev-server": "^2.4.5"
21 | },
22 | "dependencies": {
23 | "ipfs": "file:../../"
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/cli/commands/config/replace.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const path = require('path')
4 | const fs = require('fs')
5 | const utils = require('../../utils')
6 |
7 | module.exports = {
8 | command: 'replace ',
9 |
10 | describe: 'Replaces the config with ',
11 |
12 | builder: {},
13 |
14 | handler (argv) {
15 | if (argv._handled) return
16 | argv._handled = true
17 |
18 | const filePath = path.resolve(process.cwd(), argv.file)
19 |
20 | const config = utils.isDaemonOn()
21 | ? filePath : JSON.parse(fs.readFileSync(filePath, 'utf8'))
22 |
23 | argv.ipfs.config.replace(config, (err) => {
24 | if (err) {
25 | throw err
26 | }
27 | })
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/test/sharness/t0000-sharness.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | test_description="Show basic features of Sharness"
4 |
5 | . ./lib/sharness/sharness.sh
6 |
7 | test_expect_success "Success is reported like this" "
8 | echo hello world | grep hello
9 | "
10 |
11 | test_expect_success "Commands are chained this way" "
12 | test x = 'x' &&
13 | test 2 -gt 1 &&
14 | echo success
15 | "
16 |
17 | return_42() {
18 | echo "Will return soon"
19 | return 42
20 | }
21 |
22 | test_expect_success "You can test for a specific exit code" "
23 | test_expect_code 42 return_42
24 | "
25 |
26 | test_expect_failure "We expect this to fail" "
27 | test 1 = 2
28 | "
29 |
30 | test_done
31 |
32 | # vi: set ft=sh :
33 |
--------------------------------------------------------------------------------
/src/cli/commands/swarm/addrs.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const print = require('../../utils').print
4 |
5 | module.exports = {
6 | command: 'addrs',
7 |
8 | describe: '',
9 |
10 | builder (yargs) {
11 | return yargs
12 | .commandDir('addrs')
13 | },
14 |
15 | handler (argv) {
16 | argv.ipfs.swarm.addrs((err, res) => {
17 | if (err) {
18 | throw err
19 | }
20 |
21 | res.forEach((peer) => {
22 | const count = peer.multiaddrs.size
23 | print(`${peer.id.toB58String()} (${count})`)
24 |
25 | peer.multiaddrs.forEach((addr) => {
26 | const res = addr.decapsulate('ipfs').toString()
27 | print(`\t${res}`)
28 | })
29 | })
30 | })
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/cli/commands/bootstrap/rm.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const debug = require('debug')
4 | const log = debug('cli:bootstrap')
5 | log.error = debug('cli:bootstrap:error')
6 | const print = require('../../utils').print
7 |
8 | module.exports = {
9 | command: 'rm []',
10 |
11 | describe: 'Removes peers from the bootstrap list',
12 |
13 | builder: {
14 | all: {
15 | type: 'boolean',
16 | describe: 'Remove all bootstrap peers.',
17 | default: false
18 | }
19 | },
20 |
21 | handler (argv) {
22 | argv.ipfs.bootstrap.rm(argv.peer, {
23 | all: argv.all
24 | }, (err, list) => {
25 | if (err) {
26 | throw err
27 | }
28 |
29 | list.Peers.forEach((peer) => print(peer))
30 | })
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/test/http-api/spec/version.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | const expect = require('chai').expect
5 | const pkgversion = require('./../../../package.json').version
6 |
7 | module.exports = (http) => {
8 | describe('/version', () => {
9 | let api
10 |
11 | before(() => {
12 | api = http.api.server.select('API')
13 | })
14 |
15 | it('get the version', (done) => {
16 | api.inject({
17 | method: 'GET',
18 | url: '/api/v0/version'
19 | }, (res) => {
20 | expect(res.result).to.have.a.property('Version', pkgversion)
21 | expect(res.result).to.have.a.property('Commit')
22 | expect(res.result).to.have.a.property('Repo')
23 | done()
24 | })
25 | })
26 | })
27 | }
28 |
--------------------------------------------------------------------------------
/test/utils/create-repo-nodejs.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const IPFSRepo = require('ipfs-repo')
4 | const clean = require('./clean')
5 | const os = require('os')
6 | const path = require('path')
7 | const hat = require('hat')
8 | const series = require('async/series')
9 |
10 | function createTempRepo (repoPath) {
11 | repoPath = repoPath || path.join(os.tmpdir(), '/ipfs-test-' + hat())
12 |
13 | const repo = new IPFSRepo(repoPath)
14 |
15 | repo.teardown = (done) => {
16 | series([
17 | // ignore err, might have been closed already
18 | (cb) => repo.close(() => cb()),
19 | (cb) => {
20 | clean(repoPath)
21 | cb()
22 | }
23 | ], done)
24 | }
25 |
26 | return repo
27 | }
28 |
29 | module.exports = createTempRepo
30 |
--------------------------------------------------------------------------------
/examples/browser-browserify/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | js-ipfs example
6 |
7 |
14 |
15 |
16 | JS IPFS - Add data to IPFS from the browser
17 |
19 |
20 |
21 |
found in ipfs:
22 |
[ipfs hash]
23 |
[ipfs content]
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/src/cli/commands/version.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const print = require('../utils').print
4 |
5 | module.exports = {
6 | command: 'version',
7 |
8 | describe: 'Shows IPFS version information',
9 |
10 | builder: {
11 | number: {
12 | alias: 'n',
13 | type: 'boolean',
14 | default: false
15 | },
16 | commit: {
17 | type: 'boolean',
18 | default: false
19 | },
20 | repo: {
21 | type: 'boolean',
22 | default: false
23 | }
24 | },
25 |
26 | handler (argv) {
27 | // TODO: handle argv.{repo|commit|number}
28 | argv.ipfs.version((err, version) => {
29 | if (err) {
30 | throw err
31 | }
32 |
33 | print(`js-ipfs version: ${version.version}`)
34 | })
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/core/components/id.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const promisify = require('promisify-es6')
4 | const setImmediate = require('async/setImmediate')
5 |
6 | module.exports = function id (self) {
7 | return promisify((opts, callback) => {
8 | if (typeof opts === 'function') {
9 | callback = opts
10 | opts = {}
11 | }
12 |
13 | setImmediate(() => callback(null, {
14 | id: self._peerInfo.id.toB58String(),
15 | publicKey: self._peerInfo.id.pubKey.bytes.toString('base64'),
16 | addresses: self._peerInfo.multiaddrs
17 | .toArray()
18 | .map((ma) => ma.toString())
19 | .filter((ma) => ma.indexOf('ipfs') >= 0)
20 | .sort(),
21 | agentVersion: 'js-ipfs',
22 | protocolVersion: '9000'
23 | }))
24 | })
25 | }
26 |
--------------------------------------------------------------------------------
/src/cli/commands/swarm/addrs/local.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const utils = require('../../../utils')
4 | const debug = require('debug')
5 | const log = debug('cli:object')
6 | log.error = debug('cli:object:error')
7 | const print = require('../../../utils').print
8 |
9 | module.exports = {
10 | command: 'local',
11 |
12 | describe: 'List local addresses',
13 |
14 | builder: {},
15 |
16 | handler (argv) {
17 | if (!utils.isDaemonOn()) {
18 | throw new Error('This command must be run in online mode. Try running \'ipfs daemon\' first.')
19 | }
20 |
21 | argv.ipfs.swarm.localAddrs((err, res) => {
22 | if (err) {
23 | throw err
24 | }
25 |
26 | res.forEach((addr) => {
27 | print(addr.toString())
28 | })
29 | })
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/http/api/routes/bitswap.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const resources = require('./../resources')
4 |
5 | module.exports = (server) => {
6 | const api = server.select('API')
7 |
8 | api.route({
9 | method: '*',
10 | path: '/api/v0/bitswap/wantlist',
11 | config: {
12 | handler: resources.bitswap.wantlist
13 | }
14 | })
15 |
16 | api.route({
17 | method: '*',
18 | path: '/api/v0/bitswap/stat',
19 | config: {
20 | handler: resources.bitswap.stat
21 | }
22 | })
23 |
24 | api.route({
25 | method: '*',
26 | path: '/api/v0/bitswap/unwant',
27 | config: {
28 | pre: [
29 | { method: resources.bitswap.unwant.parseArgs, assign: 'args' }
30 | ],
31 | handler: resources.bitswap.unwant.handler
32 | }
33 | })
34 | }
35 |
--------------------------------------------------------------------------------
/src/core/components/index.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | exports.preStart = require('./pre-start')
4 | exports.start = require('./start')
5 | exports.stop = require('./stop')
6 | exports.isOnline = require('./is-online')
7 | exports.version = require('./version')
8 | exports.id = require('./id')
9 | exports.repo = require('./repo')
10 | exports.init = require('./init')
11 | exports.bootstrap = require('./bootstrap')
12 | exports.config = require('./config')
13 | exports.block = require('./block')
14 | exports.object = require('./object')
15 | exports.dag = require('./dag')
16 | exports.libp2p = require('./libp2p')
17 | exports.swarm = require('./swarm')
18 | exports.ping = require('./ping')
19 | exports.files = require('./files')
20 | exports.bitswap = require('./bitswap')
21 | exports.pubsub = require('./pubsub')
22 | exports.dht = require('./dht')
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | **/node_modules/
2 | **/*.log
3 | test/repo-tests*
4 | **/bundle.js
5 |
6 | # Logs
7 | logs
8 | *.log
9 |
10 | coverage
11 |
12 | # Runtime data
13 | pids
14 | *.pid
15 | *.seed
16 |
17 | # Directory for instrumented libs generated by jscoverage/JSCover
18 | lib-cov
19 |
20 | # Coverage directory used by tools like istanbul
21 | coverage
22 |
23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24 | .grunt
25 |
26 | # node-waf configuration
27 | .lock-wscript
28 |
29 | build
30 |
31 | # Dependency directory
32 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
33 | node_modules
34 |
35 | lib
36 | dist
37 | test/test-data/go-ipfs-repo/LOCK
38 | test/test-data/go-ipfs-repo/LOG
39 | test/test-data/go-ipfs-repo/LOG.old
40 |
41 | # while testing npm5
42 | package-lock.json
43 |
--------------------------------------------------------------------------------
/src/http/api/routes/pubsub.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const resources = require('./../resources')
4 |
5 | module.exports = (server) => {
6 | const api = server.select('API')
7 |
8 | api.route({
9 | method: '*',
10 | path: '/api/v0/pubsub/sub',
11 | config: {
12 | handler: resources.pubsub.subscribe.handler
13 | }
14 | })
15 |
16 | api.route({
17 | method: '*',
18 | path: '/api/v0/pubsub/pub',
19 | config: {
20 | handler: resources.pubsub.publish.handler
21 | }
22 | })
23 |
24 | api.route({
25 | method: '*',
26 | path: '/api/v0/pubsub/ls',
27 | config: {
28 | handler: resources.pubsub.ls.handler
29 | }
30 | })
31 |
32 | api.route({
33 | method: '*',
34 | path: '/api/v0/pubsub/peers',
35 | config: {
36 | handler: resources.pubsub.peers.handler
37 | }
38 | })
39 | }
40 |
--------------------------------------------------------------------------------
/examples/browser-webpack/webpack.config.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | var path = require('path')
4 | var webpack = require('webpack')
5 |
6 | module.exports = {
7 | devtool: 'eval',
8 | entry: [
9 | 'webpack-dev-server/client?http://localhost:3000',
10 | 'webpack/hot/only-dev-server',
11 | './src/components/index'
12 | ],
13 | output: {
14 | path: path.join(__dirname, 'dist'),
15 | filename: 'bundle.js',
16 | publicPath: '/static/'
17 | },
18 | plugins: [
19 | new webpack.HotModuleReplacementPlugin()
20 | ],
21 | module: {
22 | loaders: [{
23 | test: /\.js$/,
24 | loaders: ['react-hot-loader', 'babel-loader'],
25 | include: path.join(__dirname, 'src')
26 | }, { test: /\.json$/, loader: 'json-loader' }]
27 | },
28 | node: {
29 | fs: 'empty',
30 | net: 'empty',
31 | tls: 'empty'
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/circle.yml:
--------------------------------------------------------------------------------
1 | machine:
2 | node:
3 | version: stable
4 |
5 | dependencies:
6 | pre:
7 | - google-chrome --version
8 | - curl -L -o google-chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
9 | - for v in $(curl http://archive.ubuntu.com/ubuntu/pool/main/n/nss/ | grep "href=" | grep "libnss3.*deb\"" -o | grep -o "libnss3.*deb" | grep "3.28" | grep "14.04"); do curl -L -o $v http://archive.ubuntu.com/ubuntu/pool/main/n/nss/$v; done && rm libnss3-tools*_i386.deb libnss3-dev*_i386.deb
10 | - sudo dpkg -i google-chrome.deb || true
11 | - sudo dpkg -i libnss3*.deb || true
12 | - sudo apt-get update
13 | - sudo apt-get install -f || true
14 | - sudo dpkg -i libnss3*.deb
15 | - sudo apt-get install -f
16 | - sudo apt-get install --only-upgrade lsb-base
17 | - sudo dpkg -i google-chrome.deb
18 | - google-chrome --version
19 |
--------------------------------------------------------------------------------
/src/cli/commands/object/patch/add-link.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const dagPB = require('ipld-dag-pb')
4 | const DAGLink = dagPB.DAGLink
5 | const print = require('../../../utils').print
6 |
7 | module.exports = {
8 | command: 'add-link [',
9 |
10 | describe: 'Add a link to a given object',
11 |
12 | builder: {},
13 |
14 | handler (argv) {
15 | const ipfs = argv.ipfs
16 | ipfs.object.get(argv.ref, {
17 | enc: 'base58'
18 | }, (err, nodeA) => {
19 | if (err) {
20 | throw err
21 | }
22 |
23 | const link = new DAGLink(argv.name, nodeA.size, nodeA.multihash)
24 |
25 | ipfs.object.patch.addLink(argv.root, link, {
26 | enc: 'base58'
27 | }, (err, nodeB) => {
28 | if (err) {
29 | throw err
30 | }
31 |
32 | print(nodeB.toJSON().multihash)
33 | })
34 | })
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/examples/ipfs-101/1.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const series = require('async/series')
4 | const IPFS = require('ipfs')
5 |
6 | const node = new IPFS()
7 | let fileMultihash
8 |
9 | series([
10 | (cb) => node.on('ready', cb),
11 | (cb) => node.version((err, version) => {
12 | if (err) { return cb(err) }
13 | console.log('Version:', version.version)
14 | cb()
15 | }),
16 | (cb) => node.files.add({
17 | path: 'hello.txt',
18 | content: Buffer.from('Hello World 101')
19 | }, (err, result) => {
20 | if (err) { return cb(err) }
21 |
22 | console.log('\nAdded file:', result[0].path, result[0].hash)
23 | fileMultihash = result[0].hash
24 | cb()
25 | }),
26 | (cb) => node.files.cat(fileMultihash, (err, stream) => {
27 | if (err) { return cb(err) }
28 |
29 | console.log('\nFile content:')
30 | stream.pipe(process.stdout)
31 | stream.on('end', process.exit)
32 | })
33 | ])
34 |
--------------------------------------------------------------------------------
/examples/browser-video-streaming/streaming.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | /* global Hls Ipfs HlsjsIpfsLoader */
4 | /* eslint-env browser */
5 |
6 | const testhash = 'QmdpAidwAsBGptFB3b6A9Pyi5coEbgjHrL3K2Qrsutmj9K'
7 | const repoPath = 'ipfs-' + Math.random()
8 | const ipfs = new Ipfs({
9 | init: false,
10 | start: false,
11 | repo: repoPath
12 | })
13 |
14 | ipfs.init((err) => {
15 | if (err) {
16 | throw err
17 | }
18 |
19 | ipfs.start(() => {
20 | Hls.DefaultConfig.loader = HlsjsIpfsLoader
21 | Hls.DefaultConfig.debug = false
22 | if (Hls.isSupported()) {
23 | const video = document.getElementById('video')
24 | const hls = new Hls()
25 | hls.config.ipfs = ipfs
26 | hls.config.ipfsHash = testhash
27 | hls.loadSource('master.m3u8')
28 | hls.attachMedia(video)
29 | hls.on(Hls.Events.MANIFEST_PARSED, () => {
30 | video.play()
31 | })
32 | }
33 | })
34 | })
35 |
--------------------------------------------------------------------------------
/test/cli/dag.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | const expect = require('chai').expect
5 | const runOnAndOff = require('../utils/on-and-off')
6 |
7 | describe('dag', () => runOnAndOff.off((thing) => {
8 | let ipfs
9 |
10 | before(() => {
11 | ipfs = thing.ipfs
12 | })
13 |
14 | it('get', () => {
15 | // put test eth-block
16 | return ipfs('block put --format eth-block --mhtype keccak-256 test/fixtures/test-data/eth-block').then((out) => {
17 | expect(out).to.eql('z43AaGF23fmvRnDP56Ub9WcJCfzSfqtmzNCCvmz5eudT8dtdCDS\n')
18 | // lookup path on eth-block
19 | return ipfs('dag get z43AaGF23fmvRnDP56Ub9WcJCfzSfqtmzNCCvmz5eudT8dtdCDS/parentHash')
20 | }).then((out) => {
21 | let expectHash = Buffer.from('c8c0a17305adea9bbb4b98a52d44f0c1478f5c48fc4b64739ee805242501b256', 'hex')
22 | expect(out).to.be.eql('0x' + expectHash.toString('hex') + '\n')
23 | })
24 | })
25 | }))
26 |
--------------------------------------------------------------------------------
/src/cli/commands/commands.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | const print = require('../utils').print
3 | const path = require('path')
4 | const glob = require('glob').sync
5 |
6 | module.exports = {
7 | command: 'commands',
8 |
9 | describe: 'List all available commands',
10 |
11 | handler () {
12 | const basePath = path.resolve(__dirname, '..')
13 |
14 | // modeled after https://github.com/vdemedes/ronin/blob/master/lib/program.js#L78
15 | const files = glob(path.join(basePath, 'commands', '**', '*.js'))
16 | const cmds = files.map((p) => {
17 | return p.replace(/\//g, path.sep)
18 | .replace(/^./, ($1) => $1.toUpperCase())
19 | .replace(path.join(basePath, 'commands'), '')
20 | .replace(path.sep, '')
21 | .split(path.sep)
22 | .join(' ')
23 | .replace('.js', '')
24 | }).sort().map((cmd) => `ipfs ${cmd}`)
25 |
26 | print(['ipfs'].concat(cmds).join('\n'))
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/cli/commands/object/get.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const print = require('../../utils').print
4 |
5 | module.exports = {
6 | command: 'get ',
7 |
8 | describe: 'Get and serialize the DAG node named by ',
9 |
10 | builder: {},
11 |
12 | handler (argv) {
13 | argv.ipfs.object.get(argv.key, {enc: 'base58'}, (err, node) => {
14 | if (err) {
15 | throw err
16 | }
17 | const nodeJSON = node.toJSON()
18 |
19 | nodeJSON.data = nodeJSON.data ? nodeJSON.data.toString() : ''
20 |
21 | const answer = {
22 | Data: nodeJSON.data,
23 | Hash: nodeJSON.multihash,
24 | Size: nodeJSON.size,
25 | Links: nodeJSON.links.map((l) => {
26 | return {
27 | Name: l.name,
28 | Size: l.size,
29 | Hash: l.multihash
30 | }
31 | })
32 | }
33 |
34 | print(JSON.stringify(answer))
35 | })
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/test/sharness/lib/iptb-lib.sh:
--------------------------------------------------------------------------------
1 | # iptb test framework
2 | #
3 | # Copyright (c) 2014, 2016 Jeromy Johnson, Christian Couder
4 | # MIT Licensed; see the LICENSE file in this repository.
5 |
6 | export IPTB_ROOT="$(pwd)/.iptb"
7 |
8 | ipfsi() {
9 | dir="$1"
10 | shift
11 | IPFS_PATH="$IPTB_ROOT/$dir" ipfs "$@"
12 | }
13 |
14 | check_has_connection() {
15 | node="$1"
16 | ipfsi "$node" swarm peers >"swarm_peers_$node" &&
17 | grep "ipfs" "swarm_peers_$node" >/dev/null
18 | }
19 |
20 | startup_cluster() {
21 | num_nodes="$1"
22 | bound=$(expr "$num_nodes" - 1)
23 |
24 | test_expect_success "start up nodes" '
25 | iptb start
26 | '
27 |
28 | test_expect_success "connect nodes to eachother" '
29 | iptb connect [1-$bound] 0
30 | '
31 |
32 | for i in $(test_seq 0 "$bound")
33 | do
34 | test_expect_success "node $i is connected" '
35 | check_has_connection "$i" ||
36 | test_fsh cat "swarm_peers_$i"
37 | '
38 | done
39 | }
40 |
--------------------------------------------------------------------------------
/src/init-files/init-docs/readme:
--------------------------------------------------------------------------------
1 | Hello and Welcome to IPFS!
2 |
3 | ██╗██████╗ ███████╗███████╗
4 | ██║██╔══██╗██╔════╝██╔════╝
5 | ██║██████╔╝█████╗ ███████╗
6 | ██║██╔═══╝ ██╔══╝ ╚════██║
7 | ██║██║ ██║ ███████║
8 | ╚═╝╚═╝ ╚═╝ ╚══════╝
9 |
10 | If you're seeing this, you have successfully installed
11 | IPFS and are now interfacing with the ipfs merkledag!
12 |
13 | -------------------------------------------------------
14 | | Warning: |
15 | | This is alpha software. Use at your own discretion! |
16 | | Much is missing or lacking polish. There are bugs. |
17 | | Not yet secure. Read the security notes for more. |
18 | -------------------------------------------------------
19 |
20 | Check out some of the other files in this directory:
21 |
22 | ./about
23 | ./help
24 | ./quick-start <-- usage examples
25 | ./readme <-- this file
26 | ./security-notes
27 |
--------------------------------------------------------------------------------
/src/cli/commands/swarm/peers.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const mafmt = require('mafmt')
4 | const multiaddr = require('multiaddr')
5 | const utils = require('../../utils')
6 | const print = require('../../utils').print
7 |
8 | module.exports = {
9 | command: 'peers',
10 |
11 | describe: 'List peers with open connections',
12 |
13 | builder: {},
14 |
15 | handler (argv) {
16 | if (!utils.isDaemonOn()) {
17 | throw new Error('This command must be run in online mode. Try running \'ipfs daemon\' first.')
18 | }
19 |
20 | argv.ipfs.swarm.peers((err, result) => {
21 | if (err) {
22 | throw err
23 | }
24 |
25 | result.forEach((item) => {
26 | let ma = multiaddr(item.addr.toString())
27 | if (!mafmt.IPFS.matches(ma)) {
28 | ma = ma.encapsulate('/ipfs/' + item.peer.toB58String())
29 | }
30 | const addr = ma.toString()
31 | print(addr)
32 | })
33 | })
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/http/api/routes/config.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const resources = require('./../resources')
4 |
5 | module.exports = (server) => {
6 | const api = server.select('API')
7 |
8 | api.route({
9 | method: '*',
10 | path: '/api/v0/config/{key?}',
11 | config: {
12 | pre: [
13 | { method: resources.config.getOrSet.parseArgs, assign: 'args' }
14 | ],
15 | handler: resources.config.getOrSet.handler
16 | }
17 | })
18 |
19 | api.route({
20 | method: '*',
21 | path: '/api/v0/config/show',
22 | handler: resources.config.show
23 | })
24 |
25 | api.route({
26 | method: '*',
27 | path: '/api/v0/config/replace',
28 | config: {
29 | payload: {
30 | parse: false,
31 | output: 'stream'
32 | },
33 | pre: [
34 | { method: resources.config.replace.parseArgs, assign: 'args' }
35 | ],
36 | handler: resources.config.replace.handler
37 | }
38 | })
39 | }
40 |
--------------------------------------------------------------------------------
/src/init-files/init-docs/tour/0.0-intro:
--------------------------------------------------------------------------------
1 | WIP
2 |
3 | # 0.0 - Introduction
4 |
5 | Welcome to IPFS! This tour will guide you through a few of the
6 | features of this tool, and the most common commands. Then, it will
7 | immerse you into the world of merkledags and the amazing things
8 | you can do with them.
9 |
10 |
11 | This tour has many parts, and can be taken in different sequences.
12 | Different people learn different ways, so choose your own adventure:
13 |
14 | To start with the concepts, try:
15 | - The Merkle DAG
16 | - Data Structures on the Merkle DAG
17 | - Representing Files with unixfs
18 | - add, cat, ls, refs
19 | ...
20 |
21 |
22 | To start with the examples, try:
23 | - add, cat, ls, refs
24 | - Representing Files with unixfs
25 | - Data Structures on the Merkle DAG
26 | - The Merkle DAG
27 | ...
28 |
29 |
30 | To start with the network, try:
31 | - IPFS Nodes
32 | - Running the daemon
33 | - The Swarm
34 | - The Web
35 |
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/init-docs/readme:
--------------------------------------------------------------------------------
1 | Hello and Welcome to IPFS!
2 |
3 | ██╗██████╗ ███████╗███████╗
4 | ██║██╔══██╗██╔════╝██╔════╝
5 | ██║██████╔╝█████╗ ███████╗
6 | ██║██╔═══╝ ██╔══╝ ╚════██║
7 | ██║██║ ██║ ███████║
8 | ╚═╝╚═╝ ╚═╝ ╚══════╝
9 |
10 | If you're seeing this, you have successfully installed
11 | IPFS and are now interfacing with the ipfs merkledag!
12 |
13 | -------------------------------------------------------
14 | | Warning: |
15 | | This is alpha software. Use at your own discretion! |
16 | | Much is missing or lacking polish. There are bugs. |
17 | | Not yet secure. Read the security notes for more. |
18 | -------------------------------------------------------
19 |
20 | Check out some of the other files in this directory:
21 |
22 | ./about
23 | ./help
24 | ./quick-start <-- usage examples
25 | ./readme <-- this file
26 | ./security-notes
27 |
--------------------------------------------------------------------------------
/examples/explore-ethereum-blockchain/load-eth-stuffs.sh:
--------------------------------------------------------------------------------
1 | # Blocks
2 | jsipfs block put --format=eth-block --mhtype=keccak-256 eth-stuffs/block_302515
3 | jsipfs block put --format=eth-block --mhtype=keccak-256 eth-stuffs/block_302516
4 | jsipfs block put --format=eth-block --mhtype=keccak-256 eth-stuffs/block_302517
5 |
6 | # State Trie
7 | jsipfs block put --format=eth-state-trie --mhtype=keccak-256 eth-stuffs/state_000017_302516
8 | jsipfs block put --format=eth-state-trie --mhtype=keccak-256 eth-stuffs/state_00001_302516
9 | jsipfs block put --format=eth-state-trie --mhtype=keccak-256 eth-stuffs/state_00001_302516
10 | jsipfs block put --format=eth-state-trie --mhtype=keccak-256 eth-stuffs/state_000_302516
11 | jsipfs block put --format=eth-state-trie --mhtype=keccak-256 eth-stuffs/state_00_302516
12 | jsipfs block put --format=eth-state-trie --mhtype=keccak-256 eth-stuffs/state_0_302516
13 | jsipfs block put --format=eth-state-trie --mhtype=keccak-256 eth-stuffs/state_r_302516
14 |
--------------------------------------------------------------------------------
/examples/exchange-files-in-browser/img/diagram.txt:
--------------------------------------------------------------------------------
1 | ┌──────────────┐ ┌──────────────┐
2 | │ Browser │ │ Browser │
3 | │ │ WebRTC │ │
4 | │ │◀─────────────────▶│ │
5 | │ │ │ │
6 | └──────────────┘ └──────────────┘
7 | ▲ ▲
8 | │ │
9 | │ │
10 | │ │
11 | │WebSockets WebSockets│
12 | │ │
13 | │ │
14 | │ ┌──────────────┐ │
15 | │ │ Desktop │ │
16 | │ │ │ │
17 | └───────▶│ │◀─────────┘
18 | │ │
19 | └──────────────┘
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/init-docs/tour/0.0-intro:
--------------------------------------------------------------------------------
1 | WIP
2 |
3 | # 0.0 - Introduction
4 |
5 | Welcome to IPFS! This tour will guide you through a few of the
6 | features of this tool, and the most common commands. Then, it will
7 | immerse you into the world of merkledags and the amazing things
8 | you can do with them.
9 |
10 |
11 | This tour has many parts, and can be taken in different sequences.
12 | Different people learn different ways, so choose your own adventure:
13 |
14 | To start with the concepts, try:
15 | - The Merkle DAG
16 | - Data Structures on the Merkle DAG
17 | - Representing Files with unixfs
18 | - add, cat, ls, refs
19 | ...
20 |
21 |
22 | To start with the examples, try:
23 | - add, cat, ls, refs
24 | - Representing Files with unixfs
25 | - Data Structures on the Merkle DAG
26 | - The Merkle DAG
27 | ...
28 |
29 |
30 | To start with the network, try:
31 | - IPFS Nodes
32 | - Running the daemon
33 | - The Swarm
34 | - The Web
35 |
--------------------------------------------------------------------------------
/test/utils/ipfs-factory-instance/default-config.json:
--------------------------------------------------------------------------------
1 | {
2 | "Datastore": {
3 | "Type": "",
4 | "Path": "",
5 | "StorageMax": "",
6 | "StorageGCWatermark": 0,
7 | "GCPeriod": "",
8 | "Params": null,
9 | "NoSync": false
10 | },
11 | "Addresses": {
12 | "Swarm": [
13 | "/ip4/127.0.0.1/tcp/0"
14 | ],
15 | "API": "/ip4/127.0.0.1/tcp/0",
16 | "Gateway": "/ip4/127.0.0.1/tcp/0"
17 | },
18 | "Version": {
19 | "Current": "jsipfs-dev",
20 | "Check": "error",
21 | "CheckDate": "0001-01-01T00:00:00Z",
22 | "CheckPeriod": "172800000000000",
23 | "AutoUpdate": "minor"
24 | },
25 | "Discovery": {
26 | "MDNS": {
27 | "Enabled": false,
28 | "Interval": 10
29 | },
30 | "webRTCStar": {
31 | "Enabled": false
32 | }
33 | },
34 | "Ipns": {
35 | "RepublishPeriod": "",
36 | "RecordLifetime": "",
37 | "ResolveCacheSize": 128
38 | },
39 | "Bootstrap": [],
40 | "API": {
41 | "HTTPHeaders": null
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/cli/commands/object/patch/rm-link.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const DAGLink = require('ipld-dag-pb').DAGLink
4 | const debug = require('debug')
5 | const log = debug('cli:object')
6 | log.error = debug('cli:object:error')
7 | const print = require('../../../utils').print
8 |
9 | module.exports = {
10 | command: 'rm-link ',
11 |
12 | describe: 'Remove a link from an object',
13 |
14 | builder: {},
15 |
16 | handler (argv) {
17 | // TODO rmLink should support removing by name and/or multihash
18 | // without having to know everything, which in fact it does, however,
19 | // since it expectes a DAGLink type, we have to pass some fake size and
20 | // hash.
21 | const link = new DAGLink(argv.link, 1, 'Qm')
22 | argv.ipfs.object.patch.rmLink(argv.root, link, {
23 | enc: 'base58'
24 | }, (err, node) => {
25 | if (err) {
26 | throw err
27 | }
28 |
29 | const nodeJSON = node.toJSON()
30 |
31 | print(nodeJSON.multihash)
32 | })
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/cli/commands/object/put.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const bl = require('bl')
4 | const fs = require('fs')
5 | const print = require('../../utils').print
6 |
7 | function putNode (buf, enc, ipfs) {
8 | ipfs.object.put(buf, {enc: enc}, (err, node) => {
9 | if (err) {
10 | throw err
11 | }
12 |
13 | const nodeJSON = node.toJSON()
14 |
15 | print(`added ${nodeJSON.multihash}`)
16 | })
17 | }
18 |
19 | module.exports = {
20 | command: 'put [data]',
21 |
22 | describe: 'Stores input as a DAG object, outputs its key',
23 |
24 | builder: {
25 | 'input-enc': {
26 | type: 'string',
27 | default: 'json'
28 | }
29 | },
30 |
31 | handler (argv) {
32 | const ipfs = argv.ipfs
33 | if (argv.data) {
34 | const buf = fs.readFileSync(argv.data)
35 | return putNode(buf, argv.inputEnc, ipfs)
36 | }
37 |
38 | process.stdin.pipe(bl((err, input) => {
39 | if (err) {
40 | throw err
41 | }
42 |
43 | putNode(input, argv.inputEnc, ipfs)
44 | }))
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/http/gateway/utils/path.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | function splitPath (path) {
4 | if (path[path.length - 1] === '/') {
5 | path = path.substring(0, path.length - 1)
6 | }
7 |
8 | return path.substring(6).split('/')
9 | }
10 |
11 | function removeLeadingSlash (url) {
12 | if (url[0] === '/') {
13 | url = url.substring(1)
14 | }
15 |
16 | return url
17 | }
18 |
19 | function removeTrailingSlash (url) {
20 | if (url.endsWith('/')) {
21 | url = url.substring(0, url.length - 1)
22 | }
23 |
24 | return url
25 | }
26 |
27 | function removeSlashFromBothEnds (url) {
28 | url = removeLeadingSlash(url)
29 | url = removeTrailingSlash(url)
30 |
31 | return url
32 | }
33 |
34 | function joinURLParts (...urls) {
35 | urls = urls.filter((url) => url.length > 0)
36 | urls = [ '' ].concat(urls.map((url) => removeSlashFromBothEnds(url)))
37 |
38 | return urls.join('/')
39 | }
40 |
41 | module.exports = {
42 | splitPath: splitPath,
43 | removeTrailingSlash: removeTrailingSlash,
44 | joinURLParts: joinURLParts
45 | }
46 |
--------------------------------------------------------------------------------
/src/core/components/bitswap.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const OFFLINE_ERROR = require('../utils').OFFLINE_ERROR
4 |
5 | function formatWantlist (list) {
6 | return Array.from(list).map((e) => e[1])
7 | }
8 |
9 | module.exports = function bitswap (self) {
10 | return {
11 | wantlist: () => {
12 | if (!self.isOnline()) {
13 | throw new Error(OFFLINE_ERROR)
14 | }
15 |
16 | const list = self._bitswap.getWantlist()
17 | return formatWantlist(list)
18 | },
19 | stat: () => {
20 | if (!self.isOnline()) {
21 | throw new Error(OFFLINE_ERROR)
22 | }
23 |
24 | const stats = self._bitswap.stat()
25 | stats.wantlist = formatWantlist(stats.wantlist)
26 | stats.peers = stats.peers.map((id) => id.toB58String())
27 |
28 | return stats
29 | },
30 | unwant: (key) => {
31 | if (!self.isOnline()) {
32 | throw new Error(OFFLINE_ERROR)
33 | }
34 |
35 | // TODO: implement when https://github.com/ipfs/js-ipfs-bitswap/pull/10 is merged
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/test/cli/bitswap.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | const expect = require('chai').expect
5 | const runOn = require('../utils/on-and-off').on
6 |
7 | describe('bitswap', () => runOn((thing) => {
8 | let ipfs
9 | const key = 'QmUBdnXXPyoDFXj3Hj39dNJ5VkN3QFRskXxcGaYFBB8CNR'
10 |
11 | before((done) => {
12 | ipfs = thing.ipfs
13 | ipfs('block get ' + key)
14 | .then(() => {})
15 | .catch(() => {})
16 | setTimeout(done, 800)
17 | })
18 |
19 | it('wantlist', () => {
20 | return ipfs('bitswap wantlist').then((out) => {
21 | expect(out).to.eql(key + '\n')
22 | })
23 | })
24 |
25 | it('stat', () => {
26 | return ipfs('bitswap stat').then((out) => {
27 | expect(out).to.be.eql([
28 | 'bitswap status',
29 | ' blocks received: 0',
30 | ' dup blocks received: 0',
31 | ' dup data received: 0B',
32 | ' wantlist [1 keys]',
33 | ` ${key}`,
34 | ' partners [0]',
35 | ' '
36 | ].join('\n') + '\n')
37 | })
38 | })
39 | }))
40 |
--------------------------------------------------------------------------------
/test/http-api/spec/bitswap.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | const expect = require('chai').expect
5 |
6 | module.exports = (http) => {
7 | describe('/bitswap', () => {
8 | let api
9 |
10 | before(() => {
11 | api = http.api.server.select('API')
12 | })
13 |
14 | it('/wantlist', (done) => {
15 | api.inject({
16 | method: 'GET',
17 | url: '/api/v0/bitswap/wantlist'
18 | }, (res) => {
19 | expect(res.statusCode).to.equal(200)
20 | expect(res.result).to.have.property('Keys')
21 | done()
22 | })
23 | })
24 |
25 | it('/stat', (done) => {
26 | api.inject({
27 | method: 'GET',
28 | url: '/api/v0/bitswap/stat'
29 | }, (res) => {
30 | expect(res.statusCode).to.equal(200)
31 |
32 | expect(res.result).to.have.keys([
33 | 'BlocksReceived',
34 | 'Wantlist',
35 | 'Peers',
36 | 'DupBlksReceived',
37 | 'DupDataReceived'
38 | ])
39 | done()
40 | })
41 | })
42 | })
43 | }
44 |
--------------------------------------------------------------------------------
/src/cli/commands/object/patch/set-data.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const fs = require('fs')
4 | const bl = require('bl')
5 | const debug = require('debug')
6 | const log = debug('cli:object')
7 | log.error = debug('cli:object:error')
8 | const print = require('../../../utils').print
9 |
10 | function parseAndAddNode (key, data, ipfs) {
11 | ipfs.object.patch.setData(key, data, {
12 | enc: 'base58'
13 | }, (err, node) => {
14 | if (err) {
15 | throw err
16 | }
17 | const nodeJSON = node.toJSON()
18 |
19 | print(nodeJSON.multihash)
20 | })
21 | }
22 |
23 | module.exports = {
24 | command: 'set-data [data]',
25 |
26 | describe: 'Set data field of an ipfs object',
27 |
28 | builder: {},
29 |
30 | handler (argv) {
31 | const ipfs = argv.ipfs
32 | if (argv.data) {
33 | return parseAndAddNode(argv.root, fs.readFileSync(argv.data), ipfs)
34 | }
35 |
36 | process.stdin.pipe(bl((err, input) => {
37 | if (err) {
38 | throw err
39 | }
40 |
41 | parseAndAddNode(argv.root, input, ipfs)
42 | }))
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/get-path.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const createNode = require('./create-node.js')
4 |
5 | createNode((err, ipfs) => {
6 | if (err) {
7 | throw err
8 | }
9 |
10 | console.log('\nStart of the example:')
11 |
12 | const myData = {
13 | name: 'David',
14 | likes: ['js-ipfs', 'icecream', 'steak']
15 | }
16 |
17 | ipfs.dag.put(myData, { format: 'dag-cbor', hashAlg: 'sha2-256' }, (err, cid) => {
18 | if (err) {
19 | throw err
20 | }
21 |
22 | ipfs.dag.get(cid, 'name', (err, result) => {
23 | if (err) {
24 | throw err
25 | }
26 |
27 | console.log(result.value, result.remainderPath)
28 | })
29 |
30 | ipfs.dag.get(cid, 'likes', (err, result) => {
31 | if (err) {
32 | throw err
33 | }
34 |
35 | console.log(result.value)
36 | })
37 |
38 | const cidStr = cid.toBaseEncodedString()
39 |
40 | ipfs.dag.get(cidStr + '/likes/0', (err, result) => {
41 | if (err) {
42 | throw err
43 | }
44 |
45 | console.log(result.value)
46 | })
47 | })
48 | })
49 |
--------------------------------------------------------------------------------
/src/cli/commands/object/patch/append-data.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const bl = require('bl')
4 | const fs = require('fs')
5 | const debug = require('debug')
6 | const log = debug('cli:object')
7 | log.error = debug('cli:object:error')
8 | const print = require('../../../utils').print
9 |
10 | function appendData (key, data, ipfs) {
11 | ipfs.object.patch.appendData(key, data, {
12 | enc: 'base58'
13 | }, (err, node) => {
14 | if (err) {
15 | throw err
16 | }
17 | const nodeJSON = node.toJSON()
18 |
19 | print(nodeJSON.multihash)
20 | })
21 | }
22 |
23 | module.exports = {
24 | command: 'append-data [data]',
25 |
26 | describe: 'Append data to the data segment of a dag node',
27 |
28 | builder: {},
29 |
30 | handler (argv) {
31 | const ipfs = argv.ipfs
32 | if (argv.data) {
33 | return appendData(argv.root, fs.readFileSync(argv.data), ipfs)
34 | }
35 |
36 | process.stdin.pipe(bl((err, input) => {
37 | if (err) {
38 | throw err
39 | }
40 |
41 | appendData(argv.root, input, ipfs)
42 | }))
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/cli/commands/bitswap/stat.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const CID = require('cids')
4 | const print = require('../../utils').print
5 |
6 | module.exports = {
7 | command: 'stat',
8 |
9 | describe: 'Show some diagnostic information on the bitswap agent.',
10 |
11 | builder: {},
12 |
13 | handler (argv) {
14 | argv.ipfs.bitswap.stat((err, stats) => {
15 | if (err) {
16 | throw err
17 | }
18 |
19 | stats.Wantlist = stats.Wantlist || []
20 | stats.Wantlist = stats.Wantlist.map((entry) => {
21 | const buf = Buffer.from(entry.cid.hash.data)
22 | const cid = new CID(entry.cid.version, entry.cid.codec, buf)
23 | return cid.toBaseEncodedString()
24 | })
25 | stats.Peers = stats.Peers || []
26 |
27 | print(`bitswap status
28 | blocks received: ${stats.BlocksReceived}
29 | dup blocks received: ${stats.DupBlksReceived}
30 | dup data received: ${stats.DupDataReceived}B
31 | wantlist [${stats.Wantlist.length} keys]
32 | ${stats.Wantlist.join('\n ')}
33 | partners [${stats.Peers.length}]
34 | ${stats.Peers.join('\n ')}`)
35 | })
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/http/api/routes/debug.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const register = require('prom-client').register
4 | const client = require('prom-client')
5 |
6 | // Endpoint for handling debug metrics
7 | module.exports = (server) => {
8 | const api = server.select('API')
9 | // Clear the register to make sure we're not registering multiple ones
10 | register.clear()
11 | const gauge = new client.Gauge({ name: 'number_of_peers', help: 'the_number_of_currently_connected_peers' })
12 |
13 | api.route({
14 | method: 'GET',
15 | path: '/debug/metrics/prometheus',
16 | handler: (request, reply) => {
17 | if (!process.env.IPFS_MONITORING) {
18 | return reply('Monitoring is disabled. Enable it by setting environment variable IPFS_MONITORING')
19 | .code(501) // 501 = Not Implemented
20 | }
21 | server.app.ipfs.swarm.peers((err, res) => {
22 | if (err) {
23 | return reply(err).code(500)
24 | }
25 | const count = res.length
26 | gauge.set(count)
27 | reply(register.metrics()).header('Content-Type', register.contentType)
28 | })
29 | }
30 | })
31 | }
32 |
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/init-docs/security-notes:
--------------------------------------------------------------------------------
1 | IPFS Alpha Security Notes
2 |
3 | We try hard to ensure our system is safe and robust, but all software
4 | has bugs, especially new software. This distribution is meant to be an
5 | alpha preview, don't use it for anything mission critical.
6 |
7 | Please note the following:
8 |
9 | - This is alpha software and has not been audited. It is our goal
10 | to conduct a proper security audit once we close in on a 1.0 release.
11 |
12 | - ipfs is a networked program, and may have serious undiscovered
13 | vulnerabilities. It is written in Go, and we do not execute any
14 | user provided data. But please point any problems out to us in a
15 | github issue, or email security@ipfs.io privately.
16 |
17 | - ipfs uses encryption for all communication, but it's NOT PROVEN SECURE
18 | YET! It may be totally broken. For now, the code is included to make
19 | sure we benchmark our operations with encryption in mind. In the future,
20 | there will be an "unsafe" mode for high performance intranet apps.
21 | If this is a blocking feature for you, please contact us.
22 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Juan Batiz-Benet
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/core/components/stop.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const series = require('async/series')
4 | const promisify = require('promisify-es6')
5 |
6 | module.exports = (self) => {
7 | return promisify((callback) => {
8 | callback = callback || function noop () {}
9 | self.log('stop')
10 |
11 | if (self.state.state() === 'stopped') {
12 | return callback()
13 | }
14 |
15 | const done = (err) => {
16 | if (err) {
17 | self.emit('error', err)
18 | return callback(err)
19 | }
20 | self.state.stopped()
21 | self.emit('stop')
22 | callback()
23 | }
24 |
25 | if (self.state.state() !== 'running') {
26 | return done(new Error('Not able to stop from state: ' + self.state.state()))
27 | }
28 |
29 | self.state.stop()
30 | self._blockService.unsetExchange()
31 | self._bitswap.stop()
32 |
33 | series([
34 | (cb) => {
35 | if (self._options.EXPERIMENTAL.pubsub) {
36 | self._pubsub.stop(cb)
37 | } else {
38 | cb()
39 | }
40 | },
41 | (cb) => self.libp2p.stop(cb),
42 | (cb) => self._repo.close(cb)
43 | ], done)
44 | })
45 | }
46 |
--------------------------------------------------------------------------------
/src/core/components/pre-start.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const peerId = require('peer-id')
4 | const PeerInfo = require('peer-info')
5 | const multiaddr = require('multiaddr')
6 | const waterfall = require('async/waterfall')
7 |
8 | /*
9 | * Load stuff from Repo into memory
10 | */
11 | module.exports = function preStart (self) {
12 | return (callback) => {
13 | self.log('pre-start')
14 |
15 | waterfall([
16 | (cb) => self._repo.config.get(cb),
17 | (config, cb) => {
18 | const privKey = config.Identity.PrivKey
19 |
20 | peerId.createFromPrivKey(privKey, (err, id) => cb(err, config, id))
21 | },
22 | (config, id, cb) => {
23 | self._peerInfo = new PeerInfo(id)
24 |
25 | if (config.Addresses && config.Addresses.Swarm) {
26 | config.Addresses.Swarm.forEach((addr) => {
27 | let ma = multiaddr(addr)
28 |
29 | if (ma.getPeerId()) {
30 | ma = ma.encapsulate('/ipfs/' + self._peerInfo.id.toB58String())
31 | }
32 |
33 | self._peerInfo.multiaddrs.add(ma)
34 | })
35 | }
36 |
37 | cb()
38 | }
39 | ], callback)
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/http/api/resources/bitswap.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const boom = require('boom')
4 |
5 | const parseKey = require('./block').parseKey
6 |
7 | exports = module.exports
8 |
9 | exports.wantlist = (request, reply) => {
10 | let list
11 | try {
12 | list = request.server.app.ipfs.bitswap.wantlist()
13 | list = list.map((entry) => entry.cid.toBaseEncodedString())
14 | } catch (err) {
15 | return reply(boom.badRequest(err))
16 | }
17 |
18 | reply({
19 | Keys: list
20 | })
21 | }
22 |
23 | exports.stat = (request, reply) => {
24 | let stats
25 | try {
26 | stats = request.server.app.ipfs.bitswap.stat()
27 | } catch (err) {
28 | return reply(boom.badRequest(err))
29 | }
30 |
31 | reply({
32 | BlocksReceived: stats.blocksReceived,
33 | Wantlist: stats.wantlist,
34 | Peers: stats.peers,
35 | DupBlksReceived: stats.dupBlksReceived,
36 | DupDataReceived: stats.dupDataReceived
37 | })
38 | }
39 |
40 | exports.unwant = {
41 | // uses common parseKey method that returns a `key`
42 | parseArgs: parseKey,
43 |
44 | handler: (request, reply) => {
45 | reply(boom.badRequest(new Error('Not implemented yet')))
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/test/cli/file.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | const expect = require('chai').expect
5 | const runOnAndOff = require('../utils/on-and-off')
6 | const file = 'QmR56UJmAaZLXLdTT1ALrE9vVqV8soUEekm9BMd4FnuYqV'
7 | const dir = 'QmYmW4HiZhotsoSqnv2o1oUusvkRM8b9RweBoH7ao5nki2'
8 |
9 | describe('file ls', () => runOnAndOff((thing) => {
10 | let ipfs
11 |
12 | before(function () {
13 | this.timeout(50 * 1000)
14 | ipfs = thing.ipfs
15 | return ipfs('files add -r test/fixtures/test-data/recursive-get-dir')
16 | })
17 |
18 | it('prints a filename', () => {
19 | return ipfs(`file ls ${file}`)
20 | .then((out) => expect(out).to.eql(`${file}\n`))
21 | })
22 |
23 | it('prints the filenames in a directory', () => {
24 | return ipfs(`file ls ${dir}`)
25 | .then((out) => expect(out).to.eql(
26 | 'QmQQHYDwAQms78fPcvx1uFFsfho23YJNoewfLbi9AtdyJ9\n' +
27 | 'QmPkWYfSLCEBLZu7BZt4kigGDMe3cpogMbeVf97gN2xJDN\n' +
28 | 'Qma13ZrhKG52MWnwtZ6fMD8jGj8d4Q9sJgn5xtKgeZw5uz\n' +
29 | 'QmUhUuiTKkkK8J6JZ9zmj8iNHPuNfGYcszgRumzhHBxEEU\n' +
30 | 'QmR56UJmAaZLXLdTT1ALrE9vVqV8soUEekm9BMd4FnuYqV\n'
31 | ))
32 | })
33 | }))
34 |
--------------------------------------------------------------------------------
/test/sharness/t0022-init-default.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Copyright (c) 2014 Christian Couder
4 | # MIT Licensed; see the LICENSE file in this repository.
5 | #
6 |
7 | test_description="Test init command with default config"
8 |
9 | . lib/test-lib.sh
10 |
11 | cfg_key="Addresses.API"
12 | cfg_val="/ip4/0.0.0.0/tcp/5001"
13 |
14 | # test that init succeeds
15 | test_expect_success "ipfs init succeeds" '
16 | export IPFS_PATH="$(pwd)/.ipfs" &&
17 | echo "IPFS_PATH: \"$IPFS_PATH\"" &&
18 | BITS="2048" &&
19 | ipfs init --bits="$BITS" >actual_init ||
20 | test_fsh cat actual_init
21 | '
22 |
23 | test_expect_success ".ipfs/config has been created" '
24 | test -f "$IPFS_PATH"/config ||
25 | test_fsh ls -al .ipfs
26 | '
27 |
28 | test_expect_success "ipfs config succeeds" '
29 | ipfs config $cfg_flags "$cfg_key" "$cfg_val"
30 | '
31 |
32 | test_expect_success "ipfs read config succeeds" '
33 | IPFS_DEFAULT_CONFIG=$(cat "$IPFS_PATH"/config)
34 | '
35 |
36 | test_expect_success "clean up ipfs dir" '
37 | rm -rf "$IPFS_PATH"
38 | '
39 |
40 | test_expect_success "ipfs init default config succeeds" '
41 | echo $IPFS_DEFAULT_CONFIG | ipfs init - >actual_init ||
42 | test_fsh cat actual_init
43 | '
44 |
45 | test_done
46 |
--------------------------------------------------------------------------------
/src/core/runtime/libp2p-browser.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const WS = require('libp2p-websockets')
4 | const WebRTCStar = require('libp2p-webrtc-star')
5 | const Multiplex = require('libp2p-multiplex')
6 | const SECIO = require('libp2p-secio')
7 | const Railing = require('libp2p-railing')
8 | const libp2p = require('libp2p')
9 |
10 | class Node extends libp2p {
11 | constructor (peerInfo, peerBook, options) {
12 | options = options || {}
13 | const wstar = new WebRTCStar()
14 |
15 | const modules = {
16 | transport: [new WS(), wstar],
17 | connection: {
18 | muxer: [Multiplex],
19 | crypto: [SECIO]
20 | },
21 | discovery: [wstar.discovery]
22 | }
23 |
24 | if (options.bootstrap) {
25 | const r = new Railing(options.bootstrap)
26 | modules.discovery.push(r)
27 | }
28 |
29 | if (options.modules && options.modules.transport) {
30 | options.modules.transport.forEach((t) => modules.transport.push(t))
31 | }
32 |
33 | if (options.modules && options.modules.discovery) {
34 | options.modules.discovery.forEach((d) => modules.discovery.push(d))
35 | }
36 |
37 | super(modules, peerInfo, peerBook, options)
38 | }
39 | }
40 |
41 | module.exports = Node
42 |
--------------------------------------------------------------------------------
/src/core/runtime/config-browser.json:
--------------------------------------------------------------------------------
1 | {
2 | "Addresses": {
3 | "Swarm": [
4 | "/dns4/star-signal.cloud.ipfs.team/wss/p2p-webrtc-star"
5 | ],
6 | "API": "",
7 | "Gateway": ""
8 | },
9 | "Discovery": {
10 | "MDNS": {
11 | "Enabled": false,
12 | "Interval": 10
13 | },
14 | "webRTCStar": {
15 | "Enabled": true
16 | }
17 | },
18 | "Bootstrap": [
19 | "/dns4/ams-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd",
20 | "/dns4/lon-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3",
21 | "/dns4/sfo-3.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM",
22 | "/dns4/sgp-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu",
23 | "/dns4/nyc-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm",
24 | "/dns4/nyc-2.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64",
25 | "/dns4/wss0.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic",
26 | "/dns4/wss1.bootstrap.libp2p.io/tcp/443/wss/ipfs/Qmbut9Ywz9YEDrz8ySBSgWyJk41Uvm2QJPhwDJzJyGFsD6"
27 | ]
28 | }
29 |
--------------------------------------------------------------------------------
/src/core/state.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const debug = require('debug')
4 | const log = debug('jsipfs:state')
5 | log.error = debug('jsipfs:state:error')
6 |
7 | const fsm = require('fsm-event')
8 |
9 | module.exports = (self) => {
10 | const s = fsm('uninitalized', {
11 | uninitalized: {
12 | init: 'initializing',
13 | initialized: 'stopped'
14 | },
15 | initializing: {
16 | initialized: 'stopped'
17 | },
18 | stopped: {
19 | start: 'starting'
20 | },
21 | starting: {
22 | started: 'running'
23 | },
24 | running: {
25 | stop: 'stopping'
26 | },
27 | stopping: {
28 | stopped: 'stopped'
29 | }
30 | })
31 |
32 | // log events
33 | s.on('error', (err) => log.error(err))
34 | s.on('done', () => log('-> ' + s._state))
35 |
36 | // -- Actions
37 |
38 | s.init = () => {
39 | s('init')
40 | }
41 |
42 | s.initialized = () => {
43 | s('initialized')
44 | }
45 |
46 | s.stop = () => {
47 | s('stop')
48 | }
49 |
50 | s.stopped = () => {
51 | s('stopped')
52 | }
53 |
54 | s.start = () => {
55 | s('start')
56 | }
57 |
58 | s.started = () => {
59 | s('started')
60 | }
61 |
62 | s.state = () => s._state
63 |
64 | return s
65 | }
66 |
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/blocks/_README:
--------------------------------------------------------------------------------
1 | This is a repository of IPLD objects. Each IPLD object is in a single file,
2 | named .data. Where is the
3 | "base32" encoding of the CID (as specified in
4 | https://github.com/multiformats/multibase) without the 'B' prefix.
5 | All the object files are placed in a tree of directories, based on a
6 | function of the CID. This is a form of sharding similar to
7 | the objects directory in git repositories. Previously, we used
8 | prefixes, we now use the next-to-last two charters.
9 |
10 | func NextToLast(base32cid string) {
11 | nextToLastLen := 2
12 | offset := len(base32cid) - nextToLastLen - 1
13 | return str[offset : offset+nextToLastLen]
14 | }
15 |
16 | For example, an object with a base58 CIDv1 of
17 |
18 | zb2rhYSxw4ZjuzgCnWSt19Q94ERaeFhu9uSqRgjSdx9bsgM6f
19 |
20 | has a base32 CIDv1 of
21 |
22 | BAFKREIA22FLID5AJ2KU7URG47MDLROZIH6YF2KALU2PWEFPVI37YLKRSCA
23 |
24 | and will be placed at
25 |
26 | SC/AFKREIA22FLID5AJ2KU7URG47MDLROZIH6YF2KALU2PWEFPVI37YLKRSCA.data
27 |
28 | with 'SC' being the last-to-next two characters and the 'B' at the
29 | beginning of the CIDv1 string is the multibase prefix that is not
30 | stored in the filename.
31 |
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/README.md:
--------------------------------------------------------------------------------
1 | Resolve through IPLD graphs with the dag API
2 | ============================================
3 |
4 | IPLD stands for [`InterPlanetary Linked-Data`](https://ipld.io/), it is the data model of the content-addressable web. It gives IPFS the ability to resolve through any kind of content-addressed graph, as long as the [adapter for the format is available](https://github.com/ipld/interface-ipld-format#modules-that-implement-the-interface).
5 |
6 | This tutorial goes through several operations over IPLD graphs using the [DAG API](https://github.com/ipfs/interface-ipfs-core/tree/master/API/dag).
7 |
8 | ## [create nodes to build a graph](./put.js)
9 |
10 | ## [retrieve a node from a graph](./get.js)
11 |
12 | ## [resolve a path in a graph](./get-path.js)
13 |
14 | ## [resolve through graphs of different kind](./get-path-accross-formats.js)
15 |
16 | ## [explore a graph with the .tree](./tree.js)
17 |
18 | ## [traverse through a slice of the ethereum blockchain](./eth.js)
19 |
20 | ## [traverse through a git repo](./git.js)
21 |
22 | ## Video of the demos
23 |
24 | Find a video with a walkthrough of this examples on Youtube:
25 |
26 | [](https://youtu.be/drULwJ_ZDRQ?t=1m29s)
27 |
--------------------------------------------------------------------------------
/src/cli/commands/init.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const Repo = require('ipfs-repo')
4 | const IPFS = require('../../core')
5 | const utils = require('../utils')
6 | const print = utils.print
7 |
8 | module.exports = {
9 | command: 'init',
10 |
11 | describe: 'Initialize a local IPFS node',
12 |
13 | builder: {
14 | bits: {
15 | type: 'number',
16 | alias: 'b',
17 | default: '2048',
18 | describe: 'Number of bits to use in the generated RSA private key (defaults to 2048)'
19 | },
20 | emptyRepo: {
21 | alias: 'e',
22 | type: 'boolean',
23 | describe: "Don't add and pin help files to the local storage"
24 | }
25 | },
26 |
27 | handler (argv) {
28 | const path = utils.getRepoPath()
29 |
30 | print(`initializing ipfs node at ${path}`)
31 |
32 | const node = new IPFS({
33 | repo: new Repo(path),
34 | init: false,
35 | start: false
36 | })
37 |
38 | node.init({
39 | bits: argv.bits,
40 | emptyRepo: argv.emptyRepo,
41 | log: print
42 | }, (err) => {
43 | if (err) {
44 | if (err.code === 'EACCES') {
45 | err.message = `EACCES: permission denied, stat $IPFS_PATH/version`
46 | }
47 | throw err
48 | }
49 | })
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/init-files/init-docs/security-notes:
--------------------------------------------------------------------------------
1 | IPFS Alpha Security Notes
2 |
3 | We try hard to ensure our system is safe and robust, but all software
4 | has bugs, especially new software. This distribution is meant to be an
5 | alpha preview, don't use it for anything mission critical.
6 |
7 | Please note the following:
8 |
9 | - This is alpha software and has not been audited. It is our goal
10 | to conduct a proper security audit once we close in on a 1.0 release.
11 |
12 | - ipfs is a networked program, and may have serious undiscovered
13 | vulnerabilities. It is written in Go, and we do not execute any
14 | user provided data. But please point any problems out to us in a
15 | github issue, or email security@ipfs.io privately.
16 |
17 | - security@ipfs.io GPG key:
18 | - 4B9665FB 92636D17 7C7A86D3 50AAE8A9 59B13AF3
19 | - https://pgp.mit.edu/pks/lookup?op=get&search=0x50AAE8A959B13AF3
20 |
21 | - ipfs uses encryption for all communication, but it's NOT PROVEN SECURE
22 | YET! It may be totally broken. For now, the code is included to make
23 | sure we benchmark our operations with encryption in mind. In the future,
24 | there will be an "unsafe" mode for high performance intranet apps.
25 | If this is a blocking feature for you, please contact us.
26 |
--------------------------------------------------------------------------------
/test/bootstrapers.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | const chai = require('chai')
5 | const dirtyChai = require('dirty-chai')
6 | const expect = chai.expect
7 | chai.use(dirtyChai)
8 | const IPFS = require('..')
9 | const list = require('../src/core/runtime/config-browser.json').Bootstrap
10 |
11 | /*
12 | * These tests were graciously made for lgierth, so that he can test the
13 | * WebSockets Bootstrappers easily <3
14 | */
15 | describe('Check that a js-ipfs node can indeed contact the bootstrappers', function () {
16 | this.timeout(60 * 1000)
17 |
18 | it('a node connects to bootstrapers', (done) => {
19 | const node = new IPFS({
20 | config: {
21 | Addresses: {
22 | Swarm: []
23 | }
24 | }
25 | })
26 |
27 | node.on('ready', check)
28 |
29 | function check () {
30 | node.swarm.peers((err, peers) => {
31 | expect(err).to.not.exist()
32 |
33 | if (peers.length !== list.length) {
34 | return setTimeout(check, 2000)
35 | }
36 |
37 | const peerList = peers.map((peer) => peer.addr.toString())
38 | expect(peers.length).to.equal(list.length)
39 | expect(peerList).to.eql(list)
40 |
41 | node.stop(done)
42 | })
43 | }
44 | })
45 | })
46 |
--------------------------------------------------------------------------------
/src/core/runtime/config-nodejs.json:
--------------------------------------------------------------------------------
1 | {
2 | "Addresses": {
3 | "Swarm": [
4 | "/ip4/0.0.0.0/tcp/4002",
5 | "/ip4/127.0.0.1/tcp/4003/ws"
6 | ],
7 | "API": "/ip4/127.0.0.1/tcp/5002",
8 | "Gateway": "/ip4/127.0.0.1/tcp/9090"
9 | },
10 | "Discovery": {
11 | "MDNS": {
12 | "Enabled": true,
13 | "Interval": 10
14 | },
15 | "webRTCStar": {
16 | "Enabled": true
17 | }
18 | },
19 | "Bootstrap": [
20 | "/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
21 | "/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM",
22 | "/ip4/162.243.248.213/tcp/4001/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm",
23 | "/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu",
24 | "/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64",
25 | "/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd",
26 | "/ip4/178.62.61.185/tcp/4001/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3",
27 | "/dns4/wss0.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic",
28 | "/dns4/wss1.bootstrap.libp2p.io/tcp/443/wss/ipfs/Qmbut9Ywz9YEDrz8ySBSgWyJk41Uvm2QJPhwDJzJyGFsD6"
29 | ]
30 | }
31 |
--------------------------------------------------------------------------------
/test/http-api/over-ipfs-api/id.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | const chai = require('chai')
5 | const dirtyChai = require('dirty-chai')
6 | const expect = chai.expect
7 | chai.use(dirtyChai)
8 |
9 | module.exports = (ctl) => {
10 | describe('.id', () => {
11 | it('get the identity', (done) => {
12 | ctl.id((err, result) => {
13 | expect(err).to.not.exist()
14 | expect(result.id).to.equal(idResult.ID)
15 | expect(result.publicKey).to.equal(idResult.PublicKey)
16 | expect(result.agentVersion).to.equal(idResult.AgentVersion)
17 | expect(result.protocolVersion).to.equal(idResult.ProtocolVersion)
18 | done()
19 | })
20 | })
21 | })
22 | }
23 |
24 | const idResult = {
25 | ID: 'QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A',
26 | PublicKey: 'CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC2SKo/HMFZeBml1AF3XijzrxrfQXdJzjePBZAbdxqKR1Mc6juRHXij6HXYPjlAk01BhF1S3Ll4Lwi0cAHhggf457sMg55UWyeGKeUv0ucgvCpBwlR5cQ020i0MgzjPWOLWq1rtvSbNcAi2ZEVn6+Q2EcHo3wUvWRtLeKz+DZSZfw2PEDC+DGPJPl7f8g7zl56YymmmzH9liZLNrzg/qidokUv5u1pdGrcpLuPNeTODk0cqKB+OUbuKj9GShYECCEjaybJDl9276oalL9ghBtSeEv20kugatTvYy590wFlJkkvyl+nPxIH0EEYMKK9XRWlu9XYnoSfboiwcv8M3SlsjAgMBAAE=',
27 | Addresses: [ '/ip4/0.0.0.0/tcp/0' ],
28 | AgentVersion: 'js-ipfs',
29 | ProtocolVersion: '9000'
30 | }
31 |
--------------------------------------------------------------------------------
/src/http/api/routes/block.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const resources = require('./../resources')
4 |
5 | module.exports = (server) => {
6 | const api = server.select('API')
7 |
8 | api.route({
9 | method: '*',
10 | path: '/api/v0/block/get',
11 | config: {
12 | pre: [
13 | { method: resources.block.get.parseArgs, assign: 'args' }
14 | ],
15 | handler: resources.block.get.handler
16 | }
17 | })
18 |
19 | api.route({
20 | method: '*',
21 | path: '/api/v0/block/put',
22 | config: {
23 | payload: {
24 | parse: false,
25 | output: 'stream'
26 | },
27 | pre: [
28 | { method: resources.block.put.parseArgs, assign: 'args' }
29 | ],
30 | handler: resources.block.put.handler
31 | }
32 | })
33 |
34 | api.route({
35 | method: '*',
36 | path: '/api/v0/block/del',
37 | config: {
38 | pre: [
39 | { method: resources.block.del.parseArgs, assign: 'args' }
40 | ],
41 | handler: resources.block.del.handler
42 | }
43 | })
44 |
45 | api.route({
46 | method: '*',
47 | path: '/api/v0/block/stat',
48 | config: {
49 | pre: [
50 | { method: resources.block.stat.parseArgs, assign: 'args' }
51 | ],
52 | handler: resources.block.stat.handler
53 | }
54 | })
55 | }
56 |
--------------------------------------------------------------------------------
/src/http/api/routes/bootstrap.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const resources = require('./../resources')
4 |
5 | module.exports = (server) => {
6 | const api = server.select('API')
7 |
8 | // https://github.com/ipfs/http-api-spec/blob/master/apiary.apib#L818
9 | api.route({
10 | method: '*',
11 | path: '/api/v0/bootstrap',
12 | config: {
13 | handler: resources.bootstrap.list
14 | }
15 | })
16 |
17 | // https://github.com/ipfs/http-api-spec/blob/master/apiary.apib#L866
18 | api.route({
19 | method: '*',
20 | path: '/api/v0/bootstrap/add',
21 | config: {
22 | pre: [
23 | { method: resources.bootstrap.add.parseArgs, assign: 'args' }
24 | ],
25 | handler: resources.bootstrap.add.handler
26 | }
27 | })
28 |
29 | // https://github.com/ipfs/http-api-spec/blob/master/apiary.apib#L1081
30 | api.route({
31 | method: '*',
32 | path: '/api/v0/bootstrap/list',
33 | handler: resources.bootstrap.list
34 | })
35 |
36 | // https://github.com/ipfs/http-api-spec/blob/master/apiary.apib#L1131
37 | api.route({
38 | method: '*',
39 | path: '/api/v0/bootstrap/rm',
40 | config: {
41 | pre: [
42 | { method: resources.bootstrap.rm.parseArgs, assign: 'args' }
43 | ],
44 | handler: resources.bootstrap.rm.handler
45 | }
46 | })
47 | }
48 |
--------------------------------------------------------------------------------
/test/http-api/spec/id.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | const expect = require('chai').expect
5 |
6 | module.exports = (http) => {
7 | describe('/id', () => {
8 | let api
9 |
10 | before(() => {
11 | api = http.api.server.select('API')
12 | })
13 |
14 | it('get the id', (done) => {
15 | api.inject({
16 | method: 'GET',
17 | url: '/api/v0/id'
18 | }, (res) => {
19 | expect(res.result.ID).to.equal(idResult.ID)
20 | expect(res.result.PublicKey).to.equal(idResult.PublicKey)
21 | expect(res.result.AgentVersion).to.equal(idResult.AgentVersion)
22 | expect(res.result.ProtocolVersion).to.equal(idResult.ProtocolVersion)
23 | done()
24 | })
25 | })
26 | })
27 | }
28 |
29 | const idResult = {
30 | ID: 'QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A',
31 | PublicKey: 'CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC2SKo/HMFZeBml1AF3XijzrxrfQXdJzjePBZAbdxqKR1Mc6juRHXij6HXYPjlAk01BhF1S3Ll4Lwi0cAHhggf457sMg55UWyeGKeUv0ucgvCpBwlR5cQ020i0MgzjPWOLWq1rtvSbNcAi2ZEVn6+Q2EcHo3wUvWRtLeKz+DZSZfw2PEDC+DGPJPl7f8g7zl56YymmmzH9liZLNrzg/qidokUv5u1pdGrcpLuPNeTODk0cqKB+OUbuKj9GShYECCEjaybJDl9276oalL9ghBtSeEv20kugatTvYy590wFlJkkvyl+nPxIH0EEYMKK9XRWlu9XYnoSfboiwcv8M3SlsjAgMBAAE=',
32 | Addresses: [ '/ip4/0.0.0.0/tcp/0' ],
33 | AgentVersion: 'js-ipfs',
34 | ProtocolVersion: '9000'
35 | }
36 |
--------------------------------------------------------------------------------
/src/http/api/routes/files.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const resources = require('./../resources')
4 |
5 | module.exports = (server) => {
6 | const api = server.select('API')
7 |
8 | api.route({
9 | // TODO fix method
10 | method: '*',
11 | path: '/api/v0/cat',
12 | config: {
13 | pre: [
14 | { method: resources.files.cat.parseArgs, assign: 'args' }
15 | ],
16 | handler: resources.files.cat.handler
17 | }
18 | })
19 |
20 | api.route({
21 | // TODO fix method
22 | method: '*',
23 | path: '/api/v0/get',
24 | config: {
25 | pre: [
26 | { method: resources.files.get.parseArgs, assign: 'args' }
27 | ],
28 | handler: resources.files.get.handler
29 | }
30 | })
31 |
32 | api.route({
33 | // TODO fix method
34 | method: '*',
35 | path: '/api/v0/add',
36 | config: {
37 | payload: {
38 | parse: false,
39 | output: 'stream'
40 | },
41 | handler: resources.files.add.handler,
42 | validate: resources.files.add.validate
43 | }
44 | })
45 |
46 | api.route({
47 | // TODO fix method
48 | method: '*',
49 | path: '/api/v0/ls',
50 | config: {
51 | pre: [
52 | { method: resources.files.immutableLs.parseArgs, assign: 'args' }
53 | ],
54 | handler: resources.files.immutableLs.handler
55 | }
56 | })
57 | }
58 |
--------------------------------------------------------------------------------
/test/sharness/Makefile:
--------------------------------------------------------------------------------
1 | # Run sharness tests
2 | #
3 | # Copyright (c) 2016 Christian Couder
4 | # MIT Licensed; see the LICENSE file in this repository.
5 | #
6 | # NOTE: run with TEST_VERBOSE=1 for verbose sharness tests.
7 |
8 | T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
9 | LIBDIR = lib
10 | SHARNESSDIR = sharness
11 | AGGREGATE = $(LIBDIR)/$(SHARNESSDIR)/aggregate-results.sh
12 |
13 |
14 | BINS = ../bin/ipfs
15 |
16 | all: aggregate
17 |
18 | help:
19 | @echo "- use 'make' or 'make all' to run all the tests"
20 | @echo "- use 'make deps' to create an 'ipfs' executable in ../bin"
21 | @echo "- to run tests manually, make sure to include ../bin in your PATH"
22 |
23 | clean: clean-test-results
24 | @echo "*** $@ ***"
25 | -rm -rf ../bin/ipfs
26 |
27 | clean-test-results:
28 | @echo "*** $@ ***"
29 | -rm -rf test-results
30 |
31 | $(T): clean-test-results deps
32 | @echo "*** $@ ***"
33 | ./$@
34 |
35 | aggregate: clean-test-results $(T)
36 | @echo "*** $@ ***"
37 | ls test-results/t*-*.sh.*.counts | $(AGGREGATE)
38 |
39 | deps: sharness $(BINS) curl
40 |
41 | sharness:
42 | @echo "*** checking $@ ***"
43 | lib/install-sharness.sh
44 |
45 | ../bin/ipfs:
46 | mkdir -p ../bin
47 | cd ../bin && ln -s ../../src/cli/bin.js ipfs
48 |
49 | curl:
50 | @which curl >/dev/null || (echo "Please install curl!" && false)
51 |
52 | .PHONY: all help clean clean-test-results $(T) aggregate deps sharness
53 |
54 |
--------------------------------------------------------------------------------
/src/http/error-handler.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const Hoek = require('hoek')
4 |
5 | module.exports = (api, server) => {
6 | server.ext('onRequest', (request, reply) => {
7 | request.handleError = handleError
8 | reply.continue()
9 | })
10 |
11 | server.ext('onPreResponse', (request, reply) => {
12 | const res = request.response
13 | const req = request.raw.req
14 |
15 | let statusCode = 200
16 | let msg = 'Sorry, something went wrong, please retrace your steps.'
17 |
18 | if (res.isBoom) {
19 | statusCode = res.output.payload.statusCode
20 |
21 | if (res.message && res.isDeveloperError) {
22 | msg = res.message.replace('Uncaught error: ', '')
23 | }
24 |
25 | const debug = {
26 | method: req.method,
27 | url: request.url.path,
28 | headers: request.raw.req.headers,
29 | info: request.info,
30 | payload: request.payload,
31 | response: res.output.payload
32 | }
33 |
34 | api.log.error(res.stack)
35 | server.log('error', debug)
36 |
37 | reply({
38 | Message: msg,
39 | Code: 1
40 | }).code(statusCode)
41 | return
42 | }
43 |
44 | reply.continue()
45 | })
46 | }
47 |
48 | function handleError (error, errorMessage) {
49 | if (errorMessage) {
50 | return Hoek.assert(!error, errorMessage)
51 | }
52 |
53 | return Hoek.assert(!error, error)
54 | }
55 |
--------------------------------------------------------------------------------
/img/overview.txt:
--------------------------------------------------------------------------------
1 |
2 | offline mode - uses IPFS core directly
3 | ┌───────────────────────────────────────────┐
4 | │ │
5 | │ │
6 | │ online mode - uses IPFS through http-api │
7 | ┌────────────┐ │ ┌────────────────────┐ │ ┌──────────┐
8 | │ │ │ ┌ ─ ─ ─ ─ ─ ─ │ │ │ │ │
9 | │ CLI │───┴── ipfs-api ├──▶│ HTTP-API │───┴───▶│IPFS Core │
10 | │ │ └ ─ ─ ─ ─ ─ ─ │ │ │ │
11 | └────────────┘ └────────────────────┘ └──────────┘
12 | △ △ △
13 | ├───────────────────────────────────────┴────────────────────────┘
14 | │
15 | ┌────────────┐
16 | │ Tests │
17 | └────────────┘
--------------------------------------------------------------------------------
/src/http/api/routes/swarm.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const resources = require('./../resources')
4 |
5 | module.exports = (server) => {
6 | const api = server.select('API')
7 |
8 | api.route({
9 | method: '*',
10 | path: '/api/v0/swarm/peers',
11 | config: {
12 | handler: resources.swarm.peers.handler
13 | }
14 | })
15 |
16 | api.route({
17 | method: '*',
18 | path: '/api/v0/swarm/addrs',
19 | config: {
20 | handler: resources.swarm.addrs.handler
21 | }
22 | })
23 |
24 | api.route({
25 | method: '*',
26 | path: '/api/v0/swarm/addrs/local',
27 | config: {
28 | handler: resources.swarm.localAddrs.handler
29 | }
30 | })
31 |
32 | api.route({
33 | method: '*',
34 | path: '/api/v0/swarm/connect',
35 | config: {
36 | pre: [
37 | { method: resources.swarm.connect.parseArgs, assign: 'args' }
38 | ],
39 | handler: resources.swarm.connect.handler
40 | }
41 | })
42 |
43 | api.route({
44 | method: '*',
45 | path: '/api/v0/swarm/disconnect',
46 | config: {
47 | pre: [
48 | { method: resources.swarm.disconnect.parseArgs, assign: 'args' }
49 | ],
50 | handler: resources.swarm.disconnect.handler
51 | }
52 | })
53 |
54 | // TODO
55 | // api.route({
56 | // method: '*',
57 | // path: '/api/v0/swarm/filters',
58 | // config: {
59 | // handler: resources.swarm.disconnect
60 | // }
61 | // })
62 | }
63 |
--------------------------------------------------------------------------------
/examples/browser-browserify/src/index.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const concat = require('concat-stream')
4 | const Buffer = require('safe-buffer').Buffer
5 |
6 | const IPFS = require('../../../src/core') // replace this by line below
7 | // var IPFS = require('ipfs')
8 |
9 | const node = new IPFS({
10 | repo: String(Math.random() + Date.now())
11 | })
12 |
13 | node.on('ready', () => {
14 | console.log('IPFS node is ready')
15 | })
16 |
17 | function store () {
18 | var toStore = document.getElementById('source').value
19 |
20 | node.files.add(Buffer.from(toStore), (err, res) => {
21 | if (err || !res) {
22 | return console.error('ipfs add error', err, res)
23 | }
24 |
25 | res.forEach((file) => {
26 | if (file && file.hash) {
27 | console.log('successfully stored', file.hash)
28 | display(file.hash)
29 | }
30 | })
31 | })
32 | }
33 |
34 | function display (hash) {
35 | // buffer: true results in the returned result being a buffer rather than a stream
36 | node.files.cat(hash, (err, res) => {
37 | if (err || !res) {
38 | return console.error('ipfs cat error', err, res)
39 | }
40 |
41 | document.getElementById('hash').innerText = hash
42 |
43 | res.pipe(concat((data) => {
44 | document.getElementById('content').innerText = data
45 | }))
46 | })
47 | }
48 |
49 | document.addEventListener('DOMContentLoaded', () => {
50 | document.getElementById('store').onclick = store
51 | })
52 |
--------------------------------------------------------------------------------
/src/cli/commands/daemon.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const HttpAPI = require('../../http')
4 | const utils = require('../utils')
5 | const print = utils.print
6 |
7 | let httpAPI
8 |
9 | module.exports = {
10 | command: 'daemon',
11 |
12 | describe: 'Start a long-running daemon process',
13 |
14 | builder: {
15 | 'enable-sharding-experiment': {
16 | type: 'boolean',
17 | default: false
18 | },
19 | 'enable-pubsub-experiment': {
20 | type: 'boolean',
21 | default: false
22 | }
23 | },
24 |
25 | handler (argv) {
26 | print('Initializing daemon...')
27 |
28 | const repoPath = utils.getRepoPath()
29 | httpAPI = new HttpAPI(process.env.IPFS_PATH, null, argv)
30 |
31 | httpAPI.start((err) => {
32 | if (err && err.code === 'ENOENT' && err.message.match(/Uninitalized repo/i)) {
33 | print('Error: no initialized ipfs repo found in ' + repoPath)
34 | print('please run: jsipfs init')
35 | process.exit(1)
36 | }
37 | if (err) {
38 | throw err
39 | }
40 | print('Daemon is ready')
41 | })
42 |
43 | const cleanup = () => {
44 | print(`Received interrupt signal, shutting down..`)
45 | httpAPI.stop((err) => {
46 | if (err) {
47 | throw err
48 | }
49 | process.exit(0)
50 | })
51 | }
52 |
53 | // listen for graceful termination
54 | process.on('SIGTERM', cleanup)
55 | process.on('SIGINT', cleanup)
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/core/runtime/libp2p-nodejs.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const TCP = require('libp2p-tcp')
4 | const MulticastDNS = require('libp2p-mdns')
5 | const WS = require('libp2p-websockets')
6 | const Railing = require('libp2p-railing')
7 | const KadDHT = require('libp2p-kad-dht')
8 | const Multiplex = require('libp2p-multiplex')
9 | const SECIO = require('libp2p-secio')
10 | const libp2p = require('libp2p')
11 |
12 | class Node extends libp2p {
13 | constructor (peerInfo, peerBook, options) {
14 | options = options || {}
15 |
16 | const modules = {
17 | transport: [new TCP(), new WS()],
18 | connection: {
19 | muxer: [Multiplex],
20 | crypto: [SECIO]
21 | },
22 | discovery: []
23 | }
24 |
25 | if (options.dht) {
26 | modules.DHT = KadDHT
27 | }
28 |
29 | if (options.mdns) {
30 | const mdns = new MulticastDNS(peerInfo, 'ipfs.local')
31 | modules.discovery.push(mdns)
32 | }
33 |
34 | if (options.bootstrap) {
35 | const r = new Railing(options.bootstrap)
36 | modules.discovery.push(r)
37 | }
38 |
39 | if (options.modules && options.modules.transport) {
40 | options.modules.transport.forEach((t) => modules.transport.push(t))
41 | }
42 |
43 | if (options.modules && options.modules.discovery) {
44 | options.modules.discovery.forEach((d) => modules.discovery.push(d))
45 | }
46 |
47 | super(modules, peerInfo, peerBook, options)
48 | }
49 | }
50 |
51 | module.exports = Node
52 |
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/tree.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const createNode = require('./create-node.js')
4 | const series = require('async/series')
5 | const dagPB = require('ipld-dag-pb')
6 |
7 | createNode((err, ipfs) => {
8 | if (err) {
9 | throw err
10 | }
11 |
12 | console.log('\nStart of the example:')
13 |
14 | let cidPBNode
15 | let cidCBORNode
16 |
17 | series([
18 | (cb) => {
19 | const someData = Buffer.from('capoeira')
20 |
21 | dagPB.DAGNode.create(someData, (err, node) => {
22 | if (err) {
23 | cb(err)
24 | }
25 |
26 | ipfs.dag.put(node, { format: 'dag-pb', hashAlg: 'sha2-256' }, (err, cid) => {
27 | if (err) {
28 | cb(err)
29 | }
30 | cidPBNode = cid
31 | cb()
32 | })
33 | })
34 | },
35 | (cb) => {
36 | const myData = {
37 | name: 'David',
38 | likes: ['js-ipfs', 'icecream', 'steak'],
39 | hobbies: [{ '/': cidPBNode.toBaseEncodedString() }]
40 | }
41 |
42 | ipfs.dag.put(myData, { format: 'dag-cbor', hashAlg: 'sha3-512' }, (err, cid) => {
43 | if (err) {
44 | throw err
45 | }
46 |
47 | cidCBORNode = cid
48 | cb()
49 | })
50 | },
51 | (cb) => {
52 | ipfs.dag.tree(cidCBORNode, { recursive: true }, (err, paths) => {
53 | if (err) {
54 | throw err
55 | }
56 |
57 | console.log(paths)
58 | })
59 | }
60 | ])
61 | })
62 |
--------------------------------------------------------------------------------
/src/core/components/init-assets.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const path = require('path')
4 | const fs = require('fs')
5 | const glob = require('glob')
6 | const importer = require('ipfs-unixfs-engine').importer
7 | const pull = require('pull-stream')
8 | const file = require('pull-file')
9 | const CID = require('cids')
10 |
11 | // Add the default assets to the repo.
12 | module.exports = function addDefaultAssets (self, log, callback) {
13 | const initDocsPath = path.join(__dirname, '../../init-files/init-docs')
14 | const index = initDocsPath.lastIndexOf('/')
15 |
16 | pull(
17 | pull.values([initDocsPath]),
18 | pull.asyncMap((val, cb) => glob(path.join(val, '/**/*'), cb)),
19 | pull.flatten(),
20 | pull.map((element) => {
21 | const addPath = element.substring(index + 1)
22 |
23 | if (fs.statSync(element).isDirectory()) { return }
24 |
25 | return { path: addPath, content: file(element) }
26 | }),
27 | // Filter out directories, which are undefined from above
28 | pull.filter(Boolean),
29 | importer(self._ipldResolver),
30 | pull.through((el) => {
31 | if (el.path === 'init-docs') {
32 | const cid = new CID(el.multihash)
33 | log('to get started, enter:\n')
34 | log(`\t jsipfs files cat /ipfs/${cid.toBaseEncodedString()}/readme\n`)
35 | }
36 | }),
37 | pull.collect((err) => {
38 | if (err) {
39 | return callback(err)
40 | }
41 |
42 | callback(null, true)
43 | })
44 | )
45 | }
46 |
--------------------------------------------------------------------------------
/examples/explore-ethereum-blockchain/README.md:
--------------------------------------------------------------------------------
1 | # Use IPFS to explore the Ethereum Blockchain
2 |
3 | > This is a pre-example to a full Ethereum to IPFS bridge. It shows how to resolve Ethereum hashes through the IPFS DAG get API.
4 |
5 | ## Set up
6 |
7 | Make sure to have the latest js-ipfs installed by doing
8 |
9 | ```sh
10 | > npm install ipfs -g
11 | ```
12 |
13 | If this is the first time you use js-ipfs, make sure to init your repo with
14 |
15 | ```sh
16 | > jsipfs init
17 | ```
18 |
19 | ## Load ethereum chain data into ipfs
20 |
21 | We've some ethereum blocks available at [eth-stuffs](/eth-stuffs) folder, you can add them to ipfs by running:
22 |
23 | ```sh
24 | > ./load-eth-stuffs.sh
25 | z43AaGEvwdfzjrCZ3Sq7DKxdDHrwoaPQDtqF4jfdkNEVTiqGVFW
26 | z43AaGEywSDX5PUJcrn5GfZmb6FjisJyR7uahhWPk456f7k7LDA
27 | z43AaGF42R2DXsU65bNnHRCypLPr9sg6D7CUws5raiqATVaB1jj
28 | z45oqTS2AQ9SgyVa31LRGZgfibtdoPvP2miMNaXbDLLgD9MdAAr
29 | z45oqTS8wZaNGU2eepKHRbXvmV93cKQbiL241RB3bRtMYZP8hNm
30 | z45oqTS8wZaNGU2eepKHRbXvmV93cKQbiL241RB3bRtMYZP8hNm
31 | z45oqTS4E1GeJujnKVJG3xSVnS64A8mMCWhKSkCWACNCeD95mtQ
32 | z45oqTS4MnurEeEaanvFieeJDNHH3jGNk9NJEiyrwXwYQSWfxUB
33 | z45oqTRwExySeMeivsU1Y9UdzWDp2mx71TtQhmTGzRaXCcsNujj
34 | z45oqTRzb9a5xyvx5RbfSXH1K5jibyZ4AxnXyYReuLw7KU5veYw
35 | ```
36 |
37 | ## Explore these blocks using the DAG api
38 |
39 | Some examples
40 |
41 | ```sh
42 | > jsipfs dag get z43AaGEvwdfzjrCZ3Sq7DKxdDHrwoaPQDtqF4jfdkNEVTiqGVFW/
43 | > jsipfs dag get z43AaGEvwdfzjrCZ3Sq7DKxdDHrwoaPQDtqF4jfdkNEVTiqGVFW/parentHash
44 | ...
45 | ```
46 |
--------------------------------------------------------------------------------
/examples/run-in-electron/main.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const electron = require('electron')
4 | const app = electron.app
5 | const BrowserWindow = electron.BrowserWindow
6 |
7 | const IPFS = require('ipfs')
8 | const path = require('path')
9 | const url = require('url')
10 |
11 | let mainWindow
12 |
13 | function createWindow () {
14 | mainWindow = new BrowserWindow({width: 800, height: 600})
15 |
16 | // and load the index.html of the app.
17 | mainWindow.loadURL(url.format({
18 | pathname: path.join(__dirname, 'index.html'),
19 | protocol: 'file:',
20 | slashes: true
21 | }))
22 |
23 | // Open the DevTools.
24 | mainWindow.webContents.openDevTools()
25 |
26 | // Emitted when the window is closed.
27 | mainWindow.on('closed', () => {
28 | mainWindow = null
29 | })
30 | }
31 |
32 | app.on('ready', () => {
33 | createWindow()
34 |
35 | // Spawn your IPFS node \o/
36 | const node = new IPFS()
37 |
38 | node.on('ready', () => {
39 | node.id((err, id) => {
40 | if (err) {
41 | return console.log(err)
42 | }
43 | console.log(id)
44 | })
45 | })
46 | })
47 |
48 | // Quit when all windows are closed.
49 | app.on('window-all-closed', () => {
50 | if (process.platform !== 'darwin') { app.quit() }
51 | })
52 |
53 | app.on('activate', () => {
54 | if (mainWindow === null) { createWindow() }
55 | })
56 |
57 | // In this file you can include the rest of your app's specific main process
58 | // code. You can also put them in separate files and require them here.
59 |
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/get-path-accross-formats.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const createNode = require('./create-node.js')
4 | const series = require('async/series')
5 | const dagPB = require('ipld-dag-pb')
6 |
7 | createNode((err, ipfs) => {
8 | if (err) {
9 | throw err
10 | }
11 |
12 | console.log('\nStart of the example:')
13 |
14 | let cidPBNode
15 | let cidCBORNode
16 |
17 | series([
18 | (cb) => {
19 | const someData = Buffer.from('capoeira')
20 |
21 | dagPB.DAGNode.create(someData, (err, node) => {
22 | if (err) {
23 | cb(err)
24 | }
25 |
26 | ipfs.dag.put(node, { format: 'dag-pb', hashAlg: 'sha2-256' }, (err, cid) => {
27 | if (err) {
28 | cb(err)
29 | }
30 | cidPBNode = cid
31 | cb()
32 | })
33 | })
34 | },
35 | (cb) => {
36 | const myData = {
37 | name: 'David',
38 | likes: ['js-ipfs', 'icecream', 'steak'],
39 | hobbies: [{ '/': cidPBNode.toBaseEncodedString() }]
40 | }
41 |
42 | ipfs.dag.put(myData, { format: 'dag-cbor', hashAlg: 'sha3-512' }, (err, cid) => {
43 | if (err) {
44 | throw err
45 | }
46 |
47 | cidCBORNode = cid
48 | cb()
49 | })
50 | },
51 | (cb) => {
52 | ipfs.dag.get(cidCBORNode, 'hobbies/0/Data', (err, result) => {
53 | if (err) {
54 | throw err
55 | }
56 |
57 | console.log(result.value.toString())
58 | })
59 | }
60 | ])
61 | })
62 |
--------------------------------------------------------------------------------
/test/sharness/t0020-init.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Copyright (c) 2014 Christian Couder
4 | # MIT Licensed; see the LICENSE file in this repository.
5 | #
6 |
7 | test_description="Test init command"
8 |
9 | . lib/test-lib.sh
10 |
11 | # test that ipfs fails to init if IPFS_PATH isnt writeable
12 | test_expect_success "create dir and change perms succeeds" '
13 | export IPFS_PATH="$(pwd)/.badipfs" &&
14 | mkdir "$IPFS_PATH" &&
15 | chmod 000 "$IPFS_PATH"
16 | '
17 |
18 | test_expect_success "ipfs init fails" '
19 | test_must_fail ipfs init 2> init_fail_out
20 | '
21 |
22 | # Under Windows/Cygwin the error message is different,
23 | # so we use the STD_ERR_MSG prereq.
24 | if test_have_prereq STD_ERR_MSG; then
25 | init_err_msg="Error: failed to take lock at $IPFS_PATH: permission denied"
26 | else
27 | init_err_msg="Error: mkdir $IPFS_PATH: The system cannot find the path specified."
28 | fi
29 |
30 | init_js_err_msg="Error: EACCES: permission denied, stat '$IPFS_PATH/version'"
31 |
32 | # test_expect_success "ipfs init output looks good" '
33 | # echo "$init_js_err_msg" > init_fail_exp &&
34 | # test_cmp init_fail_exp init_fail_out
35 | # '
36 |
37 | test_expect_success "cleanup dir with bad perms" '
38 | chmod 775 "$IPFS_PATH" &&
39 | rmdir "$IPFS_PATH"
40 | '
41 |
42 | # test no repo error message
43 | # this applies to `ipfs add sth`, `ipfs refs `
44 | test_expect_success "ipfs cat fails" '
45 | export IPFS_PATH="$(pwd)/.ipfs" &&
46 | test_must_fail ipfs cat Qmaa4Rw81a3a1VEx4LxB7HADUAXvZFhCoRdBzsMZyZmqHD 2> cat_fail_out
47 | '
48 |
49 | test_done
50 |
--------------------------------------------------------------------------------
/examples/traverse-ipld-graphs/eth.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const createNode = require('./create-node.js')
4 | const asyncEach = require('async/each')
5 | const path = require('path')
6 | const multihashing = require('multihashing-async')
7 | const Block = require('ipfs-block')
8 | const CID = require('cids')
9 | const fs = require('fs')
10 |
11 | createNode((err, ipfs) => {
12 | if (err) {
13 | throw err
14 | }
15 |
16 | console.log('\nStart of the example:')
17 |
18 | const ethBlocks = [
19 | path.join(__dirname, '/eth-blocks/block_302516'),
20 | path.join(__dirname, '/eth-blocks/block_302517')
21 | ]
22 |
23 | asyncEach(ethBlocks, (ethBlockPath, cb) => {
24 | const data = fs.readFileSync(ethBlockPath)
25 |
26 | multihashing(data, 'keccak-256', (err, multihash) => {
27 | if (err) {
28 | cb(err)
29 | }
30 | const cid = new CID(1, 'eth-block', multihash)
31 | // console.log(cid.toBaseEncodedString())
32 |
33 | ipfs.block.put(new Block(data, cid), cb)
34 | })
35 | }, (err) => {
36 | if (err) {
37 | throw err
38 | }
39 |
40 | const block302516 = 'z43AaGEywSDX5PUJcrn5GfZmb6FjisJyR7uahhWPk456f7k7LDA'
41 | const block302517 = 'z43AaGF42R2DXsU65bNnHRCypLPr9sg6D7CUws5raiqATVaB1jj'
42 |
43 | function errOrLog (err, result) {
44 | if (err) {
45 | throw err
46 | }
47 | console.log(result.value.toString('hex'))
48 | }
49 |
50 | ipfs.dag.get(block302516 + '/number', errOrLog)
51 | ipfs.dag.get(block302517 + '/parent/number', errOrLog)
52 | })
53 | })
54 |
--------------------------------------------------------------------------------
/test/utils/ipfs-factory-daemon/default-config.json:
--------------------------------------------------------------------------------
1 | {
2 | "Identity": {
3 | "PeerID": "",
4 | "PrivKey": ""
5 | },
6 | "Datastore": {
7 | "Type": "",
8 | "Path": "",
9 | "StorageMax": "",
10 | "StorageGCWatermark": 0,
11 | "GCPeriod": "",
12 | "Params": null,
13 | "NoSync": false
14 | },
15 | "Addresses": {
16 | "Swarm": [
17 | "/ip4/127.0.0.1/tcp/0"
18 | ],
19 | "API": "/ip4/127.0.0.1/tcp/0",
20 | "Gateway": "/ip4/127.0.0.1/tcp/0"
21 | },
22 | "Mounts": {
23 | "IPFS": "/ipfs",
24 | "IPNS": "/ipns",
25 | "FuseAllowOther": false
26 | },
27 | "Version": {
28 | "Current": "jsipfs-dev",
29 | "Check": "error",
30 | "CheckDate": "0001-01-01T00:00:00Z",
31 | "CheckPeriod": "172800000000000",
32 | "AutoUpdate": "minor"
33 | },
34 | "Discovery": {
35 | "MDNS": {
36 | "Enabled": false,
37 | "Interval": 10
38 | },
39 | "webRTCStar": {
40 | "Enabled": false
41 | }
42 | },
43 | "Ipns": {
44 | "RepublishPeriod": "",
45 | "RecordLifetime": "",
46 | "ResolveCacheSize": 128
47 | },
48 | "Bootstrap": [],
49 | "Tour": {
50 | "Last": ""
51 | },
52 | "Gateway": {
53 | "HTTPHeaders": null,
54 | "RootRedirect": "",
55 | "Writable": false
56 | },
57 | "SupernodeRouting": {
58 | "Servers": []
59 | },
60 | "API": {
61 | "HTTPHeaders": null
62 | },
63 | "Swarm": {
64 | "AddrFilters": null
65 | },
66 | "Log": {
67 | "MaxSizeMB": 250,
68 | "MaxBackups": 1,
69 | "MaxAgeDays": 0
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/cli/commands/dag/get.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const CID = require('cids')
4 | const print = require('../../utils').print
5 |
6 | module.exports = {
7 | command: 'get ',
8 |
9 | describe: 'Get a dag node or value from ipfs.',
10 |
11 | builder: {
12 | 'local-resolve': {
13 | type: 'boolean',
14 | default: false
15 | }
16 | },
17 |
18 | handler (argv) {
19 | const refParts = argv.cidpath.split('/')
20 | const cidString = refParts[0]
21 | const path = refParts.slice(1).join('/')
22 | const cid = new CID(cidString)
23 |
24 | const options = {
25 | localResolve: argv.localResolve
26 | }
27 |
28 | argv.ipfs.dag.get(cid, path, options, (err, result) => {
29 | if (err) {
30 | return print(`dag get failed: ${err.message}`)
31 | }
32 |
33 | if (options.localResolve) {
34 | print('resolving path within the node only')
35 | print(`remainder path: ${result.remainderPath || 'n/a'}\n`)
36 | }
37 |
38 | const node = result.value
39 |
40 | // TODO we need to find* a way to pretty print objects
41 | // * reads as 'agree in'
42 | if (node._json) {
43 | delete node._json.multihash
44 | node._json.data = '0x' + node._json.data.toString('hex')
45 | print(node._json)
46 | return
47 | }
48 |
49 | if (Buffer.isBuffer(node)) {
50 | print('0x' + node.toString('hex'))
51 | return
52 | }
53 |
54 | if (node.raw) {
55 | print(node.raw)
56 | } else {
57 | print(node)
58 | }
59 | })
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/test/http-api/index.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | const fs = require('fs')
5 | const chai = require('chai')
6 | const dirtyChai = require('dirty-chai')
7 | const expect = chai.expect
8 | chai.use(dirtyChai)
9 | const API = require('../../src/http')
10 | const APIctl = require('ipfs-api')
11 | const ncp = require('ncp').ncp
12 | const path = require('path')
13 | const clean = require('../utils/clean')
14 |
15 | describe('HTTP API', () => {
16 | const repoExample = path.join(__dirname, '../fixtures/go-ipfs-repo')
17 | const repoTests = path.join(__dirname, '../repo-tests-run')
18 |
19 | let http = {}
20 |
21 | before((done) => {
22 | http.api = new API(repoTests)
23 |
24 | ncp(repoExample, repoTests, (err) => {
25 | expect(err).to.not.exist()
26 |
27 | http.api.start(false, done)
28 | })
29 | })
30 |
31 | after((done) => {
32 | http.api.stop((err) => {
33 | expect(err).to.not.exist()
34 | clean(repoTests)
35 | done()
36 | })
37 | })
38 |
39 | describe('## http-api spec tests', () => {
40 | fs.readdirSync(path.join(__dirname, '/spec'))
41 | .forEach((file) => require('./spec/' + file)(http))
42 | })
43 |
44 | describe('## interface tests', () => {
45 | fs.readdirSync(path.join(__dirname, '/interface'))
46 | .forEach((file) => require('./interface/' + file))
47 | })
48 |
49 | describe('## custom ipfs-api tests', () => {
50 | const ctl = APIctl('/ip4/127.0.0.1/tcp/6001')
51 |
52 | fs.readdirSync(path.join(__dirname, '/over-ipfs-api'))
53 | .forEach((file) => require('./over-ipfs-api/' + file)(ctl))
54 | })
55 | })
56 |
--------------------------------------------------------------------------------
/test/http-api/spec/files.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | const expect = require('chai').expect
5 |
6 | module.exports = (http) => {
7 | describe('/files', () => {
8 | let api
9 |
10 | before(() => {
11 | api = http.api.server.select('API')
12 | })
13 |
14 | describe('/add', () => {}) // TODO
15 |
16 | describe('/cat', () => {
17 | it('returns 400 for request without argument', (done) => {
18 | api.inject({
19 | method: 'GET',
20 | url: '/api/v0/cat'
21 | }, (res) => {
22 | expect(res.statusCode).to.equal(400)
23 | expect(res.result.Message).to.be.a('string')
24 | done()
25 | })
26 | })
27 |
28 | it('500 for request with invalid argument', (done) => {
29 | api.inject({
30 | method: 'GET',
31 | url: '/api/v0/cat?arg=invalid'
32 | }, (res) => {
33 | expect(res.statusCode).to.equal(500)
34 | expect(res.result.Message).to.be.a('string')
35 | done()
36 | })
37 | })
38 |
39 | it('valid hash', (done) => {
40 | api.inject({
41 | method: 'GET',
42 | url: '/api/v0/cat?arg=QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o'
43 | }, (res) => {
44 | expect(res.statusCode).to.equal(200)
45 | expect(res.rawPayload).to.deep.equal(Buffer.from('hello world' + '\n'))
46 | expect(res.payload).to.equal('hello world' + '\n')
47 | done()
48 | })
49 | })
50 | })
51 |
52 | describe('/get', () => {}) // TODO
53 |
54 | describe('/ls', () => {}) // TODO
55 | })
56 | }
57 |
--------------------------------------------------------------------------------
/test/utils/ipfs-factory-instance/index.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const series = require('async/series')
4 | const each = require('async/each')
5 |
6 | const defaultConfig = require('./default-config.json')
7 | const IPFS = require('../../../src/core')
8 | const createTempRepo = require('../create-repo-nodejs')
9 |
10 | module.exports = Factory
11 |
12 | function Factory () {
13 | if (!(this instanceof Factory)) {
14 | return new Factory()
15 | }
16 |
17 | const nodes = []
18 |
19 | /* yields a new started node */
20 | this.spawnNode = (repoPath, config, callback) => {
21 | if (typeof repoPath === 'function') {
22 | callback = repoPath
23 | repoPath = undefined
24 | }
25 | if (typeof config === 'function') {
26 | callback = config
27 | config = undefined
28 | }
29 |
30 | if (!repoPath) {
31 | repoPath = '/tmp/.ipfs-' + Math.random()
32 | .toString()
33 | .substring(2, 8)
34 | }
35 |
36 | config = config || defaultConfig
37 |
38 | const repo = createTempRepo(repoPath)
39 | const node = new IPFS({
40 | repo: repo,
41 | init: {
42 | bits: 1024
43 | },
44 | config: config,
45 | EXPERIMENTAL: {
46 | pubsub: true,
47 | dht: true
48 | }
49 | })
50 |
51 | node.once('ready', () => {
52 | nodes.push({ repo: repo, ipfs: node })
53 | callback(null, node)
54 | })
55 | }
56 |
57 | this.dismantle = function (callback) {
58 | series([
59 | (cb) => each(nodes, (el, cb) => el.ipfs.stop(cb), cb),
60 | (cb) => each(nodes, (el, cb) => el.repo.teardown(cb), cb)
61 | ], callback)
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/cli/commands/ls.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const utils = require('../utils')
4 |
5 | module.exports = {
6 | command: 'ls ',
7 |
8 | describe: 'List files for the given directory',
9 |
10 | builder: {
11 | v: {
12 | alias: 'headers',
13 | desc: 'Print table headers (Hash, Size, Name).',
14 | type: 'boolean',
15 | default: false
16 | },
17 | 'resolve-type': {
18 | desc: 'Resolve linked objects to find out their types. (not implemented yet)',
19 | type: 'boolean',
20 | default: false // should be true when implemented
21 | }
22 | },
23 |
24 | handler (argv) {
25 | let path = argv.key
26 | if (path.startsWith('/ipfs/')) {
27 | path = path.replace('/ipfs/', '')
28 | }
29 |
30 | argv.ipfs.ls(path, (err, links) => {
31 | if (err) {
32 | throw err
33 | }
34 |
35 | if (argv.headers) {
36 | links = [{hash: 'Hash', size: 'Size', name: 'Name'}].concat(links)
37 | }
38 |
39 | links = links.filter((link) => link.path !== path)
40 | links.forEach((link) => {
41 | if (link.type === 'dir') {
42 | // directory: add trailing "/"
43 | link.name = (link.name || '') + '/'
44 | }
45 | })
46 | const multihashWidth = Math.max.apply(null, links.map((file) => file.hash.length))
47 | const sizeWidth = Math.max.apply(null, links.map((file) => String(file.size).length))
48 |
49 | links.forEach((file) => {
50 | utils.print(utils.rightpad(file.hash, multihashWidth + 1) +
51 | utils.rightpad(file.size || '', sizeWidth + 1) +
52 | file.name)
53 | })
54 | })
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/core/components/start.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const series = require('async/series')
4 | const Bitswap = require('ipfs-bitswap')
5 | const FloodSub = require('libp2p-floodsub')
6 | const setImmediate = require('async/setImmediate')
7 | const promisify = require('promisify-es6')
8 |
9 | module.exports = (self) => {
10 | return promisify((callback) => {
11 | callback = callback || function noop () {}
12 |
13 | const done = (err) => {
14 | if (err) {
15 | setImmediate(() => self.emit('error', err))
16 | return callback(err)
17 | }
18 |
19 | self.state.started()
20 | setImmediate(() => self.emit('start'))
21 | callback()
22 | }
23 |
24 | if (self.state.state() !== 'stopped') {
25 | return done(new Error('Not able to start from state: ' + self.state.state()))
26 | }
27 |
28 | self.log('starting')
29 | self.state.start()
30 |
31 | series([
32 | (cb) => {
33 | self._repo.closed
34 | ? self._repo.open(cb)
35 | : cb()
36 | },
37 | (cb) => self.preStart(cb),
38 | (cb) => self.libp2p.start(cb)
39 | ], (err) => {
40 | if (err) {
41 | return done(err)
42 | }
43 |
44 | self._bitswap = new Bitswap(
45 | self._libp2pNode,
46 | self._repo.blocks,
47 | self._peerInfoBook
48 | )
49 |
50 | self._bitswap.start()
51 | self._blockService.setExchange(self._bitswap)
52 |
53 | if (self._options.EXPERIMENTAL.pubsub) {
54 | self._pubsub = new FloodSub(self._libp2pNode)
55 | self._pubsub.start(done)
56 | } else {
57 | done()
58 | }
59 | })
60 | })
61 | }
62 |
--------------------------------------------------------------------------------
/test/fixtures/go-ipfs-repo/datastore/LOG:
--------------------------------------------------------------------------------
1 | =============== Aug 25, 2016 (CEST) ===============
2 | 17:21:42.391799 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed
3 | 17:21:42.393115 db@open opening
4 | 17:21:42.399749 db@janitor F·5 G·1
5 | 17:21:42.399774 db@janitor removing manifest-4
6 | 17:21:42.399904 db@open done T·6.754896ms
7 | =============== Aug 25, 2016 (CEST) ===============
8 | 17:36:56.009638 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed
9 | 17:36:56.009849 version@stat F·[2] S·1KiB[1KiB] Sc·[0.50]
10 | 17:36:56.009874 db@open opening
11 | 17:36:56.009943 journal@recovery F·1
12 | 17:36:56.010918 journal@recovery recovering @8
13 | 17:36:56.012317 memdb@flush created L0@10 N·4 S·1KiB "/ip..\xf6\xe4\xa9,d12":"/pk..TOA,v9"
14 | 17:36:56.013451 version@stat F·[3] S·2KiB[2KiB] Sc·[0.75]
15 | 17:36:56.014779 db@janitor F·5 G·0
16 | 17:36:56.014815 db@open done T·4.928147ms
17 | 17:36:56.030081 db@close closing
18 | 17:36:56.030223 db@close done T·138.943µs
19 | =============== Aug 25, 2016 (CEST) ===============
20 | 17:37:32.735975 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed
21 | 17:37:32.736209 version@stat F·[3] S·2KiB[2KiB] Sc·[0.75]
22 | 17:37:32.736230 db@open opening
23 | 17:37:32.736304 journal@recovery F·1
24 | 17:37:32.737385 journal@recovery recovering @11
25 | 17:37:32.738575 version@stat F·[3] S·2KiB[2KiB] Sc·[0.75]
26 | 17:37:32.739466 db@janitor F·5 G·0
27 | 17:37:32.739492 db@open done T·3.248709ms
28 | 17:37:51.684973 db@close closing
29 | 17:37:51.685242 db@close done T·168.908µs
30 |
--------------------------------------------------------------------------------
/test/fixtures/test-data/recursive-get-dir/datastore/LOG:
--------------------------------------------------------------------------------
1 | =============== Aug 25, 2016 (CEST) ===============
2 | 17:21:42.391799 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed
3 | 17:21:42.393115 db@open opening
4 | 17:21:42.399749 db@janitor F·5 G·1
5 | 17:21:42.399774 db@janitor removing manifest-4
6 | 17:21:42.399904 db@open done T·6.754896ms
7 | =============== Aug 25, 2016 (CEST) ===============
8 | 17:36:56.009638 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed
9 | 17:36:56.009849 version@stat F·[2] S·1KiB[1KiB] Sc·[0.50]
10 | 17:36:56.009874 db@open opening
11 | 17:36:56.009943 journal@recovery F·1
12 | 17:36:56.010918 journal@recovery recovering @8
13 | 17:36:56.012317 memdb@flush created L0@10 N·4 S·1KiB "/ip..\xf6\xe4\xa9,d12":"/pk..TOA,v9"
14 | 17:36:56.013451 version@stat F·[3] S·2KiB[2KiB] Sc·[0.75]
15 | 17:36:56.014779 db@janitor F·5 G·0
16 | 17:36:56.014815 db@open done T·4.928147ms
17 | 17:36:56.030081 db@close closing
18 | 17:36:56.030223 db@close done T·138.943µs
19 | =============== Aug 25, 2016 (CEST) ===============
20 | 17:37:32.735975 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed
21 | 17:37:32.736209 version@stat F·[3] S·2KiB[2KiB] Sc·[0.75]
22 | 17:37:32.736230 db@open opening
23 | 17:37:32.736304 journal@recovery F·1
24 | 17:37:32.737385 journal@recovery recovering @11
25 | 17:37:32.738575 version@stat F·[3] S·2KiB[2KiB] Sc·[0.75]
26 | 17:37:32.739466 db@janitor F·5 G·0
27 | 17:37:32.739492 db@open done T·3.248709ms
28 | 17:37:51.684973 db@close closing
29 | 17:37:51.685242 db@close done T·168.908µs
30 |
--------------------------------------------------------------------------------
/src/cli/commands/config.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | const print = require('../utils').print
3 |
4 | module.exports = {
5 | command: 'config [value]',
6 |
7 | description: 'Get and set IPFS config values',
8 |
9 | builder (yargs) {
10 | return yargs
11 | .commandDir('config')
12 | .options({
13 | bool: {
14 | type: 'boolean',
15 | default: false,
16 | global: false
17 | },
18 | json: {
19 | type: 'boolean',
20 | default: false,
21 | global: false
22 | }
23 | })
24 | },
25 |
26 | handler (argv) {
27 | if (argv._handled) {
28 | return
29 | }
30 | argv._handled = true
31 |
32 | const bool = argv.bool
33 | const json = argv.json
34 | const key = argv.key
35 | let value = argv.value
36 |
37 | if (!value) {
38 | // Get the value of a given key
39 | argv.ipfs.config.get(key, (err, value) => {
40 | if (err) {
41 | throw new Error('failed to read the config')
42 | }
43 |
44 | if (typeof value === 'object') {
45 | print(JSON.stringify(value, null, 2))
46 | } else {
47 | print(value)
48 | }
49 | })
50 | } else {
51 | // Set the new value of a given key
52 |
53 | if (bool) {
54 | value = (value === 'true')
55 | } else if (json) {
56 | try {
57 | value = JSON.parse(value)
58 | } catch (err) {
59 | throw new Error('invalid JSON provided')
60 | }
61 | }
62 |
63 | argv.ipfs.config.set(key, value, (err) => {
64 | if (err) {
65 | throw new Error('failed to read the config')
66 | }
67 | })
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
]