diff options
author | cel <cel@lOUVT+Phkvai9a/cCS/RKo+S9hnPAQdVixms/7ldpPA=.ed25519> | 2020-05-19 09:20:21 -0400 |
---|---|---|
committer | cel <cel@lOUVT+Phkvai9a/cCS/RKo+S9hnPAQdVixms/7ldpPA=.ed25519> | 2020-05-19 09:20:21 -0400 |
commit | e537f08964e2fcfe94f3777ef75c82f928b65121 (patch) | |
tree | b658a625e5fe474212e5ddc4de2b46a00b9112f2 | |
parent | de1eaa7c9d937a82f5330e3bf3955444411fd193 (diff) | |
download | patchfoo-e537f08964e2fcfe94f3777ef75c82f928b65121.tar.gz patchfoo-e537f08964e2fcfe94f3777ef75c82f928b65121.zip |
Avoide deprecated Buffer constructor
-rw-r--r-- | lib/app.js | 12 | ||||
-rw-r--r-- | lib/serve.js | 10 |
2 files changed, 11 insertions, 11 deletions
@@ -27,7 +27,7 @@ var Base64URL = require('base64-url') var ssbKeys = require('ssb-keys') var Url = require('url') -var zeros = new Buffer(24); zeros.fill(0) +var zeros = Buffer.alloc(24); zeros.fill(0) module.exports = App @@ -52,8 +52,8 @@ function App(sbot, config) { this.portRegexp = new RegExp(':' + this.ssbPort + '$') this.caps = config.caps || {} this.peerInviteCap = this.caps.peerInvite - || new Buffer('HT0wIYuk3OWc2FtaCfHNnakV68jSGRrjRMP9Kos7IQc=', 'base64') // sha256('peer-invites') - this.devPeerInviteCap = new Buffer('pmr+IzM+4VAZgi5H5bOopXkwnzqrNussS7DtAJsfbf0=', 'base64') // sha256('peer-invites:DEVELOPMENT') + || Buffer.from('HT0wIYuk3OWc2FtaCfHNnakV68jSGRrjRMP9Kos7IQc=', 'base64') // sha256('peer-invites') + this.devPeerInviteCap = Buffer.from('pmr+IzM+4VAZgi5H5bOopXkwnzqrNussS7DtAJsfbf0=', 'base64') // sha256('peer-invites:DEVELOPMENT') this.voteBranches = !!config.voteBranches this.copyableIds = config.copyableIds == null ? true : config.copyableIds @@ -241,8 +241,8 @@ App.prototype.unboxContentWithKey = function (content, key, cb) { if (!key) return this.unboxContent(content, cb) var data try { - var contentBuf = new Buffer(content.replace(/\.box.*$/, ''), 'base64') - var keyBuf = new Buffer(key, 'base64') + var contentBuf = Buffer.from(content.replace(/\.box.*$/, ''), 'base64') + var keyBuf = Buffer.from(key, 'base64') data = PrivateBox.multibox_open_body(contentBuf, keyBuf) if (!data) return cb(new Error('failed to decrypt')) data = JSON.parse(data.toString('utf8')) @@ -476,7 +476,7 @@ App.prototype.getBlob = function (id, key) { } } if (!key) return this.sbot.blobs.get(id) - if (typeof key === 'string') key = new Buffer(key, 'base64') + if (typeof key === 'string') key = Buffer.from(key, 'base64') return pull( this.sbot.blobs.get(id), BoxStream.createUnboxStream(key, zeros) diff --git a/lib/serve.js b/lib/serve.js index 749e075..d292158 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -2090,7 +2090,7 @@ Serve.prototype.blob = function (id, path) { } if (unbox) { try { - key = new Buffer(unbox, 'base64') + key = Buffer.from(unbox, 'base64') } catch(err) { return self.respond(400, err.message) } @@ -2147,14 +2147,14 @@ Serve.prototype.blob = function (id, path) { self.res.writeHead(206) wroteHeaders = true }), - pull.map(Buffer), + pull.map(Buffer.from), self.respondSink() ) } else { pull( self.app.getBlob(id, key), - pull.map(Buffer), + pull.map(Buffer.from), ident(gotType), self.respondSink() ) @@ -2197,7 +2197,7 @@ Serve.prototype.image = function (path) { } if (unbox) { try { - key = new Buffer(unbox, 'base64') + key = Buffer.from(unbox, 'base64') } catch(err) { return self.respond(400, err.message) } @@ -2217,7 +2217,7 @@ Serve.prototype.image = function (path) { pull( self.app.getBlob(id, key), - pull.map(Buffer), + pull.map(Buffer.from), ident(heresTheType), pull.collect(onFullBuffer) ) |