http-aws-es
Advanced tools
Comparing version 3.1.3 to 4.0.0
@@ -0,1 +1,4 @@ | ||
### 4.0.0 | ||
* Use AWS XHRClient in browser. [#42][42] | ||
### 3.1.2 | ||
@@ -2,0 +5,0 @@ * Fix unicode issue. [#43][43] |
@@ -16,3 +16,3 @@ 'use strict'; | ||
const HttpConnector = require('elasticsearch/src/lib/connectors/http'); | ||
const zlib = require('zlib'); | ||
const HttpClient = require('./src/node'); | ||
@@ -33,3 +33,3 @@ class HttpAmazonESConnector extends HttpConnector { | ||
this.httpOptions = config.httpOptions || this.awsConfig.httpOptions; | ||
this.httpClient = new AWS.NodeHttpClient(); | ||
this.httpClient = new HttpClient(); | ||
} | ||
@@ -41,6 +41,2 @@ | ||
let req; | ||
let status = 0; | ||
let headers = {}; | ||
let response; | ||
let incoming; | ||
let cancelled; | ||
@@ -53,14 +49,5 @@ | ||
// general clean-up procedure to run after the request | ||
// completes, has an error, or is aborted. | ||
const cleanUp = (err) => { | ||
req && req.removeAllListeners(); | ||
incoming && incoming.removeAllListeners(); | ||
const done = (err, response, status, headers) => { | ||
this.log.trace(params.method, reqParams, params.body, response, status); | ||
if (err instanceof Error) { | ||
cb(err); | ||
} else { | ||
cb(null, response, status, headers); | ||
} | ||
cb(err, response, status, headers); | ||
}; | ||
@@ -80,30 +67,7 @@ | ||
const request = this.createRequest(params, reqParams); | ||
// Sign the request (Sigv4) | ||
this.signRequest(request, creds); | ||
req = this.httpClient.handleRequest(request, this.httpOptions, function (_incoming) { | ||
incoming = _incoming; | ||
status = incoming.statusCode; | ||
headers = incoming.headers; | ||
response = ''; | ||
let encoding = (headers['content-encoding'] || '').toLowerCase(); | ||
if (encoding === 'gzip' || encoding === 'deflate') { | ||
incoming = incoming.pipe(zlib.createUnzip()); | ||
} | ||
incoming.setEncoding('utf8'); | ||
incoming.on('data', function (d) { | ||
response += d; | ||
}); | ||
incoming.on('error', cleanUp); | ||
incoming.on('end', cleanUp); | ||
}, cleanUp); | ||
req.setNoDelay(true); | ||
req.setSocketKeepAlive(true); | ||
req = this.httpClient.handleRequest(request, this.httpOptions, done); | ||
}) | ||
.catch(cleanUp); | ||
.catch(done); | ||
@@ -139,3 +103,2 @@ return cancel; | ||
} | ||
request.headers['presigned-expires'] = false; | ||
request.headers['Host'] = this.endpoint.host; | ||
@@ -142,0 +105,0 @@ |
{ | ||
"name": "http-aws-es", | ||
"version": "3.1.3", | ||
"version": "4.0.0", | ||
"description": "Use the elasticsearch-js client with Amazon ES", | ||
@@ -26,8 +26,11 @@ "repository": "https://github.com/TheDeveloper/http-aws-es", | ||
"aws-sdk": "^2.138.0", | ||
"browserify": "^14.5.0", | ||
"chai": "^4.1.2", | ||
"elasticsearch": "^13.3.1", | ||
"eslint": "^4.9.0", | ||
"express": "^4.16.2", | ||
"minimist": "^1.2.0", | ||
"mocha": "^4.0.1", | ||
"nyc": "^11.2.1", | ||
"puppeteer": "^0.12.0", | ||
"sinon": "^4.0.0" | ||
@@ -39,6 +42,9 @@ }, | ||
"posttest": "npm run lint", | ||
"lint": "eslint ." | ||
"lint": "eslint connector.js src" | ||
}, | ||
"browser": { | ||
"./src/node.js": "./src/xhr.js" | ||
}, | ||
"author": "Geoff Wagstaff <geoff@gosquared.com>", | ||
"license": "MIT" | ||
} |
@@ -43,3 +43,5 @@ # Connection handler for Amazon ES [<img title="Version" src="https://img.shields.io/npm/v/http-aws-es.svg?style=flat-square" />](https://www.npmjs.org/package/http-aws-es) | ||
```bash | ||
npm test -- --endpoint https://amazon-es-host.us-east-1.es.amazonaws.com --region us-east-1 | ||
npm test | ||
# test against a real endpoint | ||
AWS_PROFILE=your-profile npm run integration-test -- --endpoint https://amazon-es-host.us-east-1.es.amazonaws.com --region us-east-1 | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16142
16
364
47
11
3
1