Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ac-backblaze-uploader

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ac-backblaze-uploader - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

11

CHANGELOG.md

@@ -0,1 +1,12 @@

<a name="1.1.0"></a>
# [1.1.0](https://github.com/mmpro/ac-backblaze-uploader/compare/v1.0.1...v1.1.0) (2019-09-21 06:30)
### Features
* **Uploader:** Add encryption | MP ([daa1c7b](https://github.com/mmpro/ac-backblaze-uploader/commit/daa1c7b))
You can now encrypt files during upload
<a name="1.0.1"></a>

@@ -2,0 +13,0 @@ ## [1.0.1](https://github.com/mmpro/ac-backblaze-uploader/compare/v1.0.0...v1.0.1) (2019-09-20 14:03)

42

index.js

@@ -6,2 +6,3 @@ const _ = require('lodash')

const axios = require('axios')
const crypto = require('crypto');

@@ -16,2 +17,3 @@ const acb2 = function() {

b2Auth.bucketId = _.get(params, 'bucketId')
b2Auth.encryption = _.get(params, 'encryption')
}

@@ -22,5 +24,9 @@

const fileName = _.get(params, 'fileName')
const expectedFileSize = _.get(params, 'expectedFileSize')
const bucketId = _.get(b2Auth, 'bucketId')
const b2 = new B2(b2Auth)
const b2 = new B2({
applicationKeyId: b2Auth.applicationKeyId,
applicationKey: b2Auth.applicationKey
})
await b2.authorize()

@@ -56,4 +62,17 @@

let authToken = response.data.authorizationToken;
axios({
method: 'get',
url,
responseType: 'arraybuffer'
})
.then(response => {
let uploadData = response.data
if (_.get(b2Auth, 'encryption.enabled') && _.get(b2Auth, 'encryption.password')) {
const algorithm = _.get(b2Auth, 'encryption.algorithm', 'aes256')
const password = _.get(b2Auth, 'encryption.password')
const cipher = crypto.createCipher(algorithm, password)
uploadData = Buffer.concat([new Buffer(cipher.update(uploadData), 'binary'), new Buffer(cipher.final('binary'), 'binary')])
}
axios.get(url).then(response => {
b2.uploadFile({

@@ -65,5 +84,10 @@ uploadUrl,

mime: contentType,
data: response.data
data: uploadData
})
.then(done)
.then(response => {
if (!_.get(b2Auth, 'encryption.enabled') && _.get(response, 'data.contentLength') !== expectedFileSize) {
return done({ message: 'fileSizeMismatch', status: 400, additionaInfo: { fileSize: _.get(response, 'data.contentLength'), expectedFileSize } })
}
return done(null, response.data)
})
.catch(done)

@@ -104,2 +128,10 @@ })

rangeStart += res.data.length
let uploadData = res.data
if (_.get(b2Auth, 'encryption.enabled') && _.get(b2Auth, 'encryption.password')) {
const algorithm = _.get(b2Auth, 'encryption.algorithm', 'aes256')
const password = _.get(b2Auth, 'encryption.password')
const cipher = crypto.createCipher(algorithm, password)
uploadData = Buffer.concat([new Buffer(cipher.update(uploadData), 'binary'), new Buffer(cipher.final('binary'), 'binary')])
}

@@ -116,3 +148,3 @@ // upload that part

uploadAuthToken: authToken,
data: res.data
data: uploadData
})

@@ -119,0 +151,0 @@ .then(part => {

2

package.json

@@ -6,3 +6,3 @@ {

"repository": "mmpro/ac-backblaze-uploader",
"version": "1.0.1",
"version": "1.1.0",
"dependencies": {

@@ -9,0 +9,0 @@ "async": "^3.1.0",

@@ -12,3 +12,8 @@ # AC Backblaze Uploader

applicationKey: 'yyyy',
bucketId: 'zzz'
bucketId: 'zzz',
encryption: {
enabled: true,
password: 'very-good-password',
algorithm: 'aes256' // default
}
}

@@ -15,0 +20,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc