Skip to content

Commit

Permalink
Merge pull request #45 from ssbc/Bufferfrom
Browse files Browse the repository at this point in the history
convert new Buffer() to Buffer.from everywhere
  • Loading branch information
christianbundy authored Jan 7, 2020
2 parents 1628f96 + 79021ad commit 06305ad
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 17 deletions.
17 changes: 4 additions & 13 deletions plugins/shs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var u = require('../util')
var u = require('../util')
var Shs = require('multiserver/plugins/shs')

exports.name = 'multiserver-shs'
Expand All @@ -9,10 +9,10 @@ function isFunction (f) { return 'function' === typeof f }
function isString (s) { return 'string' === typeof s }
function isObject (o) { return o && 'object' === typeof o && !Array.isArray(o) }

function toBuffer(base64) {
function toBuffer (base64) {
if(Buffer.isBuffer(base64)) return base64
var i = base64.indexOf('.')
return new Buffer(~i ? base64.substring(0, i) : base64, 'base64')
return Buffer.from(~i ? base64.substring(0, i) : base64, 'base64')
}

function toSodiumKeys (keys) {
Expand All @@ -34,7 +34,7 @@ exports.init = function (api, config, permissions) {

//set all timeouts to one setting, needed in the tests.
if(opts.timeout)
timeout_handshake = timeout_inactivity = opts.timeout
timeout_handshake = opts.timeout

var shsCap = (config.caps && config.caps.shs) || config.appKey
if(!shsCap) throw new Error('secret-stack/plugins/shs must have caps.shs configured')
Expand Down Expand Up @@ -67,12 +67,3 @@ exports.init = function (api, config, permissions) {
}
})
}









3 changes: 1 addition & 2 deletions test/local.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
var Illuminati = require('../')
var tape = require('tape')
var u = require('../util')

var seeds = require('./seeds')

var appkey = new Buffer(32)
var appkey = Buffer.alloc(32)

var create = Illuminati({
appKey: appkey,
Expand Down
2 changes: 1 addition & 1 deletion test/seeds.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//using vanity-ed25519 module.

function S (base64) {
return new Buffer(base64, 'base64')
return Buffer.from(base64, 'base64')
}

exports.alice = S('8C37zWNNunT5q2K8hS9WX6FitXQ9kfU6uZLJV+Swc/s=')
Expand Down
2 changes: 1 addition & 1 deletion util.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ exports.parseAddress = function (e) {
}

var fromId = exports.fromId = function (id) {
return new Buffer(id.substring(0, id.indexOf('.')), 'base64')
return Buffer.from(id.substring(0, id.indexOf('.')), 'base64')
}

exports.toId = function (pub) {
Expand Down

0 comments on commit 06305ad

Please sign in to comment.