From 73a0dc4e5614b12ac1942ff8e940596d63a97064 Mon Sep 17 00:00:00 2001 From: Kagami Hiiragi Date: Tue, 10 Feb 2015 17:59:49 +0300 Subject: [PATCH] address/net documentation --- lib/address.js | 16 ++++++++-------- lib/crypto.js | 6 +++--- lib/net/base.js | 1 - lib/net/tcp.js | 13 +++++++++++++ lib/net/ws.js | 12 ++++++++++++ package.json | 2 +- 6 files changed, 37 insertions(+), 13 deletions(-) diff --git a/lib/address.js b/lib/address.js index cc50dd1..25fcfb1 100644 --- a/lib/address.js +++ b/lib/address.js @@ -30,7 +30,7 @@ var popkey = require("./_util").popkey; /** * Create a new Bitmessage address object. - * @param {?Object} opts - Optional address options + * @param {?Object} opts - Address options * @param {number} opts.version - Version number (4 by default) * @param {number} opts.stream - Stream number (1 by default) * @param {Object} opts.behavior - [Pubkey features]{@link module:bitmessage/structs.PubkeyBitfield} (`DOES_ACK` by default) @@ -248,12 +248,12 @@ Address.prototype.encode = function() { /** * Create a new Bitmessage address with random encryption and signing * private keys. - * @param {?Object} opts - Optional address options + * @param {?Object} opts - Address options * @param {number} opts.ripeLength - Required length of the short RIPEMD * hash (19 by default) - * @param {number} opts.version - Version number - * @param {number} opts.stream - Stream number - * @param {Object} opts.behavior - [Pubkey features]{@link module:bitmessage/structs.PubkeyBitfield} + * @param {number} opts.version - Version number (4 by default) + * @param {number} opts.stream - Stream number (1 by default) + * @param {Object} opts.behavior - [Pubkey features]{@link module:bitmessage/structs.PubkeyBitfield} (`DOES_ACK` by default) * @return {Address} New address object. */ Address.fromRandom = function(opts) { @@ -289,9 +289,9 @@ Address.fromRandom = function(opts) { * @param {string} opts.passphrase - Passphrase to generate address from * @param {?number} opts.ripeLength - Required length of the short * RIPEMD hash (19 by default) - * @param {?number} opts.version - Version number - * @param {?number} opts.stream - Stream number - * @param {?Object} opts.behavior - [Pubkey features]{@link module:bitmessage/structs.PubkeyBitfield} + * @param {?number} opts.version - Version number (4 by default) + * @param {?number} opts.stream - Stream number (1 by default) + * @param {?Object} opts.behavior - [Pubkey features]{@link module:bitmessage/structs.PubkeyBitfield} (`DOES_ACK` by default) * @return {Address} New address object. */ Address.fromPassphrase = function(opts) { diff --git a/lib/crypto.js b/lib/crypto.js index 8673085..e7ee903 100644 --- a/lib/crypto.js +++ b/lib/crypto.js @@ -54,7 +54,7 @@ exports.ripemd160 = platform.ripemd160; exports.randomBytes = platform.randomBytes; /** - * Generate new random private key. + * Generate a new random private key. * @return {Buffer} New private key. */ exports.getPrivate = function() { @@ -86,8 +86,8 @@ exports.sign = function(privateKey, msg) { * @param {Buffer} publicKey - A 65-byte public key * @param {Buffer} msg - The message being verified * @param {Buffer} sig - The signature in DER format - * @return {Promise.} A promise that resolves on correct - * signature and rejects on bad key or signature. + * @return {Promise.} A promise that resolves on correct signature + * and rejects on bad key or signature. */ exports.verify = function(publicKey, msg, sig) { var hash = sha1(msg); diff --git a/lib/net/base.js b/lib/net/base.js index be2a2d1..ea934b1 100644 --- a/lib/net/base.js +++ b/lib/net/base.js @@ -18,7 +18,6 @@ var structs = require("../structs"); /** * Base transport class. Allows to use single class for both client and * server modes (as separate instances). - * @param {?Object} opts - Transport options * @constructor * @static */ diff --git a/lib/net/tcp.js b/lib/net/tcp.js index 58d70e2..452d43a 100644 --- a/lib/net/tcp.js +++ b/lib/net/tcp.js @@ -24,6 +24,19 @@ var unmap = BaseTransport._unmap; /** * TCP transport class. Implements * [base transport interface]{@link module:bitmessage/net/base.BaseTransport}. + * @param {?Object} opts - Transport options + * @param {Array} opts.seeds - Bootstrap nodes (none by default) + * @param {Array} opts.dnsSeeds - Bootstrap DNS nodes (none by default) + * @param {Object} opts.services - + * [Service features]{@link module:bitmessage/structs.ServicesBitfield} + * provided by this node (`NODE_NETWORK` by default) + * @param {(Array|string|Buffer)} opts.userAgent - + * [User agent]{@link module:bitmessage/user-agent} of this node + * (bitmessage's by default) + * @param {number[]} opts.streamNumbers - Streams accepted by this node + * (1 by default) + * @param {number} opts.port - Incoming port of this node (8444 by + * default) * @constructor * @static */ diff --git a/lib/net/ws.js b/lib/net/ws.js index 2ce0357..7490580 100644 --- a/lib/net/ws.js +++ b/lib/net/ws.js @@ -25,6 +25,18 @@ var unmap = BaseTransport._unmap; /** * WebSocket transport class. Implements * [base transport interface]{@link module:bitmessage/net/base.BaseTransport}. + * @param {?Object} opts - Transport options + * @param {Array} opts.seeds - Bootstrap nodes (none by default) + * @param {Object} opts.services - + * [Service features]{@link module:bitmessage/structs.ServicesBitfield} + * provided by this node (`NODE_NETWORK` by default) + * @param {(Array|string|Buffer)} opts.userAgent - + * [User agent]{@link module:bitmessage/user-agent} of this node + * (bitmessage's by default) + * @param {number[]} opts.streamNumbers - Streams accepted by this node + * (1 by default) + * @param {number} opts.port - Incoming port of this node (8444 by + * default) * @constructor * @static */ diff --git a/package.json b/package.json index 99136e4..9f6ac7a 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "bn.js": "^1.0.0", "bs58": "^2.0.0", "buffer-equal": "~0.0.1", - "eccrypto": "^0.9.5", + "eccrypto": "^0.9.6", "es6-promise": "^2.0.1", "hash.js": "^1.0.2", "inherits": "^2.0.1",