fix: clean repo and bundle size reduction

This commit is contained in:
Hugo Dias 2018-12-05 12:01:29 +00:00 committed by Pedro Teixeira
parent 8e030b24d4
commit cd2099305e
6 changed files with 19 additions and 122 deletions

View File

@ -1,28 +0,0 @@
# Logs
logs
*.log
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Optional npm cache directory
.npm
# Optional REPL history
.node_repl_history
test

View File

@ -1,32 +0,0 @@
# Warning: This file is automatically synced from https://github.com/ipfs/ci-sync so if you want to change it, please change it there and ask someone to sync all repositories.
sudo: false
language: node_js
matrix:
include:
- node_js: 6
env: CXX=g++-4.8
- node_js: 8
env: CXX=g++-4.8
# - node_js: stable
# env: CXX=g++-4.8
script:
- npm run lint
- npm run test
- npm run coverage
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
after_success:
- npm run coverage-publish
addons:
firefox: 'latest'
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8

View File

@ -1,29 +0,0 @@
# Warning: This file is automatically synced from https://github.com/ipfs/ci-sync so if you want to change it, please change it there and ask someone to sync all repositories.
version: "{build}"
environment:
matrix:
- nodejs_version: "6"
- nodejs_version: "8"
matrix:
fast_finish: true
install:
# Install Node.js
- ps: Install-Product node $env:nodejs_version
# Upgrade npm
- npm install -g npm
# Output our current versions for debugging
- node --version
- npm --version
# Install our package dependencies
- npm install
test_script:
- npm run test:node
build: off

View File

@ -1,15 +0,0 @@
# Warning: This file is automatically synced from https://github.com/ipfs/ci-sync so if you want to change it, please change it there and ask someone to sync all repositories.
machine:
node:
version: stable
dependencies:
pre:
- google-chrome --version
- curl -L -o google-chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
- sudo dpkg -i google-chrome.deb || true
- sudo apt-get update
- sudo apt-get install -f
- sudo apt-get install --only-upgrade lsb-base
- sudo dpkg -i google-chrome.deb
- google-chrome --version

View File

@ -14,19 +14,20 @@
"release": "aegir release",
"release-minor": "aegir release --type minor",
"release-major": "aegir release --type major",
"coverage": "aegir coverage"
"coverage": "aegir coverage",
"size": "bundlesize -f dist/index.min.js -s 140kB"
},
"files": [
"src",
"dist"
],
"keywords": [
"IPFS"
],
"license": "MIT",
"pre-push": [
"lint",
"test"
],
"engines": {
"node": ">=6.0.0",
"npm": ">=3.0.0"
"node": ">=10.0.0",
"npm": ">=6.0.0"
},
"bugs": {
"url": "https://github.com/libp2p/js-peer-id/issues"
@ -34,15 +35,15 @@
"homepage": "https://github.com/libp2p/js-peer-id",
"devDependencies": {
"aegir": "^18.0.2",
"bundlesize": "^0.17.0",
"chai": "^4.2.0",
"dirty-chai": "^2.0.1"
},
"dependencies": {
"async": "^2.6.1",
"class-is": "^1.1.0",
"libp2p-crypto": "~0.15.0",
"lodash": "^4.17.11",
"multihashes": "~0.4.14"
"libp2p-crypto": "libp2p/js-libp2p-crypto#feat/bundle-size",
"multihashes": "~0.4.13"
},
"repository": {
"type": "git",

View File

@ -5,7 +5,7 @@
'use strict'
const mh = require('multihashes')
const crypto = require('libp2p-crypto')
const cryptoKeys = require('libp2p-crypto/src/keys')
const assert = require('assert')
const waterfall = require('async/waterfall')
const withIs = require('class-is')
@ -57,14 +57,14 @@ class PeerId {
// Return the protobuf version of the public key, matching go ipfs formatting
marshalPubKey () {
if (this.pubKey) {
return crypto.keys.marshalPublicKey(this.pubKey)
return cryptoKeys.marshalPublicKey(this.pubKey)
}
}
// Return the protobuf version of the private key, matching go ipfs formatting
marshalPrivKey () {
if (this.privKey) {
return crypto.keys.marshalPrivateKey(this.privKey)
return cryptoKeys.marshalPrivateKey(this.privKey)
}
}
@ -147,7 +147,7 @@ exports.create = function (opts, callback) {
opts.bits = opts.bits || 2048
waterfall([
(cb) => crypto.keys.generateKeyPair('RSA', opts.bits, cb),
(cb) => cryptoKeys.generateKeyPair('RSA', opts.bits, cb),
(privKey, cb) => privKey.public.hash((err, digest) => {
cb(err, digest, privKey)
})
@ -188,7 +188,7 @@ exports.createFromPubKey = function (key, callback) {
if (!Buffer.isBuffer(buf)) throw new Error('Supplied key is neither a base64 string nor a buffer')
pubKey = crypto.keys.unmarshalPublicKey(buf)
pubKey = cryptoKeys.unmarshalPublicKey(buf)
} catch (err) {
return callback(err)
}
@ -221,7 +221,7 @@ exports.createFromPrivKey = function (key, callback) {
}
waterfall([
(cb) => crypto.keys.unmarshalPrivateKey(buf, cb),
(cb) => cryptoKeys.unmarshalPrivateKey(buf, cb),
(privKey, cb) => privKey.public.hash((err, digest) => {
cb(err, digest, privKey)
})
@ -248,14 +248,14 @@ exports.createFromJSON = function (obj, callback) {
id = mh.fromB58String(obj.id)
rawPrivKey = obj.privKey && Buffer.from(obj.privKey, 'base64')
rawPubKey = obj.pubKey && Buffer.from(obj.pubKey, 'base64')
pub = rawPubKey && crypto.keys.unmarshalPublicKey(rawPubKey)
pub = rawPubKey && cryptoKeys.unmarshalPublicKey(rawPubKey)
} catch (err) {
return callback(err)
}
if (rawPrivKey) {
waterfall([
(cb) => crypto.keys.unmarshalPrivateKey(rawPrivKey, cb),
(cb) => cryptoKeys.unmarshalPrivateKey(rawPrivKey, cb),
(priv, cb) => priv.public.hash((err, digest) => {
cb(err, digest, priv)
}),