Socket
Socket
Sign inDemoInstall

documentdb

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

documentdb - npm Package Compare versions

Comparing version 1.7.0 to 1.8.0

lib/endpointDiscoveryRetryPolicy.js

4

changelog.md

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

## Changes in 1.8.0 : ##
- Added the support for geo-replicated database accounts.
## Changes in 1.7.0 : ##

@@ -2,0 +6,0 @@

27

lib/auth.js

@@ -58,11 +58,19 @@ /*

getAuthorizationTokenUsingResourceTokens: function (resourceTokens, path, resourceId) {
if (resourceTokens[resourceId]) {
return resourceTokens[resourceId];
} else {
var pathParts = path.split("/");
var resourceTypes = ["dbs", "colls", "docs", "sprocs", "udfs", "triggers", "users", "permissions", "attachments", "media", "conflicts", "offers"];
for (var i = pathParts.length - 1; i >= 0; i--) {
if (resourceTypes.indexOf(pathParts[i]) === -1) {
if (resourceTokens[pathParts[i]]) {
return resourceTokens[pathParts[i]];
if (resourceTokens && Object.keys(resourceTokens).length > 0) {
// For database account access(through getDatabaseAccount API), path and resourceId are "",
// so in this case we return the first token to be used for creating the auth header as the service will accept any token in this case
if (!path && !resourceId) {
return resourceTokens[Object.keys(resourceTokens)[0]];
}
if (resourceTokens[resourceId]) {
return resourceTokens[resourceId];
} else {
var pathParts = path.split("/");
var resourceTypes = ["dbs", "colls", "docs", "sprocs", "udfs", "triggers", "users", "permissions", "attachments", "media", "conflicts", "offers"];
// Get the last resource id from the path and get it's token from resourceTokens
for (var i = pathParts.length - 1; i >= 0; i--) {
if (resourceTypes.indexOf(pathParts[i]) === -1) {
if (resourceTokens[pathParts[i]]) {
return resourceTokens[pathParts[i]];
}
}

@@ -72,2 +80,3 @@ }

}
return null;
}

@@ -74,0 +83,0 @@ };

@@ -149,9 +149,18 @@ /*

// Upsert header
IsUpsert: "x-ms-documentdb-is-upsert"
IsUpsert: "x-ms-documentdb-is-upsert",
// Sub status of the error
SubStatus: "x-ms-substatus"
},
CurrentVersion: "2015-12-16",
// GlobalDB related constants
WritableLocations: 'writableLocations',
ReadableLocations: 'readableLocations',
Name: 'name',
DatabaseAccountEndpoint: 'databaseAccountEndpoint',
UserAgent: "documentdb-nodejs-sdk-1.7.0",
CurrentVersion: "2016-05-30",
UserAgent: "documentdb-nodejs-sdk-1.8.0",
DefaultPrecisions: {

@@ -158,0 +167,0 @@ DefaultNumberHashPrecision: 3,

@@ -35,3 +35,3 @@ /*

* @property {string} DatabasesLink - The self-link for Databases in the databaseAccount.
* @property {string} MediaLink - The self-link for Media in the databaseAccount.
* @property {string} MediaLink - The self-link for Media in the databaseAccount.
* @property {number} MaxMediaStorageUsageInMB - Attachment content (media) storage quota in MBs ( Retrieved from gateway ).

@@ -44,4 +44,10 @@ * @property {number} CurrentMediaStorageUsageInMB - <p> Current attachment content (media) usage in MBs (Retrieved from gateway )<br>

* @property {number} ConsistencyPolicy.maxStalenessIntervalInSeconds - In bounded staleness consistency, the maximum allowed staleness in terms time interval.
* @property {Array} WritableLocations - The list of writable locations for a geo-replicated database account.
* @property {Array} ReadableLocations - The list of readable locations for a geo-replicated database account.
*/
DatabaseAccount: Base.defineClass(function() {
DatabaseAccount: Base.defineClass(function () {
this._writableLocations = [];
this._readableLocations = [];
Object.defineProperty(this, "DatabasesLink", {

@@ -102,2 +108,16 @@ value: "",

});
Object.defineProperty(this, "WritableLocations", {
get: function () {
return this._writableLocations;
},
enumerable: true
});
Object.defineProperty(this, "ReadableLocations", {
get: function () {
return this._readableLocations;
},
enumerable: true
});
}),

@@ -276,2 +296,4 @@

this.RequestTimeout = this._defaultRequestTimeout;
this.EnableEndpointDiscovery = true;
this.PreferredLocations = [];
})

@@ -278,0 +300,0 @@ }

@@ -31,2 +31,3 @@ /*

, querystring = require("querystring")
, RetryUtility = require("./retryUtility")
// Dedicated Agent for socket pooling

@@ -69,3 +70,8 @@ , keepAliveAgent = new https.Agent({ keepAlive: true, maxSockets: Infinity });

if (response.statusCode >= 400) {
callback({code: response.statusCode, body: data}, undefined, response.headers);
if (Constants.HttpHeaders.SubStatus in response.headers) {
var subStatus = parseInt(response.headers[Constants.HttpHeaders.SubStatus]);
callback({ code: response.statusCode, substatus: subStatus, body: data }, undefined, response.headers);
} else {
callback({ code: response.statusCode, body: data }, undefined, response.headers);
}
return;

@@ -109,5 +115,10 @@ }

var RequestHandler = {
_createRequestObjectStub: function (connectionPolicy, requestOptions, callback) {
return createRequestObject(connectionPolicy, requestOptions, callback);
},
/**
* Creates the request object, call the passed callback when the response is retrieved.
* @param {object} connectionPolicy - an instance of ConectionPolicy that has the connection configs.
* @param {object} globalEndpointManager - an instance of GlobalEndpointManager class.
* @param {object} connectionPolicy - an instance of ConnectionPolicy that has the connection configs.
* @param {string} method - the http request method ( 'get', 'post', 'put', .. etc ).

@@ -121,5 +132,5 @@ * @param {String} url - The base url for the endpoint.

*/
request: function (connectionPolicy, method, url, path, data, queryParams, headers, callback) {
request: function (globalEndpointManager, connectionPolicy, method, url, path, data, queryParams, headers, callback) {
var body;
if (data) {

@@ -129,3 +140,3 @@ body = bodyFromData(data);

}
var buffer;

@@ -145,3 +156,3 @@ var stream;

}
var requestOptions = parse(url);

@@ -153,24 +164,20 @@ requestOptions.method = method;

requestOptions.secureProtocol = "TLSv1_client_method";
if (queryParams) {
requestOptions.path += "?" + querystring.stringify(queryParams);
}
if (buffer) {
requestOptions.headers[Constants.HttpHeaders.ContentLength] = buffer.length;
var httpsRequest = createRequestObject(connectionPolicy, requestOptions, callback);
httpsRequest.write(buffer);
httpsRequest.end();
RetryUtility.execute(globalEndpointManager, { buffer: buffer, stream: null }, this._createRequestObjectStub, connectionPolicy, requestOptions, callback);
} else if (stream) {
var httpsRequest = createRequestObject(connectionPolicy, requestOptions, callback);
stream.pipe(httpsRequest);
RetryUtility.execute(globalEndpointManager, { buffer: null, stream: stream }, this._createRequestObjectStub, connectionPolicy, requestOptions, callback);
} else {
var httpsRequest = createRequestObject(connectionPolicy, requestOptions, callback);
httpsRequest.end();
RetryUtility.execute(globalEndpointManager, { buffer: null, stream: null }, this._createRequestObjectStub, connectionPolicy, requestOptions, callback);
}
}
};
}
if (typeof exports !== "undefined") {
module.exports = RequestHandler;
}
}

@@ -12,3 +12,3 @@ {

],
"version": "1.7.0",
"version": "1.8.0",
"author": "Microsoft Corporation",

@@ -33,2 +33,2 @@ "main": "./index.js",

"license": "Apache-2.0"
}
}

@@ -24,6 +24,6 @@ /*

var masterKey = "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==";
var host = "https://localhost:443";
var masterKey = "[YOUR_KEY_HERE]";
var host = "[YOUR_ENDPOINT_HERE]";
exports.host = host;
exports.masterKey = masterKey;

@@ -179,3 +179,3 @@ /*

var fs = require('fs');
var content = fs.readFileSync('../../.net/Microsoft.Azure.Documents.Client.Test/Routing/resources/BaselineTest.PathParser.json');
var content = fs.readFileSync('BaselineTest.PathParser.json');
var obj = JSON.parse(content);

@@ -186,2 +186,2 @@ obj.forEach(function (entry) {

});
});
});

Sorry, the diff of this file is not supported yet

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

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

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