
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
dropbox-v2-api-bendtech
Advanced tools
Dropbox API v2 wrapper for nodejs.
The dropbox-v2-api
package interface is generated automatically - it's based on Dropbox endpoints description JSON file which is a mirror of Dropbox API HTTP endpoints description, retrived from official documentaion webpage.
$ npm i -s dropbox-v2-api
const dropboxV2Api = require('dropbox-v2-api');
// create session ref:
const dropbox = dropboxV2Api.authenticate({
token: 'your token'
});
// use session ref to call API, i.e.:
dropbox({
resource: 'users/get_account',
parameters: {
'account_id': 'dbid:AAH4f99T0taONIb-OurWxbNQ6ywGRopQngc'
}
}, (err, result, response) => {
if (err) { return console.log(err); }
console.log(result);
});
//set credentials
const dropbox = dropboxV2Api.authenticate({
client_id: 'APP_KEY',
client_secret: 'APP_SECRET',
redirect_uri: 'REDIRECT_URI'
});
//generate and visit authorization sevice
const authUrl = dropbox.generateAuthUrl();
//after redirection, you should receive code
dropbox.getToken(code, (err, result, response) => {
//you are authorized now!
});
dropbox({
resource: (string),
parameters: (object?),
readStream: (readable stream object?)
}, (err, result, response) => {
if (err) { return console.log('err:', err); }
console.log(result);
console.log(response.headers);
});
resource
(string) represent API target. It contains Dropbox's namespace and method name. eg. 'users/get_account'
, 'users/get_space_usage'
, 'files/upload'
, 'files/list_folder/longpoll'
, 'sharing/share_folder'
more at official documentationparameters
(object?) optional parameters, depends on resource
fieldreadStream
(readable stream?) Upload-type requests might contains readStream
field, which is readable streamFor Download-type requests, the function dropbox
returns readable stream.
Upload-type requests might contains readStream
field, which is readable stream
dropbox({
resource: 'files/upload',
parameters: {
path: '/dropbox/path/to/file.js'
},
readStream: fs.createReadStream('path/to/file.js')
}, (err, result, response) => {
//upload completed
});
or, using streams:
const dropboxUploadStream = dropbox({
resource: 'files/upload',
parameters: {
path: '/dropbox/path/to/file.js'
}
}, (err, result, response) => {
//upload completed
});
fs.createReadStream('path/to/file.js').pipe(dropboxUploadStream);
Download-type requests return writableStream
dropbox({
resource: 'files/download',
parameters: {
path: '/dropbox/image.jpg'
}
}, (err, result, response) => {
//download completed
})
.pipe(fs.createWriteStream('./image.jpg'));
You can easely use streams:
const downloadStream = dropbox({
resource: 'files/download',
parameters: { path: '/source/file/path' }
});
const uploadStream = dropbox({
resource: 'files/upload',
parameters: { path: '/target/file/path' }
}, (err, result, response) => {
//upload finished
});
downloadStream.pipe(uploadStream);
dropbox({
resource: 'users/get_current_account'
}, (err, result, response) => {
if (err) { return console.log('err:', err); }
console.log(result);
});
dropbox({
resource: 'files/get_metadata',
parameters: {
path: '/dropbox/path/to/file.js',
include_media_info: false
}
}, (err, result, response) => {
if(err){ return console.log('err:', err); }
console.log(result);
});
const CHUNK_LENGTH = 100;
//create read streams, which generates set of 100 (CHUNK_LENGTH) characters of values: 1 and 2
const firstUploadChunkStream = () => utils.createMockedReadStream('1', CHUNK_LENGTH);
const secondUploadChunkStream = () => utils.createMockedReadStream('2', CHUNK_LENGTH);
sessionStart((sessionId) => {
sessionAppend(sessionId, () => {
sessionFinish(sessionId);
});
});
function sessionStart(cb) {
dropbox({
resource: 'files/upload_session/start',
parameters: {
close: false
},
readStream: firstUploadChunkStream()
}, (err, result, response) => {
if (err) { return console.log('sessionStart error: ', err) }
console.log('sessionStart result:', result);
cb(result.session_id);
});
}
function sessionAppend(sessionId, cb) {
dropbox({
resource: 'files/upload_session/append_v2',
parameters: {
cursor: {
session_id: sessionId,
offset: CHUNK_LENGTH
},
close: false,
},
readStream: secondUploadChunkStream()
}, (err, result, response) => {
if(err){ return console.log('sessionAppend error: ', err) }
console.log('sessionAppend result:', result);
cb();
});
}
function sessionFinish(sessionId) {
dropbox({
resource: 'files/upload_session/finish',
parameters: {
cursor: {
session_id: sessionId,
offset: CHUNK_LENGTH * 2
},
commit: {
path: "/result.txt",
mode: "add",
autorename: true,
mute: false
}
}
}, (err, result, response) => {
if (err) { return console.log('sessionFinish error: ', err) }
console.log('sessionFinish result:', result);
});
}
FAQs
NodeJS Dropbox v2 API wrapper specifically for Bendtech
The npm package dropbox-v2-api-bendtech receives a total of 0 weekly downloads. As such, dropbox-v2-api-bendtech popularity was classified as not popular.
We found that dropbox-v2-api-bendtech demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.