You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

dropbox-v2-api

Package Overview
Dependencies
Maintainers
1
Versions
107
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dropbox-v2-api - npm Package Compare versions

Comparing version

to
2.5.10

dist/cjs/index-cjs.d.ts

7

dist/cjs/dropbox-api.d.ts

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

declare namespace _default {
function authenticate(config: any): (userOpt: any, cb: any) => any;
}
export default _default;
export default function init(apiDesc: any): {
authenticate: (config: any) => (userOpt: any, cb: any) => any;
};

@@ -10,10 +10,4 @@ "use strict";

const promises_1 = require("fs/promises");
let apiJSON;
try {
apiJSON = JSON.parse(await (0, promises_1.readFile)(new URL('./api.json', global.import.meta.url)));
}
catch (err) {
apiJSON = JSON.parse(require('fs').readFileSync(require('path').join(__dirname, 'api.json')).toString());
}
console.log(apiJSON);
const path_1 = require("path");
const url_1 = require("url");
const RPC_RESOURCE_CATEGORY = 'rpc';

@@ -65,3 +59,2 @@ const UPLOAD_RESOURCE_CATEGORY = 'upload';

];
const resourcesDescriptionList = loadResourcesDescriptionList();
//------------------------------------------------------------------------------------

@@ -150,68 +143,72 @@ function generateResourcesHandlingFunctions(resourcesDescriptionList, config) {

}
exports.default = {
authenticate: function (config) {
const resourceHandlingFunctions = generateResourcesHandlingFunctions(resourcesDescriptionList, config);
const clientSession = function (userOpt, cb) {
const opt = {
parameters: userOpt.parameters || {},
resource: userOpt.resource || '',
readStream: userOpt.readStream
function init(apiDesc) {
let resourcesDescriptionList = loadResourcesDescriptionList(apiDesc);
return {
authenticate: function (config) {
const resourceHandlingFunctions = generateResourcesHandlingFunctions(resourcesDescriptionList, config);
const clientSession = function (userOpt, cb) {
const opt = {
parameters: userOpt.parameters || {},
resource: userOpt.resource || '',
readStream: userOpt.readStream
};
const resourceName = opt.resource;
if (resourceHandlingFunctions[resourceName]) {
return resourceHandlingFunctions[resourceName](opt, cb);
}
else {
throwError(`resource "${opt.resource}" is invalid.`);
}
};
const resourceName = opt.resource;
if (resourceHandlingFunctions[resourceName]) {
return resourceHandlingFunctions[resourceName](opt, cb);
}
else {
throwError(`resource "${opt.resource}" is invalid.`);
}
};
Object.assign(clientSession, {
generateAuthUrl: (input) => {
return `${OAUTH2_AUTHORIZE}?client_id=${config.client_id}&response_type=code${config.token_access_type ? `&token_access_type=${config.token_access_type}` : ''}&redirect_uri=${config.redirect_uri}${config.state ? `&state=${config.state}` : ''}`;
},
getToken: (code, userCb) => {
(0, request_1.default)({
method: 'POST',
uri: OAUTH2_TOKEN,
followRedirect: true,
json: true,
form: {
code: code,
client_id: config.client_id,
client_secret: config.client_secret,
grant_type: 'authorization_code',
redirect_uri: config.redirect_uri
}
}, (err, resp, body) => {
if (err || body.error) {
userCb(body.error || {});
}
config.token = body.access_token;
userCb(false, body);
});
},
refreshToken: (refreshToken, userCb) => {
(0, request_1.default)({
method: 'POST',
uri: OAUTH2_TOKEN,
followRedirect: true,
json: true,
form: {
refresh_token: refreshToken,
client_id: config.client_id,
client_secret: config.client_secret,
grant_type: 'refresh_token'
}
}, (err, resp, body) => {
if (err || body.error) {
userCb(body.error || {});
}
config.token = body.access_token;
userCb(false, body);
});
}
});
return clientSession;
}
};
Object.assign(clientSession, {
generateAuthUrl: (input) => {
return `${OAUTH2_AUTHORIZE}?client_id=${config.client_id}&response_type=code${config.token_access_type ? `&token_access_type=${config.token_access_type}` : ''}&redirect_uri=${config.redirect_uri}${config.state ? `&state=${config.state}` : ''}`;
},
getToken: (code, userCb) => {
(0, request_1.default)({
method: 'POST',
uri: OAUTH2_TOKEN,
followRedirect: true,
json: true,
form: {
code: code,
client_id: config.client_id,
client_secret: config.client_secret,
grant_type: 'authorization_code',
redirect_uri: config.redirect_uri
}
}, (err, resp, body) => {
if (err || body.error) {
userCb(body.error || {});
}
config.token = body.access_token;
userCb(false, body);
});
},
refreshToken: (refreshToken, userCb) => {
(0, request_1.default)({
method: 'POST',
uri: OAUTH2_TOKEN,
followRedirect: true,
json: true,
form: {
refresh_token: refreshToken,
client_id: config.client_id,
client_secret: config.client_secret,
grant_type: 'refresh_token'
}
}, (err, resp, body) => {
if (err || body.error) {
userCb(body.error || {});
}
config.token = body.access_token;
userCb(false, body);
});
}
});
return clientSession;
}
};
}
exports.default = init;
function throwError(content) {

@@ -228,3 +225,3 @@ throw content;

}
function loadResourcesDescriptionList() {
function loadResourcesDescriptionList(apiJSON) {
return (0, compress_json_1.decompress)(apiJSON);

@@ -231,0 +228,0 @@ }

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

declare namespace _default {
function authenticate(config: any): (userOpt: any, cb: any) => any;
}
export default _default;
export default function init(apiDesc: any): {
authenticate: (config: any) => (userOpt: any, cb: any) => any;
};

@@ -5,10 +5,4 @@ import request from 'request';

import { readFile } from 'fs/promises';
let apiJSON;
try {
apiJSON = JSON.parse(await readFile(new URL('./api.json', global.import.meta.url)));
}
catch (err) {
apiJSON = JSON.parse(require('fs').readFileSync(require('path').join(__dirname, 'api.json')).toString());
}
console.log(apiJSON);
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';
const RPC_RESOURCE_CATEGORY = 'rpc';

@@ -60,3 +54,2 @@ const UPLOAD_RESOURCE_CATEGORY = 'upload';

];
const resourcesDescriptionList = loadResourcesDescriptionList();
//------------------------------------------------------------------------------------

@@ -145,68 +138,71 @@ function generateResourcesHandlingFunctions(resourcesDescriptionList, config) {

}
export default {
authenticate: function (config) {
const resourceHandlingFunctions = generateResourcesHandlingFunctions(resourcesDescriptionList, config);
const clientSession = function (userOpt, cb) {
const opt = {
parameters: userOpt.parameters || {},
resource: userOpt.resource || '',
readStream: userOpt.readStream
export default function init(apiDesc) {
let resourcesDescriptionList = loadResourcesDescriptionList(apiDesc);
return {
authenticate: function (config) {
const resourceHandlingFunctions = generateResourcesHandlingFunctions(resourcesDescriptionList, config);
const clientSession = function (userOpt, cb) {
const opt = {
parameters: userOpt.parameters || {},
resource: userOpt.resource || '',
readStream: userOpt.readStream
};
const resourceName = opt.resource;
if (resourceHandlingFunctions[resourceName]) {
return resourceHandlingFunctions[resourceName](opt, cb);
}
else {
throwError(`resource "${opt.resource}" is invalid.`);
}
};
const resourceName = opt.resource;
if (resourceHandlingFunctions[resourceName]) {
return resourceHandlingFunctions[resourceName](opt, cb);
}
else {
throwError(`resource "${opt.resource}" is invalid.`);
}
};
Object.assign(clientSession, {
generateAuthUrl: (input) => {
return `${OAUTH2_AUTHORIZE}?client_id=${config.client_id}&response_type=code${config.token_access_type ? `&token_access_type=${config.token_access_type}` : ''}&redirect_uri=${config.redirect_uri}${config.state ? `&state=${config.state}` : ''}`;
},
getToken: (code, userCb) => {
request({
method: 'POST',
uri: OAUTH2_TOKEN,
followRedirect: true,
json: true,
form: {
code: code,
client_id: config.client_id,
client_secret: config.client_secret,
grant_type: 'authorization_code',
redirect_uri: config.redirect_uri
}
}, (err, resp, body) => {
if (err || body.error) {
userCb(body.error || {});
}
config.token = body.access_token;
userCb(false, body);
});
},
refreshToken: (refreshToken, userCb) => {
request({
method: 'POST',
uri: OAUTH2_TOKEN,
followRedirect: true,
json: true,
form: {
refresh_token: refreshToken,
client_id: config.client_id,
client_secret: config.client_secret,
grant_type: 'refresh_token'
}
}, (err, resp, body) => {
if (err || body.error) {
userCb(body.error || {});
}
config.token = body.access_token;
userCb(false, body);
});
}
});
return clientSession;
}
};
Object.assign(clientSession, {
generateAuthUrl: (input) => {
return `${OAUTH2_AUTHORIZE}?client_id=${config.client_id}&response_type=code${config.token_access_type ? `&token_access_type=${config.token_access_type}` : ''}&redirect_uri=${config.redirect_uri}${config.state ? `&state=${config.state}` : ''}`;
},
getToken: (code, userCb) => {
request({
method: 'POST',
uri: OAUTH2_TOKEN,
followRedirect: true,
json: true,
form: {
code: code,
client_id: config.client_id,
client_secret: config.client_secret,
grant_type: 'authorization_code',
redirect_uri: config.redirect_uri
}
}, (err, resp, body) => {
if (err || body.error) {
userCb(body.error || {});
}
config.token = body.access_token;
userCb(false, body);
});
},
refreshToken: (refreshToken, userCb) => {
request({
method: 'POST',
uri: OAUTH2_TOKEN,
followRedirect: true,
json: true,
form: {
refresh_token: refreshToken,
client_id: config.client_id,
client_secret: config.client_secret,
grant_type: 'refresh_token'
}
}, (err, resp, body) => {
if (err || body.error) {
userCb(body.error || {});
}
config.token = body.access_token;
userCb(false, body);
});
}
});
return clientSession;
}
};
}
function throwError(content) {

@@ -223,3 +219,3 @@ throw content;

}
function loadResourcesDescriptionList() {
function loadResourcesDescriptionList(apiJSON) {
return decompress(apiJSON);

@@ -226,0 +222,0 @@ }

@@ -1,4 +0,5 @@

// require('./src/generate-api-description.js')();
const {decompress} = require("compress-json");
const apiJSON = require('./src/api.json');
console.log(decompress(apiJSON));
const generateApiDescription2 = require('./src/generate-api-description.js');
generateApiDescription2()
// const {decompress} = require("compress-json");
// const apiJSON = require('./src/api.json');
// console.log(decompress(apiJSON));
{
"name": "dropbox-v2-api",
"version": "2.5.10-next.3",
"version": "2.5.10",
"description": "NodeJS Dropbox v2 API wrapper",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -10,3 +10,3 @@ # dropbox-v2-api

[api.json]: <https://github.com/adasq/dropbox-v2-api/blob/master/dist/api.json>
[api.json]: <https://github.com/adasq/dropbox-v2-api/blob/master/src/api.json>
## Why this package?

@@ -13,0 +13,0 @@

@@ -7,6 +7,6 @@ const should = require('should');

const expect = require('expect.js');
const {decompress} = require("compress-json");
const generate = require('../../src/generate-api-description.js');
const API_DESC_FILE_PATH = path.join(__dirname, '../../dist/api.json');
const API_DESC_FILE_PATH = path.join(__dirname, '../../src/api.json');
describe('Docs change detection', function() {

@@ -23,10 +23,16 @@ this.timeout(16000);

it('contains equal content', function (done) {
const currentDocsDescription = normalizeString(fs.readFileSync(API_DESC_FILE_PATH).toString());
generate((err, retrievedDocsDescription) => {
expect(err).to.be(null);
try {
const currentDocsDescription = normalizeString(JSON.stringify(decompress(JSON.parse(fs.readFileSync(API_DESC_FILE_PATH).toString())), null, '\t'))
generate((err, retrievedDocsDescription) => {
console.log(err)
expect(err).to.be(null);
retrievedDocsDescription = normalizeString(JSON.stringify(retrievedDocsDescription, null, '\t'));
expect(md5(retrievedDocsDescription)).to.be(md5(currentDocsDescription));
done();
});
retrievedDocsDescription = normalizeString(JSON.stringify(retrievedDocsDescription, null, '\t'));
expect(md5(retrievedDocsDescription)).to.be(md5(currentDocsDescription));
done();
});
} catch(err) {
console.log(err);
throw err;
}
});

@@ -33,0 +39,0 @@ function normalizeString(str) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display