Socket
Socket
Sign inDemoInstall

node-dropbox

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-dropbox - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

10

CHANGELOG.txt

@@ -11,10 +11,2 @@ VERSION 0.1.0:

- Renamed api.fileops.removeFolder to just remove.
- Updated README
VERSION 0.1.3:
- Added getMetadata() method (thanks @elarnellis)
VERSION 0.1.4:
- Added getFile() method for retreiving a files contents (thanks @elarnellis)
- Updated README

4

Gruntfile.js

@@ -11,3 +11,3 @@ module.exports = function(grunt) {

options: {
reporter: 'nyan'
reporter: 'spec'
},

@@ -25,2 +25,2 @@ src: ['test/test.js']

}
}

@@ -11,3 +11,3 @@ var request = require('request');

account: '/account/info',
metadata: '/metadata/auto',
metadata: '/metadata',
fileops: {

@@ -20,3 +20,3 @@ createFolder: '/fileops/create_folder',

putFiles: '/files_put',
getFiles: '/files/auto'
getFiles: '/files'
};

@@ -93,7 +93,9 @@

headers: {
"Content-Length": body.length,
"Content-Length": getByteLength(body),
"Authorization": "Bearer " + access_token
},
json: true,
body: body
}
request(options, function(err, res, body) {

@@ -117,3 +119,3 @@ cb(err, res, body);

getMetadata: function(path, cb) {
options = optionsBuilder(apiRoot + api.metadata + path, access_token);
options = optionsBuilder(apiRoot + api.metadata + "/auto/" + path, access_token);
request.get(options, function(err, res, body) {

@@ -128,3 +130,3 @@ cb(err, res, body);

getFile: function(path, cb) {
options = optionsBuilder(apiContentRoot + api.getFiles + path, access_token);
options = optionsBuilder(apiContentRoot + api.getFiles + '/auto' + path, access_token);

@@ -134,3 +136,14 @@ request(options, function(err, res, body) {

})
}
},
/**
* Gets changes to files and folders in a user's Dropbox.
*/
getDelta: function(cursor, path, cb) {
options = postBuilder(apiRoot + '/delta',
{cursor:cursor, path_prefix:path}, access_token);
request.post(options, function(err, res, body) {
cb(err, res, body);
})
},
}

@@ -143,2 +156,3 @@

url: url,
json: true,
headers: {

@@ -153,2 +167,3 @@ "Authorization": "Bearer " + access_token

url: url,
json: true,
headers: {

@@ -159,2 +174,19 @@ "Authorization": "Bearer " + access_token

}
}
}
function getByteLength(normal_val) {
// Force string type
normal_val = String(normal_val);
var byteLen = 0;
for (var i = 0; i < normal_val.length; i++) {
var c = normal_val.charCodeAt(i);
byteLen += c < (1 << 7) ? 1 :
c < (1 << 11) ? 2 :
c < (1 << 16) ? 3 :
c < (1 << 21) ? 4 :
c < (1 << 26) ? 5 :
c < (1 << 31) ? 6 : Number.NaN;
}
return byteLen;
}
{
"name": "node-dropbox",
"description": "A simple Dropbox API client for node.js",
"version": "0.1.4",
"version": "0.1.5",
"author": "Joshua Kidd <kidd.josh.343@gmail.com>",

@@ -13,4 +13,4 @@ "keywords": [

"repository": {
"type": "git",
"url": "https://github.com/g33kidd/node-dropbox"
"type": "git",
"url": "https://github.com/g33kidd/node-dropbox"
},

@@ -17,0 +17,0 @@ "dependencies": {

@@ -17,3 +17,3 @@ # Node Dropbox

var node_dropbox = require('node_dropbox');
var node_dropbox = require('node-dropbox');
node_dropbox.Authenticate('key', 'secret', 'redirect_url', function(err, url){

@@ -66,2 +66,3 @@ // redirect user to the url.

api.getFile(path, callback) // Downloads a file.
api.getDelta(cursor, path, callback) // Gets changes to files and folders in a user's Dropbox.

@@ -68,0 +69,0 @@ // Each callback will return the error message, response, and body(json data).

@@ -6,2 +6,2 @@ {

"redirect_url": "http://localhost:3000/dropbox_callback"
}
}

@@ -1,3 +0,3 @@

var fs = require("fs")
var should = require("should")
var fs = require("fs");
var should = require("should");
var node_dropbox = require('../');

@@ -10,4 +10,4 @@

before(function(done) {
api = node_dropbox.api(config.access_token)
done()
api = node_dropbox.api(config.access_token);
done();
})

@@ -18,7 +18,7 @@

it("should create valid auth url", function(done) {
link = "https://www.dropbox.com/1/oauth2/authorize?client_id=" + config.app_key + "&response_type=code&redirect_uri=" + config.redirect_url;
link = "https://www.dropbox.com/1/oauth2/authorize?client_id=" + config.app_key + "&response_type=token&redirect_uri=" + config.redirect_url;
node_dropbox.Authenticate(config.app_key, config.app_secret, config.redirect_url, function(err, url) {
url.should.eql(link)
err.should.eql("")
done()
url.should.eql(link);
err.should.eql("");
done();
})

@@ -36,64 +36,75 @@ })

it("should get account object", function(done) {
api.account(function(err, res, body) {
var json = JSON.parse(body);
res.statusCode.should.eql(200)
json.should.have.property("display_name")
json.should.have.property("email")
done()
describe("#API", function() {
this.timeout(15000);
it("should get account object", function(done) {
api.account(function(err, res, body) {
res.statusCode.should.eql(200);
body.should.have.property("display_name");
body.should.have.property("email");
done();
})
})
})
it("should create a directory", function(done) {
api.createDir("myfirstdir", function(err, res, body) {
var json = JSON.parse(body);
res.statusCode.should.eql(200)
json.should.have.property("path", "/myfirstdir")
done()
it("should create a directory", function(done) {
api.createDir("myfirstdir", function(err, res, body) {
res.statusCode.should.eql(200);
body.should.have.property("path", "/myfirstdir");
done();
})
})
})
it("should remove a directory", function(done) {
api.removeDir("myfirstdir", function(err, res, body) {
var json = JSON.parse(body);
res.statusCode.should.eql(200)
json.should.have.property("path", "/myfirstdir")
done()
it("should get metadata of directory", function(done) {
api.getMetadata("myfirstdir", function(err, res, body) {
res.statusCode.should.eql(200);
body.should.have.property("is_dir", true);
done();
})
})
})
it("should create a file", function(done) {
api.createFile("test_file.txt", "Test Content", function(err, res, body) {
var json = JSON.parse(body);
res.statusCode.should.eql(200)
json.should.have.property("path", "/test_file.txt")
done()
it("should remove a directory", function(done) {
api.removeDir("myfirstdir", function(err, res, body) {
res.statusCode.should.eql(200);
body.should.have.property("path", "/myfirstdir");
done();
})
})
})
it("should move a file", function(done) {
api.moveSomething("test_file.txt", "renamed_testfile.txt", function(err, res, body) {
var json = JSON.parse(body);
res.statusCode.should.eql(200)
json.should.have.property("path", "/renamed_testfile.txt")
done()
it("should create a file", function(done) {
api.createFile("test_file.txt", "Test Content", function(err, res, body) {
res.statusCode.should.eql(200);
body.should.have.property("path", "/test_file.txt");
done();
})
})
})
it("should remove a file", function(done) {
api.removeFile("renamed_testfile.txt", function(err, res, body) {
var json = JSON.parse(body);
res.statusCode.should.eql(200)
json.should.have.property("path", "/renamed_testfile.txt")
json.should.have.property("is_deleted", true)
done()
it("should get metadata of file", function(done) {
api.getMetadata("test_file.txt", function(err, res, body) {
res.statusCode.should.eql(200);
body.should.have.property("is_dir", false);
done();
})
})
})
it.skip("should get metadata of file", function(done) {
})
it("should move a file", function(done) {
api.moveSomething("test_file.txt", "renamed_testfile.txt", function(err, res, body) {
res.statusCode.should.eql(200);
body.should.have.property("path", "/renamed_testfile.txt");
done();
})
})
it.skip("should get delta of file", function(done) {
it("should remove a file", function(done) {
api.removeFile("renamed_testfile.txt", function(err, res, body) {
res.statusCode.should.eql(200);
body.should.have.property("path", "/renamed_testfile.txt");
body.should.have.property("is_deleted", true);
done();
})
})
it.skip("should get delta of file", function(done) {})
})
});
});
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