Socket
Socket
Sign inDemoInstall

aws-sdk

Package Overview
Dependencies
3
Maintainers
1
Versions
1902
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.0 to 1.3.0

features/cloudfront/cloudfront-2012-05-05.feature

72

doc-src/guide/Examples.md

@@ -77,2 +77,74 @@ # Examples

### Amazon S3: Getting a pre-signed URL for a getObject operation (getSignedUrl)
A pre-signed URL allows you to give one-off access to other users who may not
have direct access to execute the operations. Pre-signing generates a valid
URL signed with your credentials that any user can access. By default, the SDK
sets all URLs to expire within 15 minutes, but this value can be adjusted.
To generate a simple pre-signed URL that allows any user to view the contents
of a private object in a bucket you own, you can use the following call to
`getSignedUrl()`:
```js
var params = {Bucket: 'myBucket', Key: 'myKey'};
s3.getSignedUrl('getObject', params, function (err, url) {
console.log("The URL is", url);
});
```
The `getSignedUrl()` operation can also be called synchronously, when the
callback is omitted. When it is called without a callback, the return value is
the pre-signed URL. The above example can be re-written synchronously as:
```js
var params = {Bucket: 'myBucket', Key: 'myKey'};
var url = s3.getSignedUrl('getObject', params);
console.log("The URL is", url);
```
Note that this method should only be called synchronously if you can guarantee
that your credentials are already loaded (or defined statically). In general,
it is safe to use this method synchronously unless you are using EC2 IAM roles
or another custom asynchronous credential provider.
### Amazon S3: Getting a pre-signed URL for a PUT operation with a specific payload
If a Body parameter is passed to the payload of a pre-signed PUT object
operation and checksums are being computed, the SDK will generate the URL
with a Content-MD5 representing the expected payload contents. You can use
this functionality to generate pre-signed PUT operations that require a specific
payload to be uploaded by the consumer of the URL. To generate such a URL,
simply provide a Body property to the parameter list:
```js
var s3 = new AWS.S3({computeChecksums: true}); // this is the default setting
var params = {Bucket: 'myBucket', Key: 'myKey', Body: 'EXPECTED CONTENTS'};
var url = s3.getSignedUrl('putObject', params);
console.log("The URL is", url);
```
You can also omit the Body parameter to generate a URL that allows a user to
write any contents to the given object:
```js
var params = {Bucket: 'myBucket', Key: 'myKey'};
var url = s3.getSignedUrl('putObject', params);
console.log("The URL is", url);
```
### Amazon S3: Controlling Expires time with pre-signed URLs
As mentioned above, pre-signed URLs will expire in 15 minutes by default
when generated by the SDK. This value is adjustable with the `Expires`
parameter, an integer representing the number of seconds that the URL will be
valid, and can be set with any call to `getSignedUrl()`:
```js
// This URL will expire in one minute (60 seconds)
var params = {Bucket: 'myBucket', Key: 'myKey', Expires: 60};
var url = s3.getSignedUrl('getObject', params);
console.log("The URL is", url);
```
## Amazon DynamoDB

@@ -79,0 +151,0 @@

55

features/cloudfront/step_definitions/cloudfront.js

@@ -17,56 +17,7 @@ /**

module.exports = function() {
var createParams = {
CallerReference: '',
Aliases: {
Quantity: 0
},
DefaultRootObject: '',
Origins: {
Items: [{
Id: 'origin',
DomainName: 'example.com',
CustomOriginConfig: {
HTTPPort: 80,
HTTPSPort: 443,
OriginProtocolPolicy: 'match-viewer'
}
}],
Quantity: 1,
},
DefaultCacheBehavior: {
TargetOriginId: 'origin',
ForwardedValues: {
QueryString: false
},
TrustedSigners: {
Items: [],
Enabled: false,
Quantity: 0
},
ViewerProtocolPolicy: 'allow-all',
MinTTL: 0
},
CacheBehaviors: {
Items: [],
Quantity: 0
},
Comment: '',
Logging: {
Enabled: false,
Bucket: 'invalidbucket.s3.amazonaws.com',
Prefix: 'prefix'
},
Enabled: false
};
this.Before("@cloudfront", function (callback) {
this.service = new this.AWS.CloudFront.Client();
callback();
});
this.Given(/^I create a CloudFront distribution with name prefix "([^"]*)"$/, function(prefix, callback) {
this.cfName = this.uniqueName(prefix);
createParams.CallerReference = this.cfName;
createParams.Origins.Items[0].Id = (this.cfName === '' ? 'origin' : 'InvalidOrigin');
this.request(null, 'createDistribution', { DistributionConfig: createParams }, callback, false);
this.cfCreateParams.CallerReference = this.cfName;
this.cfCreateParams.Origins.Items[0].Id = (this.cfName === '' ? 'origin' : 'InvalidOrigin');
this.request(null, 'createDistribution', { DistributionConfig: this.cfCreateParams }, callback, false);
});

@@ -73,0 +24,0 @@

@@ -16,6 +16,19 @@ /**

var realExit = process.exit;
module.exports = function () {
var world = require("./world.js").WorldInstance;
this.World = require("./world.js").World;
world.cleanupTasks = new world.AWS.SequentialExecutor();
process.exit = function(code) {
var finalCallback = function() { realExit(code); };
world.cleanupTasks.emit('cleanup', [], finalCallback);
};
this.AfterAll = function(callback) {
world.cleanupTasks.onAsync('cleanup', callback.bind(world));
}
/* Global error code steps */

@@ -22,0 +35,0 @@

@@ -25,1 +25,2 @@ /**

exports.World = WorldConstructor;
exports.WorldInstance = world;

@@ -18,2 +18,25 @@ /**

function cleanBucket(world, bucket, callback) {
if (!bucket) { callback(); return; }
var params = {Bucket: bucket};
var deleteBucket = function() {
delete params.Delete;
world.request('s3', 'deleteBucket', params, callback, false);
}
world.s3.listObjects(params, function (err, data) {
if (err) { deleteBucket(); return; }
if (data.Contents.length > 0) {
params.Delete = { Objects: [] };
AWS.util.arrayEach(data.Contents, function (item) {
params.Delete.Objects.push({Key: item.Key});
});
world.request('s3', 'deleteObjects', params, deleteBucket);
} else {
deleteBucket();
}
});
}
this.Before("@s3", function (callback) {

@@ -24,2 +47,10 @@ this.service = this.s3 = new this.AWS.S3.Client();

this.After("@s3", function (callback) {
cleanBucket(this, this.bucket, callback);
});
this.AfterAll(function(callback) {
cleanBucket(this, this.sharedBucket, callback);
});
};

@@ -111,2 +111,50 @@ /**

this.When(/^I get a pre\-signed URL to GET the key "([^"]*)"$/, function(key, callback) {
this.signedUrl = this.s3.getSignedUrl('getObject', {Bucket: this.sharedBucket, Key: key});
callback();
});
this.When(/^I access the URL via HTTP GET$/, function(callback, verb) {
var world = this;
this.data = '';
require('https').get(this.signedUrl, function (res) {
res.on('data', function (chunk) {
world.data += chunk.toString();
}).on('end', callback);
}).on('error', callback.fail);
});
this.Given(/^I get a pre\-signed URL to PUT the key "([^"]*)"(?: with data "([^"]*)")?$/, function(key, body, callback) {
var params = {Bucket: this.sharedBucket, Key: key};
if (body) params.Body = body;
this.signedUrl = this.s3.getSignedUrl('putObject', params);
callback();
});
this.Given(/^I access the URL via HTTP PUT with data "([^"]*)"$/, function(body, callback) {
var world = this;
this.data = '';
var data = body;
var options = require('url').parse(this.signedUrl);
options.method = 'PUT';
options.headers = {'Content-Length': data.length};
var req = require('https').request(options, function (res) {
res.on('data', function (chunk) {
world.data += chunk.toString();
}).on('end', callback);
}).on('error', callback.fail).end(data);
});
this.Then(/^the HTTP response should equal "([^"]*)"$/, function(data, callback) {
this.assert.equal(this.data, data);
callback();
});
this.Then(/^the HTTP response should contain "([^"]*)"$/, function(data, callback) {
this.assert.match(this.data, data);
callback();
});
// this scenario is a work around for not having an after all hook

@@ -113,0 +161,0 @@ this.Then(/^I delete the shared bucket$/, function(next) {

@@ -28,3 +28,3 @@ /**

*/
VERSION: 'v1.2.0',
VERSION: 'v1.3.0',

@@ -31,0 +31,0 @@ /**

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

AttributeValue: {
required: true
}

@@ -339,3 +338,2 @@ }

AttributeValue: {
required: true
}

@@ -362,3 +360,2 @@ }

Endpoint: {
required: true
}

@@ -365,0 +362,0 @@ }

@@ -296,21 +296,2 @@ /**

},
resolveCase: {
name: 'ResolveCase',
input: {
type: 'structure',
members: {
caseId: {
}
}
},
output: {
type: 'structure',
members: {
initialCaseStatus: {
},
finalCaseStatus: {
}
}
}
},
describeTrustedAdvisorCheckRefreshStatuses: {

@@ -567,4 +548,23 @@ name: 'DescribeTrustedAdvisorCheckRefreshStatuses',

}
},
resolveCase: {
name: 'ResolveCase',
input: {
type: 'structure',
members: {
caseId: {
}
}
},
output: {
type: 'structure',
members: {
initialCaseStatus: {
},
finalCaseStatus: {
}
}
}
}
}
};

@@ -18,4 +18,4 @@ /**

AWS.CloudFront = AWS.Service.defineService('cloudfront', ['2012-05-05']);
AWS.CloudFront = AWS.Service.defineService('cloudfront', ['2013-05-12', '2012-05-05']);
module.exports = AWS.CloudFront;

@@ -18,4 +18,4 @@ /**

AWS.RDS = AWS.Service.defineService('rds', ['2013-02-12']);
AWS.RDS = AWS.Service.defineService('rds', ['2013-05-15', '2013-02-12', '2013-01-10']);
module.exports = AWS.RDS;

@@ -51,3 +51,3 @@ /**

if (!req.service.pathStyleBucketName(b)) {
httpRequest.endpoint.hostname = b + '.' +
httpRequest.endpoint.host = httpRequest.endpoint.hostname = b + '.' +
httpRequest.endpoint.hostname;

@@ -235,2 +235,95 @@

}
},
/**
* Get a pre-signed URL for a given operation name.
*
* @note You must ensure that you have static or previously resolved
* credentials if you call this method synchronously (with no callback),
* otherwise it may not properly sign the request. If you cannot guarantee
* this (you are using an asynchronous credential provider, i.e., EC2
* IAM roles), you should always call this method with an asynchronous
* callback.
* @param operation [String] the name of the operation to call
* @param params [map] parameters to pass to the operation. See the given
* operation for the expected operation parameters. In addition, you can
* also pass the "Expires" parameter to inform S3 how long the URL should
* work for.
* @option params Expires [Integer] (900) the number of seconds to expire
* the pre-signed URL operation in. Defaults to 15 minutes.
* @param callback [Function] if a callback is provided, this function will
* pass the URL as the second parameter (after the error parameter) to
* the callback function.
* @return [String] if called synchronously (with no callback), returns the
* signed URL.
* @return [null] nothing is returned if a callback is provided.
* @example Pre-signing a getObject operation (synchronously)
* var params = {Bucket: 'bucket', Key: 'key'};
* var url = s3.getSignedUrl('getObject', params);
* console.log('The URL is', url);
* @example Pre-signing a putObject (asynchronously)
* var params = {Bucket: 'bucket', Key: 'key'};
* s3.getSignedUrl('putObject', params, function (err, url) {
* console.log('The URL is', url);
* });
* @example Pre-signing a putObject operation with a specific payload
* var params = {Bucket: 'bucket', Key: 'key', Body: 'body'};
* var url = s3.getSignedUrl('putObject', params);
* console.log('The URL is', url);
* @example Passing in a 1-minute expiry time for a pre-signed URL
* var params = {Bucket: 'bucket', Key: 'key', Expires: 60};
* var url = s3.getSignedUrl('getObject', params);
* console.log('The URL is', url); // expires in 60 seconds
*/
getSignedUrl: function getSignedUrl(operation, params, callback) {
var url = require('url');
var events = ['validate', 'build', 'sign'];
var request = this.makeRequest(operation, params);
var expires = params.Expires || 900;
function signedUrlBuilder() {
delete request.httpRequest.headers['User-Agent'];
request.httpRequest.headers['Expires'] = parseInt(
AWS.util.date.unixTimestamp() + expires, 10).toString();
}
function signedUrlSigner() {
var queryParams = {};
AWS.util.each(request.httpRequest.headers, function (key, value) {
queryParams[key] = value;
});
var auth = queryParams['Authorization'].split(':');
delete queryParams['Authorization'];
queryParams['AWSAccessKeyId'] = auth[0].split(' ')[1];
queryParams['Signature'] = auth[1];
// build URL
var endpoint = request.httpRequest.endpoint;
var parsedUrl = url.parse(request.httpRequest.path);
var querystring = AWS.util.queryParamsToString(queryParams);
endpoint.pathname = parsedUrl.pathname;
endpoint.search = !parsedUrl.search ? querystring :
parsedUrl.search + '&' + querystring;
}
request.on('build', signedUrlBuilder);
request.on('sign', signedUrlSigner);
if (!params.Body) { // no Content-MD5 signing if body is not provided
request.removeListener('build', this.computeContentMd5);
}
delete params.Expires; // we can't validate this
if (callback) {
request.emitEvents(events, new AWS.Response(request), function (err) {
if (err) callback(err, null);
else callback(null, url.format(request.httpRequest.endpoint));
});
} else {
AWS.util.arrayEach(events, function (item) {
request.emitEvent(item, [request]);
});
return url.format(request.httpRequest.endpoint);
}
}

@@ -237,0 +330,0 @@ });

@@ -60,3 +60,5 @@ /**

addAuthorization: function addAuthorization(credentials, date) {
this.request.headers['Date'] = AWS.util.date.rfc822(date);
if (!this.request.headers['Expires']) {
this.request.headers['Date'] = AWS.util.date.rfc822(date);
}

@@ -79,3 +81,3 @@ if (credentials.sessionToken)

parts.push(r.headers['Content-Type'] || '');
parts.push(r.headers['Date'] || '');
parts.push(r.headers['Expires'] || r.headers['Date'] || '');
var headers = this.canonicalizedAmzHeaders();

@@ -82,0 +84,0 @@ if (headers) parts.push(headers);

@@ -78,3 +78,5 @@ /**

if (Array.isArray(value)) {
result = ename + '=' + value.sort().join('&' + ename + '=');
var vals = [];
AWS.util.arrayEach(value, function(item) { vals.push(escape(item)); });
result = ename + '=' + vals.sort().join('&' + ename + '=');
} else if (value !== undefined && value !== null) {

@@ -136,3 +138,3 @@ result = ename + '=' + escape(value);

return string.length;
} else if (string.path !== undefined) {
} else if (typeof(string.path) === 'string') {
return require('fs').lstatSync(string.path).size;

@@ -139,0 +141,0 @@ } else {

{
"name": "aws-sdk",
"description": "AWS SDK for JavaScript",
"version": "v1.2.0",
"version": "v1.3.0",
"author": {

@@ -6,0 +6,0 @@ "name":"Amazon Web Services",

@@ -85,3 +85,3 @@ # AWS SDK for Node.js [![Build Status](https://travis-ci.org/aws/aws-sdk-js.png?branch=master)](https://travis-ci.org/aws/aws-sdk-js)

<td>Amazon CloudFront</td>
<td>2012-05-05</td>
<td>2013-05-12<br>2012-05-05</td>
<td>AWS.CloudFront</td>

@@ -111,3 +111,3 @@ </tr>

<td>Amazon DynamoDB</td>
<td>2012-08-10, 2011-12-05</td>
<td>2012-08-10<br>2011-12-05</td>
<td>AWS.DynamoDB</td>

@@ -171,4 +171,4 @@ </tr>

<tr>
<td>Amazon Relational Database Service (Beta)</td>
<td>2012-07-31</td>
<td>Amazon Relational Database Service</td>
<td>2013-05-15<br>2013-02-12<br>2013-01-10</td>
<td>AWS.RDS</td>

@@ -175,0 +175,0 @@ </tr>

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

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc