Comparing version 1.10.0 to 1.12.0
@@ -19,2 +19,5 @@ /** | ||
// Load Node HTTP client | ||
require('./http/node'); | ||
// Load all service classes | ||
@@ -21,0 +24,0 @@ require('./services'); |
@@ -75,3 +75,4 @@ /** | ||
* SSL connections, a special Agent object is used in order to enable | ||
* peer certificate verification. | ||
* peer certificate verification. This feature is only supported in the | ||
* Node.js environment. | ||
* * **timeout** [Integer] — The number of milliseconds to wait before | ||
@@ -129,3 +130,4 @@ * giving up on a connection attempt. Defaults to no timeout. | ||
* SSL connections, a special Agent object is used in order to enable | ||
* peer certificate verification. | ||
* peer certificate verification. This feature is only available in the | ||
* Node.js environment. | ||
* * **timeout** [Integer] — The number of milliseconds to wait before | ||
@@ -231,2 +233,3 @@ * giving up on a connection attempt. Defaults to no timeout. | ||
* on the object. | ||
* @!macro nobrowser | ||
* @param path [String] the path to load configuration from | ||
@@ -233,0 +236,0 @@ * @return [AWS.Config] the same configuration object |
@@ -18,2 +18,5 @@ /** | ||
* The main AWS namespace | ||
* | ||
* @!macro [new] nobrowser | ||
* @note This feature is not supported in the browser environment of the SDK. | ||
*/ | ||
@@ -29,3 +32,3 @@ var AWS = {}; | ||
*/ | ||
VERSION: '1.10.0', | ||
VERSION: '1.12.0', | ||
@@ -80,1 +83,3 @@ /** | ||
AWS.events = new AWS.SequentialExecutor(); | ||
if (typeof window !== 'undefined') window.AWS = AWS; |
@@ -41,3 +41,3 @@ /** | ||
* | ||
* ```js | ||
* ```javascript | ||
* var diskProvider = new AWS.FileSystemCredentials('./creds.json'); | ||
@@ -44,0 +44,0 @@ * var chain = new AWS.CredentialProviderChain(); |
@@ -27,2 +27,4 @@ /** | ||
* configuration. | ||
* | ||
* @!macro nobrowser | ||
*/ | ||
@@ -29,0 +31,0 @@ AWS.EC2MetadataCredentials = AWS.util.inherit(AWS.Credentials, { |
@@ -26,3 +26,3 @@ /** | ||
* | ||
* ```js | ||
* ```javascript | ||
* accessKeyId: ACCESS_KEY_ID | ||
@@ -49,3 +49,3 @@ * secretAccessKey: SECRET_ACCESS_KEY | ||
* | ||
* ```js | ||
* ```javascript | ||
* var creds = new AWS.EnvironmentCredentials('AWS'); | ||
@@ -77,3 +77,2 @@ * creds.accessKeyId == 'AKID' // from AWS_ACCESS_KEY_ID env var | ||
refresh: function refresh(callback) { | ||
/*jshint maxcomplexity:10*/ | ||
if (!callback) callback = function(err) { if (err) throw err; }; | ||
@@ -80,0 +79,0 @@ |
@@ -27,3 +27,3 @@ /** | ||
* | ||
* ```js | ||
* ```javascript | ||
* {accessKeyId: 'akid', secretAccessKey: 'secret', sessionToken: 'optional'} | ||
@@ -40,2 +40,3 @@ * ``` | ||
* credentials. | ||
* @!macro nobrowser | ||
*/ | ||
@@ -42,0 +43,0 @@ AWS.FileSystemCredentials = AWS.util.inherit(AWS.Credentials, { |
@@ -32,3 +32,3 @@ /** | ||
* | ||
* ```js | ||
* ```javascript | ||
* // Note that environment credentials are loaded by default, | ||
@@ -35,0 +35,0 @@ * // the following line is shown for clarity: |
@@ -44,3 +44,3 @@ /** | ||
* | ||
* ```js | ||
* ```javascript | ||
* AWS.config.credentials.params.WebIdentityToken = updatedToken; | ||
@@ -47,0 +47,0 @@ * ``` |
@@ -24,2 +24,6 @@ /** | ||
/* jshint -W079 */ | ||
var Buffer = require('buffer').Buffer; | ||
/* jshint +W079 */ | ||
/** | ||
@@ -217,3 +221,3 @@ * The namespace used to register global event listeners for request building | ||
add('HTTP_DATA', 'httpData', function HTTP_DATA(chunk, resp) { | ||
if (chunk) resp.httpResponse.buffers.push(chunk); | ||
if (chunk) resp.httpResponse.buffers.push(new Buffer(chunk)); | ||
}); | ||
@@ -220,0 +224,0 @@ |
102
lib/http.js
@@ -17,3 +17,2 @@ /** | ||
var AWS = require('./core'); | ||
var Stream = require('stream').Stream; | ||
var inherit = AWS.util.inherit; | ||
@@ -28,3 +27,3 @@ | ||
* | ||
* ```js | ||
* ```javascript | ||
* var ep = new AWS.Endpoint('awsproxy.example.com'); | ||
@@ -118,9 +117,17 @@ * var s3 = new AWS.S3({endpoint: ep}); | ||
this.headers = {}; | ||
this.headers['User-Agent'] = AWS.util.userAgent(); | ||
this.body = ''; | ||
this.endpoint = endpoint; | ||
this.region = region; | ||
this.setUserAgent(); | ||
}, | ||
/** | ||
* @api private | ||
*/ | ||
setUserAgent: function setUserAgent() { | ||
var prefix = AWS.util.isBrowser() ? 'X-Amz-' : ''; | ||
this.headers[prefix + 'User-Agent'] = AWS.util.userAgent(); | ||
}, | ||
/** | ||
* @return [String] the part of the {path} excluding the | ||
@@ -166,95 +173,8 @@ * query string | ||
/** | ||
* @api private | ||
*/ | ||
AWS.NodeHttpClient = inherit({ | ||
handleRequest: function handleRequest(httpRequest, httpOptions, callback, errCallback) { | ||
var endpoint = httpRequest.endpoint; | ||
var pathPrefix = ''; | ||
if (!httpOptions) httpOptions = {}; | ||
if (httpOptions.proxy) { | ||
pathPrefix = endpoint.protocol + '//' + endpoint.hostname; | ||
if (endpoint.port != 80 && endpoint.port != 443) { | ||
pathPrefix += ':' + endpoint.port; | ||
} | ||
endpoint = new AWS.Endpoint(httpOptions.proxy); | ||
} | ||
var useSSL = endpoint.protocol === 'https:'; | ||
var http = useSSL ? require('https') : require('http'); | ||
var options = { | ||
host: endpoint.hostname, | ||
port: endpoint.port, | ||
method: httpRequest.method, | ||
headers: httpRequest.headers, | ||
path: pathPrefix + httpRequest.path | ||
}; | ||
AWS.HttpClient = inherit({}); | ||
if (useSSL && !httpOptions.agent) { | ||
options.agent = this.sslAgent(http); | ||
} | ||
AWS.util.update(options, httpOptions); | ||
delete options.proxy; // proxy isn't an HTTP option | ||
delete options.timeout; // timeout isn't an HTTP option | ||
var stream = http.request(options, callback); | ||
httpRequest.stream = stream; // attach stream to httpRequest | ||
// timeout support | ||
stream.setTimeout(httpOptions.timeout || 0); | ||
stream.once('timeout', function() { | ||
var msg = 'Connection timed out after ' + httpOptions.timeout + 'ms'; | ||
errCallback(AWS.util.error(new Error(msg), {code: 'TimeoutError'})); | ||
// HACK - abort the connection without tripping our error handler | ||
// since we already raised our TimeoutError. Otherwise the connection | ||
// comes back with ECONNRESET, which is not a helpful error message | ||
stream.removeListener('error', errCallback); | ||
stream.on('error', function() { }); | ||
stream.abort(); | ||
}); | ||
stream.on('error', errCallback); | ||
this.writeBody(stream, httpRequest); | ||
return stream; | ||
}, | ||
writeBody: function writeBody(stream, httpRequest) { | ||
if (httpRequest.body instanceof Stream) { | ||
httpRequest.body.pipe(stream); | ||
} else if (httpRequest.body) { | ||
stream.end(httpRequest.body); | ||
} else { | ||
stream.end(); | ||
} | ||
}, | ||
sslAgent: function sslAgent(http) { | ||
if (!AWS.NodeHttpClient.sslAgent) { | ||
AWS.NodeHttpClient.sslAgent = new http.Agent({ | ||
rejectUnauthorized: true | ||
}); | ||
} | ||
return AWS.NodeHttpClient.sslAgent; | ||
} | ||
}); | ||
/** | ||
* @!ignore | ||
*/ | ||
/** | ||
* @api private | ||
*/ | ||
AWS.HttpClient = AWS.NodeHttpClient; | ||
/** | ||
* @api private | ||
*/ | ||
AWS.HttpClient.streamsApiVersion = require('stream').Readable ? 2 : 1; | ||
/** | ||
* @api private | ||
*/ | ||
AWS.HttpClient.getInstance = function getInstance() { | ||
@@ -261,0 +181,0 @@ /*jshint newcap:false */ |
@@ -27,2 +27,3 @@ /** | ||
* @return [map] a map of options to pass to the underlying HTTP request | ||
* @!macro nobrowser | ||
*/ | ||
@@ -29,0 +30,0 @@ AWS.MetadataService = inherit({ |
@@ -17,3 +17,2 @@ /** | ||
var AWS = require('./core'); | ||
var Stream = require('stream').Stream; | ||
@@ -110,3 +109,3 @@ /** | ||
case 'binary': | ||
return this.validateType(context, value, ['string', Buffer, Stream]); | ||
return this.validatePayload(context, value); | ||
case 'integer': | ||
@@ -141,5 +140,5 @@ case 'float': | ||
if (value instanceof acceptedTypes[i]) return; | ||
if (AWS.util.isType(value, acceptedTypes[i].name)) return; | ||
if (AWS.util.isType(value, acceptedTypes[i])) return; | ||
if (!type && !foundInvalidType) acceptedTypes = acceptedTypes.slice(); | ||
acceptedTypes[i] = acceptedTypes[i].name; | ||
acceptedTypes[i] = AWS.util.typeName(acceptedTypes[i]); | ||
} | ||
@@ -158,3 +157,23 @@ foundInvalidType = true; | ||
vowel + ' ' + acceptedType); | ||
}, | ||
validatePayload: function validatePayload(context, value) { | ||
if (typeof value === 'string') return; | ||
if (value && typeof value.byteLength === 'number') return; // typed arrays | ||
if (AWS.util.isNode()) { // special check for buffer/stream in Node.js | ||
var Stream = require('stream').Stream; | ||
if (value instanceof Buffer || value instanceof Stream) return; | ||
} | ||
var types = ['Buffer', 'Stream', 'File', 'Blob', 'ArrayBuffer', 'DataView']; | ||
if (value) { | ||
for (var i = 0; i < types.length; i++) { | ||
if (AWS.util.isType(value, types[i])) return; | ||
if (AWS.util.typeName(value.constructor) === types[i]) return; | ||
} | ||
} | ||
this.fail('InvalidParameterType', 'Expected ' + context + ' to be a ' + | ||
'string, Buffer, Stream, Blob, or typed array object'); | ||
} | ||
}); |
@@ -18,3 +18,2 @@ /** | ||
var inherit = AWS.util.inherit; | ||
var streams = require('stream'); | ||
@@ -32,3 +31,3 @@ /** | ||
* | ||
* ```js | ||
* ```javascript | ||
* // request is an AWS.Request object | ||
@@ -46,3 +45,3 @@ * var request = ec2.describeInstances(); | ||
* | ||
* ```js | ||
* ```javascript | ||
* request.send(); | ||
@@ -69,3 +68,3 @@ * ``` | ||
* | ||
* ```js | ||
* ```javascript | ||
* request. | ||
@@ -287,2 +286,3 @@ * on('success', function(response) { | ||
* | ||
* @!macro nobrowser | ||
* @example Aborting a request after sending | ||
@@ -382,3 +382,3 @@ * var params = { | ||
var resultKey = config.resultKey; | ||
if (AWS.util.isType(resultKey, Array)) resultKey = resultKey[0]; | ||
if (Array.isArray(resultKey)) resultKey = resultKey[0]; | ||
var results = AWS.util.jamespath.query(resultKey, data); | ||
@@ -421,2 +421,3 @@ AWS.util.arrayEach(results, function(result) { | ||
createReadStream: function createReadStream() { | ||
var streams = require('stream'); | ||
var req = this; | ||
@@ -535,3 +536,3 @@ var stream = null; | ||
var response = null; | ||
if (AWS.util.isType(args, Array)) { | ||
if (Array.isArray(args)) { | ||
response = args[args.length - 1]; | ||
@@ -555,3 +556,2 @@ } else { | ||
eventParameters: function eventParameters(eventName, response) { | ||
/*jshint maxcomplexity:8*/ | ||
switch (eventName) { | ||
@@ -700,3 +700,2 @@ case 'validate': | ||
nextPage: function nextPage(callback) { | ||
/*jshint maxcomplexity:10*/ | ||
var config; | ||
@@ -745,3 +744,2 @@ var service = this.request.service; | ||
cacheNextPageTokens: function cacheNextPageTokens() { | ||
/*jshint maxcomplexity:10*/ | ||
if (this.hasOwnProperty('nextPageTokens')) return this.nextPageTokens; | ||
@@ -748,0 +746,0 @@ this.nextPageTokens = undefined; |
@@ -260,5 +260,7 @@ /** | ||
this.domain.emit('error', err); | ||
} else { | ||
} else if (process.exit) { | ||
console.error(err.stack ? err.stack : err); | ||
process.exit(1); | ||
} else { | ||
throw err; | ||
} | ||
@@ -265,0 +267,0 @@ } |
@@ -56,3 +56,2 @@ /** | ||
populateBody: function populateBody(req) { | ||
/*jshint maxcomplexity:10*/ | ||
var input = req.service.api.operations[req.operation].input; | ||
@@ -59,0 +58,0 @@ var payload = input.payload; |
@@ -76,3 +76,2 @@ /** | ||
populateBody: function populateBody(req) { | ||
/*jshint maxcomplexity:10*/ | ||
var input = req.service.api.operations[req.operation].input; | ||
@@ -79,0 +78,0 @@ var payload = input.payload; |
@@ -91,3 +91,2 @@ /** | ||
getLatestServiceVersion: function getLatestServiceVersion(version) { | ||
/*jshint maxcomplexity:10*/ | ||
if (!this.constructor.services || this.constructor.services.length === 0) { | ||
@@ -212,3 +211,2 @@ throw new Error('No services defined on ' + | ||
serviceInterface: function serviceInterface() { | ||
/*jshint maxcomplexity:8*/ | ||
switch (this.api.format) { | ||
@@ -353,3 +351,3 @@ case 'query': return AWS.EventListeners.Query; | ||
defineService: function defineService(serviceIdentifier, versions, features) { | ||
if (!AWS.util.isType(versions, Array)) { | ||
if (!Array.isArray(versions)) { | ||
features = versions; | ||
@@ -383,3 +381,3 @@ versions = []; | ||
*/ | ||
defineServiceApi: function defineServiceApi(superclass, version) { | ||
defineServiceApi: function defineServiceApi(superclass, version, apiConfig) { | ||
var svc = inherit(superclass, { | ||
@@ -392,3 +390,3 @@ serviceIdentifier: superclass.serviceIdentifier | ||
try { | ||
svc.prototype.api = require('./services/api/' + apiFile); | ||
svc.prototype.api = apiConfig || require('./services/api/' + apiFile); | ||
} catch (err) { | ||
@@ -395,0 +393,0 @@ throw AWS.util.error(err, { |
@@ -83,2 +83,6 @@ /** | ||
}, | ||
StackPolicyBody: { | ||
}, | ||
StackPolicyURL: { | ||
}, | ||
Tags: { | ||
@@ -389,2 +393,20 @@ type: 'list', | ||
}, | ||
getStackPolicy: { | ||
name: 'GetStackPolicy', | ||
input: { | ||
type: 'structure', | ||
members: { | ||
StackName: { | ||
required: true | ||
} | ||
} | ||
}, | ||
output: { | ||
type: 'structure', | ||
members: { | ||
StackPolicyBody: { | ||
} | ||
} | ||
} | ||
}, | ||
getTemplate: { | ||
@@ -498,2 +520,22 @@ name: 'GetTemplate', | ||
}, | ||
setStackPolicy: { | ||
name: 'SetStackPolicy', | ||
input: { | ||
type: 'structure', | ||
members: { | ||
StackName: { | ||
required: true | ||
}, | ||
StackPolicyBody: { | ||
}, | ||
StackPolicyURL: { | ||
} | ||
} | ||
}, | ||
output: { | ||
type: 'structure', | ||
members: { | ||
} | ||
} | ||
}, | ||
updateStack: { | ||
@@ -511,2 +553,6 @@ name: 'UpdateStack', | ||
}, | ||
StackPolicyDuringUpdateBody: { | ||
}, | ||
StackPolicyDuringUpdateURL: { | ||
}, | ||
Parameters: { | ||
@@ -528,2 +574,6 @@ type: 'list', | ||
} | ||
}, | ||
StackPolicyBody: { | ||
}, | ||
StackPolicyURL: { | ||
} | ||
@@ -530,0 +580,0 @@ } |
@@ -22,3 +22,3 @@ /** | ||
serviceFullName: 'Amazon CloudSearch', | ||
signatureVersion: 'v2', | ||
signatureVersion: 'v4', | ||
timestampFormat: 'iso8601', | ||
@@ -25,0 +25,0 @@ operations: { |
@@ -453,2 +453,31 @@ /** | ||
}, | ||
describeLoadBalancerAttributes: { | ||
name: 'DescribeLoadBalancerAttributes', | ||
input: { | ||
type: 'structure', | ||
members: { | ||
LoadBalancerName: { | ||
required: true | ||
} | ||
} | ||
}, | ||
output: { | ||
type: 'structure', | ||
members: { | ||
LoadBalancerAttributes: { | ||
type: 'structure', | ||
members: { | ||
CrossZoneLoadBalancing: { | ||
type: 'structure', | ||
members: { | ||
Enabled: { | ||
type: 'boolean' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
describeLoadBalancerPolicies: { | ||
@@ -806,2 +835,33 @@ name: 'DescribeLoadBalancerPolicies', | ||
}, | ||
modifyLoadBalancerAttributes: { | ||
name: 'ModifyLoadBalancerAttributes', | ||
input: { | ||
type: 'structure', | ||
members: { | ||
LoadBalancerName: { | ||
required: true | ||
}, | ||
LoadBalancerAttributes: { | ||
type: 'structure', | ||
members: { | ||
CrossZoneLoadBalancing: { | ||
type: 'structure', | ||
members: { | ||
Enabled: { | ||
type: 'boolean', | ||
required: true | ||
} | ||
} | ||
} | ||
}, | ||
required: true | ||
} | ||
} | ||
}, | ||
output: { | ||
type: 'structure', | ||
members: { | ||
} | ||
} | ||
}, | ||
registerInstancesWithLoadBalancer: { | ||
@@ -808,0 +868,0 @@ name: 'RegisterInstancesWithLoadBalancer', |
@@ -17,4 +17,7 @@ /** | ||
var AWS = require('../core'); | ||
var Stream = require('stream').Stream; | ||
/* jshint -W079 */ | ||
var Buffer = require('buffer').Buffer; | ||
/* jshint +W079 */ | ||
AWS.S3 = AWS.Service.defineService('s3', ['2006-03-01'], { | ||
@@ -30,2 +33,3 @@ /** | ||
setupRequestListeners: function setupRequestListeners(request) { | ||
request.addListener('build', this.addContentType); | ||
request.addListener('build', this.populateURI); | ||
@@ -66,4 +70,20 @@ request.addListener('build', this.computeContentMd5); | ||
/** | ||
* Adds a default content type if none is supplied. | ||
* | ||
* @api private | ||
*/ | ||
addContentType: function addContentType(req) { | ||
var httpRequest = req.httpRequest; | ||
if (!httpRequest.headers['Content-Type']) { // always have a Content-Type | ||
httpRequest.headers['Content-Type'] = 'application/octet-stream'; | ||
if (AWS.util.isBrowser() && navigator.userAgent.match(/Firefox/)) { | ||
var charset = '; charset=' + document.characterSet; | ||
httpRequest.headers['Content-Type'] += charset; | ||
} | ||
} | ||
}, | ||
/** | ||
* @api private | ||
*/ | ||
computableChecksumOperations: { | ||
@@ -91,3 +111,6 @@ putBucketCors: true, | ||
// TODO: compute checksums for Stream objects | ||
if (req.httpRequest.body instanceof Stream) return false; | ||
if (!Buffer.isBuffer(req.httpRequest.body) && | ||
typeof req.httpRequest.body !== 'string') { | ||
return false; | ||
} | ||
@@ -291,2 +314,3 @@ var rules = req.service.api.operations[req.operation].input.members; | ||
delete request.httpRequest.headers['User-Agent']; | ||
delete request.httpRequest.headers['X-Amz-User-Agent']; | ||
request.httpRequest.headers[expiresHeader] = parseInt( | ||
@@ -322,2 +346,3 @@ AWS.util.date.unixTimestamp() + expires, 10).toString(); | ||
request.on('sign', signedUrlSigner); | ||
request.removeListener('build', this.addContentType); | ||
if (!params.Body) { // no Content-MD5 signing if body is not provided | ||
@@ -324,0 +349,0 @@ request.removeListener('build', this.computeContentMd5); |
@@ -18,4 +18,4 @@ /** | ||
AWS.StorageGateway = AWS.Service.defineService('storagegateway', ['2012-06-30']); | ||
AWS.StorageGateway = AWS.Service.defineService('storagegateway', ['2013-06-30', '2012-06-30']); | ||
module.exports = AWS.StorageGateway; |
@@ -28,3 +28,3 @@ /** | ||
stringToSign: function stringToSign() { | ||
return this.request.headers['Date']; | ||
return this.request.headers['X-Amz-Date']; | ||
} | ||
@@ -31,0 +31,0 @@ }); |
@@ -29,3 +29,2 @@ /** | ||
AWS.Signers.RequestSigner.getVersion = function getVersion(version) { | ||
/*jshint maxcomplexity:8*/ | ||
switch (version) { | ||
@@ -32,0 +31,0 @@ case 'v2': return AWS.Signers.V2; |
@@ -38,2 +38,3 @@ /** | ||
'requestPayment': 1, | ||
'restore': 1, | ||
'tagging': 1, | ||
@@ -62,3 +63,3 @@ 'torrent': 1, | ||
if (!this.request.headers['presigned-expires']) { | ||
this.request.headers['Date'] = AWS.util.date.rfc822(date); | ||
this.request.headers['X-Amz-Date'] = AWS.util.date.rfc822(date); | ||
} | ||
@@ -84,3 +85,8 @@ | ||
parts.push(r.headers['Content-Type'] || ''); | ||
parts.push(r.headers['presigned-expires'] || r.headers['Date'] || ''); | ||
// This is the "Date" header, but we use X-Amz-Date. | ||
// The S3 signing mechanism requires us to pass an empty | ||
// string for this Date header regardless. | ||
parts.push(r.headers['presigned-expires'] || ''); | ||
var headers = this.canonicalizedAmzHeaders(); | ||
@@ -87,0 +93,0 @@ if (headers) parts.push(headers); |
@@ -27,3 +27,2 @@ /** | ||
this.request.headers['Date'] = datetime; | ||
this.request.headers['X-Amz-Date'] = datetime; | ||
@@ -30,0 +29,0 @@ |
@@ -41,3 +41,2 @@ /** | ||
addHeaders: function addHeaders(credentials, datetime) { | ||
this.request.headers['Date'] = datetime; | ||
this.request.headers['X-Amz-Date'] = datetime; | ||
@@ -111,3 +110,5 @@ if (credentials.sessionToken) { | ||
AWS.util.arrayEach.call(this, headers, function (item) { | ||
if (item[0] !== 'Authorization') { | ||
if (item[0] !== 'Authorization' && | ||
item[0] !== 'User-Agent' && item[0] !== 'X-Amz-User-Agent' && | ||
item[0] !== 'Content-Type') { | ||
parts.push(item[0].toLowerCase() + ':' + | ||
@@ -128,3 +129,4 @@ this.canonicalHeaderValues(item[1].toString())); | ||
key = key.toLowerCase(); | ||
if (key !== 'authorization') keys.push(key); | ||
if (key !== 'authorization' && key !== 'user-agent' && | ||
key !== 'x-amz-user-agent' && key !== 'content-type') keys.push(key); | ||
}); | ||
@@ -131,0 +133,0 @@ return keys.sort().join(';'); |
@@ -21,2 +21,6 @@ /** | ||
/* jshint -W079 */ | ||
var Buffer = require('buffer').Buffer; | ||
/* jshint +W079 */ | ||
/** | ||
@@ -37,11 +41,20 @@ * A set of utility methods for use with the AWS SDK. | ||
AWS.util = { | ||
engine: function enc() { | ||
return process.platform + '/' + process.version; | ||
engine: function engine() { | ||
if (AWS.util.isBrowser() && typeof navigator !== 'undefined') { | ||
return navigator.userAgent; | ||
} else { | ||
return process.platform + '/' + process.version; | ||
} | ||
}, | ||
userAgent: function userAgent() { | ||
return 'aws-sdk-nodejs/' + AWS.VERSION + ' ' + AWS.util.engine(); | ||
var name = AWS.util.isBrowser() ? 'js' : 'nodejs'; | ||
var agent = 'aws-sdk-' + name + '/' + AWS.VERSION; | ||
if (name === 'nodejs') agent += ' ' + AWS.util.engine(); | ||
return agent; | ||
}, | ||
isBrowser: function isBrowser() { return typeof window !== 'undefined'; }, | ||
isNode: function isNode() { return !AWS.util.isBrowser(); }, | ||
uriEscape: function uriEscape(string) { | ||
@@ -95,2 +108,3 @@ /*jshint undef:false */ | ||
readFileSync: function readFileSync(path) { | ||
if (typeof window !== 'undefined') return null; | ||
return require('fs').readFileSync(path, 'utf-8'); | ||
@@ -142,10 +156,13 @@ }, | ||
if (string.length !== undefined) { | ||
if (typeof string.byteLength === 'number') { | ||
return string.byteLength; | ||
} else if (typeof string.length === 'number') { | ||
return string.length; | ||
} else if (typeof(string.path) === 'string') { | ||
} else if (typeof string.size === 'number') { | ||
return string.size; | ||
} else if (typeof string.path === 'string') { | ||
return require('fs').lstatSync(string.path).size; | ||
} else { | ||
throw AWS.util.error(new Error(), { | ||
message: 'Cannot determine length of ' + string, object: string | ||
}); | ||
throw AWS.util.error(new Error('Cannot determine length of ' + string), | ||
{ object: string }); | ||
} | ||
@@ -182,3 +199,3 @@ } | ||
AWS.util.arrayEach.call(this, objects, function (obj) { | ||
if (AWS.util.isType(obj, Array)) { | ||
if (Array.isArray(obj)) { | ||
if (match[2] === '*') { | ||
@@ -344,3 +361,4 @@ newObjects = newObjects.concat(obj); | ||
for (var i = 0; i < data.length; i++) { | ||
crc = (crc>>>8) ^ tbl[(crc^data[i])&0xFF]; | ||
var code = data.readUInt8(i); | ||
crc = (crc>>>8) ^ tbl[(crc^code)&0xFF]; | ||
} | ||
@@ -441,6 +459,13 @@ return (crc ^ -1) >>> 0; | ||
// handle cross-"frame" objects | ||
if (typeof type === 'function') type = type.name; | ||
if (typeof type === 'function') type = AWS.util.typeName(type); | ||
return Object.prototype.toString.call(obj) === '[object ' + type + ']'; | ||
}, | ||
typeName: function typeName(type) { | ||
if (type.hasOwnProperty('name')) return type.name; | ||
var str = type.toString(); | ||
var match = str.match(/^\s*function (.+)\(/); | ||
return match ? match[1] : str; | ||
}, | ||
error: function error(err, options) { | ||
@@ -447,0 +472,0 @@ err.message = err.message || null; |
{ | ||
"name": "aws-sdk", | ||
"description": "AWS SDK for JavaScript", | ||
"version": "1.10.0", | ||
"version": "1.12.0", | ||
"author": { | ||
@@ -16,12 +16,12 @@ "name":"Amazon Web Services", | ||
"devDependencies": { | ||
"repl.history": "latest", | ||
"jasmine-node": "latest", | ||
"semver": "latest", | ||
"coffee-script": "latest", | ||
"jshint": "2.1.0", | ||
"cucumber": "latest" | ||
"repl.history": "", | ||
"jasmine-node": "", | ||
"semver": "", | ||
"coffee-script": "", | ||
"jshint": "", | ||
"cucumber": "" | ||
}, | ||
"dependencies": { | ||
"xml2js": "0.2.4", | ||
"xmlbuilder": "latest" | ||
"xmlbuilder": "0.4.2" | ||
}, | ||
@@ -28,0 +28,0 @@ "main": "lib/aws.js", |
@@ -1,4 +0,5 @@ | ||
# AWS SDK for Node.js [![NPM version](https://badge.fury.io/js/aws-sdk.png)](http://badge.fury.io/js/aws-sdk) [![Build Status](https://travis-ci.org/aws/aws-sdk-js.png?branch=master)](https://travis-ci.org/aws/aws-sdk-js) | ||
# AWS SDK for JavaScript [![Version](https://badge.fury.io/js/aws-sdk.png)](http://badge.fury.io/js/aws-sdk) [![Build Status](https://travis-ci.org/aws/aws-sdk-js.png?branch=master)](https://travis-ci.org/aws/aws-sdk-js) | ||
The official JavaScript implementation of the AWS SDK for Node.js. | ||
The official AWS SDK for JavaScript, available for browsers and mobile devices, | ||
or Node.js backends | ||
@@ -9,2 +10,11 @@ Release notes can be found at http://aws.amazon.com/releasenotes/SDK/JavaScript | ||
### In the Browser | ||
To use the SDK in the browser, simply add the following script tag to your | ||
HTML pages: | ||
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.0.0-rc1.min.js"></script> | ||
### In Node.js | ||
The preferred way to install the AWS SDK for Node.js is to use the | ||
@@ -18,49 +28,7 @@ [npm](http://npmjs.org) package manager for Node.js. Simply type the following | ||
## Usage | ||
## Usage and Getting Started | ||
After you've installed the SDK, you can require the AWS package in your node | ||
application using `require`: | ||
```js | ||
var AWS = require('aws-sdk'); | ||
``` | ||
Here is a quick example that makes some requests against Amazon S3 with the SDK: | ||
```js | ||
// Load the AWS SDK for Node.js | ||
var AWS = require('aws-sdk'); | ||
/** | ||
* Don't hard-code your credentials! | ||
* Load them from disk or your environment instead. | ||
*/ | ||
// AWS.config.update({accessKeyId: 'AKID', secretAccessKey: 'SECRET'}); | ||
// Instead, do this: | ||
AWS.config.loadFromPath('./path/to/credentials.json'); | ||
// Set your region for future requests. | ||
AWS.config.update({region: 'us-east-1'}); | ||
// Create a bucket using bound parameters and put something in it. | ||
// Make sure to change the bucket name from "myBucket" to something unique. | ||
var s3bucket = new AWS.S3({params: {Bucket: 'myBucket'}}); | ||
s3bucket.createBucket(function() { | ||
var data = {Key: 'myKey', Body: 'Hello!'}; | ||
s3bucket.putObject(data, function(err, data) { | ||
if (err) { | ||
console.log("Error uploading data: ", err); | ||
} else { | ||
console.log("Successfully uploaded data to myBucket/myKey"); | ||
} | ||
}); | ||
}); | ||
``` | ||
## Getting Started Guide | ||
You can find a getting started guide at: | ||
http://docs.amazonwebservices.com/nodejs/latest/dg/ | ||
http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/ | ||
@@ -67,0 +35,0 @@ ## Supported Services |
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
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
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
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
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
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
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
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
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
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
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
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
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
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
3909037
302
112227
102
15
+ Addedxmlbuilder@0.4.2(transitive)
- Removedxmlbuilder@15.1.1(transitive)
Updatedxmlbuilder@0.4.2