Skip to content
This repository was archived by the owner on Aug 12, 2020. It is now read-only.

Commit 1cbaaea

Browse files
dignifiedquiredaviddias
authored andcommitted
Setup dignified.js
1 parent efa0dcb commit 1cbaaea

File tree

103 files changed

+482
-92
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+482
-92
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@ build/Release
2929
# Dependency directory
3030
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
3131
node_modules
32+
33+
dist
34+
lib

karma.conf.js

-54
This file was deleted.

package.json

+10-9
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,20 @@
44
"description": "JavaScript implementation of the layout and chunking mechanisms used by IPFS",
55
"main": "src/index.js",
66
"scripts": {
7-
"lint": "standard",
8-
"test": "npm run test:node && npm run test:browser",
9-
"test:node": "mocha tests/index.js",
10-
"test:browser": "karma start karma.conf.js"
7+
"lint": "dignified-lint",
8+
"build": "dignified-build",
9+
"test": "dignified-test",
10+
"test:node": "dignified-test node",
11+
"test:browser": "dignified-test browser",
12+
"release": "dignified-release"
1113
},
1214
"pre-commit": [
1315
"lint",
1416
"test"
1517
],
1618
"repository": {
1719
"type": "git",
18-
"url": "git+https://github.com/diasdavid/js-ipfs-data-importing.git"
20+
"url": "git+https://github.com/ipfs/js-ipfs-data-importing.git"
1921
},
2022
"keywords": [
2123
"IPFS"
@@ -28,9 +30,11 @@
2830
"homepage": "https://github.com/diasdavid/js-ipfs-data-importing#readme",
2931
"devDependencies": {
3032
"brfs": "^1.4.3",
33+
"block-stream2": "^1.1.0",
3134
"bs58": "^3.0.0",
3235
"buffer-loader": "0.0.1",
3336
"chai": "^3.4.1",
37+
"dignified.js": "github:dignifiedquire/dignified.js",
3438
"fs-blob-store": "^5.2.1",
3539
"highland": "^2.7.1",
3640
"idb-plus-blob-store": "^1.0.0",
@@ -50,10 +54,7 @@
5054
"pre-commit": "^1.1.2",
5155
"raw-loader": "^0.5.1",
5256
"rimraf": "^2.5.1",
53-
"standard": "^6.0.8",
54-
"string-to-stream": "^1.0.1",
55-
"transform-loader": "^0.2.3",
56-
"webpack": "^2.0.7-beta"
57+
"string-to-stream": "^1.0.1"
5758
},
5859
"dependencies": {
5960
"async": "^1.5.2",

src/chunker-fixed-size.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
var chunker = require('block-stream2')
1+
'use strict'
2+
3+
const chunker = require('block-stream2')
24

35
exports = module.exports = function (size) {
46
return chunker({ size: size, zeroPadding: false })

src/index.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict'
2+
13
const debug = require('debug')
24
const log = debug('importer')
35
log.err = debug('importer:error')
@@ -7,6 +9,7 @@ const FixedSizeChunker = require('./chunker-fixed-size')
79
const through2 = require('through2')
810
const UnixFS = require('ipfs-unixfs')
911
const async = require('async')
12+
1013
exports = module.exports
1114

1215
const CHUNK_SIZE = 262144

tests/browser.js renamed to test/browser.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/* eslint-env mocha */
2+
'use strict'
3+
24
const tests = require('./buffer-test')
35
const async = require('async')
46
const store = require('idb-plus-blob-store')
@@ -17,7 +19,7 @@ idb.deleteDatabase('ipfs/blocks')
1719
describe('IPFS data importing tests on the Browser', function () {
1820
before(function (done) {
1921
this.timeout(23000)
20-
var repoData = []
22+
const repoData = []
2123
repoContext.keys().forEach(function (key) {
2224
repoData.push({
2325
key: key.replace('./', ''),

tests/buffer-test.js renamed to test/buffer-test.js

+66-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/* eslint-env mocha */
2+
'use strict'
3+
24
const importer = require('./../src')
35
const BlockService = require('ipfs-blocks').BlockService
46
const DAGService = require('ipfs-merkle-dag').DAGService
@@ -14,12 +16,69 @@ const bigLink = require('buffer!./test-data/1.2MiB.txt.link-block0')
1416
const marbuf = require('buffer!./test-data/200Bytes.txt.block')
1517

1618
module.exports = function (repo) {
19+
describe('chunker: fixed size', function () {
20+
this.timeout(10000)
21+
22+
it('256 Bytes chunks', function (done) {
23+
let counter = 0
24+
fileStream()
25+
.pipe(FixedSizeChunker(256))
26+
.pipe(through(function (chunk, enc, cb) {
27+
if (chunk.length < 256) {
28+
expect(counter).to.be.below(1)
29+
counter += 1
30+
return cb()
31+
}
32+
expect(chunk.length).to.equal(256)
33+
cb()
34+
}, () => {
35+
done()
36+
}))
37+
})
38+
39+
it('256 KiB chunks', function (done) {
40+
let counter = 0
41+
const KiB256 = 262144
42+
fileStream()
43+
.pipe(FixedSizeChunker(KiB256))
44+
.pipe(through((chunk, enc, cb) => {
45+
if (chunk.length < 262144) {
46+
expect(counter).to.be.below(1)
47+
counter += 1
48+
return cb()
49+
}
50+
expect(chunk.length).to.equal(262144)
51+
cb()
52+
}, () => {
53+
done()
54+
}))
55+
})
56+
57+
it('256 KiB chunks of non scalar filesize', function (done) {
58+
let counter = 0
59+
const KiB256 = 262144
60+
fileStream()
61+
.pipe(FixedSizeChunker(KiB256))
62+
.pipe(through((chunk, enc, cb) => {
63+
if (chunk.length < KiB256) {
64+
expect(counter).to.be.below(2)
65+
counter += 1
66+
return cb()
67+
}
68+
expect(chunk.length).to.equal(KiB256)
69+
cb()
70+
}, () => {
71+
done()
72+
}))
73+
})
74+
})
75+
1776
describe('layout: importer', function () {
1877
it('import a small buffer', function (done) {
1978
// this is just like "import a small file"
20-
var bs = new BlockService(repo)
21-
var ds = new DAGService(bs)
22-
var buf = smallBuf
79+
const bs = new BlockService(repo)
80+
const ds = new DAGService(bs)
81+
const buf = smallBuf
2382
importer.import(buf, ds, function (err, stat) {
2483
expect(err).to.not.exist
2584
ds.get(stat.Hash, function (err, node) {
@@ -35,9 +94,9 @@ module.exports = function (repo) {
3594

3695
it('import a big buffer', function (done) {
3796
// this is just like "import a big file"
38-
var buf = bigBuf
39-
var bs = new BlockService(repo)
40-
var ds = new DAGService(bs)
97+
const buf = bigBuf
98+
const bs = new BlockService(repo)
99+
const ds = new DAGService(bs)
41100
importer.import(buf, ds, function (err, stat) {
42101
expect(err).to.not.exist
43102
ds.get(stat.Hash, function (err, node) {
@@ -61,7 +120,7 @@ module.exports = function (repo) {
61120
expect(err).to.not.exist
62121
const leaf = new DAGNode()
63122

64-
var marbuf2 = bigLink
123+
const marbuf2 = bigLink
65124
leaf.unMarshal(marbuf2)
66125
expect(node.links).to.deep.equal(leaf.links)
67126
expect(node.links.length).to.equal(0)

tests/index.js renamed to test/node.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ const fs = require('fs')
66
const ncp = require('ncp').ncp
77
const rimraf = require('rimraf')
88
const expect = require('chai').expect
9+
const path = require('path')
910

1011
describe('core', () => {
11-
const repoExample = process.cwd() + '/tests/repo-example'
12-
const repoTests = process.cwd() + '/tests/repo-tests' + Date.now()
12+
const repoExample = path.join(process.cwd(), '/test/repo-example')
13+
const repoTests = path.join(process.cwd(), '/test/repo-tests' + Date.now())
1314

1415
before((done) => {
1516
ncp(repoExample, repoTests, (err) => {
@@ -35,9 +36,9 @@ describe('core', () => {
3536
file === 'buffer-test.js' ||
3637
file.indexOf('repo-tests') > -1) {
3738
return false
38-
} else {
39-
return true
4039
}
40+
41+
return true
4142
}).forEach((file) => {
4243
require('./' + file)
4344
})
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
��Hello and Welcome to IPFS!
3+
4+
██╗██████╗ ███████╗███████╗
5+
██║██╔══██╗██╔════╝██╔════╝
6+
██║██████╔╝█████╗ ███████╗
7+
██║██╔═══╝ ██╔══╝ ╚════██║
8+
██║██║ ██║ ███████║
9+
╚═╝╚═╝ ╚═╝ ╚══════╝
10+
11+
If you're seeing this, you have successfully installed
12+
IPFS and are now interfacing with the ipfs merkledag!
13+
14+
-------------------------------------------------------
15+
| Warning: |
16+
| This is alpha software. Use at your own discretion! |
17+
| Much is missing or lacking polish. There are bugs. |
18+
| Not yet secure. Read the security notes for more. |
19+
-------------------------------------------------------
20+
21+
Check out some of the other files in this directory:
22+
23+
./about
24+
./help
25+
./quick-start <-- usage examples
26+
./readme <-- this file
27+
./security-notes
28+
�
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
5
2+
" ���׾F�_�uؔ�l��z�S?��|ڲ��Pc@ js-ipfs-repo�
3+
4+

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
�� IPFS Alpha Security Notes
3+
4+
We try hard to ensure our system is safe and robust, but all software
5+
has bugs, especially new software. This distribution is meant to be an
6+
alpha preview, don't use it for anything mission critical.
7+
8+
Please note the following:
9+
10+
- This is alpha software and has not been audited. It is our goal
11+
to conduct a proper security audit once we close in on a 1.0 release.
12+
13+
- ipfs is a networked program, and may have serious undiscovered
14+
vulnerabilities. It is written in Go, and we do not execute any
15+
user provided data. But please point any problems out to us in a
16+
github issue, or email [email protected] privately.
17+
18+
- ipfs uses encryption for all communication, but it's NOT PROVEN SECURE
19+
YET! It may be totally broken. For now, the code is included to make
20+
sure we benchmark our operations with encryption in mind. In the future,
21+
there will be an "unsafe" mode for high performance intranet apps.
22+
If this is a blocking feature for you, please contact us.
23+
�
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+


0 commit comments

Comments
 (0)