Compare commits

...

7 Commits

Author SHA1 Message Date
cd99cb2c7d chore: release version v0.13.13 2020-06-23 18:58:05 +02:00
c295329300 chore: update contributors 2020-06-23 18:58:04 +02:00
bb32b12395 chore: update deps (#126)
Allows for deduping multihashes module
2020-06-23 18:43:30 +02:00
6fd5ca2a12 chore(deps-dev): bump aegir from 21.10.2 to 22.0.0 (#124)
Bumps [aegir](https://github.com/ipfs/aegir) from 21.10.2 to 22.0.0.
- [Release notes](https://github.com/ipfs/aegir/releases)
- [Changelog](https://github.com/ipfs/aegir/blob/master/CHANGELOG.md)
- [Commits](https://github.com/ipfs/aegir/compare/v21.10.2...v22.0.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-05-28 18:10:20 +02:00
020b963711 chore: release version v0.13.12 2020-04-22 16:35:07 +02:00
e3da29a440 chore: update contributors 2020-04-22 16:35:07 +02:00
8cd9dfb137 feat(cli): add support for specifying type and size (#122) 2020-04-22 16:32:38 +02:00
5 changed files with 46 additions and 15 deletions

View File

@ -1,3 +1,18 @@
<a name="0.13.13"></a>
## [0.13.13](https://github.com/libp2p/js-peer-id/compare/v0.13.12...v0.13.13) (2020-06-23)
<a name="0.13.12"></a>
## [0.13.12](https://github.com/libp2p/js-peer-id/compare/v0.13.11...v0.13.12) (2020-04-22)
### Features
* **cli:** add support for specifying type and size ([#122](https://github.com/libp2p/js-peer-id/issues/122)) ([8cd9dfb](https://github.com/libp2p/js-peer-id/commit/8cd9dfb))
<a name="0.13.11"></a> <a name="0.13.11"></a>
## [0.13.11](https://github.com/libp2p/js-peer-id/compare/v0.13.10...v0.13.11) (2020-03-26) ## [0.13.11](https://github.com/libp2p/js-peer-id/compare/v0.13.10...v0.13.11) (2020-03-26)

View File

@ -28,6 +28,7 @@
- [Node.js](#nodejs) - [Node.js](#nodejs)
- [Browser: Browserify, Webpack, other bundlers](#browser-browserify-webpack-other-bundlers) - [Browser: Browserify, Webpack, other bundlers](#browser-browserify-webpack-other-bundlers)
- [Browser: `<script>` Tag](#browser-script-tag) - [Browser: `<script>` Tag](#browser-script-tag)
- [CLI](#cli)
- [API](#api) - [API](#api)
- [Create](#create) - [Create](#create)
- [`new PeerId(id[, privKey, pubKey])`](#new-peeridid-privkey-pubkey) - [`new PeerId(id[, privKey, pubKey])`](#new-peeridid-privkey-pubkey)
@ -117,6 +118,14 @@ the global namespace.
<script src="https://unpkg.com/peer-id/dist/index.js"></script> <script src="https://unpkg.com/peer-id/dist/index.js"></script>
``` ```
# CLI
After installing `peer-id`, `npm install peer-id`, you can leverage the cli to generate keys exported as JSON. You can specify the type for the key and size, as detailed in [`create([opts])`](#createopts). The defaults are shown here.
```sh
> peer-id --type rsa --bits 2048
```
# API # API
```js ```js
@ -137,7 +146,8 @@ The key format is detailed in [libp2p-crypto](https://github.com/libp2p/js-libp2
Generates a new Peer ID, complete with public/private keypair. Generates a new Peer ID, complete with public/private keypair.
- `opts: Object`: Default: `{bits: 2048, keyType: 'rsa'}` - `opts.bits: number` - The size of the key. Default: `2048`
- `opts.keyType: string` - The key type, one of: `['rsa', 'ed25519', 'secp256k1']`. Default: `rsa`
Returns `Promise<PeerId>`. Returns `Promise<PeerId>`.

View File

@ -1,6 +1,6 @@
{ {
"name": "peer-id", "name": "peer-id",
"version": "0.13.11", "version": "0.13.13",
"description": "IPFS Peer Id implementation in Node.js", "description": "IPFS Peer Id implementation in Node.js",
"leadMaintainer": "Vasco Santos <santos.vasco10@gmail.com>", "leadMaintainer": "Vasco Santos <santos.vasco10@gmail.com>",
"main": "src/index.js", "main": "src/index.js",
@ -39,7 +39,7 @@
"@types/chai": "^4.2.7", "@types/chai": "^4.2.7",
"@types/dirty-chai": "^2.0.2", "@types/dirty-chai": "^2.0.2",
"@types/mocha": "^7.0.2", "@types/mocha": "^7.0.2",
"aegir": "^21.2.0", "aegir": "^22.0.0",
"bundlesize": "~0.18.0", "bundlesize": "~0.18.0",
"chai": "^4.2.0", "chai": "^4.2.0",
"dirty-chai": "^2.0.1" "dirty-chai": "^2.0.1"
@ -48,8 +48,9 @@
"buffer": "^5.5.0", "buffer": "^5.5.0",
"cids": "^0.8.0", "cids": "^0.8.0",
"class-is": "^1.1.0", "class-is": "^1.1.0",
"libp2p-crypto": "~0.17.3", "libp2p-crypto": "^0.17.7",
"multihashes": "~0.4.15", "minimist": "^1.2.5",
"multihashes": "^1.0.1",
"protons": "^1.0.2" "protons": "^1.0.2"
}, },
"repository": { "repository": {
@ -64,22 +65,22 @@
"Jacob Heun <jacobheun@gmail.com>", "Jacob Heun <jacobheun@gmail.com>",
"Pedro Teixeira <i@pgte.me>", "Pedro Teixeira <i@pgte.me>",
"Stephen Whitmore <stephen.whitmore@gmail.com>", "Stephen Whitmore <stephen.whitmore@gmail.com>",
"Maciej Krüger <mkg20001@gmail.com>",
"Hugo Dias <hugomrdias@gmail.com>", "Hugo Dias <hugomrdias@gmail.com>",
"Maciej Krüger <mkg20001@gmail.com>",
"Alex Potsides <alex@achingbrain.net>",
"Nate Foss <npfoss@gmail.com>", "Nate Foss <npfoss@gmail.com>",
"Robert Kiel <robert.kiel@validitylabs.org>", "Robert Kiel <robert.kiel@validitylabs.org>",
"ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ <victorbjelkholm@gmail.com>",
"Arve Knudsen <arve.knudsen@gmail.com>",
"Carson Farmer <carson.farmer@gmail.com>",
"Christian Paul <info@jaller.de>",
"Henrique Dias <hacdias@gmail.com>",
"Marcin Rataj <lidel@lidel.org>",
"Michael Garvin <gar+gh@danger.computer>", "Michael Garvin <gar+gh@danger.computer>",
"Prashanth Chandra <coolshanth94@gmail.com>",
"Richard Littauer <richard.littauer@gmail.com>", "Richard Littauer <richard.littauer@gmail.com>",
"Richard Schneider <makaretu@gmail.com>", "Richard Schneider <makaretu@gmail.com>",
"ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ <victorbjelkholm@gmail.com>",
"Marcin Rataj <lidel@lidel.org>",
"Topper Bowers <topper@quorumcontrol.com>", "Topper Bowers <topper@quorumcontrol.com>",
"Henrique Dias <hacdias@gmail.com>",
"Yahya <ya7yaz@gmail.com>", "Yahya <ya7yaz@gmail.com>",
"Alex Potsides <alex@achingbrain.net>" "Christian Paul <info@jaller.de>",
"Carson Farmer <carson.farmer@gmail.com>",
"Arve Knudsen <arve.knudsen@gmail.com>",
"Prashanth Chandra <coolshanth94@gmail.com>"
] ]
} }

View File

@ -3,9 +3,13 @@
'use strict' 'use strict'
const PeerId = require('./index.js') const PeerId = require('./index.js')
const argv = require('minimist')(process.argv.slice(2))
async function main () { async function main () {
const id = await PeerId.create() const id = await PeerId.create({
keyType: argv.type,
bits: argv.bits
})
console.log(JSON.stringify(id.toJSON(), null, 2)) // eslint-disable-line no-console console.log(JSON.stringify(id.toJSON(), null, 2)) // eslint-disable-line no-console
} }

View File

@ -63,6 +63,7 @@ describe('PeerId', () => {
const id = await PeerId.create(testOpts) const id = await PeerId.create(testOpts)
expect(id.toB58String().length).to.equal(46) expect(id.toB58String().length).to.equal(46)
expect(() => { expect(() => {
// @ts-ignore
id.id = Buffer.from('hello') id.id = Buffer.from('hello')
}).to.throw(/immutable/) }).to.throw(/immutable/)
}) })