New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

aws-sigv4

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aws-sigv4 - npm Package Compare versions

Comparing version 1.5.1 to 1.6.0

24

lib/index.js

@@ -75,4 +75,6 @@ 'use strict';

*/
function canonicalRequest(httpRequestMethod, canonicalURI, canonicalQueryString, canonicalHeaders, signedHeaders, requestPayload) {
return [httpRequestMethod, canonicalURI, canonicalQueryString, canonicalHeaders, '', signedHeaders, hash(requestPayload || '')].join('\n');
function canonicalRequest(httpRequestMethod, canonicalURI, canonicalQueryString, canonicalHeaders, signedHeaders) {
var requestPayload = arguments.length <= 5 || arguments[5] === undefined ? '' : arguments[5];
return [httpRequestMethod, canonicalURI, canonicalQueryString, canonicalHeaders, '', signedHeaders, hash(requestPayload)].join('\n');
}

@@ -134,3 +136,3 @@

return [algorithm, Object.keys(auth).map(function (key) {
return [key, auth[key]].join('=');
return key + '=' + auth[key];
}).join(', ')].join(' ');

@@ -188,4 +190,6 @@ }

*/
function unparseRequest(head, body) {
return [head, body].join(CRLF.repeat(2)).trim();
function unparseRequest(head) {
var body = arguments.length <= 1 || arguments[1] === undefined ? '' : arguments[1];
return ('' + head + CRLF.repeat(2) + body).trim();
}

@@ -281,3 +285,3 @@

return queryParams[key].sort().map(function (val) {
return [encodeURIComponent(key), encodeURIComponent(val || '')].join('=');
return encodeURIComponent(key) + '=' + encodeURIComponent(val || '');
}).join('&');

@@ -296,3 +300,3 @@ }).join('&');

*
* @param {string} rawHeaders
* @param {Array<string>} rawHeaders
* @returns {{canonicalHeadersString: string, signedHeadersString: string}}

@@ -333,3 +337,3 @@ */

var canonicalHeadersString = signedHeadersList.map(function (key) {
return [key, headersMap[key].join(',')].join(':');
return key + ':' + headersMap[key].join(',');
}).join('\n');

@@ -352,4 +356,6 @@

var parsedRequest = parseRequest(request);
var tokenLine = securityToken ? CRLF + 'X-Amz-Security-Token:' + securityToken : '';
var authorizationLine = CRLF + 'Authorization: ' + authorization;
return unparseRequest([parsedRequest.head, securityToken ? CRLF + 'X-Amz-Security-Token:' + securityToken : '', CRLF + 'Authorization: ' + authorization].join(''), parsedRequest.body);
return unparseRequest('' + parsedRequest.head + tokenLine + authorizationLine, parsedRequest.body);
}

@@ -356,0 +362,0 @@

{
"name": "aws-sigv4",
"version": "1.5.1",
"version": "1.6.0",
"description": "AWS Signature Version 4",

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

@@ -18,3 +18,3 @@ # aws-sigv4

```JavaScript
var sigv4 = require('aws-sigv4');
const sigv4 = require('aws-sigv4');

@@ -28,2 +28,35 @@ sigv4.sign(

);
```
// Or, more specifically for S3:
const date = sigv4
.formatDateTime(new Date())
.slice(0, 8);
const credential = `${process.env.AWS_ACCESS_KEY_ID}/${date}/${process.env.AWS_REGION}/s3/aws4_request`
const policy = new Buffer(
JSON.stringify({
expiration: new Date(Date.now() + 15 * 60000).toISOString(), // 15 minutes from now
conditions: [
{bucket: 'my-bucket-name'},
{key: 'my-s3-key.mov'},
{acl: 'private'},
['starts-with', '$Content-Type', 'video/'],
['content-length-range', 0, 10 * 1024 * 1024],
{'x-amz-credential': credential},
{'x-amz-algorithm': 'AWS4-HMAC-SHA256'},
{'x-amz-date': date + 'T000000Z'}
]
})
)
.toString('base64');
sigv4.sign(
process.env.AWS_SECRET_ACCESS_KEY,
date,
process.env.AWS_REGION,
's3',
policy
);
```
See [Authenticating Requests in Browser-Based Uploads Using POST (AWS Signature Version 4)](https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-UsingHTTPPOST.html) as the primary use case.

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 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