Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
NodeJS SDK for the Dropbox API ( with saveurl endpoint ), while waiting to approve pull request on repository
A Node.JS convenience wrapper around the Dropbox API ( with saveurl endpoint ). Simplifies OAuth handshake and removes HTTP ceremony.
https://github.com/sintaxi/dbox
I always recommend you bundle your dependencies with your application. To do
this, create a package.json
file in the root of your project with the minimum
information...
{
"name": "yourapplication",
"version": "0.1.0",
"dependencies": {
"dbox2": "0.6.5"
}
}
Then run the following command using npm...
npm install
OR, if you just want to start playing with the library run...
npm install dbox2
dbox2
methods (where dbox is set from requiring the dbox library)...
app <-- creates application object
app
methods (where app is created from the above app
call)...
requesttoken <-- creates request token for getting request token and authorization url
accesstoken <-- creates access token for creating a client object
client <-- creates client object with access to users dropbox account
client
methods (where client is created from the above client
call)...
account <-- view account
mkdir <-- make directory
mv <-- move file or directory
cp <-- copy file or directory
rm <-- remove file or directory
put <-- upload file
saveurl <-- save a file from the specified URL into Dropbox
get <-- download file
metadata <-- get file or directory information
revisions <-- get revision history
restore <-- restore previous version
search <-- search directory
shares <-- create link to view file
media <-- create streamable link to file
thumbnails <-- get thumbnail of file
copyref <-- create copy reference to file
delta <-- get list of delta entries
stream <-- creates readable stream
readdir <-- recursively reads directory
Creating a functional dbox
client is a four step process.
app
using application credentials provided by dropboxvar dbox = require("dbox2")
var app = dbox.app({ "app_key": "umdez34678ck01fx", "app_secret": "tjm89017sci88o6" })
Authorization is a three step process.
a) Get a request token...
app.requesttoken(function(status, request_token){
console.log(request_token)
})
b) User must visit the url to grant authorization to the client...
https://www.dropbox.com/1/oauth/authorize?oauth_token=#{ request_token.oauth_token }
c) Generate our access token with the request token...
app.accesstoken(request_token, function(status, access_token){
console.log(access_token)
})
var client = app.client(access_token)
Now we have a client that gives us access to all the api functionality.
Returns account information.
client.account(function(status, reply){
console.log(reply)
})
output of reply
returns...
{
uid: 123456789,
display_name: 'Brock Whitten',
email: 'brock@sintaxi.com',
country: 'CA',
referral_link: 'https://www.dropbox.com/referrals/NTc0NzYwNDc5',
quota_info: {
shared: 1100727791,
quota: 2415919104,
normal: 226168599
}
}
Creates directory at specified location.
client.mkdir("foo", options, function(status, reply){
console.log(reply)
})
output of reply
returns...
{
"size": "0 bytes",
"rev": "1f477dd351f",
"thumb_exists": false,
"bytes": 0,
"modified": "Wed, 10 Aug 2011 18:21:30 +0000",
"path": "/foo",
"is_dir": true,
"icon": "folder",
"root": "sandbox",
"revision": 5023410
}
Moves file or directory to a new location.
client.mv("foo", "bar", function(status, reply){
console.log(reply)
})
output of reply
returns...
{
"size": "0 bytes",
"rev": "irt77dd3728",
"thumb_exists": false,
"bytes": 0,
"modified": "Wed, 10 Aug 2011 18:21:30 +0000",
"path": "/bar",
"is_dir": true,
"icon": "folder",
"root": "sandbox",
"revision": 5023410
}
Copies a file or directory to a new location.
client.cp("bar", "baz", function(status, reply){
console.log(reply)
})
{
"size": "0 bytes",
"rev": "irt77dd3728",
"thumb_exists": false,
"bytes": 0,
"modified": "Wed, 10 Aug 2011 18:21:30 +0000",
"path": "/baz",
"is_dir": true,
"icon": "folder",
"root": "sandbox",
"revision": 5023410
}
Removes a file or directory.
client.rm("README.txt", function(status, reply){
console.log(reply)
})
output of reply
returns...
{
"size": "0 bytes",
"is_deleted": true,
"bytes": 0,
"thumb_exists": false,
"rev": "1f33043551f",
"modified": "Wed, 10 Aug 2011 18:21:30 +0000",
"path": "/README.txt",
"is_dir": false,
"icon": "page_white_text",
"root": "sandbox",
"mime_type": "text/plain",
"revision": 492341
}
Creates or modifies a file with given data. data
may be a string or a buffer.
client.put("foo/hello.txt", "here is some text", function(status, reply){
console.log(reply)
})
output of reply
returns...
{
"size": "225.4KB",
"rev": "35e97029684fe",
"thumb_exists": false,
"bytes": 230783,
"modified": "Tue, 19 Jul 2011 21:55:38 +0000",
"path": "/foo/hello.txt",
"is_dir": false,
"icon": "page_white_text",
"root": "sandbox",
"mime_type": "text/plain",
"revision": 220823
}
Save a file from the specified URL into Dropbox. If the given path already exists, the file will be renamed to avoid the conflict (e.g. myfile (1).txt).
client.saveurl("myurlfile.txt", "https://raw.githubusercontent.com/silverbux/dbox/master/README.md", function(status, reply){
console.log(reply)
})
output of reply
returns...
{
"status": "PENDING",
"job": "ghs5y7p7iR8AAAAAAAAPvQ"
}
Pulls down file (available as a buffer) with its metadata.
client.get("foo/hello.txt", function(status, reply, metadata){
console.log(reply.toString(), metadata)
})
output of reply.toString()
returns...
here is some text
output of metadata
returns...
{
"revision": 11,
"rev": "b07a93bb3",
"thumb_exists": false,
"bytes": 17,
"modified": "Sat, 12 May 2012 19:31:08 +0000",
"client_mtime": "Sat, 12 May 2012 19:30:52 +0000",
"path": "/foo/hello.txt",
"is_dir": false,
"icon": "page_white_text",
"root": "app_folder",
"mime_type": "text/plain",
"size": "17 bytes"
}
Retrieves file or directory metadata.
// available options...
var options = {
file_limit : 10000, // optional
hash : ..., // optional
list : true, // optional
include_deleted : false, // optional
rev : 7, // optional
locale: : "en", // optional
root: : "sandbox" // optional
}
client.metadata("Getting_Started.pdf", options, function(status, reply){
console.log(reply)
})
output of reply
returns...
{
"size": "225.4KB",
"rev": "35e97029684fe",
"thumb_exists": false,
"bytes": 230783,
"modified": "Tue, 19 Jul 2011 21:55:38 +0000",
"path": "/Getting_Started.pdf",
"is_dir": false,
"icon": "page_white_acrobat",
"root": "sandbox",
"mime_type": "application/pdf",
"revision": 220823
}
Obtains metadata for the previous revisions of a file.
// available options...
var options = {
rev_limit : 10, // optional
locale: : "en" // optional
}
client.revisions("foo/hello.txt", options, function(status, reply){
console.log(reply)
})
output of reply
returns...
[
{
"is_deleted": true,
"revision": 4,
"rev": "40000000d",
"thumb_exists": false,
"bytes": 0,
"modified": "Wed, 20 Jul 2011 22:41:09 +0000",
"path": "foo/hello.txt",
"is_dir": false,
"icon": "page_white",
"root": "sandbox",
"mime_type": "text/plain",
"size": "0 bytes"
},
{
"revision": 1,
"rev": "10000000d",
"thumb_exists": false,
"bytes": 3,
"modified": "Wed, 20 Jul 2011 22:40:43 +0000",
"path": "foo/hello.txt",
"is_dir": false,
"icon": "page_white",
"root": "sandbox",
"mime_type": "text/plain",
"size": "3 bytes"
}
]
Restores a file path to a previous revision.
client.revisions("foo/hello.txt", 4, function(status, reply){
console.log(reply)
})
output of reply
returns...
{
"is_deleted": true,
"revision": 4,
"rev": "40000000d",
"thumb_exists": false,
"bytes": 0,
"modified": "Wed, 20 Jul 2011 22:41:09 +0000",
"path": "/foo/hello.txt",
"is_dir": false,
"icon": "page_white",
"root": "sandbox",
"mime_type": "text/plain",
"size": "0 bytes"
}
Returns metadata for all files and directories that match the search query.
var options = {
file_limit : 10000, // optional
include_deleted : false, // optional
locale: : "en" // optional
}
client.search("foo", "hello", options, function(status, reply){
console.log(reply)
})
output of reply
returns...
[
{
"size": "0 bytes",
"rev": "35c1f029684fe",
"thumb_exists": false,
"bytes": 0,
"modified": "Mon, 18 Jul 2011 20:13:43 +0000",
"path": "/foo/hello.txt",
"is_dir": false,
"icon": "page_white_text",
"root": "sandbox",
"mime_type": "text/plain",
"revision": 220191
}
]
Creates and/or returns a shareable link to a file or directory.
client.shares("foo/hello.txt", options, function(status, reply){
console.log(reply)
})
output of reply
returns...
{
"url": "http://db.tt/APqhX1",
"expires": "Sat, 17 Aug 2011 02:34:33 +0000"
}
Creates and/or returns a shareable link to a file or directory. This endpoint is similar to /shares but content is streamable.
client.media("foo/hello.txt", function(status, reply){
console.log(reply)
})
output of reply
returns...
{
"url": "http://www.dropbox.com/s/m/a2mbDa2",
"expires": "Thu, 16 Sep 2011 01:01:25 +0000"
}
Gets a thumbnail for an image.
client.thumbnails("foo/koala.jpg", function(status, reply, metadata){
console.log(metadata);
require('fs').writeFile('koala_small.jpg', reply, function () {
console.log('Thumbnail saved!');
});
})
output of reply
is a buffer which should be sent to a new image file.
output of metadata
returns...
{
"revision": 13,
"rev": "d07a93bb3",
"thumb_exists": true,
"bytes": 780831,
"modified": "Sat, 12 May 2012 19:48:59 +0000",
"client_mtime": "Tue, 14 Jul 2009 05:32:31 +0000",
"path": "/foo/koala.jpg",
"is_dir": false,
"icon": "page_white_picture",
"root": "app_folder",
"mime_type": "image/jpeg",
"size": "762.5 KB"
}
client.cpref("song.mp3", function(status, reply){
console.log(reply)
})
output of reply
returns...
{
expires: 'Thu, 03 Apr 2042 22:33:49 +0000',
copy_ref: 'ALGf72Jrc3A0ZTh5MzA4Mg'
}
client.delta(function(status, reply){
console.log(reply)
})
output of reply
returns...
{
reset: true,
cursor: 'AkMCE0f1CsMA7tobhXR1vwEZaM1KjFqTNjxgWITCks6oeJxjKBL2Z2Co0WOp_rSOgYHxJwMQAAAyKwSY',
has_more: false,
entries: [
[ '/foo', [Object] ],
[ '/bar', [Object] ]
]
}
Get an array of paths for all files and directories found in the given path. The method calls recursively to dropbox so it can take a long time to evaluate.
client.readdir('/', function(status, reply){
console.log(reply)
})
Output of readdir
returns...
['/','/foo','/bar']
Copyright 2011 Chloi Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
NodeJS SDK for the Dropbox API ( with saveurl endpoint ), while waiting to approve pull request on repository
We found that dbox2 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.