Socket
Socket
Sign inDemoInstall

@ibm-cloud/cloudant

Package Overview
Dependencies
Maintainers
2
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ibm-cloud/cloudant - npm Package Compare versions

Comparing version 0.0.17 to 0.0.18

4

lib/cloudantBaseService.d.ts

@@ -62,2 +62,6 @@ /**

private configureSessionAuthenticator;
/**
* Extend createRequest to handle document and attachment validation.
*/
protected createRequest(parameters: any): Promise<any>;
}

@@ -39,3 +39,52 @@ "use strict";

var common_1 = require("./common");
var DocumentOperations = [
'deleteDocument',
'getDocument',
'headDocument',
'putDocument',
'deleteAttachment',
'getAttachment',
'headAttachment',
'putAttachment',
];
var AttachmentOperations = [
'deleteAttachment',
'getAttachment',
'headAttachment',
'putAttachment',
];
var docIdRule = {
pathSegment: 'doc_id',
errorParameterName: 'Document ID',
operationIds: DocumentOperations,
};
var attIdRule = {
pathSegment: 'attachment_name',
errorParameterName: 'Attachment name',
operationIds: AttachmentOperations,
};
var validationRules = [docIdRule, attIdRule];
var rulesByOperation = {};
for (var _i = 0, validationRules_1 = validationRules; _i < validationRules_1.length; _i++) {
var rule = validationRules_1[_i];
for (var _a = 0, _b = rule.operationIds; _a < _b.length; _a++) {
var operationId = _b[_a];
if (!(operationId in rulesByOperation)) {
rulesByOperation[operationId] = [];
}
rulesByOperation[operationId].push(rule);
}
}
Object.freeze(rulesByOperation);
/**
* Extend Error interface to access the proper Error definition.
*/
var InvalidArgumentValueError = /** @class */ (function (_super) {
__extends(InvalidArgumentValueError, _super);
function InvalidArgumentValueError() {
return _super !== null && _super.apply(this, arguments) || this;
}
return InvalidArgumentValueError;
}(Error));
/**
* Cloudant specific service that extends the base service functions.

@@ -118,2 +167,36 @@ *

};
/**
* Extend createRequest to handle document and attachment validation.
*/
CloudantBaseService.prototype.createRequest = function (parameters) {
var operationId = null;
if ('X-IBMCloud-SDK-Analytics' in parameters['defaultOptions']['headers']) {
// Extract operation id
var analyticsHeader = parameters['defaultOptions']['headers']['X-IBMCloud-SDK-Analytics'];
for (var _i = 0, _a = analyticsHeader.split(';'); _i < _a.length; _i++) {
var element = _a[_i];
if (element.startsWith('operation_id')) {
operationId = element.split('=')[1];
}
}
// Check if operation id exists in rulesByOperation object
if (operationId != null &&
Object.keys(rulesByOperation).includes(operationId)) {
for (var _b = 0, _c = rulesByOperation[operationId]; _b < _c.length; _b++) {
var rule = _c[_b];
// get the path segment e.g. doc_id from the response's path object
if ('path' in parameters['options'] &&
rule.pathSegment in parameters['options']['path']) {
var segmentToValidate = parameters['options']['path'][rule.pathSegment];
if (segmentToValidate.startsWith('_')) {
var err = new InvalidArgumentValueError(rule.errorParameterName + " " + segmentToValidate + " starts with the invalid _ character.");
err.code = 'ERR_INVALID_ARG_VALUE';
return Promise.reject(err);
}
}
}
}
}
return _super.prototype.createRequest.call(this, parameters);
};
return CloudantBaseService;

@@ -120,0 +203,0 @@ }(ibm_cloud_sdk_core_1.BaseService));

4

package.json
{
"name": "@ibm-cloud/cloudant",
"version": "0.0.17",
"version": "0.0.18",
"description": "IBM Cloudant Node.js SDK",

@@ -38,3 +38,3 @@ "main": "index.js",

"extend": "^3.0.2",
"ibm-cloud-sdk-core": "~2.11.0"
"ibm-cloud-sdk-core": "~2.13.0"
},

@@ -41,0 +41,0 @@ "jest": {

@@ -5,3 +5,3 @@ [![Build Status](https://travis-ci.com/IBM/cloudant-node-sdk.svg?branch=master)](https://travis-ci.com/IBM/cloudant-node-sdk)

# IBM Cloudant Node.js SDK Version 0.0.17
# IBM Cloudant Node.js SDK Version 0.0.18

@@ -8,0 +8,0 @@ IBM Cloudant Node.js SDK is a client library that interacts with the

Sorry, the diff of this file is not supported yet

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