ACM = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
APIGateway = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
AppStream = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
ApplicationAutoScaling = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
AutoScaling = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
Batch = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
Budgets = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
CUR = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
CloudDirectory = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
CloudFormation = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
CloudFront = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Signer(keyPairId, privateKey) { if (keyPairId === void 0 || privateKey === void 0) { throw new Error('A key pair ID and private key are required'); } this.keyPairId = keyPairId; this.privateKey = privateKey; }
n/a
CloudHSM = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
CloudSearch = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
CloudSearchDomain = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
CloudTrail = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
CloudWatch = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
CloudWatchEvents = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
CloudWatchLogs = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
CodeBuild = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
CodeCommit = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
CodeDeploy = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
CodePipeline = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
CognitoIdentity = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function CognitoIdentityCredentials(params, clientConfig) { AWS.Credentials.call(this); this.expired = true; this.params = params; this.data = null; this._identityId = null; this._clientConfig = AWS.util.copy(clientConfig || {}); this.loadCachedId(); var self = this; Object.defineProperty(this, 'identityId', { get: function() { self.loadCachedId(); return self._identityId || self.params.IdentityId; }, set: function(identityId) { self._identityId = identityId; } }); }
n/a
CognitoIdentityServiceProvider = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
CognitoSync = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Config(options) { if (options === undefined) options = {}; options = this.extractCredentials(options); AWS.util.each.call(this, this.keys, function (key, value) { this.set(key, options[key], value); }); }
...
/**
* Creates a new configuration object. This is the object that passes
* option data along to service requests, including credentials, security,
* region information, and some service specific settings.
*
* @example Creating a new configuration object with credentials and region
* var config = new AWS.Config({
* accessKeyId: 'AKID', secretAccessKey: 'SECRET', region: 'us-west-2'
* });
* @option options accessKeyId [String] your AWS access key ID.
* @option options secretAccessKey [String] your AWS secret access key.
* @option options sessionToken [AWS.Credentials] the optional AWS
* session token to sign requests with.
* @option options credentials [AWS.Credentials] the AWS credentials
...
ConfigService = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function CredentialProviderChain(providers) { if (providers) { this.providers = providers; } else { this.providers = AWS.CredentialProviderChain.defaultProviders.slice(0); } }
...
* @return [AWS.Config] the same configuration object
*/
loadFromPath: function loadFromPath(path) {
this.clear();
var options = JSON.parse(AWS.util.readFileSync(path));
var fileSystemCreds = new AWS.FileSystemCredentials(path);
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
...
function Credentials() { // hide secretAccessKey from being displayed with util.inspect AWS.util.hideProperties(this, ['secretAccessKey']); this.expired = false; this.expireTime = null; if (arguments.length === 1 && typeof arguments[0] === 'object') { var creds = arguments[0].credentials || arguments[0]; this.accessKeyId = creds.accessKeyId; this.secretAccessKey = creds.secretAccessKey; this.sessionToken = creds.sessionToken; } else { this.accessKeyId = arguments[0]; this.secretAccessKey = arguments[1]; this.sessionToken = arguments[2]; } }
...
* from a configuration hash.
*
* @api private
*/
extractCredentials: function extractCredentials(options) {
if (options.accessKeyId && options.secretAccessKey) {
options = AWS.util.copy(options);
options.credentials = new AWS.Credentials(options);
}
return options;
},
/**
* Sets the promise dependency the SDK will use wherever Promises are returned.
* Passing `null` will force the SDK to use native Promises if they are available.
...
DMS = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
DataPipeline = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
DeviceFarm = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
DirectConnect = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
DirectoryService = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
Discovery = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
DynamoDB = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function DocumentClient(options) { var self = this; self.options = options || {}; self.configure(self.options); }
n/a
DynamoDBStreams = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
EC2 = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function EC2MetadataCredentials(options) { AWS.Credentials.call(this); options = options ? AWS.util.copy(options) : {}; options = AWS.util.merge( {maxRetries: this.defaultMaxRetries}, options); if (!options.httpOptions) options.httpOptions = {}; options.httpOptions = AWS.util.merge( {timeout: this.defaultTimeout}, options.httpOptions); this.metadataService = new AWS.MetadataService(options); this.metadata = {}; }
...
function () { return new AWS.EnvironmentCredentials('AWS'); },
function () { return new AWS.EnvironmentCredentials('AMAZON'); },
function () { return new AWS.SharedIniFileCredentials(); },
function () {
if (AWS.ECSCredentials.prototype.getECSRelativeUri() !== undefined) {
return new AWS.ECSCredentials();
}
return new AWS.EC2MetadataCredentials();
}
];
// Update configuration keys
AWS.util.update(AWS.Config.prototype.keys, {
credentials: function () {
var credentials = null;
...
ECR = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
ECS = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function ECSCredentials(options) { AWS.Credentials.call(this); options = options ? AWS.util.copy(options) : {}; if (!options.httpOptions) options.httpOptions = {}; options.httpOptions = AWS.util.merge( this.httpOptions, options.httpOptions); AWS.util.update(this, options); }
...
// credentials/credential_provider_chain.js
AWS.CredentialProviderChain.defaultProviders = [
function () { return new AWS.EnvironmentCredentials('AWS'); },
function () { return new AWS.EnvironmentCredentials('AMAZON'); },
function () { return new AWS.SharedIniFileCredentials(); },
function () {
if (AWS.ECSCredentials.prototype.getECSRelativeUri() !== undefined) {
return new AWS.ECSCredentials();
}
return new AWS.EC2MetadataCredentials();
}
];
// Update configuration keys
AWS.util.update(AWS.Config.prototype.keys, {
...
EFS = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
ELB = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
ELBv2 = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
EMR = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
ES = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
ElastiCache = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
ElasticBeanstalk = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
ElasticTranscoder = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Endpoint(endpoint, config) { AWS.util.hideProperties(this, ['slashes', 'auth', 'hash', 'search', 'query']); if (typeof endpoint === 'undefined' || endpoint === null) { throw new Error('Invalid endpoint: ' + endpoint); } else if (typeof endpoint !== 'string') { return AWS.util.copy(endpoint); } if (!endpoint.match(/^http/)) { var useSSL = config && config.sslEnabled !== undefined ? config.sslEnabled : AWS.config.sslEnabled; endpoint = (useSSL ? 'https' : 'http') + '://' + endpoint; } AWS.util.update(this, AWS.util.urlParse(endpoint)); // Ensure the port property is set as an integer if (this.port) { this.port = parseInt(this.port, 10); } else { this.port = this.protocol === 'https:' ? 443 : 80; } }
...
}
});
add('REDIRECT', 'retry', function REDIRECT(resp) {
if (resp.error && resp.error.statusCode >= 300 &&
resp.error.statusCode < 400 && resp.httpResponse.headers['location']) {
this.httpRequest.endpoint =
new AWS.Endpoint(resp.httpResponse.headers['location']);
this.httpRequest.headers['Host'] = this.httpRequest.endpoint.host;
resp.error.redirect = true;
resp.error.retryable = true;
}
});
add('RETRY_CHECK', 'retry', function RETRY_CHECK(resp) {
...
function EnvironmentCredentials(envPrefix) { AWS.Credentials.call(this); this.envPrefix = envPrefix; this.get(function() {}); }
...
require('./credentials/shared_ini_file_credentials');
// Setup default chain providers
// If this changes, please update documentation for
// AWS.CredentialProviderChain.defaultProviders in
// credentials/credential_provider_chain.js
AWS.CredentialProviderChain.defaultProviders = [
function () { return new AWS.EnvironmentCredentials('AWS'); },
function () { return new AWS.EnvironmentCredentials('AMAZON'); },
function () { return new AWS.SharedIniFileCredentials(); },
function () {
if (AWS.ECSCredentials.prototype.getECSRelativeUri() !== undefined) {
return new AWS.ECSCredentials();
}
return new AWS.EC2MetadataCredentials();
...
function FileSystemCredentials(filename) { AWS.Credentials.call(this); this.filename = filename; this.get(function() {}); }
...
* working directory to load configuration from.
* @return [AWS.Config] the same configuration object
*/
loadFromPath: function loadFromPath(path) {
this.clear();
var options = JSON.parse(AWS.util.readFileSync(path));
var fileSystemCreds = new AWS.FileSystemCredentials(path);
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
...
Firehose = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
GameLift = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
Glacier = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
Health = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
HttpClient = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function HttpRequest(endpoint, region) { endpoint = new AWS.Endpoint(endpoint); this.method = 'POST'; this.path = endpoint.path || '/'; this.headers = {}; this.body = ''; this.endpoint = endpoint; this.region = region; this._userAgent = ''; this.setUserAgent(); }
...
req.httpRequest.headers['Host'] = req.httpRequest.endpoint.host;
});
add('RESTART', 'restart', function RESTART() {
var err = this.response.error;
if (!err || !err.retryable) return;
this.httpRequest = new AWS.HttpRequest(
this.service.endpoint,
this.service.region
);
if (this.response.retryCount < this.service.config.maxRetries) {
this.response.retryCount++;
} else {
...
function HttpResponse() { this.statusCode = undefined; this.headers = {}; this.body = undefined; this.streaming = false; this.stream = null; }
...
*/
constructor: function Response(request) {
this.request = request;
this.data = null;
this.error = null;
this.retryCount = 0;
this.redirectCount = 0;
this.httpResponse = new AWS.HttpResponse();
if (request) {
this.maxRetries = request.service.numRetries();
this.maxRedirects = request.service.config.maxRedirects;
}
},
/**
...
IAM = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
ImportExport = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
Inspector = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
Iot = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
IotData = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function JsonBuilder() { }
n/a
function JsonParser() { }
n/a
KMS = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
Kinesis = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
KinesisAnalytics = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
Lambda = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
LexRuntime = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
Lightsail = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
MTurk = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
MachineLearning = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
MarketplaceCommerceAnalytics = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
MarketplaceMetering = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function MetadataService(options) { AWS.util.update(this, options); }
n/a
MobileAnalytics = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Shape(shape, options, memberName) { options = options || {}; property(this, 'shape', shape.shape); property(this, 'api', options.api, false); property(this, 'type', shape.type); property(this, 'enum', shape.enum); property(this, 'min', shape.min); property(this, 'max', shape.max); property(this, 'pattern', shape.pattern); property(this, 'location', shape.location || this.location || 'body'); property(this, 'name', this.name || shape.xmlName || shape.queryName || shape.locationName || memberName); property(this, 'isStreaming', shape.streaming || this.isStreaming || false); property(this, 'isComposite', shape.isComposite || false); property(this, 'isShape', true, false); property(this, 'isQueryName', Boolean(shape.queryName), false); property(this, 'isLocationName', Boolean(shape.locationName), false); property(this, 'isIdempotent', shape.idempotencyToken === true); property(this, 'isJsonValue', shape.jsonvalue === true); if (options.documentation) { property(this, 'documentation', shape.documentation); property(this, 'documentationUrl', shape.documentationUrl); } if (shape.xmlAttribute) { property(this, 'isXmlAttribute', shape.xmlAttribute || false); } // type conversion and parsing property(this, 'defaultValue', null); this.toWireFormat = function(value) { if (value === null || value === undefined) return ''; return value; }; this.toType = function(value) { return value; }; }
n/a
NodeHttpClient = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
OpsWorks = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
OpsWorksCM = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
Organizations = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function ParamValidator(validation) { if (validation === true || validation === undefined) { validation = {'min': true}; } this.validation = validation; }
...
}
req.params = params;
});
add('VALIDATE_PARAMETERS', 'validate', function VALIDATE_PARAMETERS(req) {
var rules = req.service.api.operations[req.operation].input;
var validation = req.service.config.paramValidation;
new AWS.ParamValidator(validation).validate(rules, req.params);
});
addAsync('COMPUTE_SHA256', 'afterBuild', function COMPUTE_SHA256(req, done) {
req.haltHandlersOnError();
if (!req.service.api.signatureVersion) return done(); // none
if (req.service.getSignerClass(req) === AWS.Signers.V4) {
var body = req.httpRequest.body || '';
...
Pinpoint = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
Polly = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Signer(options) { options = options || {}; this.options = options; this.service = options.service; this.bindServiceObject(options); this._operations = {}; }
n/a
RDS = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
Redshift = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
Rekognition = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Request(service, operation, params) { var endpoint = service.endpoint; var region = service.config.region; var customUserAgent = service.config.customUserAgent; // global endpoints sign as us-east-1 if (service.isGlobalEndpoint) region = 'us-east-1'; this.domain = domain && domain.active; this.service = service; this.operation = operation; this.params = params || {}; this.httpRequest = new AWS.HttpRequest(endpoint, region); this.httpRequest.appendToUserAgent(customUserAgent); this.startTime = AWS.util.date.getDate(); this.response = new AWS.Response(this); this._asm = new AcceptorStateMachine(fsm.states, 'validate'); this._haltHandlersOnError = false; AWS.SequentialExecutor.call(this); this.emit = this.emitEvent; }
n/a
function constructor(service, state) { this.service = service; this.state = state; this.loadWaiterConfig(this.state); }
...
/**
* Waits for a given state on a service object
* @param service [Service] the service object to wait on
* @param state [String] the state (defined in waiter configuration) to wait
* for.
* @example Create a waiter for running EC2 instances
* var ec2 = new AWS.EC2;
* var waiter = new AWS.ResourceWaiter(ec2, 'instanceRunning');
*/
constructor: function constructor(service, state) {
this.service = service;
this.state = state;
this.loadWaiterConfig(this.state);
},
...
function Response(request) { this.request = request; this.data = null; this.error = null; this.retryCount = 0; this.redirectCount = 0; this.httpResponse = new AWS.HttpResponse(); if (request) { this.maxRetries = request.service.numRetries(); this.maxRedirects = request.service.config.maxRedirects; } }
...
this.service = service;
this.operation = operation;
this.params = params || {};
this.httpRequest = new AWS.HttpRequest(endpoint, region);
this.httpRequest.appendToUserAgent(customUserAgent);
this.startTime = AWS.util.date.getDate();
this.response = new AWS.Response(this);
this._asm = new AcceptorStateMachine(fsm.states, 'validate');
this._haltHandlersOnError = false;
AWS.SequentialExecutor.call(this);
this.emit = this.emitEvent;
},
...
Route53 = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
Route53Domains = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
S3 = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function ManagedUpload(options) { var self = this; AWS.SequentialExecutor.call(self); self.body = null; self.sliceFn = null; self.callback = null; self.parts = {}; self.completeInfo = []; self.fillQueue = function() { self.callback(new Error('Unsupported body payload ' + typeof self.body)); }; self.configure(options); }
n/a
function SAMLCredentials(params) { AWS.Credentials.call(this); this.expired = true; this.params = params; }
n/a
SES = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
SMS = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
SNS = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
SQS = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
SSM = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
STS = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
SWF = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function SequentialExecutor() { this._events = {}; }
...
return expected === resp.error.code;
}
// if expected is not string, can be boolean indicating presence of error
return expected === !!resp.error;
}
},
listeners: new AWS.SequentialExecutor().addNamedListeners(function(add) {
add('RETRY_CHECK', 'retry', function(resp) {
var waiter = resp.request._waiter;
if (resp.error && resp.error.code === 'ResourceNotReady') {
resp.error.retryDelay = (waiter.config.delay || 0) * 1000;
}
});
...
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
ServiceCatalog = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function SharedIniFileCredentials(options) { AWS.Credentials.call(this); options = options || {}; this.filename = options.filename; this.profile = options.profile || process.env.AWS_PROFILE || 'default'; this.disableAssumeRole = !!options.disableAssumeRole; this.get(function() {}); }
...
// Setup default chain providers
// If this changes, please update documentation for
// AWS.CredentialProviderChain.defaultProviders in
// credentials/credential_provider_chain.js
AWS.CredentialProviderChain.defaultProviders = [
function () { return new AWS.EnvironmentCredentials('AWS'); },
function () { return new AWS.EnvironmentCredentials('AMAZON'); },
function () { return new AWS.SharedIniFileCredentials(); },
function () {
if (AWS.ECSCredentials.prototype.getECSRelativeUri() !== undefined) {
return new AWS.ECSCredentials();
}
return new AWS.EC2MetadataCredentials();
}
];
...
Shield = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
Signers.Presign = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
* @api private
*/
presign: function presign(expires, callback) {
if (!callback && typeof expires === 'function') {
callback = expires;
expires = null;
}
return new AWS.Signers.Presign().sign(this.toGet(), expires, callback);
},
/**
* @api private
*/
isPresigned: function isPresigned() {
return Object.prototype.hasOwnProperty.call(this.httpRequest.headers, 'presigned-expires');
...
function RequestSigner(request) { this.request = request; }
n/a
Signers.S3 = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
Signers.V2 = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
Signers.V3 = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
Signers.V3Https = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function V4(request, serviceName, signatureCache) { AWS.Signers.RequestSigner.call(this, request); this.serviceName = serviceName; this.signatureCache = signatureCache; }
n/a
SimpleDB = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
Snowball = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
StepFunctions = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
StorageGateway = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
Support = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function TemporaryCredentials(params, masterCredentials) { AWS.Credentials.call(this); this.loadMasterCredentials(masterCredentials); this.expired = true; this.params = params || {}; if (this.params.RoleArn) { this.params.RoleSessionName = this.params.RoleSessionName || 'temporary-credentials'; } }
n/a
WAF = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
WAFRegional = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function WebIdentityCredentials(params, clientConfig) { AWS.Credentials.call(this); this.expired = true; this.params = params; this.params.RoleSessionName = this.params.RoleSessionName || 'web-identity'; this.data = null; this._clientConfig = AWS.util.copy(clientConfig || {}); }
n/a
WorkDocs = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
WorkSpaces = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
XHRClient = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function XmlBuilder() { }
n/a
function NodeXmlParser() { }
n/a
XRay = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
apiLoader = function (svc, version) { if (!AWS.apiLoader.services.hasOwnProperty(svc)) { throw new Error('InvalidService: Failed to load api for ' + svc); } return AWS.apiLoader.services[svc][version]; }
n/a
function AcceptorStateMachine(states, state) { this.currentState = state || null; this.states = states || {}; }
n/a
function Buffer(arg, encodingOrOffset, length) { // Common case. if (typeof arg === 'number') { if (typeof encodingOrOffset === 'string') { throw new Error( 'If encoding is specified then the first argument must be a string' ); } return Buffer.allocUnsafe(arg); } return Buffer.from(arg, encodingOrOffset, length); }
...
});
add('HTTP_HEADERS', 'httpHeaders',
function HTTP_HEADERS(statusCode, headers, resp, statusMessage) {
resp.httpResponse.statusCode = statusCode;
resp.httpResponse.statusMessage = statusMessage;
resp.httpResponse.headers = headers;
resp.httpResponse.body = new AWS.util.Buffer('');
resp.httpResponse.buffers = [];
resp.httpResponse.numBytes = 0;
var dateHeader = headers.date || headers.Date;
if (dateHeader) {
var serverTime = Date.parse(dateHeader);
if (resp.request.service.config.correctClockSkew
&& AWS.util.isClockSkewed(serverTime)) {
...
ACM = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
APIGateway = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function setAcceptHeader(req) { var httpRequest = req.httpRequest; httpRequest.headers['Accept'] = 'application/json'; }
n/a
function setupRequestListeners(request) { request.addListener('build', this.setAcceptHeader); if (request.operation === 'getSdk') { request.addListener('extractData', this.useRawPayload); } }
n/a
function useRawPayload(resp) { var req = resp.request; var operation = req.operation; var rules = req.service.api.operations[operation].output || {}; if (rules.payload) { var body = resp.httpResponse.body; resp.data[rules.payload] = body; } }
n/a
AppStream = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
ApplicationAutoScaling = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
AutoScaling = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
Batch = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
Budgets = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
CUR = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
CloudDirectory = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
CloudFormation = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
CloudFront = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Signer(keyPairId, privateKey) { if (keyPairId === void 0 || privateKey === void 0) { throw new Error('A key pair ID and private key are required'); } this.keyPairId = keyPairId; this.privateKey = privateKey; }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
function Signer(keyPairId, privateKey) { if (keyPairId === void 0 || privateKey === void 0) { throw new Error('A key pair ID and private key are required'); } this.keyPairId = keyPairId; this.privateKey = privateKey; }
n/a
function Object() { [native code] }
n/a
function Signer(keyPairId, privateKey) { if (keyPairId === void 0 || privateKey === void 0) { throw new Error('A key pair ID and private key are required'); } this.keyPairId = keyPairId; this.privateKey = privateKey; }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
getSignedCookie = function (options, cb) { var signatureHash = 'policy' in options ? signWithCustomPolicy(options.policy, this.keyPairId, this.privateKey) : signWithCannedPolicy(options.url, options.expires, this.keyPairId, this.privateKey); var cookieHash = {}; for (var key in signatureHash) { if (Object.prototype.hasOwnProperty.call(signatureHash, key)) { cookieHash['CloudFront-' + key] = signatureHash[key]; } } return handleSuccess(cookieHash, cb); }
n/a
getSignedUrl = function (options, cb) { try { var resource = getResource(options.url); } catch (err) { return handleError(err, cb); } var parsedUrl = url.parse(options.url, true), signatureHash = Object.prototype.hasOwnProperty.call(options, 'policy') ? signWithCustomPolicy(options.policy, this.keyPairId, this.privateKey) : signWithCannedPolicy(resource, options.expires, this.keyPairId, this.privateKey); parsedUrl.search = null; for (var key in signatureHash) { if (Object.prototype.hasOwnProperty.call(signatureHash, key)) { parsedUrl.query[key] = signatureHash[key]; } } try { var signedUrl = determineScheme(options.url) === 'rtmp' ? getRtmpUrl(url.format(parsedUrl)) : url.format(parsedUrl); } catch (err) { return handleError(err, cb); } return handleSuccess(signedUrl, cb); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function setupRequestListeners(request) { request.addListener('extractData', AWS.util.hoistPayloadMember); }
n/a
CloudHSM = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
CloudSearch = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
CloudSearchDomain = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
convertGetToPost = function (request) { var httpRequest = request.httpRequest // convert queries to POST to avoid length restrictions var path = httpRequest.path.split('?') httpRequest.method = 'POST' httpRequest.path = path[0] httpRequest.body = path[1] httpRequest.headers['Content-Length'] = httpRequest.body.length httpRequest.headers['Content-Type'] = 'application/x-www-form-urlencoded' }
n/a
function setupRequestListeners(request) { request.removeListener('validate', AWS.EventListeners.Core.VALIDATE_CREDENTIALS ); request.onAsync('validate', this.validateCredentials); request.addListener('validate', this.updateRegion); if (request.operation === 'search') { request.addListener('build', this.convertGetToPost); } }
n/a
function updateRegion(request) { var endpoint = request.httpRequest.endpoint.hostname; var zones = endpoint.split('.'); request.httpRequest.region = zones[1] || request.httpRequest.region; }
n/a
validateCredentials = function (req, done) { if (!req.service.api.signatureVersion) return done(); // none req.service.config.getCredentials(function(err) { if (err) { req.removeListener('sign', AWS.EventListeners.Core.SIGN); } done(); }); }
n/a
function validateService() { if (!this.config.endpoint || this.config.endpoint.indexOf('{') >= 0) { var msg = 'AWS.CloudSearchDomain requires an explicit ' + '`endpoint\' configuration option.'; throw AWS.util.error(new Error(), {name: 'InvalidEndpoint', message: msg}); } }
n/a
CloudTrail = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
CloudWatch = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
CloudWatchEvents = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
CloudWatchLogs = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
CodeBuild = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
CodeCommit = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
CodeDeploy = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
CodePipeline = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
CognitoIdentity = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function getCredentialsForIdentity(params, callback) { return this.makeUnauthenticatedRequest('getCredentialsForIdentity', params, callback); }
n/a
function getId(params, callback) { return this.makeUnauthenticatedRequest('getId', params, callback); }
n/a
function getOpenIdToken(params, callback) { return this.makeUnauthenticatedRequest('getOpenIdToken', params, callback); }
n/a
function CognitoIdentityCredentials(params, clientConfig) { AWS.Credentials.call(this); this.expired = true; this.params = params; this.data = null; this._identityId = null; this._clientConfig = AWS.util.copy(clientConfig || {}); this.loadCachedId(); var self = this; Object.defineProperty(this, 'identityId', { get: function() { self.loadCachedId(); return self._identityId || self.params.IdentityId; }, set: function(identityId) { self._identityId = identityId; } }); }
n/a
function Credentials() { // hide secretAccessKey from being displayed with util.inspect AWS.util.hideProperties(this, ['secretAccessKey']); this.expired = false; this.expireTime = null; if (arguments.length === 1 && typeof arguments[0] === 'object') { var creds = arguments[0].credentials || arguments[0]; this.accessKeyId = creds.accessKeyId; this.secretAccessKey = creds.secretAccessKey; this.sessionToken = creds.sessionToken; } else { this.accessKeyId = arguments[0]; this.secretAccessKey = arguments[1]; this.sessionToken = arguments[2]; } }
n/a
function cacheId(data) { this._identityId = data.IdentityId; this.params.IdentityId = this._identityId; // cache this IdentityId in browser localStorage if possible if (AWS.util.isBrowser()) { this.setStorage('id', data.IdentityId); if (this.params.Logins) { this.setStorage('providers', Object.keys(this.params.Logins).join(',')); } } }
n/a
function clearCache() { this._identityId = null; delete this.params.IdentityId; var poolId = this.params.IdentityPoolId; var loginId = this.params.LoginId || ''; delete this.storage[this.localStorageKey.id + poolId + loginId]; delete this.storage[this.localStorageKey.providers + poolId + loginId]; }
n/a
function clearIdOnNotAuthorized(err) { var self = this; if (err.code == 'NotAuthorizedException') { self.clearCachedId(); } }
n/a
function CognitoIdentityCredentials(params, clientConfig) { AWS.Credentials.call(this); this.expired = true; this.params = params; this.data = null; this._identityId = null; this._clientConfig = AWS.util.copy(clientConfig || {}); this.loadCachedId(); var self = this; Object.defineProperty(this, 'identityId', { get: function() { self.loadCachedId(); return self._identityId || self.params.IdentityId; }, set: function(identityId) { self._identityId = identityId; } }); }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
createClients = function () { var clientConfig = this._clientConfig; this.webIdentityCredentials = this.webIdentityCredentials || new AWS.WebIdentityCredentials(this.params, clientConfig); if (!this.cognito) { var cognitoConfig = AWS.util.merge({}, clientConfig); cognitoConfig.params = this.params; this.cognito = new CognitoIdentity(cognitoConfig); } this.sts = this.sts || new STS(clientConfig); }
n/a
function getCredentialsForIdentity(callback) { var self = this; self.cognito.getCredentialsForIdentity(function(err, data) { if (!err) { self.cacheId(data); self.data = data; self.loadCredentials(self.data, self); } else { self.clearIdOnNotAuthorized(err); } callback(err); }); }
n/a
function getCredentialsFromSTS(callback) { var self = this; self.cognito.getOpenIdToken(function(err, data) { if (!err) { self.cacheId(data); self.params.WebIdentityToken = data.Token; self.webIdentityCredentials.refresh(function(webErr) { if (!webErr) { self.data = self.webIdentityCredentials.data; self.sts.credentialsFrom(self.data, self); } callback(webErr); }); } else { self.clearIdOnNotAuthorized(err); callback(err); } }); }
n/a
function getId(callback) { var self = this; if (typeof self.params.IdentityId === 'string') { return callback(null, self.params.IdentityId); } self.cognito.getId(function(err, data) { if (!err && data.IdentityId) { self.params.IdentityId = data.IdentityId; callback(null, data.IdentityId); } else { callback(err); } }); }
n/a
function getStorage(key) { return this.storage[this.localStorageKey[key] + this.params.IdentityPoolId + (this.params.LoginId || '')]; }
n/a
function loadCachedId() { var self = this; // in the browser we source default IdentityId from localStorage if (AWS.util.isBrowser() && !self.params.IdentityId) { var id = self.getStorage('id'); if (id && self.params.Logins) { var actualProviders = Object.keys(self.params.Logins); var cachedProviders = (self.getStorage('providers') || '').split(','); // only load ID if at least one provider used this ID before var intersect = cachedProviders.filter(function(n) { return actualProviders.indexOf(n) !== -1; }); if (intersect.length !== 0) { self.params.IdentityId = id; } } else if (id) { self.params.IdentityId = id; } } }
n/a
function loadCredentials(data, credentials) { if (!data || !credentials) return; credentials.expired = false; credentials.accessKeyId = data.Credentials.AccessKeyId; credentials.secretAccessKey = data.Credentials.SecretKey; credentials.sessionToken = data.Credentials.SessionToken; credentials.expireTime = data.Credentials.Expiration; }
n/a
function refresh(callback) { var self = this; self.createClients(); self.data = null; self._identityId = null; self.getId(function(err) { if (!err) { if (!self.params.RoleArn) { self.getCredentialsForIdentity(callback); } else { self.getCredentialsFromSTS(callback); } } else { self.clearIdOnNotAuthorized(err); callback(err); } }); }
n/a
function setStorage(key, val) { try { this.storage[this.localStorageKey[key] + this.params.IdentityPoolId + (this.params.LoginId || '')] = val; } catch (_) {} }
n/a
CognitoIdentityServiceProvider = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
CognitoSync = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function Config(options) { if (options === undefined) options = {}; options = this.extractCredentials(options); AWS.util.each.call(this, this.keys, function (key, value) { this.set(key, options[key], value); }); }
...
/**
* Creates a new configuration object. This is the object that passes
* option data along to service requests, including credentials, security,
* region information, and some service specific settings.
*
* @example Creating a new configuration object with credentials and region
* var config = new AWS.Config({
* accessKeyId: 'AKID', secretAccessKey: 'SECRET', region: 'us-west-2'
* });
* @option options accessKeyId [String] your AWS access key ID.
* @option options secretAccessKey [String] your AWS secret access key.
* @option options sessionToken [AWS.Credentials] the optional AWS
* session token to sign requests with.
* @option options credentials [AWS.Credentials] the AWS credentials
...
function Object() { [native code] }
n/a
function clear() {
/*jshint forin:false */
AWS.util.each.call(this, this.keys, function (key) {
delete this[key];
});
// reset credential provider
this.set('credentials', undefined);
this.set('credentialProvider', undefined);
}
...
* on the object.
* @!macro nobrowser
* @param path [String] the path relative to your process's current
* working directory to load configuration from.
* @return [AWS.Config] the same configuration object
*/
loadFromPath: function loadFromPath(path) {
this.clear();
var options = JSON.parse(AWS.util.readFileSync(path));
var fileSystemCreds = new AWS.FileSystemCredentials(path);
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
...
function Config(options) { if (options === undefined) options = {}; options = this.extractCredentials(options); AWS.util.each.call(this, this.keys, function (key, value) { this.set(key, options[key], value); }); }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function extractCredentials(options) { if (options.accessKeyId && options.secretAccessKey) { options = AWS.util.copy(options); options.credentials = new AWS.Credentials(options); } return options; }
...
* 'v2', 'v3', 'v4'.
* @option options signatureCache [Boolean] whether the signature to sign
* requests with (overriding the API configuration) is cached. Only applies
* to the signature version 'v4'. Defaults to `true`.
*/
constructor: function Config(options) {
if (options === undefined) options = {};
options = this.extractCredentials(options);
AWS.util.each.call(this, this.keys, function (key, value) {
this.set(key, options[key], value);
});
},
/**
...
function getCredentials(callback) { var self = this; function finish(err) { callback(err, err ? null : self.credentials); } function credError(msg, err) { return new AWS.util.error(err || new Error(), { code: 'CredentialsError', message: msg, name: 'CredentialsError' }); } function getAsyncCredentials() { self.credentials.get(function(err) { if (err) { var msg = 'Could not load credentials from ' + self.credentials.constructor.name; err = credError(msg, err); } finish(err); }); } function getStaticCredentials() { var err = null; if (!self.credentials.accessKeyId || !self.credentials.secretAccessKey) { err = credError('Missing credentials'); } finish(err); } if (self.credentials) { if (typeof self.credentials.get === 'function') { getAsyncCredentials(); } else { // static credentials getStaticCredentials(); } } else if (self.credentialProvider) { self.credentialProvider.resolve(function(err, creds) { if (err) { err = credError('Could not load credentials from any providers', err); } self.credentials = creds; finish(err); }); } else { finish(credError('No credentials to load')); } }
...
* directly to provide accurate credential data stored in the object.
*
* @note If you configure the SDK with static or environment credentials,
* the credential data should already be present in {credentials} attribute.
* This method is primarily necessary to load credentials from asynchronous
* sources, or sources that can refresh credentials periodically.
* @example Getting your access key
* AWS.config.getCredentials(function(err) {
* if (err) console.log(err.stack); // credentials not loaded
* else console.log("Access Key:", AWS.config.credentials.accessKeyId);
* })
* @callback callback function(err)
* Called when the {credentials} have been properly set on the configuration
* object.
*
...
function getPromisesDependency() { return PromisesDependency; }
n/a
function loadFromPath(path) { this.clear(); var options = JSON.parse(AWS.util.readFileSync(path)); var fileSystemCreds = new AWS.FileSystemCredentials(path); var chain = new AWS.CredentialProviderChain(); chain.providers.unshift(fileSystemCreds); chain.resolve(function (err, creds) { if (err) throw err; else options.credentials = creds; }); this.constructor(options); return this; }
n/a
function set(property, value, defaultValue) { if (value === undefined) { if (defaultValue === undefined) { defaultValue = this.keys[property]; } if (typeof defaultValue === 'function') { this[property] = defaultValue.call(this); } else { this[property] = defaultValue; } } else if (property === 'httpOptions' && this[property]) { // deep merge httpOptions this[property] = AWS.util.merge(this[property], value); } else { this[property] = value; } }
...
* to the signature version 'v4'. Defaults to `true`.
*/
constructor: function Config(options) {
if (options === undefined) options = {};
options = this.extractCredentials(options);
AWS.util.each.call(this, this.keys, function (key, value) {
this.set(key, options[key], value);
});
},
/**
* @!group Managing Credentials
*/
...
function setPromisesDependency(dep) { PromisesDependency = dep; // if null was passed in, we should try to use native promises if (dep === null && typeof Promise === 'function') { PromisesDependency = Promise; } var constructors = [AWS.Request, AWS.Credentials, AWS.CredentialProviderChain]; if (AWS.S3 && AWS.S3.ManagedUpload) constructors.push(AWS.S3.ManagedUpload); AWS.util.addPromises(constructors, PromisesDependency); }
n/a
function update(options, allowUnknownKeys) { allowUnknownKeys = allowUnknownKeys || false; options = this.extractCredentials(options); AWS.util.each.call(this, options, function (key, value) { if (allowUnknownKeys || Object.prototype.hasOwnProperty.call(this.keys, key) || AWS.Service.hasService(key)) { this.set(key, value); } }); }
...
* @!group General Configuration Options
*
* @!attribute credentials
* @return [AWS.Credentials] the AWS credentials to sign requests with.
*
* @!attribute region
* @example Set the global region setting to us-west-2
* AWS.config.update({region: 'us-west-2'});
* @return [AWS.Credentials] The region to send service requests to.
* @see http://docs.amazonwebservices.com/general/latest/gr/rande.html
* A list of available endpoints for each AWS service
*
* @!attribute maxRetries
* @return [Integer] the maximum amount of retries to perform for a
* service request. By default this value is calculated by the specific
...
credentialProvider = function () { return new AWS.CredentialProviderChain(); }
n/a
credentials = function () { var credentials = null; new AWS.CredentialProviderChain([ function () { return new AWS.EnvironmentCredentials('AWS'); }, function () { return new AWS.EnvironmentCredentials('AMAZON'); }, function () { return new AWS.SharedIniFileCredentials({ disableAssumeRole: true }); } ]).resolve(function(err, creds) { if (!err) credentials = creds; }); return credentials; }
n/a
region = function () { return process.env.AWS_REGION || process.env.AMAZON_REGION; }
n/a
ConfigService = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function CredentialProviderChain(providers) { if (providers) { this.providers = providers; } else { this.providers = AWS.CredentialProviderChain.defaultProviders.slice(0); } }
...
* @return [AWS.Config] the same configuration object
*/
loadFromPath: function loadFromPath(path) {
this.clear();
var options = JSON.parse(AWS.util.readFileSync(path));
var fileSystemCreds = new AWS.FileSystemCredentials(path);
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
...
function Credentials() { // hide secretAccessKey from being displayed with util.inspect AWS.util.hideProperties(this, ['secretAccessKey']); this.expired = false; this.expireTime = null; if (arguments.length === 1 && typeof arguments[0] === 'object') { var creds = arguments[0].credentials || arguments[0]; this.accessKeyId = creds.accessKeyId; this.secretAccessKey = creds.secretAccessKey; this.sessionToken = creds.sessionToken; } else { this.accessKeyId = arguments[0]; this.secretAccessKey = arguments[1]; this.sessionToken = arguments[2]; } }
n/a
function addPromisesToClass(PromiseDependency) { this.prototype.resolvePromise = AWS.util.promisifyMethod('resolve', PromiseDependency); }
n/a
function deletePromisesFromClass() { delete this.prototype.resolvePromise; }
n/a
0 = function () { return new AWS.EnvironmentCredentials('AWS'); }
n/a
1 = function () { return new AWS.EnvironmentCredentials('AMAZON'); }
n/a
2 = function () { return new AWS.SharedIniFileCredentials(); }
n/a
3 = function () { if (AWS.ECSCredentials.prototype.getECSRelativeUri() !== undefined) { return new AWS.ECSCredentials(); } return new AWS.EC2MetadataCredentials(); }
n/a
function CredentialProviderChain(providers) { if (providers) { this.providers = providers; } else { this.providers = AWS.CredentialProviderChain.defaultProviders.slice(0); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function resolve(callback) { if (this.providers.length === 0) { callback(new Error('No providers')); return this; } var index = 0; var providers = this.providers.slice(0); function resolveNext(err, creds) { if ((!err && creds) || index === providers.length) { callback(err, creds); return; } var provider = providers[index++]; if (typeof provider === 'function') { creds = provider.call(); } else { creds = provider; } if (creds.get) { creds.get(function(getErr) { resolveNext(getErr, getErr ? null : creds); }); } else { resolveNext(null, creds); } } resolveNext(); return this; }
...
if (self.credentials) {
if (typeof self.credentials.get === 'function') {
getAsyncCredentials();
} else { // static credentials
getStaticCredentials();
}
} else if (self.credentialProvider) {
self.credentialProvider.resolve(function(err, creds) {
if (err) {
err = credError('Could not load credentials from any providers', err);
}
self.credentials = creds;
finish(err);
});
} else {
...
function promise() { var self = this; return new PromiseDependency(function(resolve, reject) { self[methodName](function(err, data) { if (err) { reject(err); } else { resolve(data); } }); }); }
n/a
function Credentials() { // hide secretAccessKey from being displayed with util.inspect AWS.util.hideProperties(this, ['secretAccessKey']); this.expired = false; this.expireTime = null; if (arguments.length === 1 && typeof arguments[0] === 'object') { var creds = arguments[0].credentials || arguments[0]; this.accessKeyId = creds.accessKeyId; this.secretAccessKey = creds.secretAccessKey; this.sessionToken = creds.sessionToken; } else { this.accessKeyId = arguments[0]; this.secretAccessKey = arguments[1]; this.sessionToken = arguments[2]; } }
...
* from a configuration hash.
*
* @api private
*/
extractCredentials: function extractCredentials(options) {
if (options.accessKeyId && options.secretAccessKey) {
options = AWS.util.copy(options);
options.credentials = new AWS.Credentials(options);
}
return options;
},
/**
* Sets the promise dependency the SDK will use wherever Promises are returned.
* Passing `null` will force the SDK to use native Promises if they are available.
...
function Object() { [native code] }
n/a
function addPromisesToClass(PromiseDependency) { this.prototype.getPromise = AWS.util.promisifyMethod('get', PromiseDependency); this.prototype.refreshPromise = AWS.util.promisifyMethod('refresh', PromiseDependency); }
n/a
function deletePromisesFromClass() { delete this.prototype.getPromise; delete this.prototype.refreshPromise; }
n/a
function Credentials() { // hide secretAccessKey from being displayed with util.inspect AWS.util.hideProperties(this, ['secretAccessKey']); this.expired = false; this.expireTime = null; if (arguments.length === 1 && typeof arguments[0] === 'object') { var creds = arguments[0].credentials || arguments[0]; this.accessKeyId = creds.accessKeyId; this.secretAccessKey = creds.secretAccessKey; this.sessionToken = creds.sessionToken; } else { this.accessKeyId = arguments[0]; this.secretAccessKey = arguments[1]; this.sessionToken = arguments[2]; } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function get(callback) { var self = this; if (this.needsRefresh()) { this.refresh(function(err) { if (!err) self.expired = false; // reset expired flag if (callback) callback(err); }); } else if (callback) { callback(); } }
...
code: 'CredentialsError',
message: msg,
name: 'CredentialsError'
});
}
function getAsyncCredentials() {
self.credentials.get(function(err) {
if (err) {
var msg = 'Could not load credentials from ' +
self.credentials.constructor.name;
err = credError(msg, err);
}
finish(err);
});
...
function promise() { var self = this; return new PromiseDependency(function(resolve, reject) { self[methodName](function(err, data) { if (err) { reject(err); } else { resolve(data); } }); }); }
n/a
function needsRefresh() { var currentTime = AWS.util.date.getDate().getTime(); var adjustedTime = new Date(currentTime + this.expiryWindow * 1000); if (this.expireTime && adjustedTime > this.expireTime) { return true; } else { return this.expired || !this.accessKeyId || !this.secretAccessKey; } }
n/a
function refresh(callback) { this.expired = false; callback(); }
n/a
function promise() { var self = this; return new PromiseDependency(function(resolve, reject) { self[methodName](function(err, data) { if (err) { reject(err); } else { resolve(data); } }); }); }
n/a
DMS = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
DataPipeline = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
DeviceFarm = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
DirectConnect = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
DirectoryService = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
Discovery = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
DynamoDB = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function DocumentClient(options) { var self = this; self.options = options || {}; self.configure(self.options); }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
function convertInput(data, options) { options = options || {}; var type = typeOf(data); if (type === 'Object') { return formatMap(data, options); } else if (type === 'Array') { return formatList(data, options); } else if (type === 'Set') { return formatSet(data, options); } else if (type === 'String') { if (data.length === 0 && options.convertEmptyValues) { return convertInput(null); } return { S: data }; } else if (type === 'Number') { return { N: data.toString() }; } else if (type === 'Binary') { if (data.length === 0 && options.convertEmptyValues) { return convertInput(null); } return { B: data }; } else if (type === 'Boolean') { return { BOOL: data }; } else if (type === 'null') { return { NULL: true }; } else if (type !== 'undefined' && type !== 'Function') { // this value has a custom constructor return formatMap(data, options); } }
n/a
function convertOutput(data) { var list, map, i; for (var type in data) { var values = data[type]; if (type === 'M') { map = {}; for (var key in values) { map[key] = convertOutput(values[key]); } return map; } else if (type === 'L') { list = []; for (i = 0; i < values.length; i++) { list.push(convertOutput(values[i])); } return list; } else if (type === 'SS') { list = []; for (i = 0; i < values.length; i++) { list.push(values[i] + ''); } return new DynamoDBSet(list); } else if (type === 'NS') { list = []; for (i = 0; i < values.length; i++) { list.push(Number(values[i])); } return new DynamoDBSet(list); } else if (type === 'BS') { list = []; for (i = 0; i < values.length; i++) { list.push(new util.Buffer(values[i])); } return new DynamoDBSet(list); } else if (type === 'S') { return values + ''; } else if (type === 'N') { return Number(values); } else if (type === 'B') { return new util.Buffer(values); } else if (type === 'BOOL') { return (values === 'true' || values === 'TRUE' || values === true); } else if (type === 'NULL') { return null; } } }
n/a
function DocumentClient(options) { var self = this; self.options = options || {}; self.configure(self.options); }
n/a
function Object() { [native code] }
n/a
batchGet = function (params, callback) { var self = this; var request = self.service.batchGetItem(params); self.setupRequest(request); self.setupResponse(request); if (typeof callback === 'function') { request.send(callback); } return request; }
n/a
batchWrite = function (params, callback) { var self = this; var request = self.service.batchWriteItem(params); self.setupRequest(request); self.setupResponse(request); if (typeof callback === 'function') { request.send(callback); } return request; }
n/a
function bindServiceObject(options) { var self = this; options = options || {}; if (!self.service) { self.service = new AWS.DynamoDB(options); } else { var config = AWS.util.copy(self.service.config); self.service = new self.service.constructor.__super__(config); self.service.config.params = AWS.util.merge(self.service.config.params || {}, options.params); } }
n/a
function configure(options) { var self = this; self.service = options.service; self.bindServiceObject(options); self.attrValue = options.attrValue = self.service.api.operations.putItem.input.members.Item.value.shape; }
n/a
function DocumentClient(options) { var self = this; self.options = options || {}; self.configure(self.options); }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
createSet = function (list, options) { options = options || {}; return new DynamoDBSet(list, options); }
n/a
delete = function (params, callback) { var self = this; var request = self.service.deleteItem(params); self.setupRequest(request); self.setupResponse(request); if (typeof callback === 'function') { request.send(callback); } return request; }
n/a
get = function (params, callback) { var self = this; var request = self.service.getItem(params); self.setupRequest(request); self.setupResponse(request); if (typeof callback === 'function') { request.send(callback); } return request; }
...
code: 'CredentialsError',
message: msg,
name: 'CredentialsError'
});
}
function getAsyncCredentials() {
self.credentials.get(function(err) {
if (err) {
var msg = 'Could not load credentials from ' +
self.credentials.constructor.name;
err = credError(msg, err);
}
finish(err);
});
...
getTranslator = function () { return new Translator(this.options); }
n/a
function put(params, callback) { var self = this; var request = self.service.putItem(params); self.setupRequest(request); self.setupResponse(request); if (typeof callback === 'function') { request.send(callback); } return request; }
n/a
query = function (params, callback) { var self = this; var request = self.service.query(params); self.setupRequest(request); self.setupResponse(request); if (typeof callback === 'function') { request.send(callback); } return request; }
n/a
scan = function (params, callback) { var self = this; var request = self.service.scan(params); self.setupRequest(request); self.setupResponse(request); if (typeof callback === 'function') { request.send(callback); } return request; }
n/a
function setupRequest(request) { var self = this; var translator = self.getTranslator(); var operation = request.operation; var inputShape = request.service.api.operations[operation].input; request._events.validate.unshift(function(req) { req.rawParams = AWS.util.copy(req.params); req.params = translator.translateInput(req.rawParams, inputShape); }); }
n/a
function setupResponse(request) { var self = this; var translator = self.getTranslator(); var outputShape = self.service.api.operations[request.operation].output; request.on('extractData', function(response) { response.data = translator.translateOutput(response.data, outputShape); }); var response = request.response; response.nextPage = function(cb) { var resp = this; var req = resp.request; var config; var service = req.service; var operation = req.operation; try { config = service.paginationConfig(operation, true); } catch (e) { resp.error = e; } if (!resp.hasNextPage()) { if (cb) cb(resp.error, null); else if (resp.error) throw resp.error; return null; } var params = AWS.util.copy(req.rawParams); if (!resp.nextPageTokens) { return cb ? cb(null, null) : null; } else { var inputTokens = config.inputToken; if (typeof inputTokens === 'string') inputTokens = [inputTokens]; for (var i = 0; i < inputTokens.length; i++) { params[inputTokens[i]] = resp.nextPageTokens[i]; } return self[operation](params, cb); } }; }
n/a
update = function (params, callback) { var self = this; var request = self.service.updateItem(params); self.setupRequest(request); self.setupResponse(request); if (typeof callback === 'function') { request.send(callback); } return request; }
...
* @!group General Configuration Options
*
* @!attribute credentials
* @return [AWS.Credentials] the AWS credentials to sign requests with.
*
* @!attribute region
* @example Set the global region setting to us-west-2
* AWS.config.update({region: 'us-west-2'});
* @return [AWS.Credentials] The region to send service requests to.
* @see http://docs.amazonwebservices.com/general/latest/gr/rande.html
* A list of available endpoints for each AWS service
*
* @!attribute maxRetries
* @return [Integer] the maximum amount of retries to perform for a
* service request. By default this value is calculated by the specific
...
function checkCrc32(resp) { if (!resp.httpResponse.streaming && !resp.request.service.crc32IsValid(resp)) { resp.data = null; resp.error = AWS.util.error(new Error(), { code: 'CRC32CheckFailed', message: 'CRC32 integrity check failed', retryable: true }); resp.request.haltHandlersOnError(); throw (resp.error); } }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function crc32IsValid(resp) { var crc = resp.httpResponse.headers['x-amz-crc32']; if (!crc) return true; // no (valid) CRC32 header return parseInt(crc, 10) === AWS.util.crypto.crc32(resp.httpResponse.body); }
n/a
function retryDelays(retryCount) { var retryDelayOptions = AWS.util.copy(this.config.retryDelayOptions); if (typeof retryDelayOptions.base !== 'number') { retryDelayOptions.base = 50; // default for dynamodb } var delay = AWS.util.calculateRetryDelay(retryCount, retryDelayOptions); return delay; }
...
});
add('RETRY_CHECK', 'retry', function RETRY_CHECK(resp) {
if (resp.error) {
if (resp.error.redirect && resp.redirectCount < resp.maxRedirects) {
resp.error.retryDelay = 0;
} else if (resp.retryCount < resp.maxRetries) {
resp.error.retryDelay = this.service.retryDelays(resp.retryCount) || 0;
}
}
});
addAsync('RESET_RETRY_STATE', 'afterRetry', function RESET_RETRY_STATE(resp, done) {
var delay, willRetry = false;
...
function setupRequestListeners(request) { if (request.service.config.dynamoDbCrc32) { request.removeListener('extractData', AWS.EventListeners.Json.EXTRACT_DATA); request.addListener('extractData', this.checkCrc32); request.addListener('extractData', AWS.EventListeners.Json.EXTRACT_DATA); } }
n/a
DynamoDBStreams = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
EC2 = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
function buildCopySnapshotPresignedUrl(req, done) { if (req.params.PresignedUrl || req._subRequest) { return done(); } req.params = AWS.util.copy(req.params); req.params.DestinationRegion = req.service.config.region; var config = AWS.util.copy(req.service.config); delete config.endpoint; config.region = req.params.SourceRegion; var svc = new req.service.constructor(config); var newReq = svc[req.operation](req.params); newReq._subRequest = true; newReq.presign(function(err, url) { if (err) done(err); else { req.params.PresignedUrl = url; done(); } }); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function extractError(resp) { // EC2 nests the error code and message deeper than other AWS Query services. var httpResponse = resp.httpResponse; var data = new AWS.XML.Parser().parse(httpResponse.body.toString() || ''); if (data.Errors) { resp.error = AWS.util.error(new Error(), { code: data.Errors.Error.Code, message: data.Errors.Error.Message }); } else { resp.error = AWS.util.error(new Error(), { code: httpResponse.statusCode, message: null }); } resp.error.requestId = data.RequestID || null; }
n/a
function setupRequestListeners(request) { request.removeListener('extractError', AWS.EventListeners.Query.EXTRACT_ERROR); request.addListener('extractError', this.extractError); if (request.operation === 'copySnapshot') { request.onAsync('validate', this.buildCopySnapshotPresignedUrl); } }
n/a
function EC2MetadataCredentials(options) { AWS.Credentials.call(this); options = options ? AWS.util.copy(options) : {}; options = AWS.util.merge( {maxRetries: this.defaultMaxRetries}, options); if (!options.httpOptions) options.httpOptions = {}; options.httpOptions = AWS.util.merge( {timeout: this.defaultTimeout}, options.httpOptions); this.metadataService = new AWS.MetadataService(options); this.metadata = {}; }
...
function () { return new AWS.EnvironmentCredentials('AWS'); },
function () { return new AWS.EnvironmentCredentials('AMAZON'); },
function () { return new AWS.SharedIniFileCredentials(); },
function () {
if (AWS.ECSCredentials.prototype.getECSRelativeUri() !== undefined) {
return new AWS.ECSCredentials();
}
return new AWS.EC2MetadataCredentials();
}
];
// Update configuration keys
AWS.util.update(AWS.Config.prototype.keys, {
credentials: function () {
var credentials = null;
...
function Credentials() { // hide secretAccessKey from being displayed with util.inspect AWS.util.hideProperties(this, ['secretAccessKey']); this.expired = false; this.expireTime = null; if (arguments.length === 1 && typeof arguments[0] === 'object') { var creds = arguments[0].credentials || arguments[0]; this.accessKeyId = creds.accessKeyId; this.secretAccessKey = creds.secretAccessKey; this.sessionToken = creds.sessionToken; } else { this.accessKeyId = arguments[0]; this.secretAccessKey = arguments[1]; this.sessionToken = arguments[2]; } }
n/a
function EC2MetadataCredentials(options) { AWS.Credentials.call(this); options = options ? AWS.util.copy(options) : {}; options = AWS.util.merge( {maxRetries: this.defaultMaxRetries}, options); if (!options.httpOptions) options.httpOptions = {}; options.httpOptions = AWS.util.merge( {timeout: this.defaultTimeout}, options.httpOptions); this.metadataService = new AWS.MetadataService(options); this.metadata = {}; }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function refresh(callback) { var self = this; if (!callback) callback = function(err) { if (err) throw err; }; self.metadataService.loadCredentials(function (err, creds) { if (!err) { self.expired = false; self.metadata = creds; self.accessKeyId = creds.AccessKeyId; self.secretAccessKey = creds.SecretAccessKey; self.sessionToken = creds.Token; self.expireTime = new Date(creds.Expiration); } callback(err); }); }
n/a
ECR = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
ECS = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function ECSCredentials(options) { AWS.Credentials.call(this); options = options ? AWS.util.copy(options) : {}; if (!options.httpOptions) options.httpOptions = {}; options.httpOptions = AWS.util.merge( this.httpOptions, options.httpOptions); AWS.util.update(this, options); }
...
// credentials/credential_provider_chain.js
AWS.CredentialProviderChain.defaultProviders = [
function () { return new AWS.EnvironmentCredentials('AWS'); },
function () { return new AWS.EnvironmentCredentials('AMAZON'); },
function () { return new AWS.SharedIniFileCredentials(); },
function () {
if (AWS.ECSCredentials.prototype.getECSRelativeUri() !== undefined) {
return new AWS.ECSCredentials();
}
return new AWS.EC2MetadataCredentials();
}
];
// Update configuration keys
AWS.util.update(AWS.Config.prototype.keys, {
...
function Credentials() { // hide secretAccessKey from being displayed with util.inspect AWS.util.hideProperties(this, ['secretAccessKey']); this.expired = false; this.expireTime = null; if (arguments.length === 1 && typeof arguments[0] === 'object') { var creds = arguments[0].credentials || arguments[0]; this.accessKeyId = creds.accessKeyId; this.secretAccessKey = creds.secretAccessKey; this.sessionToken = creds.sessionToken; } else { this.accessKeyId = arguments[0]; this.secretAccessKey = arguments[1]; this.sessionToken = arguments[2]; } }
n/a
function ECSCredentials(options) { AWS.Credentials.call(this); options = options ? AWS.util.copy(options) : {}; if (!options.httpOptions) options.httpOptions = {}; options.httpOptions = AWS.util.merge( this.httpOptions, options.httpOptions); AWS.util.update(this, options); }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function credsFormatIsValid(credData) { return (!!credData.AccessKeyId && !!credData.SecretAccessKey && !!credData.Token && !!credData.Expiration); }
n/a
function getECSRelativeUri() { if (process && process.env) return process.env[this.environmentVar]; }
...
// AWS.CredentialProviderChain.defaultProviders in
// credentials/credential_provider_chain.js
AWS.CredentialProviderChain.defaultProviders = [
function () { return new AWS.EnvironmentCredentials('AWS'); },
function () { return new AWS.EnvironmentCredentials('AMAZON'); },
function () { return new AWS.SharedIniFileCredentials(); },
function () {
if (AWS.ECSCredentials.prototype.getECSRelativeUri() !== undefined) {
return new AWS.ECSCredentials();
}
return new AWS.EC2MetadataCredentials();
}
];
// Update configuration keys
...
function refresh(callback) { var self = this; var refreshQueue = self.refreshQueue; if (!callback) callback = function(err) { if (err) throw err; }; refreshQueue.push({ provider: self, errCallback: callback }); if (refreshQueue.length > 1) { return; } function callbacks(err, creds) { var call, cb; while ((call = refreshQueue.shift()) !== undefined) { cb = call.errCallback; if (!err) AWS.util.update(call.provider, creds); cb(err); } } if (process === undefined) { callbacks(AWS.util.error( new Error('No process info available'), { code: 'ECSCredentialsProviderFailure' } )); return; } var relativeUri = this.getECSRelativeUri(); if (relativeUri === undefined) { callbacks(AWS.util.error( new Error('Variable ' + this.environmentVar + ' not set.'), { code: 'ECSCredentialsProviderFailure' } )); return; } this.request(relativeUri, function(err, data) { if (!err) { try { data = JSON.parse(data); if (self.credsFormatIsValid(data)) { var creds = { expired: false, accessKeyId: data.AccessKeyId, secretAccessKey: data.SecretAccessKey, sessionToken: data.Token, expireTime: new Date(data.Expiration) }; } else { throw AWS.util.error( new Error('Response data is not in valid format'), { code: 'ECSCredentialsProviderFailure' } ); } } catch (dataError) { err = dataError; } } callbacks(err, creds); }); }
n/a
function request(path, callback) { path = path || '/'; var httpRequest = new AWS.HttpRequest('http://' + this.host + path); httpRequest.method = 'GET'; httpRequest.headers.Accept = 'application/json'; AWS.util.handleRequestWithRetries(httpRequest, this, callback); }
n/a
EFS = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
ELB = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
ELBv2 = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
EMR = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
ES = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
ElastiCache = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
ElasticBeanstalk = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
ElasticTranscoder = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function Endpoint(endpoint, config) { AWS.util.hideProperties(this, ['slashes', 'auth', 'hash', 'search', 'query']); if (typeof endpoint === 'undefined' || endpoint === null) { throw new Error('Invalid endpoint: ' + endpoint); } else if (typeof endpoint !== 'string') { return AWS.util.copy(endpoint); } if (!endpoint.match(/^http/)) { var useSSL = config && config.sslEnabled !== undefined ? config.sslEnabled : AWS.config.sslEnabled; endpoint = (useSSL ? 'https' : 'http') + '://' + endpoint; } AWS.util.update(this, AWS.util.urlParse(endpoint)); // Ensure the port property is set as an integer if (this.port) { this.port = parseInt(this.port, 10); } else { this.port = this.protocol === 'https:' ? 443 : 80; } }
...
}
});
add('REDIRECT', 'retry', function REDIRECT(resp) {
if (resp.error && resp.error.statusCode >= 300 &&
resp.error.statusCode < 400 && resp.httpResponse.headers['location']) {
this.httpRequest.endpoint =
new AWS.Endpoint(resp.httpResponse.headers['location']);
this.httpRequest.headers['Host'] = this.httpRequest.endpoint.host;
resp.error.redirect = true;
resp.error.retryable = true;
}
});
add('RETRY_CHECK', 'retry', function RETRY_CHECK(resp) {
...
function Object() { [native code] }
n/a
function Endpoint(endpoint, config) { AWS.util.hideProperties(this, ['slashes', 'auth', 'hash', 'search', 'query']); if (typeof endpoint === 'undefined' || endpoint === null) { throw new Error('Invalid endpoint: ' + endpoint); } else if (typeof endpoint !== 'string') { return AWS.util.copy(endpoint); } if (!endpoint.match(/^http/)) { var useSSL = config && config.sslEnabled !== undefined ? config.sslEnabled : AWS.config.sslEnabled; endpoint = (useSSL ? 'https' : 'http') + '://' + endpoint; } AWS.util.update(this, AWS.util.urlParse(endpoint)); // Ensure the port property is set as an integer if (this.port) { this.port = parseInt(this.port, 10); } else { this.port = this.protocol === 'https:' ? 443 : 80; } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function EnvironmentCredentials(envPrefix) { AWS.Credentials.call(this); this.envPrefix = envPrefix; this.get(function() {}); }
...
require('./credentials/shared_ini_file_credentials');
// Setup default chain providers
// If this changes, please update documentation for
// AWS.CredentialProviderChain.defaultProviders in
// credentials/credential_provider_chain.js
AWS.CredentialProviderChain.defaultProviders = [
function () { return new AWS.EnvironmentCredentials('AWS'); },
function () { return new AWS.EnvironmentCredentials('AMAZON'); },
function () { return new AWS.SharedIniFileCredentials(); },
function () {
if (AWS.ECSCredentials.prototype.getECSRelativeUri() !== undefined) {
return new AWS.ECSCredentials();
}
return new AWS.EC2MetadataCredentials();
...
function Credentials() { // hide secretAccessKey from being displayed with util.inspect AWS.util.hideProperties(this, ['secretAccessKey']); this.expired = false; this.expireTime = null; if (arguments.length === 1 && typeof arguments[0] === 'object') { var creds = arguments[0].credentials || arguments[0]; this.accessKeyId = creds.accessKeyId; this.secretAccessKey = creds.secretAccessKey; this.sessionToken = creds.sessionToken; } else { this.accessKeyId = arguments[0]; this.secretAccessKey = arguments[1]; this.sessionToken = arguments[2]; } }
n/a
function EnvironmentCredentials(envPrefix) { AWS.Credentials.call(this); this.envPrefix = envPrefix; this.get(function() {}); }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function refresh(callback) { if (!callback) callback = function(err) { if (err) throw err; }; if (!process || !process.env) { callback(AWS.util.error( new Error('No process info or environment variables available'), { code: 'EnvironmentCredentialsProviderFailure' } )); return; } var keys = ['ACCESS_KEY_ID', 'SECRET_ACCESS_KEY', 'SESSION_TOKEN']; var values = []; for (var i = 0; i < keys.length; i++) { var prefix = ''; if (this.envPrefix) prefix = this.envPrefix + '_'; values[i] = process.env[prefix + keys[i]]; if (!values[i] && keys[i] !== 'SESSION_TOKEN') { callback(AWS.util.error( new Error('Variable ' + prefix + keys[i] + ' not set.'), { code: 'EnvironmentCredentialsProviderFailure' } )); return; } } this.expired = false; AWS.Credentials.apply(this, values); callback(); }
n/a
function FileSystemCredentials(filename) { AWS.Credentials.call(this); this.filename = filename; this.get(function() {}); }
...
* working directory to load configuration from.
* @return [AWS.Config] the same configuration object
*/
loadFromPath: function loadFromPath(path) {
this.clear();
var options = JSON.parse(AWS.util.readFileSync(path));
var fileSystemCreds = new AWS.FileSystemCredentials(path);
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
...
function Credentials() { // hide secretAccessKey from being displayed with util.inspect AWS.util.hideProperties(this, ['secretAccessKey']); this.expired = false; this.expireTime = null; if (arguments.length === 1 && typeof arguments[0] === 'object') { var creds = arguments[0].credentials || arguments[0]; this.accessKeyId = creds.accessKeyId; this.secretAccessKey = creds.secretAccessKey; this.sessionToken = creds.sessionToken; } else { this.accessKeyId = arguments[0]; this.secretAccessKey = arguments[1]; this.sessionToken = arguments[2]; } }
n/a
function FileSystemCredentials(filename) { AWS.Credentials.call(this); this.filename = filename; this.get(function() {}); }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function refresh(callback) { if (!callback) callback = function(err) { if (err) throw err; }; try { var creds = JSON.parse(AWS.util.readFileSync(this.filename)); AWS.Credentials.call(this, creds); if (!this.accessKeyId || !this.secretAccessKey) { throw AWS.util.error( new Error('Credentials not set in ' + this.filename), { code: 'FileSystemCredentialsProviderFailure' } ); } this.expired = false; callback(); } catch (err) { callback(err); } }
n/a
Firehose = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
GameLift = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
Glacier = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
function addGlacierApiVersion(request) { var version = request.service.api.apiVersion; request.httpRequest.headers['x-amz-glacier-version'] = version; }
n/a
function addTreeHashHeaders(request) { if (request.params.body === undefined) return; var hashes = request.service.computeChecksums(request.params.body); request.httpRequest.headers['X-Amz-Content-Sha256'] = hashes.linearHash; if (!request.httpRequest.headers['x-amz-sha256-tree-hash']) { request.httpRequest.headers['x-amz-sha256-tree-hash'] = hashes.treeHash; } }
n/a
function buildHashTree(hashes) { // merge leaf nodes while (hashes.length > 1) { var tmpHashes = []; for (var i = 0; i < hashes.length; i += 2) { if (hashes[i + 1]) { var tmpHash = new AWS.util.Buffer(64); tmpHash.write(hashes[i], 0, 32, 'binary'); tmpHash.write(hashes[i + 1], 32, 32, 'binary'); tmpHashes.push(AWS.util.crypto.sha256(tmpHash)); } else { tmpHashes.push(hashes[i]); } } hashes = tmpHashes; } return AWS.util.crypto.toHex(hashes[0]); }
n/a
function computeChecksums(data) { if (!AWS.util.Buffer.isBuffer(data)) data = new AWS.util.Buffer(data); var mb = 1024 * 1024; var hashes = []; var hash = AWS.util.crypto.createHash('sha256'); // build leaf nodes in 1mb chunks for (var i = 0; i < data.length; i += mb) { var chunk = data.slice(i, Math.min(i + mb, data.length)); hash.update(chunk); hashes.push(AWS.util.crypto.sha256(chunk)); } return { linearHash: hash.digest('hex'), treeHash: this.buildHashTree(hashes) }; }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function setupRequestListeners(request) { if (Array.isArray(request._events.validate)) { request._events.validate.unshift(this.validateAccountId); } else { request.on('validate', this.validateAccountId); } request.removeListener('afterBuild', AWS.EventListeners.Core.COMPUTE_SHA256); request.on('build', this.addGlacierApiVersion); request.on('build', this.addTreeHashHeaders); }
n/a
function validateAccountId(request) { if (request.params.accountId !== undefined) return; request.params = AWS.util.copy(request.params); request.params.accountId = '-'; }
n/a
Health = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
HttpClient = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Object() { [native code] }
n/a
function getInstance() { if (this.singleton === undefined) { this.singleton = new this(); } return this.singleton; }
...
});
resp.request.emit('httpError', [resp.error, resp], function() {
done();
});
}
function executeSend() {
var http = AWS.HttpClient.getInstance();
var httpOptions = resp.request.service.config.httpOptions || {};
try {
var stream = http.handleRequest(resp.request.httpRequest, httpOptions,
callback, error);
progress(stream);
} catch (err) {
error(err);
...
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function handleRequest(httpRequest, httpOptions, callback, errCallback) { var self = this; var cbAlreadyCalled = false; 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 }; if (useSSL && !httpOptions.agent) { options.agent = this.sslAgent(); } 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, function (httpResp) { if (cbAlreadyCalled) return; cbAlreadyCalled = true; callback(httpResp); httpResp.emit( 'headers', httpResp.statusCode, httpResp.headers, httpResp.statusMessage ); }); httpRequest.stream = stream; // attach stream to httpRequest // timeout support stream.setTimeout(httpOptions.timeout || 0, function() { if (cbAlreadyCalled) return; cbAlreadyCalled = true; var msg = 'Connection timed out after ' + httpOptions.timeout + 'ms'; errCallback(AWS.util.error(new Error(msg), {code: 'TimeoutError'})); stream.abort(); }); stream.on('error', function() { if (cbAlreadyCalled) return; cbAlreadyCalled = true; errCallback.apply(this, arguments); }); var expect = httpRequest.headers.Expect || httpRequest.headers.expect; if (expect === '100-continue') { stream.on('continue', function() { self.writeBody(stream, httpRequest); }); } else { this.writeBody(stream, httpRequest); } return stream; }
...
});
}
function executeSend() {
var http = AWS.HttpClient.getInstance();
var httpOptions = resp.request.service.config.httpOptions || {};
try {
var stream = http.handleRequest(resp.request.httpRequest, httpOptions,
callback, error);
progress(stream);
} catch (err) {
error(err);
}
}
...
function progressStream(stream, totalBytes) { if (typeof TransformStream === 'undefined') { // for node 0.8 there is no streaming progress return; } var loadedBytes = 0; var reporter = new TransformStream(); reporter._transform = function(chunk, encoding, callback) { if (chunk) { loadedBytes += chunk.length; stream.emit('sendProgress', { loaded: loadedBytes, total: totalBytes }); } callback(null, chunk); }; return reporter; }
n/a
function sslAgent() { var https = require('https'); if (!AWS.NodeHttpClient.sslAgent) { AWS.NodeHttpClient.sslAgent = new https.Agent({rejectUnauthorized: true}); AWS.NodeHttpClient.sslAgent.setMaxListeners(0); // delegate maxSockets to globalAgent, set a default limit of 50 if current value is Infinity. // Users can bypass this default by supplying their own Agent as part of SDK configuration. Object.defineProperty(AWS.NodeHttpClient.sslAgent, 'maxSockets', { enumerable: true, get: function() { var defaultMaxSockets = 50; var globalAgent = https.globalAgent; if (globalAgent && globalAgent.maxSockets !== Infinity && typeof globalAgent.maxSockets === 'number') { return globalAgent.maxSockets; } return defaultMaxSockets; } }); } return AWS.NodeHttpClient.sslAgent; }
n/a
function writeBody(stream, httpRequest) { var body = httpRequest.body; var totalBytes = parseInt(httpRequest.headers['Content-Length'], 10); if (body instanceof Stream) { // For progress support of streaming content - // pipe the data through a transform stream to emit 'sendProgress' events var progressStream = this.progressStream(stream, totalBytes); if (progressStream) { body.pipe(progressStream).pipe(stream); } else { body.pipe(stream); } } else if (body) { // The provided body is a buffer/string and is already fully available in memory - // For performance it's best to send it as a whole by calling stream.end(body), // Callers expect a 'sendProgress' event which is best emitted once // the http request stream has been fully written and all data flushed. // The use of totalBytes is important over body.length for strings where // length is char length and not byte length. stream.once('finish', function() { stream.emit('sendProgress', { loaded: totalBytes, total: totalBytes }); }); stream.end(body); } else { // no request body stream.end(); } }
n/a
function HttpRequest(endpoint, region) { endpoint = new AWS.Endpoint(endpoint); this.method = 'POST'; this.path = endpoint.path || '/'; this.headers = {}; this.body = ''; this.endpoint = endpoint; this.region = region; this._userAgent = ''; this.setUserAgent(); }
...
req.httpRequest.headers['Host'] = req.httpRequest.endpoint.host;
});
add('RESTART', 'restart', function RESTART() {
var err = this.response.error;
if (!err || !err.retryable) return;
this.httpRequest = new AWS.HttpRequest(
this.service.endpoint,
this.service.region
);
if (this.response.retryCount < this.service.config.maxRetries) {
this.response.retryCount++;
} else {
...
function Object() { [native code] }
n/a
function appendToUserAgent(agentPartial) { if (typeof agentPartial === 'string' && agentPartial) { this._userAgent += ' ' + agentPartial; } this.headers[this.getUserAgentHeaderName()] = this._userAgent; }
...
if (service.isGlobalEndpoint) region = 'us-east-1';
this.domain = domain && domain.active;
this.service = service;
this.operation = operation;
this.params = params || {};
this.httpRequest = new AWS.HttpRequest(endpoint, region);
this.httpRequest.appendToUserAgent(customUserAgent);
this.startTime = AWS.util.date.getDate();
this.response = new AWS.Response(this);
this._asm = new AcceptorStateMachine(fsm.states, 'validate');
this._haltHandlersOnError = false;
AWS.SequentialExecutor.call(this);
...
function HttpRequest(endpoint, region) { endpoint = new AWS.Endpoint(endpoint); this.method = 'POST'; this.path = endpoint.path || '/'; this.headers = {}; this.body = ''; this.endpoint = endpoint; this.region = region; this._userAgent = ''; this.setUserAgent(); }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function getUserAgent() { return this._userAgent; }
n/a
function getUserAgentHeaderName() { var prefix = AWS.util.isBrowser() ? 'X-Amz-' : ''; return prefix + 'User-Agent'; }
n/a
function pathname() { return this.path.split('?', 1)[0]; }
n/a
function search() { var query = this.path.split('?', 2)[1]; if (query) { query = AWS.util.queryStringParse(query); return AWS.util.queryParamsToString(query); } return ''; }
...
function wrappedCallback(err, data) {
if (err) return callback(err, null);
if (data === null) return callback(null, null);
var config = self.service.paginationConfig(self.operation);
var resultKey = config.resultKey;
if (Array.isArray(resultKey)) resultKey = resultKey[0];
var items = jmespath.search(data, resultKey);
var continueIteration = true;
AWS.util.arrayEach(items, function(item) {
continueIteration = callback(null, item);
if (continueIteration === false) {
return AWS.util.abort;
}
});
...
function setUserAgent() { this._userAgent = this.headers[this.getUserAgentHeaderName()] = AWS.util.userAgent(); }
n/a
function HttpResponse() { this.statusCode = undefined; this.headers = {}; this.body = undefined; this.streaming = false; this.stream = null; }
...
*/
constructor: function Response(request) {
this.request = request;
this.data = null;
this.error = null;
this.retryCount = 0;
this.redirectCount = 0;
this.httpResponse = new AWS.HttpResponse();
if (request) {
this.maxRetries = request.service.numRetries();
this.maxRedirects = request.service.config.maxRedirects;
}
},
/**
...
function Object() { [native code] }
n/a
function HttpResponse() { this.statusCode = undefined; this.headers = {}; this.body = undefined; this.streaming = false; this.stream = null; }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function createUnbufferedStream() { this.streaming = true; return this.stream; }
...
} else if (AWS.HttpClient.streamsApiVersion === 2) {
stream.end();
} else {
stream.emit('end')
}
}
var httpStream = resp.httpResponse.createUnbufferedStream();
if (AWS.HttpClient.streamsApiVersion === 2) {
if (shouldCheckContentLength) {
var lengthAccumulator = new streams.PassThrough();
lengthAccumulator._write = function(chunk) {
if (chunk && chunk.length) {
receivedLen += chunk.length;
...
IAM = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
ImportExport = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
Inspector = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
Iot = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
IotData = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function setupRequestListeners(request) { request.addListener('validateResponse', this.validateResponseBody) }
n/a
function validateResponseBody(resp) { var body = resp.httpResponse.body.toString() || '{}'; var bodyCheck = body.trim(); if (!bodyCheck || bodyCheck.charAt(0) !== '{') { resp.httpResponse.body = ''; } }
n/a
function validateService() { if (!this.config.endpoint || this.config.endpoint.indexOf('{') >= 0) { var msg = 'AWS.IotData requires an explicit ' + '`endpoint\' configuration option.'; throw AWS.util.error(new Error(), {name: 'InvalidEndpoint', message: msg}); } }
n/a
function JsonBuilder() { }
n/a
function JsonParser() { }
n/a
function JsonBuilder() { }
n/a
build = function (value, shape) { return JSON.stringify(translate(value, shape)); }
n/a
function JsonParser() { }
n/a
parse = function (value, shape) { return translate(JSON.parse(value), shape); }
...
* @param path [String] the path relative to your process's current
* working directory to load configuration from.
* @return [AWS.Config] the same configuration object
*/
loadFromPath: function loadFromPath(path) {
this.clear();
var options = JSON.parse(AWS.util.readFileSync(path));
var fileSystemCreds = new AWS.FileSystemCredentials(path);
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
...
KMS = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
Kinesis = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
KinesisAnalytics = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
Lambda = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
LexRuntime = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
Lightsail = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
MTurk = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
MachineLearning = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
function buildEndpoint(request) { var url = request.params.PredictEndpoint; if (url) { request.httpRequest.endpoint = new AWS.Endpoint(url); } }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function setupRequestListeners(request) { if (request.operation === 'predict') { request.addListener('build', this.buildEndpoint); } }
n/a
MarketplaceCommerceAnalytics = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
MarketplaceMetering = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function MetadataService(options) { AWS.util.update(this, options); }
n/a
function Object() { [native code] }
n/a
function MetadataService(options) { AWS.util.update(this, options); }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function loadCredentials(callback) { var self = this; var basePath = '/latest/meta-data/iam/security-credentials/'; self.loadCredentialsCallbacks.push(callback); if (self.loadCredentialsCallbacks.length > 1) { return; } function callbacks(err, creds) { var cb; while ((cb = self.loadCredentialsCallbacks.shift()) !== undefined) { cb(err, creds); } } self.request(basePath, function (err, roleName) { if (err) callbacks(err); else { roleName = roleName.split('\n')[0]; // grab first (and only) role self.request(basePath + roleName, function (credErr, credData) { if (credErr) callbacks(credErr); else { try { var credentials = JSON.parse(credData); callbacks(null, credentials); } catch (parseError) { callbacks(parseError); } } }); } }); }
n/a
function request(path, callback) { path = path || '/'; var httpRequest = new AWS.HttpRequest('http://' + this.host + path); httpRequest.method = 'GET'; AWS.util.handleRequestWithRetries(httpRequest, this, callback); }
n/a
MobileAnalytics = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function Api(api, options) { api = api || {}; options = options || {}; options.api = this; api.metadata = api.metadata || {}; property(this, 'isApi', true, false); property(this, 'apiVersion', api.metadata.apiVersion); property(this, 'endpointPrefix', api.metadata.endpointPrefix); property(this, 'signingName', api.metadata.signingName); property(this, 'globalEndpoint', api.metadata.globalEndpoint); property(this, 'signatureVersion', api.metadata.signatureVersion); property(this, 'jsonVersion', api.metadata.jsonVersion); property(this, 'targetPrefix', api.metadata.targetPrefix); property(this, 'protocol', api.metadata.protocol); property(this, 'timestampFormat', api.metadata.timestampFormat); property(this, 'xmlNamespaceUri', api.metadata.xmlNamespace); property(this, 'abbreviation', api.metadata.serviceAbbreviation); property(this, 'fullName', api.metadata.serviceFullName); memoizedProperty(this, 'className', function() { var name = api.metadata.serviceAbbreviation || api.metadata.serviceFullName; if (!name) return null; name = name.replace(/^Amazon|AWS\s*|\(.*|\s+|\W+/g, ''); if (name === 'ElasticLoadBalancing') name = 'ELB'; return name; }); property(this, 'operations', new Collection(api.operations, options, function(name, operation) { return new Operation(name, operation, options); }, util.string.lowerFirst)); property(this, 'shapes', new Collection(api.shapes, options, function(name, shape) { return Shape.create(shape, options); })); property(this, 'paginators', new Collection(api.paginators, options, function(name, paginator) { return new Paginator(name, paginator, options); })); property(this, 'waiters', new Collection(api.waiters, options, function(name, waiter) { return new ResourceWaiter(name, waiter, options); }, util.string.lowerFirst)); if (options.documentation) { property(this, 'documentation', api.documentation); property(this, 'documentationUrl', api.documentationUrl); } }
n/a
function Operation(name, operation, options) { var self = this; options = options || {}; property(this, 'name', operation.name || name); property(this, 'api', options.api, false); operation.http = operation.http || {}; property(this, 'httpMethod', operation.http.method || 'POST'); property(this, 'httpPath', operation.http.requestUri || '/'); property(this, 'authtype', operation.authtype || ''); memoizedProperty(this, 'input', function() { if (!operation.input) { return new Shape.create({type: 'structure'}, options); } return Shape.create(operation.input, options); }); memoizedProperty(this, 'output', function() { if (!operation.output) { return new Shape.create({type: 'structure'}, options); } return Shape.create(operation.output, options); }); memoizedProperty(this, 'errors', function() { var list = []; if (!operation.errors) return null; for (var i = 0; i < operation.errors.length; i++) { list.push(Shape.create(operation.errors[i], options)); } return list; }); memoizedProperty(this, 'paginator', function() { return options.api.paginators[name]; }); if (options.documentation) { property(this, 'documentation', operation.documentation); property(this, 'documentationUrl', operation.documentationUrl); } // idempotentMembers only tracks top-level input shapes memoizedProperty(this, 'idempotentMembers', function() { var idempotentMembers = []; var input = self.input; var members = input.members; if (!input.members) { return idempotentMembers; } for (var name in members) { if (!members.hasOwnProperty(name)) { continue; } if (members[name].isIdempotent === true) { idempotentMembers.push(name); } } return idempotentMembers; }); }
n/a
function Paginator(name, paginator) { property(this, 'inputToken', paginator.input_token); property(this, 'limitKey', paginator.limit_key); property(this, 'moreResults', paginator.more_results); property(this, 'outputToken', paginator.output_token); property(this, 'resultKey', paginator.result_key); }
n/a
function ResourceWaiter(name, waiter, options) { options = options || {}; property(this, 'name', name); property(this, 'api', options.api, false); if (waiter.operation) { property(this, 'operation', util.string.lowerFirst(waiter.operation)); } var self = this; var keys = [ 'type', 'description', 'delay', 'maxAttempts', 'acceptors' ]; keys.forEach(function(key) { var value = waiter[key]; if (value) { property(self, key, value); } }); }
...
/**
* Waits for a given state on a service object
* @param service [Service] the service object to wait on
* @param state [String] the state (defined in waiter configuration) to wait
* for.
* @example Create a waiter for running EC2 instances
* var ec2 = new AWS.EC2;
* var waiter = new AWS.ResourceWaiter(ec2, 'instanceRunning');
*/
constructor: function constructor(service, state) {
this.service = service;
this.state = state;
this.loadWaiterConfig(this.state);
},
...
function Shape(shape, options, memberName) { options = options || {}; property(this, 'shape', shape.shape); property(this, 'api', options.api, false); property(this, 'type', shape.type); property(this, 'enum', shape.enum); property(this, 'min', shape.min); property(this, 'max', shape.max); property(this, 'pattern', shape.pattern); property(this, 'location', shape.location || this.location || 'body'); property(this, 'name', this.name || shape.xmlName || shape.queryName || shape.locationName || memberName); property(this, 'isStreaming', shape.streaming || this.isStreaming || false); property(this, 'isComposite', shape.isComposite || false); property(this, 'isShape', true, false); property(this, 'isQueryName', Boolean(shape.queryName), false); property(this, 'isLocationName', Boolean(shape.locationName), false); property(this, 'isIdempotent', shape.idempotencyToken === true); property(this, 'isJsonValue', shape.jsonvalue === true); if (options.documentation) { property(this, 'documentation', shape.documentation); property(this, 'documentationUrl', shape.documentationUrl); } if (shape.xmlAttribute) { property(this, 'isXmlAttribute', shape.xmlAttribute || false); } // type conversion and parsing property(this, 'defaultValue', null); this.toWireFormat = function(value) { if (value === null || value === undefined) return ''; return value; }; this.toType = function(value) { return value; }; }
n/a
function Shape(shape, options, memberName) { options = options || {}; property(this, 'shape', shape.shape); property(this, 'api', options.api, false); property(this, 'type', shape.type); property(this, 'enum', shape.enum); property(this, 'min', shape.min); property(this, 'max', shape.max); property(this, 'pattern', shape.pattern); property(this, 'location', shape.location || this.location || 'body'); property(this, 'name', this.name || shape.xmlName || shape.queryName || shape.locationName || memberName); property(this, 'isStreaming', shape.streaming || this.isStreaming || false); property(this, 'isComposite', shape.isComposite || false); property(this, 'isShape', true, false); property(this, 'isQueryName', Boolean(shape.queryName), false); property(this, 'isLocationName', Boolean(shape.locationName), false); property(this, 'isIdempotent', shape.idempotencyToken === true); property(this, 'isJsonValue', shape.jsonvalue === true); if (options.documentation) { property(this, 'documentation', shape.documentation); property(this, 'documentationUrl', shape.documentationUrl); } if (shape.xmlAttribute) { property(this, 'isXmlAttribute', shape.xmlAttribute || false); } // type conversion and parsing property(this, 'defaultValue', null); this.toWireFormat = function(value) { if (value === null || value === undefined) return ''; return value; }; this.toType = function(value) { return value; }; }
n/a
function create(shape, options, memberName) { if (shape.isShape) return shape; var refShape = Shape.resolve(shape, options); if (refShape) { var filteredKeys = Object.keys(shape); if (!options.documentation) { filteredKeys = filteredKeys.filter(function(name) { return !name.match(/documentation/); }); } if (filteredKeys === ['shape']) { // no inline customizations return refShape; } // create an inline shape with extra members var InlineShape = function() { refShape.constructor.call(this, shape, options, memberName); }; InlineShape.prototype = refShape; return new InlineShape(); } else { // set type if not set if (!shape.type) { if (shape.members) shape.type = 'structure'; else if (shape.member) shape.type = 'list'; else if (shape.key) shape.type = 'map'; else shape.type = 'string'; } // normalize types var origType = shape.type; if (Shape.normalizedTypes[shape.type]) { shape.type = Shape.normalizedTypes[shape.type]; } if (Shape.types[shape.type]) { return new Shape.types[shape.type](shape, options, memberName); } else { throw new Error('Unrecognized shape type: ' + origType); } } }
n/a
function resolve(shape, options) { if (shape.shape) { var refShape = options.api.shapes[shape.shape]; if (!refShape) { throw new Error('Cannot find shape reference: ' + shape.shape); } return refShape; } else { return null; } }
...
if (self.credentials) {
if (typeof self.credentials.get === 'function') {
getAsyncCredentials();
} else { // static credentials
getStaticCredentials();
}
} else if (self.credentialProvider) {
self.credentialProvider.resolve(function(err, creds) {
if (err) {
err = credError('Could not load credentials from any providers', err);
}
self.credentials = creds;
finish(err);
});
} else {
...
NodeHttpClient = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Object() { [native code] }
n/a
OpsWorks = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
OpsWorksCM = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
Organizations = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function ParamValidator(validation) { if (validation === true || validation === undefined) { validation = {'min': true}; } this.validation = validation; }
...
}
req.params = params;
});
add('VALIDATE_PARAMETERS', 'validate', function VALIDATE_PARAMETERS(req) {
var rules = req.service.api.operations[req.operation].input;
var validation = req.service.config.paramValidation;
new AWS.ParamValidator(validation).validate(rules, req.params);
});
addAsync('COMPUTE_SHA256', 'afterBuild', function COMPUTE_SHA256(req, done) {
req.haltHandlersOnError();
if (!req.service.api.signatureVersion) return done(); // none
if (req.service.getSignerClass(req) === AWS.Signers.V4) {
var body = req.httpRequest.body || '';
...
function Object() { [native code] }
n/a
function ParamValidator(validation) { if (validation === true || validation === undefined) { validation = {'min': true}; } this.validation = validation; }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function fail(code, message) { this.errors.push(AWS.util.error(new Error(message), {code: code})); }
...
this.validateType(params, context, ['object'], 'structure');
var paramName;
for (var i = 0; shape.required && i < shape.required.length; i++) {
paramName = shape.required[i];
var value = params[paramName];
if (value === undefined || value === null) {
this.fail('MissingRequiredParameter',
'Missing required key \'' + paramName + '\' in ' + context);
}
}
// validate hash members
for (paramName in params) {
if (!Object.prototype.hasOwnProperty.call(params, paramName)) continue;
...
function validate(shape, params, context) { this.errors = []; this.validateMember(shape, params || {}, context || 'params'); if (this.errors.length > 1) { var msg = this.errors.join('\n* '); msg = 'There were ' + this.errors.length + ' validation errors:\n* ' + msg; throw AWS.util.error(new Error(msg), {code: 'MultipleValidationErrors', errors: this.errors}); } else if (this.errors.length === 1) { throw this.errors[0]; } else { return true; } }
...
}
req.params = params;
});
add('VALIDATE_PARAMETERS', 'validate', function VALIDATE_PARAMETERS(req) {
var rules = req.service.api.operations[req.operation].input;
var validation = req.service.config.paramValidation;
new AWS.ParamValidator(validation).validate(rules, req.params);
});
addAsync('COMPUTE_SHA256', 'afterBuild', function COMPUTE_SHA256(req, done) {
req.haltHandlersOnError();
if (!req.service.api.signatureVersion) return done(); // none
if (req.service.getSignerClass(req) === AWS.Signers.V4) {
var body = req.httpRequest.body || '';
...
function validateRange(shape, value, context) { if (this.validation['enum'] && shape['enum'] !== undefined) { // Fail if the string value is not present in the enum list if (shape['enum'].indexOf(value) === -1) { this.fail('EnumError', 'Found string value of ' + value + ', but ' + 'expected ' + shape['enum'].join('|') + ' for ' + context); } } }
...
validateString: function validateString(shape, value, context) {
var validTypes = ['string'];
if (shape.isJsonValue) {
validTypes = validTypes.concat(['number', 'object', 'boolean']);
}
if (value !== null && this.validateType(value, context, validTypes)) {
this.validateEnum(shape, value, context);
this.validateRange(shape, value.length, context, 'string length');
this.validatePattern(shape, value, context);
}
},
validatePattern: function validatePattern(shape, value, context) {
if (this.validation['pattern'] && shape['pattern'] !== undefined) {
...
function validateList(shape, params, context) { if (this.validateType(params, context, [Array])) { this.validateRange(shape, params.length, context, 'list member count'); // validate array members for (var i = 0; i < params.length; i++) { this.validateMember(shape.member, params[i], context + '[' + i + ']'); } } }
...
},
validateMember: function validateMember(shape, param, context) {
switch (shape.type) {
case 'structure':
return this.validateStructure(shape, param, context);
case 'list':
return this.validateList(shape, param, context);
case 'map':
return this.validateMap(shape, param, context);
default:
return this.validateScalar(shape, param, context);
}
},
...
function validateMap(shape, params, context) { if (this.validateType(params, context, ['object'], 'map')) { // Build up a count of map members to validate range traits. var mapCount = 0; for (var param in params) { if (!Object.prototype.hasOwnProperty.call(params, param)) continue; // Validate any map key trait constraints this.validateMember(shape.key, param, context + '[key=\'' + param + '\']') this.validateMember(shape.value, params[param], context + '[\'' + param + '\']'); mapCount++; } this.validateRange(shape, mapCount, context, 'map member count'); } }
...
validateMember: function validateMember(shape, param, context) {
switch (shape.type) {
case 'structure':
return this.validateStructure(shape, param, context);
case 'list':
return this.validateList(shape, param, context);
case 'map':
return this.validateMap(shape, param, context);
default:
return this.validateScalar(shape, param, context);
}
},
validateList: function validateList(shape, params, context) {
if (this.validateType(params, context, [Array])) {
...
function validateMember(shape, param, context) { switch (shape.type) { case 'structure': return this.validateStructure(shape, param, context); case 'list': return this.validateList(shape, param, context); case 'map': return this.validateMap(shape, param, context); default: return this.validateScalar(shape, param, context); } }
...
validation = {'min': true};
}
this.validation = validation;
},
validate: function validate(shape, params, context) {
this.errors = [];
this.validateMember(shape, params || {}, context || 'params');
if (this.errors.length > 1) {
var msg = this.errors.join('\n* ');
msg = 'There were ' + this.errors.length +
' validation errors:\n* ' + msg;
throw AWS.util.error(new Error(msg),
{code: 'MultipleValidationErrors', errors: this.errors});
...
function validateNumber(shape, value, context) { if (value === null || value === undefined) return; if (typeof value === 'string') { var castedValue = parseFloat(value); if (castedValue.toString() === value) value = castedValue; } if (this.validateType(value, context, ['number'])) { this.validateRange(shape, value, context, 'numeric value'); } }
...
case 'string':
return this.validateString(shape, value, context);
case 'base64':
case 'binary':
return this.validatePayload(value, context);
case 'integer':
case 'float':
return this.validateNumber(shape, value, context);
case 'boolean':
return this.validateType(value, context, ['boolean']);
case 'timestamp':
return this.validateType(value, context, [Date,
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z$/, 'number'],
'Date object, ISO-8601 string, or a UNIX timestamp');
default:
...
function validatePattern(shape, value, context) { if (this.validation['pattern'] && shape['pattern'] !== undefined) { if (!(new RegExp(shape['pattern'])).test(value)) { this.fail('PatternMatchError', 'Provided value "' + value + '" ' + 'does not match regex pattern /' + shape['pattern'] + '/ for ' + context); } } }
...
var validTypes = ['string'];
if (shape.isJsonValue) {
validTypes = validTypes.concat(['number', 'object', 'boolean']);
}
if (value !== null && this.validateType(value, context, validTypes)) {
this.validateEnum(shape, value, context);
this.validateRange(shape, value.length, context, 'string length');
this.validatePattern(shape, value, context);
}
},
validatePattern: function validatePattern(shape, value, context) {
if (this.validation['pattern'] && shape['pattern'] !== undefined) {
if (!(new RegExp(shape['pattern'])).test(value)) {
this.fail('PatternMatchError', 'Provided value "' + value + '" '
...
function validatePayload(value, context) { if (value === null || value === undefined) return; 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 = AWS.util.stream.Stream; if (AWS.util.Buffer.isBuffer(value) || 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'); }
...
switch (shape.type) {
case null:
case undefined:
case 'string':
return this.validateString(shape, value, context);
case 'base64':
case 'binary':
return this.validatePayload(value, context);
case 'integer':
case 'float':
return this.validateNumber(shape, value, context);
case 'boolean':
return this.validateType(value, context, ['boolean']);
case 'timestamp':
return this.validateType(value, context, [Date,
...
function validateRange(shape, value, context, descriptor) { if (this.validation['min']) { if (shape['min'] !== undefined && value < shape['min']) { this.fail('MinRangeError', 'Expected ' + descriptor + ' >= ' + shape['min'] + ', but found ' + value + ' for ' + context); } } if (this.validation['max']) { if (shape['max'] !== undefined && value > shape['max']) { this.fail('MaxRangeError', 'Expected ' + descriptor + ' <= ' + shape['max'] + ', but found ' + value + ' for ' + context); } } }
...
default:
return this.validateScalar(shape, param, context);
}
},
validateList: function validateList(shape, params, context) {
if (this.validateType(params, context, [Array])) {
this.validateRange(shape, params.length, context, 'list member count');
// validate array members
for (var i = 0; i < params.length; i++) {
this.validateMember(shape.member, params[i], context + '[' + i + ']');
}
}
},
...
function validateScalar(shape, value, context) { switch (shape.type) { case null: case undefined: case 'string': return this.validateString(shape, value, context); case 'base64': case 'binary': return this.validatePayload(value, context); case 'integer': case 'float': return this.validateNumber(shape, value, context); case 'boolean': return this.validateType(value, context, ['boolean']); case 'timestamp': return this.validateType(value, context, [Date, /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z$/, 'number'], 'Date object, ISO-8601 string, or a UNIX timestamp'); default: return this.fail('UnkownType', 'Unhandled type ' + shape.type + ' for ' + context); } }
...
case 'structure':
return this.validateStructure(shape, param, context);
case 'list':
return this.validateList(shape, param, context);
case 'map':
return this.validateMap(shape, param, context);
default:
return this.validateScalar(shape, param, context);
}
},
validateList: function validateList(shape, params, context) {
if (this.validateType(params, context, [Array])) {
this.validateRange(shape, params.length, context, 'list member count');
// validate array members
...
function validateString(shape, value, context) { var validTypes = ['string']; if (shape.isJsonValue) { validTypes = validTypes.concat(['number', 'object', 'boolean']); } if (value !== null && this.validateType(value, context, validTypes)) { this.validateEnum(shape, value, context); this.validateRange(shape, value.length, context, 'string length'); this.validatePattern(shape, value, context); } }
...
},
validateScalar: function validateScalar(shape, value, context) {
switch (shape.type) {
case null:
case undefined:
case 'string':
return this.validateString(shape, value, context);
case 'base64':
case 'binary':
return this.validatePayload(value, context);
case 'integer':
case 'float':
return this.validateNumber(shape, value, context);
case 'boolean':
...
function validateStructure(shape, params, context) { this.validateType(params, context, ['object'], 'structure'); var paramName; for (var i = 0; shape.required && i < shape.required.length; i++) { paramName = shape.required[i]; var value = params[paramName]; if (value === undefined || value === null) { this.fail('MissingRequiredParameter', 'Missing required key \'' + paramName + '\' in ' + context); } } // validate hash members for (paramName in params) { if (!Object.prototype.hasOwnProperty.call(params, paramName)) continue; var paramValue = params[paramName], memberShape = shape.members[paramName]; if (memberShape !== undefined) { var memberContext = [context, paramName].join('.'); this.validateMember(memberShape, paramValue, memberContext); } else { this.fail('UnexpectedParameter', 'Unexpected key \'' + paramName + '\' found in ' + context); } } return true; }
...
return true;
},
validateMember: function validateMember(shape, param, context) {
switch (shape.type) {
case 'structure':
return this.validateStructure(shape, param, context);
case 'list':
return this.validateList(shape, param, context);
case 'map':
return this.validateMap(shape, param, context);
default:
return this.validateScalar(shape, param, context);
}
...
function validateType(value, context, acceptedTypes, type) { // We will not log an error for null or undefined, but we will return // false so that callers know that the expected type was not strictly met. if (value === null || value === undefined) return false; var foundInvalidType = false; for (var i = 0; i < acceptedTypes.length; i++) { if (typeof acceptedTypes[i] === 'string') { if (typeof value === acceptedTypes[i]) return true; } else if (acceptedTypes[i] instanceof RegExp) { if ((value || '').toString().match(acceptedTypes[i])) return true; } else { if (value instanceof acceptedTypes[i]) return true; if (AWS.util.isType(value, acceptedTypes[i])) return true; if (!type && !foundInvalidType) acceptedTypes = acceptedTypes.slice(); acceptedTypes[i] = AWS.util.typeName(acceptedTypes[i]); } foundInvalidType = true; } var acceptedType = type; if (!acceptedType) { acceptedType = acceptedTypes.join(', ').replace(/,([^,]+)$/, ', or$1'); } var vowel = acceptedType.match(/^[aeiou]/i) ? 'n' : ''; this.fail('InvalidParameterType', 'Expected ' + context + ' to be a' + vowel + ' ' + acceptedType); return false; }
...
},
fail: function fail(code, message) {
this.errors.push(AWS.util.error(new Error(message), {code: code}));
},
validateStructure: function validateStructure(shape, params, context) {
this.validateType(params, context, ['object'], 'structure');
var paramName;
for (var i = 0; shape.required && i < shape.required.length; i++) {
paramName = shape.required[i];
var value = params[paramName];
if (value === undefined || value === null) {
this.fail('MissingRequiredParameter',
...
Pinpoint = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
Polly = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Signer(options) { options = options || {}; this.options = options; this.service = options.service; this.bindServiceObject(options); this._operations = {}; }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
function Signer(options) { options = options || {}; this.options = options; this.service = options.service; this.bindServiceObject(options); this._operations = {}; }
n/a
function Object() { [native code] }
n/a
function bindServiceObject(options) { options = options || {}; if (!this.service) { this.service = new AWS.Polly(options); } else { var config = AWS.util.copy(this.service.config); this.service = new this.service.constructor.__super__(config); this.service.config.params = AWS.util.merge(this.service.config.params || {}, options.params); } }
n/a
function Signer(options) { options = options || {}; this.options = options; this.service = options.service; this.bindServiceObject(options); this._operations = {}; }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function convertPostToGet(req) { // convert method req.httpRequest.method = 'GET'; var operation = req.service.api.operations[req.operation]; // get cached operation input first var input = this._operations[req.operation]; if (!input) { // modify the original input this._operations[req.operation] = input = this.modifyInputMembers(operation.input); } var uri = rest.generateURI(req.httpRequest.endpoint.path, operation.httpPath, input, req.params); req.httpRequest.path = uri; req.httpRequest.body = ''; // don't need these headers on a GET request delete req.httpRequest.headers['Content-Length']; delete req.httpRequest.headers['Content-Type']; }
n/a
function getSynthesizeSpeechUrl(params, expires, callback) { var self = this; var request = this.service.makeRequest('synthesizeSpeech', params); // remove existing build listeners request.removeAllListeners('build'); request.on('build', function(req) { self.convertPostToGet(req); }); return request.presign(expires, callback); }
n/a
function modifyInputMembers(input) { // make copies of the input so we don't overwrite the api // need to be careful to copy anything we access/modify var modifiedInput = AWS.util.copy(input); modifiedInput.members = AWS.util.copy(input.members); AWS.util.each(input.members, function(name, member) { modifiedInput.members[name] = AWS.util.copy(member); // update location and locationName if (!member.location || member.location === 'body') { modifiedInput.members[name].location = 'querystring'; modifiedInput.members[name].locationName = name; } }); return modifiedInput; }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
RDS = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
function buildCrossRegionPresignedUrl(req, done) { var config = AWS.util.copy(req.service.config); config.region = req.params.SourceRegion; delete req.params.SourceRegion; delete config.endpoint; // relevant params for the operation will already be in req.params delete config.params; config.signatureVersion = 'v4'; var destinationRegion = req.service.config.region; var svc = new req.service.constructor(config); var newReq = svc[req.operation](AWS.util.copy(req.params)); newReq.on('build', function addDestinationRegionParam(request) { var httpRequest = request.httpRequest; httpRequest.params.DestinationRegion = destinationRegion; httpRequest.body = AWS.util.queryParamsToString(httpRequest.params); }); newReq.presign(function(err, url) { if (err) done(err); else { req.params.PreSignedUrl = url; done(); } }); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function setupRequestListeners(request) { if (crossRegionOperations.indexOf(request.operation) !== -1 && request.params.SourceRegion) { request.params = AWS.util.copy(request.params); if (request.params.PreSignedUrl || request.params.SourceRegion === this.config.region) { delete request.params.SourceRegion; } else { var doesParamValidation = !!this.config.paramValidation; // remove the validate parameters listener so we can re-add it after we build the URL if (doesParamValidation) { request.removeListener('validate', AWS.EventListeners.Core.VALIDATE_PARAMETERS); } request.onAsync('validate', this.buildCrossRegionPresignedUrl); if (doesParamValidation) { request.addListener('validate', AWS.EventListeners.Core.VALIDATE_PARAMETERS); } } } }
n/a
Redshift = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
Rekognition = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function Request(service, operation, params) { var endpoint = service.endpoint; var region = service.config.region; var customUserAgent = service.config.customUserAgent; // global endpoints sign as us-east-1 if (service.isGlobalEndpoint) region = 'us-east-1'; this.domain = domain && domain.active; this.service = service; this.operation = operation; this.params = params || {}; this.httpRequest = new AWS.HttpRequest(endpoint, region); this.httpRequest.appendToUserAgent(customUserAgent); this.startTime = AWS.util.date.getDate(); this.response = new AWS.Response(this); this._asm = new AcceptorStateMachine(fsm.states, 'validate'); this._haltHandlersOnError = false; AWS.SequentialExecutor.call(this); this.emit = this.emitEvent; }
n/a
function Object() { [native code] }
n/a
function addPromisesToClass(PromiseDependency) { this.prototype.promise = function promise() { var self = this; // append to user agent this.httpRequest.appendToUserAgent('promise'); return new PromiseDependency(function(resolve, reject) { self.on('complete', function(resp) { if (resp.error) { reject(resp.error); } else { resolve(resp.data); } }); self.runTo(); }); }; }
n/a
function deletePromisesFromClass() { delete this.prototype.promise; }
n/a
function abort() { this.removeAllListeners('validateResponse'); this.removeAllListeners('extractError'); this.on('validateResponse', function addAbortedError(resp) { resp.error = AWS.util.error(new Error('Request aborted by user'), { code: 'RequestAbortedError', retryable: false }); }); if (this.httpRequest.stream) { // abort HTTP stream this.httpRequest.stream.abort(); if (this.httpRequest._abortCallback) { this.httpRequest._abortCallback(); } else { this.removeAllListeners('send'); // haven't sent yet, so let's not } } return this; }
...
this.on('validateResponse', function addAbortedError(resp) {
resp.error = AWS.util.error(new Error('Request aborted by user'), {
code: 'RequestAbortedError', retryable: false
});
});
if (this.httpRequest.stream) { // abort HTTP stream
this.httpRequest.stream.abort();
if (this.httpRequest._abortCallback) {
this.httpRequest._abortCallback();
} else {
this.removeAllListeners('send'); // haven't sent yet, so let's not
}
}
...
function on(eventName, listener) { if (this._events[eventName]) { this._events[eventName].push(listener); } else { this._events[eventName] = [listener]; } return this; }
...
/**
* @api private
*/
toGet: function toGet() {
if (this.service.api.protocol === 'query' ||
this.service.api.protocol === 'ec2') {
this.removeListener('build', this.buildAsGet);
this.addListener('build', this.buildAsGet);
}
return this;
},
/**
* @api private
*/
...
function addListeners(listeners) { var self = this; // extract listeners if parameter is an SequentialExecutor object if (listeners._events) listeners = listeners._events; AWS.util.each(listeners, function(event, callbacks) { if (typeof callbacks === 'function') callbacks = [callbacks]; AWS.util.arrayEach(callbacks, function(callback) { self.on(event, callback); }); }); return self; }
...
}
delete params.$waiter;
}
var request = this.service.makeRequest(this.config.operation, params);
request._waiter = this;
request.response.maxRetries = this.config.maxAttempts;
request.addListeners(this.listeners);
if (callback) request.send(callback);
return request;
},
setSuccess: function setSuccess(resp) {
resp.error = null;
...
function addNamedAsyncListener(name, eventName, callback) { callback._isAsync = true; return this.addNamedListener(name, eventName, callback); }
n/a
function addNamedListener(name, eventName, callback) { this[name] = callback; this.addListener(eventName, callback); return this; }
n/a
function addNamedListeners(callback) { var self = this; callback( function() { self.addNamedListener.apply(self, arguments); }, function() { self.addNamedAsyncListener.apply(self, arguments); } ); return this; }
...
* @return [Function]
* @readonly
*/
Core: {} /* doc hack */
};
AWS.EventListeners = {
Core: new SequentialExecutor().addNamedListeners(function(add, addAsync) {
addAsync('VALIDATE_CREDENTIALS', 'validate',
function VALIDATE_CREDENTIALS(req, done) {
if (!req.service.api.signatureVersion) return done(); // none
req.service.config.getCredentials(function(err) {
if (err) {
req.response.error = AWS.util.error(err,
{code: 'CredentialsError', message: 'Missing credentials in config'});
...
function build(callback) { return this.runTo('send', callback); }
n/a
function buildAsGet(request) { request.httpRequest.method = 'GET'; request.httpRequest.path = request.service.endpoint.path + '?' + request.httpRequest.body; request.httpRequest.body = ''; // don't need these headers on a GET request delete request.httpRequest.headers['Content-Length']; delete request.httpRequest.headers['Content-Type']; }
n/a
function callListeners(listeners, args, doneCallback, prevError) { var self = this; var error = prevError || null; function callNextListener(err) { if (err) { error = AWS.util.error(error || new Error(), err); if (self._haltHandlersOnError) { return doneCallback.call(self, error); } } self.callListeners(listeners, args, doneCallback, error); } while (listeners.length > 0) { var listener = listeners.shift(); if (listener._isAsync) { // asynchronous listener listener.apply(self, args.concat([callNextListener])); return; // stop here, callNextListener will continue } else { // synchronous listener try { listener.apply(self, args); } catch (err) { error = AWS.util.error(error || new Error(), err); } if (error && self._haltHandlersOnError) { doneCallback.call(self, error); return; } } } doneCallback.call(self, error); }
n/a
function Request(service, operation, params) { var endpoint = service.endpoint; var region = service.config.region; var customUserAgent = service.config.customUserAgent; // global endpoints sign as us-east-1 if (service.isGlobalEndpoint) region = 'us-east-1'; this.domain = domain && domain.active; this.service = service; this.operation = operation; this.params = params || {}; this.httpRequest = new AWS.HttpRequest(endpoint, region); this.httpRequest.appendToUserAgent(customUserAgent); this.startTime = AWS.util.date.getDate(); this.response = new AWS.Response(this); this._asm = new AcceptorStateMachine(fsm.states, 'validate'); this._haltHandlersOnError = false; AWS.SequentialExecutor.call(this); this.emit = this.emitEvent; }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function createReadStream() { var streams = AWS.util.stream; var req = this; var stream = null; if (AWS.HttpClient.streamsApiVersion === 2) { stream = new streams.PassThrough(); req.send(); } else { stream = new streams.Stream(); stream.readable = true; stream.sent = false; stream.on('newListener', function(event) { if (!stream.sent && event === 'data') { stream.sent = true; process.nextTick(function() { req.send(); }); } }); } this.on('httpHeaders', function streamHeaders(statusCode, headers, resp) { if (statusCode < 300) { req.removeListener('httpData', AWS.EventListeners.Core.HTTP_DATA); req.removeListener('httpError', AWS.EventListeners.Core.HTTP_ERROR); req.on('httpError', function streamHttpError(error) { resp.error = error; resp.error.retryable = false; }); var shouldCheckContentLength = false; var expectedLen; if (req.httpRequest.method !== 'HEAD') { expectedLen = parseInt(headers['content-length'], 10); } if (expectedLen !== undefined && !isNaN(expectedLen) && expectedLen >= 0) { shouldCheckContentLength = true; var receivedLen = 0; } var checkContentLengthAndEmit = function checkContentLengthAndEmit() { if (shouldCheckContentLength && receivedLen !== expectedLen) { stream.emit('error', AWS.util.error( new Error('Stream content length mismatch. Received ' + receivedLen + ' of ' + expectedLen + ' bytes.'), { code: 'StreamContentLengthMismatch' } )); } else if (AWS.HttpClient.streamsApiVersion === 2) { stream.end(); } else { stream.emit('end') } } var httpStream = resp.httpResponse.createUnbufferedStream(); if (AWS.HttpClient.streamsApiVersion === 2) { if (shouldCheckContentLength) { var lengthAccumulator = new streams.PassThrough(); lengthAccumulator._write = function(chunk) { if (chunk && chunk.length) { receivedLen += chunk.length; } return streams.PassThrough.prototype._write.apply(this, arguments); }; lengthAccumulator.on('end', checkContentLengthAndEmit); httpStream.pipe(lengthAccumulator).pipe(stream, { end: false }); } else { httpStream.pipe(stream); } } else { if (shouldCheckContentLength) { httpStream.on('data', function(arg) { if (arg && arg.length) { receivedLen += arg.length; } }); } httpStream.on('data', function(arg) { stream.emit('data', arg); }); httpStream.on('end', checkContentLengthAndEmit); } httpStream.on('error', function(err) { shouldCheckContentLength = false; stream.emit('error', err); }); } }); this.on('error', function(err) { stream.emit('error', err); }); return stream; }
...
/**
* Converts the request object into a readable stream that
* can be read from or piped into a writable stream.
*
* @note The data read from a readable stream contains only
* the raw HTTP body contents.
* @example Manually reading from a stream
* request.createReadStream().on('data', function(data) {
* console.log("Got data:", data.toString());
* });
* @example Piping a request body into a file
* var out = fs.createWriteStream('/path/to/outfile.jpg');
* s3.service.getObject(params).createReadStream().pipe(out);
* @return [Stream] the readable stream object that can be piped
* or read from (by registering 'data' event listeners).
...
function eachItem(callback) { var self = this; function wrappedCallback(err, data) { if (err) return callback(err, null); if (data === null) return callback(null, null); var config = self.service.paginationConfig(self.operation); var resultKey = config.resultKey; if (Array.isArray(resultKey)) resultKey = resultKey[0]; var items = jmespath.search(data, resultKey); var continueIteration = true; AWS.util.arrayEach(items, function(item) { continueIteration = callback(null, item); if (continueIteration === false) { return AWS.util.abort; } }); return continueIteration; } this.eachPage(wrappedCallback); }
n/a
function eachPage(callback) { // Make all callbacks async-ish callback = AWS.util.fn.makeAsync(callback, 3); function wrappedCallback(response) { callback.call(response, response.error, response.data, function (result) { if (result === false) return; if (response.hasNextPage()) { response.nextPage().on('complete', wrappedCallback).send(); } else { callback.call(response, null, null, AWS.util.fn.noop); } }); } this.on('complete', wrappedCallback).send(); }
...
* Iterates over each page of results given a pageable request, calling
* the provided callback with each page of data. After all pages have been
* retrieved, the callback is called with `null` data.
*
* @note This operation can generate multiple requests to a service.
* @example Iterating over multiple pages of objects in an S3 bucket
* var pages = 1;
* s3.listObjects().eachPage(function(err, data) {
* if (err) return;
* console.log("Page", pages++);
* console.log(data);
* });
* @example Iterating over multiple pages with an asynchronous callback
* s3.listObjects(params).eachPage(function(err, data, done) {
* doSomethingAsyncAndOrExpensive(function() {
...
function emit(eventName, eventArgs, doneCallback) { if (!doneCallback) doneCallback = function() { }; var listeners = this.listeners(eventName); var count = listeners.length; this.callListeners(listeners, eventArgs, doneCallback); return count > 0; }
...
resp.error = null;
resp.data = null;
function callback(httpResp) {
resp.httpResponse.stream = httpResp;
httpResp.on('headers', function onHeaders(statusCode, headers, statusMessage) {
resp.request.emit(
'httpHeaders',
[statusCode, headers, resp, statusMessage]
);
if (!resp.httpResponse.streaming) {
if (AWS.HttpClient.streamsApiVersion === 2) { // streams2 API check
httpResp.on('readable', function onReadable() {
...
function emit(eventName, args, done) { if (typeof args === 'function') { done = args; args = null; } if (!done) done = function() { }; if (!args) args = this.eventParameters(eventName, this.response); var origEmit = AWS.SequentialExecutor.prototype.emit; origEmit.call(this, eventName, args, function (err) { if (err) this.response.error = err; done.call(this, err); }); }
n/a
function eventParameters(eventName) { switch (eventName) { case 'restart': case 'validate': case 'sign': case 'build': case 'afterValidate': case 'afterBuild': return [this]; case 'error': return [this.response.error, this.response]; default: return [this.response]; } }
...
* @param [Array,Response] args This should be the response object,
* or an array of args to send to the event.
* @api private
*/
emitEvent: function emit(eventName, args, done) {
if (typeof args === 'function') { done = args; args = null; }
if (!done) done = function() { };
if (!args) args = this.eventParameters(eventName, this.response);
var origEmit = AWS.SequentialExecutor.prototype.emit;
origEmit.call(this, eventName, args, function (err) {
if (err) this.response.error = err;
done.call(this, err);
});
},
...
function haltHandlersOnError() { this._haltHandlersOnError = true; }
...
add('VALIDATE_PARAMETERS', 'validate', function VALIDATE_PARAMETERS(req) {
var rules = req.service.api.operations[req.operation].input;
var validation = req.service.config.paramValidation;
new AWS.ParamValidator(validation).validate(rules, req.params);
});
addAsync('COMPUTE_SHA256', 'afterBuild', function COMPUTE_SHA256(req, done) {
req.haltHandlersOnError();
if (!req.service.api.signatureVersion) return done(); // none
if (req.service.getSignerClass(req) === AWS.Signers.V4) {
var body = req.httpRequest.body || '';
AWS.util.computeSha256(body, function(err, sha) {
if (err) {
done(err);
}
...
function isPageable() { return this.service.paginationConfig(this.operation) ? true : false; }
n/a
function isPresigned() { return Object.prototype.hasOwnProperty.call(this.httpRequest.headers, 'presigned-expires'); }
n/a
function listeners(eventName) { return this._events[eventName] ? this._events[eventName].slice(0) : []; }
n/a
function on(eventName, listener) { if (this._events[eventName]) { this._events[eventName].push(listener); } else { this._events[eventName] = [listener]; } return this; }
...
* @return [Function]
* @!attribute SEND
* A request listener that initiates the HTTP connection for a
* request being sent. Handles the {AWS.Request~send 'send' Request event}
* @example Replacing the HTTP handler
* var listener = AWS.EventListeners.Core.SEND;
* request.removeListener('send', listener);
* request.on('send', function(response) {
* customHandler.send(response);
* });
* @return [Function]
* @readonly
* @!attribute HTTP_DATA
* A request listener that reads data from the HTTP connection in order
* to build the response data.
...
function onAsync(eventName, listener) { listener._isAsync = true; return this.on(eventName, listener); }
n/a
function presign(expires, callback) { if (!callback && typeof expires === 'function') { callback = expires; expires = null; } return new AWS.Signers.Presign().sign(this.toGet(), expires, callback); }
n/a
function promise() { var self = this; // append to user agent this.httpRequest.appendToUserAgent('promise'); return new PromiseDependency(function(resolve, reject) { self.on('complete', function(resp) { if (resp.error) { reject(resp.error); } else { resolve(resp.data); } }); self.runTo(); }); }
...
* @param data [Object] the de-serialized data returned from the request.
* @callback rejectedCallback function(error)
* Called if the promise is rejected.
* @param error [Error] the error object returned from the request.
* @return [Promise] A promise that represents the state of the request.
* @example Sending a request using promises.
* var request = s3.putObject({Bucket: 'bucket', Key: 'key'});
* var result = request.promise();
* result.then(function(data) { ... }, function(error) { ... });
*/
/**
* @api private
*/
build: function build(callback) {
...
function removeAllListeners(eventName) { if (eventName) { delete this._events[eventName]; } else { this._events = {}; } return this; }
...
* setTimeout(request.abort.bind(request), 1000);
*
* // prints "Error: RequestAbortedError Request aborted by user"
* @return [AWS.Request] the same request object, for chaining.
* @since v1.4.0
*/
abort: function abort() {
this.removeAllListeners('validateResponse');
this.removeAllListeners('extractError');
this.on('validateResponse', function addAbortedError(resp) {
resp.error = AWS.util.error(new Error('Request aborted by user'), {
code: 'RequestAbortedError', retryable: false
});
});
...
function removeListener(eventName, listener) { var listeners = this._events[eventName]; if (listeners) { var length = listeners.length; var position = -1; for (var i = 0; i < length; ++i) { if (listeners[i] === listener) { position = i; } } if (position > -1) { listeners.splice(position, 1); } } return this; }
...
/**
* @!attribute VALIDATE_CREDENTIALS
* A request listener that validates whether the request is being
* sent with credentials.
* Handles the {AWS.Request~validate 'validate' Request event}
* @example Sending a request without validating credentials
* var listener = AWS.EventListeners.Core.VALIDATE_CREDENTIALS;
* request.removeListener('validate', listener);
* @readonly
* @return [Function]
* @!attribute VALIDATE_REGION
* A request listener that validates whether the region is set
* for a request.
* Handles the {AWS.Request~validate 'validate' Request event}
* @example Sending a request without validating region configuration
...
function runTo(state, done) { this._asm.runTo(state, done, this); return this; }
...
if (callback) {
// append to user agent
this.httpRequest.appendToUserAgent('callback');
this.on('complete', function (resp) {
callback.call(resp, resp.error, resp.data);
});
}
this.runTo();
return this.response;
},
/**
* @!method promise()
* Returns a 'thenable' promise.
...
function send(callback) { if (callback) { // append to user agent this.httpRequest.appendToUserAgent('callback'); this.on('complete', function (resp) { callback.call(resp, resp.error, resp.data); }); } this.runTo(); return this.response; }
...
* @!attribute SEND
* A request listener that initiates the HTTP connection for a
* request being sent. Handles the {AWS.Request~send 'send' Request event}
* @example Replacing the HTTP handler
* var listener = AWS.EventListeners.Core.SEND;
* request.removeListener('send', listener);
* request.on('send', function(response) {
* customHandler.send(response);
* });
* @return [Function]
* @readonly
* @!attribute HTTP_DATA
* A request listener that reads data from the HTTP connection in order
* to build the response data.
* Handles the {AWS.Request~httpData 'httpData' Request event}.
...
function toGet() { if (this.service.api.protocol === 'query' || this.service.api.protocol === 'ec2') { this.removeListener('build', this.buildAsGet); this.addListener('build', this.buildAsGet); } return this; }
...
* @api private
*/
presign: function presign(expires, callback) {
if (!callback && typeof expires === 'function') {
callback = expires;
expires = null;
}
return new AWS.Signers.Presign().sign(this.toGet(), expires, callback);
},
/**
* @api private
*/
isPresigned: function isPresigned() {
return Object.prototype.hasOwnProperty.call(this.httpRequest.headers, 'presigned-expires');
...
function toUnauthenticated() { this.removeListener('validate', AWS.EventListeners.Core.VALIDATE_CREDENTIALS); this.removeListener('sign', AWS.EventListeners.Core.SIGN); return this; }
n/a
function constructor(service, state) { this.service = service; this.state = state; this.loadWaiterConfig(this.state); }
...
/**
* Waits for a given state on a service object
* @param service [Service] the service object to wait on
* @param state [String] the state (defined in waiter configuration) to wait
* for.
* @example Create a waiter for running EC2 instances
* var ec2 = new AWS.EC2;
* var waiter = new AWS.ResourceWaiter(ec2, 'instanceRunning');
*/
constructor: function constructor(service, state) {
this.service = service;
this.state = state;
this.loadWaiterConfig(this.state);
},
...
function Object() { [native code] }
n/a
function constructor(service, state) { this.service = service; this.state = state; this.loadWaiterConfig(this.state); }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function loadWaiterConfig(state) { if (!this.service.api.waiters[state]) { throw new AWS.util.error(new Error(), { code: 'StateNotFoundError', message: 'State ' + state + ' not found.' }); } this.config = AWS.util.copy(this.service.api.waiters[state]); }
...
* @example Create a waiter for running EC2 instances
* var ec2 = new AWS.EC2;
* var waiter = new AWS.ResourceWaiter(ec2, 'instanceRunning');
*/
constructor: function constructor(service, state) {
this.service = service;
this.state = state;
this.loadWaiterConfig(this.state);
},
service: null,
state: null,
config: null,
...
function setError(resp, retryable) { resp.data = null; resp.error = AWS.util.error(resp.error || new Error(), { code: 'ResourceNotReady', message: 'Resource is not in the state ' + this.state, retryable: retryable }); }
...
});
if (!acceptorMatched && resp.error) state = 'failure';
if (state === 'success') {
waiter.setSuccess(resp);
} else {
waiter.setError(resp, state === 'retry');
}
}
/**
* @api private
*/
AWS.ResourceWaiter = inherit({
...
function setSuccess(resp) { resp.error = null; resp.data = resp.data || {}; resp.request.removeAllListeners('extractData'); }
...
}
}
});
if (!acceptorMatched && resp.error) state = 'failure';
if (state === 'success') {
waiter.setSuccess(resp);
} else {
waiter.setError(resp, state === 'retry');
}
}
/**
* @api private
...
function wait(params, callback) { if (typeof params === 'function') { callback = params; params = undefined; } if (params && params.$waiter) { params = AWS.util.copy(params); if (typeof params.$waiter.delay === 'number') { this.config.delay = params.$waiter.delay; } if (typeof params.$waiter.maxAttempts === 'number') { this.config.maxAttempts = params.$waiter.maxAttempts; } delete params.$waiter; } var request = this.service.makeRequest(this.config.operation, params); request._waiter = this; request.response.maxRetries = this.config.maxAttempts; request.addListeners(this.listeners); if (callback) request.send(callback); return request; }
n/a
function CHECK_ACCEPTORS(resp) { var waiter = resp.request._waiter; var acceptors = waiter.config.acceptors; var acceptorMatched = false; var state = 'retry'; acceptors.forEach(function(acceptor) { if (!acceptorMatched) { var matcher = waiter.matchers[acceptor.matcher]; if (matcher && matcher(resp, acceptor.expected, acceptor.argument)) { acceptorMatched = true; state = acceptor.state; } } }); if (!acceptorMatched && resp.error) state = 'failure'; if (state === 'success') { waiter.setSuccess(resp); } else { waiter.setError(resp, state === 'retry'); } }
n/a
function CHECK_ACCEPTORS(resp) { var waiter = resp.request._waiter; var acceptors = waiter.config.acceptors; var acceptorMatched = false; var state = 'retry'; acceptors.forEach(function(acceptor) { if (!acceptorMatched) { var matcher = waiter.matchers[acceptor.matcher]; if (matcher && matcher(resp, acceptor.expected, acceptor.argument)) { acceptorMatched = true; state = acceptor.state; } } }); if (!acceptorMatched && resp.error) state = 'failure'; if (state === 'success') { waiter.setSuccess(resp); } else { waiter.setError(resp, state === 'retry'); } }
n/a
RETRY_CHECK = function (resp) { var waiter = resp.request._waiter; if (resp.error && resp.error.code === 'ResourceNotReady') { resp.error.retryDelay = (waiter.config.delay || 0) * 1000; } }
n/a
error = function (resp, expected) { if (typeof expected === 'string' && resp.error) { return expected === resp.error.code; } // if expected is not string, can be boolean indicating presence of error return expected === !!resp.error; }
...
var self = this;
function finish(err) {
callback(err, err ? null : self.credentials);
}
function credError(msg, err) {
return new AWS.util.error(err || new Error(), {
code: 'CredentialsError',
message: msg,
name: 'CredentialsError'
});
}
function getAsyncCredentials() {
...
path = function (resp, expected, argument) { var result = jmespath.search(resp.data, argument); return jmespath.strictDeepEqual(result,expected); }
n/a
pathAll = function (resp, expected, argument) { var results = jmespath.search(resp.data, argument); if (!Array.isArray(results)) results = [results]; var numResults = results.length; if (!numResults) return false; for (var ind = 0 ; ind < numResults; ind++) { if (!jmespath.strictDeepEqual(results[ind], expected)) { return false; } } return true; }
n/a
pathAny = function (resp, expected, argument) { var results = jmespath.search(resp.data, argument); if (!Array.isArray(results)) results = [results]; var numResults = results.length; for (var ind = 0 ; ind < numResults; ind++) { if (jmespath.strictDeepEqual(results[ind], expected)) { return true; } } return false; }
n/a
status = function (resp, expected) { var statusCode = resp.httpResponse.statusCode; return (typeof statusCode === 'number') && (statusCode === expected); }
n/a
function Response(request) { this.request = request; this.data = null; this.error = null; this.retryCount = 0; this.redirectCount = 0; this.httpResponse = new AWS.HttpResponse(); if (request) { this.maxRetries = request.service.numRetries(); this.maxRedirects = request.service.config.maxRedirects; } }
...
this.service = service;
this.operation = operation;
this.params = params || {};
this.httpRequest = new AWS.HttpRequest(endpoint, region);
this.httpRequest.appendToUserAgent(customUserAgent);
this.startTime = AWS.util.date.getDate();
this.response = new AWS.Response(this);
this._asm = new AcceptorStateMachine(fsm.states, 'validate');
this._haltHandlersOnError = false;
AWS.SequentialExecutor.call(this);
this.emit = this.emitEvent;
},
...
function Object() { [native code] }
n/a
function cacheNextPageTokens() { if (Object.prototype.hasOwnProperty.call(this, 'nextPageTokens')) return this.nextPageTokens; this.nextPageTokens = undefined; var config = this.request.service.paginationConfig(this.request.operation); if (!config) return this.nextPageTokens; this.nextPageTokens = null; if (config.moreResults) { if (!jmespath.search(this.data, config.moreResults)) { return this.nextPageTokens; } } var exprs = config.outputToken; if (typeof exprs === 'string') exprs = [exprs]; AWS.util.arrayEach.call(this, exprs, function (expr) { var output = jmespath.search(this.data, expr); if (output) { this.nextPageTokens = this.nextPageTokens || []; this.nextPageTokens.push(output); } }); return this.nextPageTokens; }
...
/**
* @return [Boolean] whether more pages of data can be returned by further
* requests
* @since v1.4.0
*/
hasNextPage: function hasNextPage() {
this.cacheNextPageTokens();
if (this.nextPageTokens) return true;
if (this.nextPageTokens === undefined) return undefined;
else return false;
},
/**
* @api private
...
function Response(request) { this.request = request; this.data = null; this.error = null; this.retryCount = 0; this.redirectCount = 0; this.httpResponse = new AWS.HttpResponse(); if (request) { this.maxRetries = request.service.numRetries(); this.maxRedirects = request.service.config.maxRedirects; } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function hasNextPage() { this.cacheNextPageTokens(); if (this.nextPageTokens) return true; if (this.nextPageTokens === undefined) return undefined; else return false; }
...
// Make all callbacks async-ish
callback = AWS.util.fn.makeAsync(callback, 3);
function wrappedCallback(response) {
callback.call(response, response.error, response.data, function (result) {
if (result === false) return;
if (response.hasNextPage()) {
response.nextPage().on('complete', wrappedCallback).send();
} else {
callback.call(response, null, null, AWS.util.fn.noop);
}
});
}
...
function nextPage(callback) { var config; var service = this.request.service; var operation = this.request.operation; try { config = service.paginationConfig(operation, true); } catch (e) { this.error = e; } if (!this.hasNextPage()) { if (callback) callback(this.error, null); else if (this.error) throw this.error; return null; } var params = AWS.util.copy(this.request.params); if (!this.nextPageTokens) { return callback ? callback(null, null) : null; } else { var inputTokens = config.inputToken; if (typeof inputTokens === 'string') inputTokens = [inputTokens]; for (var i = 0; i < inputTokens.length; i++) { params[inputTokens[i]] = this.nextPageTokens[i]; } return service.makeRequest(this.request.operation, params, callback); } }
...
callback = AWS.util.fn.makeAsync(callback, 3);
function wrappedCallback(response) {
callback.call(response, response.error, response.data, function (result) {
if (result === false) return;
if (response.hasNextPage()) {
response.nextPage().on('complete', wrappedCallback).send();
} else {
callback.call(response, null, null, AWS.util.fn.noop);
}
});
}
this.on('complete', wrappedCallback).send();
...
Route53 = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function retryableError(error) { if (error.code === 'PriorRequestNotComplete' && error.statusCode === 400) { return true; } else { var _super = AWS.Service.prototype.retryableError; return _super.call(this, error); } }
...
delete resp.httpResponse.buffers;
});
add('FINALIZE_ERROR', 'retry', function FINALIZE_ERROR(resp) {
if (resp.httpResponse.statusCode) {
resp.error.statusCode = resp.httpResponse.statusCode;
if (resp.error.retryable === undefined) {
resp.error.retryable = this.service.retryableError(resp.error, this);
}
}
});
add('INVALIDATE_CREDENTIALS', 'retry', function INVALIDATE_CREDENTIALS(resp) {
if (!resp.error) return;
switch (resp.error.code) {
...
function sanitizeUrl(request) { var path = request.httpRequest.path; request.httpRequest.path = path.replace(/\/%2F\w+%2F/, '/'); }
n/a
function setupRequestListeners(request) { request.on('build', this.sanitizeUrl); }
n/a
Route53Domains = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
S3 = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function ManagedUpload(options) { var self = this; AWS.SequentialExecutor.call(self); self.body = null; self.sliceFn = null; self.callback = null; self.parts = {}; self.completeInfo = []; self.fillQueue = function() { self.callback(new Error('Unsupported body payload ' + typeof self.body)); }; self.configure(options); }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
function ManagedUpload(options) { var self = this; AWS.SequentialExecutor.call(self); self.body = null; self.sliceFn = null; self.callback = null; self.parts = {}; self.completeInfo = []; self.fillQueue = function() { self.callback(new Error('Unsupported body payload ' + typeof self.body)); }; self.configure(options); }
n/a
function Object() { [native code] }
n/a
function addPromisesToClass(PromiseDependency) { this.prototype.promise = AWS.util.promisifyMethod('send', PromiseDependency); }
n/a
function deletePromisesFromClass() { delete this.prototype.promise; }
n/a
abort = function () { this.cleanup(AWS.util.error(new Error('Request aborted by user'), { code: 'RequestAbortedError', retryable: false })); }
...
this.on('validateResponse', function addAbortedError(resp) {
resp.error = AWS.util.error(new Error('Request aborted by user'), {
code: 'RequestAbortedError', retryable: false
});
});
if (this.httpRequest.stream) { // abort HTTP stream
this.httpRequest.stream.abort();
if (this.httpRequest._abortCallback) {
this.httpRequest._abortCallback();
} else {
this.removeAllListeners('send'); // haven't sent yet, so let's not
}
}
...
function on(eventName, listener) { if (this._events[eventName]) { this._events[eventName].push(listener); } else { this._events[eventName] = [listener]; } return this; }
...
/**
* @api private
*/
toGet: function toGet() {
if (this.service.api.protocol === 'query' ||
this.service.api.protocol === 'ec2') {
this.removeListener('build', this.buildAsGet);
this.addListener('build', this.buildAsGet);
}
return this;
},
/**
* @api private
*/
...
function addListeners(listeners) { var self = this; // extract listeners if parameter is an SequentialExecutor object if (listeners._events) listeners = listeners._events; AWS.util.each(listeners, function(event, callbacks) { if (typeof callbacks === 'function') callbacks = [callbacks]; AWS.util.arrayEach(callbacks, function(callback) { self.on(event, callback); }); }); return self; }
...
}
delete params.$waiter;
}
var request = this.service.makeRequest(this.config.operation, params);
request._waiter = this;
request.response.maxRetries = this.config.maxAttempts;
request.addListeners(this.listeners);
if (callback) request.send(callback);
return request;
},
setSuccess: function setSuccess(resp) {
resp.error = null;
...
function addNamedAsyncListener(name, eventName, callback) { callback._isAsync = true; return this.addNamedListener(name, eventName, callback); }
n/a
function addNamedListener(name, eventName, callback) { this[name] = callback; this.addListener(eventName, callback); return this; }
n/a
function addNamedListeners(callback) { var self = this; callback( function() { self.addNamedListener.apply(self, arguments); }, function() { self.addNamedAsyncListener.apply(self, arguments); } ); return this; }
...
* @return [Function]
* @readonly
*/
Core: {} /* doc hack */
};
AWS.EventListeners = {
Core: new SequentialExecutor().addNamedListeners(function(add, addAsync) {
addAsync('VALIDATE_CREDENTIALS', 'validate',
function VALIDATE_CREDENTIALS(req, done) {
if (!req.service.api.signatureVersion) return done(); // none
req.service.config.getCredentials(function(err) {
if (err) {
req.response.error = AWS.util.error(err,
{code: 'CredentialsError', message: 'Missing credentials in config'});
...
function adjustTotalBytes() { var self = this; try { // try to get totalBytes self.totalBytes = byteLength(self.body); } catch (e) { } // try to adjust partSize if we know payload length if (self.totalBytes) { var newPartSize = Math.ceil(self.totalBytes / self.maxTotalParts); if (newPartSize > self.partSize) self.partSize = newPartSize; } else { self.totalBytes = undefined; } }
n/a
function bindServiceObject(params) { params = params || {}; var self = this; // bind parameters to new service object if (!self.service) { self.service = new AWS.S3({params: params}); } else { var config = AWS.util.copy(self.service.config); self.service = new self.service.constructor.__super__(config); self.service.config.params = AWS.util.merge(self.service.config.params || {}, params); } }
n/a
function callListeners(listeners, args, doneCallback, prevError) { var self = this; var error = prevError || null; function callNextListener(err) { if (err) { error = AWS.util.error(error || new Error(), err); if (self._haltHandlersOnError) { return doneCallback.call(self, error); } } self.callListeners(listeners, args, doneCallback, error); } while (listeners.length > 0) { var listener = listeners.shift(); if (listener._isAsync) { // asynchronous listener listener.apply(self, args.concat([callNextListener])); return; // stop here, callNextListener will continue } else { // synchronous listener try { listener.apply(self, args); } catch (err) { error = AWS.util.error(error || new Error(), err); } if (error && self._haltHandlersOnError) { doneCallback.call(self, error); return; } } } doneCallback.call(self, error); }
n/a
function cleanup(err) { var self = this; if (self.failed) return; // clean up stream if (typeof self.body.removeAllListeners === 'function' && typeof self.body.resume === 'function') { self.body.removeAllListeners('readable'); self.body.removeAllListeners('end'); self.body.resume(); } if (self.service.config.params.UploadId && !self.leavePartsOnError) { self.service.abortMultipartUpload().send(); } AWS.util.each(self.parts, function(partNumber, part) { part.removeAllListeners('complete'); part.abort(); }); self.activeParts = 0; self.partPos = 0; self.numParts = 0; self.totalPartNumbers = 0; self.parts = {}; self.failed = true; self.callback(err); }
n/a
function configure(options) { options = options || {}; this.partSize = this.minPartSize; if (options.queueSize) this.queueSize = options.queueSize; if (options.partSize) this.partSize = options.partSize; if (options.leavePartsOnError) this.leavePartsOnError = true; if (options.tags) { if (!Array.isArray(options.tags)) { throw new Error('Tags must be specified as an array; ' + typeof options.tags + ' provided.'); } this.tags = options.tags; } if (this.partSize < this.minPartSize) { throw new Error('partSize must be greater than ' + this.minPartSize); } this.service = options.service; this.bindServiceObject(options.params); this.validateBody(); this.adjustTotalBytes(); }
n/a
function ManagedUpload(options) { var self = this; AWS.SequentialExecutor.call(self); self.body = null; self.sliceFn = null; self.callback = null; self.parts = {}; self.completeInfo = []; self.fillQueue = function() { self.callback(new Error('Unsupported body payload ' + typeof self.body)); }; self.configure(options); }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function emit(eventName, eventArgs, doneCallback) { if (!doneCallback) doneCallback = function() { }; var listeners = this.listeners(eventName); var count = listeners.length; this.callListeners(listeners, eventArgs, doneCallback); return count > 0; }
...
resp.error = null;
resp.data = null;
function callback(httpResp) {
resp.httpResponse.stream = httpResp;
httpResp.on('headers', function onHeaders(statusCode, headers, statusMessage) {
resp.request.emit(
'httpHeaders',
[statusCode, headers, resp, statusMessage]
);
if (!resp.httpResponse.streaming) {
if (AWS.HttpClient.streamsApiVersion === 2) { // streams2 API check
httpResp.on('readable', function onReadable() {
...
function fillBuffer() { var self = this; var bodyLen = byteLength(self.body); if (bodyLen === 0) { self.isDoneChunking = true; self.numParts = 1; self.nextChunk(self.body); return; } while (self.activeParts < self.queueSize && self.partPos < bodyLen) { var endPos = Math.min(self.partPos + self.partSize, bodyLen); var buf = self.sliceFn.call(self.body, self.partPos, endPos); self.partPos += self.partSize; if (byteLength(buf) < self.partSize || self.partPos === bodyLen) { self.isDoneChunking = true; self.numParts = self.totalPartNumbers + 1; } self.nextChunk(buf); } }
n/a
function fillStream() { var self = this; if (self.activeParts >= self.queueSize) return; var buf = self.body.read(self.partSize - self.partBufferLength) || self.body.read(); if (buf) { self.partBuffers.push(buf); self.partBufferLength += buf.length; self.totalChunkedBytes += buf.length; } if (self.partBufferLength >= self.partSize) { // if we have single buffer we avoid copyfull concat var pbuf = self.partBuffers.length === 1 ? self.partBuffers[0] : Buffer.concat(self.partBuffers); self.partBuffers = []; self.partBufferLength = 0; // if we have more than partSize, push the rest back on the queue if (pbuf.length > self.partSize) { var rest = pbuf.slice(self.partSize); self.partBuffers.push(rest); self.partBufferLength += rest.length; pbuf = pbuf.slice(0, self.partSize); } self.nextChunk(pbuf); } if (self.isDoneChunking && !self.isDoneSending) { // if we have single buffer we avoid copyfull concat pbuf = self.partBuffers.length === 1 ? self.partBuffers[0] : Buffer.concat(self.partBuffers); self.partBuffers = []; self.partBufferLength = 0; self.totalBytes = self.totalChunkedBytes; self.isDoneSending = true; if (self.numParts === 0 || pbuf.length > 0) { self.numParts++; self.nextChunk(pbuf); } } self.body.read(0); }
n/a
function finishMultiPart() { var self = this; var completeParams = { MultipartUpload: { Parts: self.completeInfo.slice(1) } }; self.service.completeMultipartUpload(completeParams, function(err, data) { if (err) { return self.cleanup(err); } if (Array.isArray(self.tags)) { self.service.putObjectTagging( {Tagging: {TagSet: self.tags}}, self.callback ); } else { self.callback(err, data); } }); }
n/a
function finishSinglePart(err, data) { var upload = this.request._managedUpload; var httpReq = this.request.httpRequest; var endpoint = httpReq.endpoint; if (err) return upload.callback(err); data.Location = [endpoint.protocol, '//', endpoint.host, httpReq.path].join(''); data.key = this.request.params.Key; // will stay undocumented data.Key = this.request.params.Key; data.Bucket = this.request.params.Bucket; upload.callback(err, data); }
n/a
function getTaggingHeader() { var kvPairStrings = []; for (var i = 0; i < this.tags.length; i++) { kvPairStrings.push(AWS.util.uriEscape(this.tags[i].Key) + '=' + AWS.util.uriEscape(this.tags[i].Value)); } return kvPairStrings.join('&'); }
n/a
function listeners(eventName) { return this._events[eventName] ? this._events[eventName].slice(0) : []; }
n/a
function nextChunk(chunk) { var self = this; if (self.failed) return null; var partNumber = ++self.totalPartNumbers; if (self.isDoneChunking && partNumber === 1) { var params = {Body: chunk}; if (this.tags) { params.Tagging = this.getTaggingHeader(); } var req = self.service.putObject(params); req._managedUpload = self; req.on('httpUploadProgress', self.progress).send(self.finishSinglePart); return null; } else if (self.service.config.params.ContentMD5) { var err = AWS.util.error(new Error('The Content-MD5 you specified is invalid for multi-part uploads.'), { code: 'InvalidDigest', retryable: false }); self.cleanup(err); return null; } if (self.completeInfo[partNumber] && self.completeInfo[partNumber].ETag !== null) { return null; // Already uploaded this part. } self.activeParts++; if (!self.service.config.params.UploadId) { if (!self.multipartReq) { // create multipart self.multipartReq = self.service.createMultipartUpload(); self.multipartReq.on('success', function(resp) { self.service.config.params.UploadId = resp.data.UploadId; self.multipartReq = null; }); self.queueChunks(chunk, partNumber); self.multipartReq.on('error', function(err) { self.cleanup(err); }); self.multipartReq.send(); } else { self.queueChunks(chunk, partNumber); } } else { // multipart is created, just send self.uploadPart(chunk, partNumber); } }
n/a
function on(eventName, listener) { if (this._events[eventName]) { this._events[eventName].push(listener); } else { this._events[eventName] = [listener]; } return this; }
...
* @return [Function]
* @!attribute SEND
* A request listener that initiates the HTTP connection for a
* request being sent. Handles the {AWS.Request~send 'send' Request event}
* @example Replacing the HTTP handler
* var listener = AWS.EventListeners.Core.SEND;
* request.removeListener('send', listener);
* request.on('send', function(response) {
* customHandler.send(response);
* });
* @return [Function]
* @readonly
* @!attribute HTTP_DATA
* A request listener that reads data from the HTTP connection in order
* to build the response data.
...
function onAsync(eventName, listener) { listener._isAsync = true; return this.on(eventName, listener); }
n/a
function progress(info) { var upload = this._managedUpload; if (this.operation === 'putObject') { info.part = 1; info.key = this.params.Key; } else { upload.totalUploadedBytes += info.loaded - this._lastUploadedBytes; this._lastUploadedBytes = info.loaded; info = { loaded: upload.totalUploadedBytes, total: upload.totalBytes, part: this.params.PartNumber, key: this.params.Key }; } upload.emit('httpUploadProgress', [info]); }
n/a
function promise() { var self = this; return new PromiseDependency(function(resolve, reject) { self[methodName](function(err, data) { if (err) { reject(err); } else { resolve(data); } }); }); }
...
* @param data [Object] the de-serialized data returned from the request.
* @callback rejectedCallback function(error)
* Called if the promise is rejected.
* @param error [Error] the error object returned from the request.
* @return [Promise] A promise that represents the state of the request.
* @example Sending a request using promises.
* var request = s3.putObject({Bucket: 'bucket', Key: 'key'});
* var result = request.promise();
* result.then(function(data) { ... }, function(error) { ... });
*/
/**
* @api private
*/
build: function build(callback) {
...
function queueChunks(chunk, partNumber) { var self = this; self.multipartReq.on('success', function() { self.uploadPart(chunk, partNumber); }); }
n/a
function removeAllListeners(eventName) { if (eventName) { delete this._events[eventName]; } else { this._events = {}; } return this; }
...
* setTimeout(request.abort.bind(request), 1000);
*
* // prints "Error: RequestAbortedError Request aborted by user"
* @return [AWS.Request] the same request object, for chaining.
* @since v1.4.0
*/
abort: function abort() {
this.removeAllListeners('validateResponse');
this.removeAllListeners('extractError');
this.on('validateResponse', function addAbortedError(resp) {
resp.error = AWS.util.error(new Error('Request aborted by user'), {
code: 'RequestAbortedError', retryable: false
});
});
...
function removeListener(eventName, listener) { var listeners = this._events[eventName]; if (listeners) { var length = listeners.length; var position = -1; for (var i = 0; i < length; ++i) { if (listeners[i] === listener) { position = i; } } if (position > -1) { listeners.splice(position, 1); } } return this; }
...
/**
* @!attribute VALIDATE_CREDENTIALS
* A request listener that validates whether the request is being
* sent with credentials.
* Handles the {AWS.Request~validate 'validate' Request event}
* @example Sending a request without validating credentials
* var listener = AWS.EventListeners.Core.VALIDATE_CREDENTIALS;
* request.removeListener('validate', listener);
* @readonly
* @return [Function]
* @!attribute VALIDATE_REGION
* A request listener that validates whether the region is set
* for a request.
* Handles the {AWS.Request~validate 'validate' Request event}
* @example Sending a request without validating region configuration
...
send = function (callback) { var self = this; self.failed = false; self.callback = callback || function(err) { if (err) throw err; }; var runFill = true; if (self.sliceFn) { self.fillQueue = self.fillBuffer; } else if (AWS.util.isNode()) { var Stream = AWS.util.stream.Stream; if (self.body instanceof Stream) { runFill = false; self.fillQueue = self.fillStream; self.partBuffers = []; self.body. on('error', function(err) { self.cleanup(err); }). on('readable', function() { self.fillQueue(); }). on('end', function() { self.isDoneChunking = true; self.numParts = self.totalPartNumbers; self.fillQueue.call(self); if (self.isDoneChunking && self.totalPartNumbers >= 1 && self.doneParts === self.numParts) { self.finishMultiPart(); } }); } } if (runFill) self.fillQueue.call(self); }
...
* @!attribute SEND
* A request listener that initiates the HTTP connection for a
* request being sent. Handles the {AWS.Request~send 'send' Request event}
* @example Replacing the HTTP handler
* var listener = AWS.EventListeners.Core.SEND;
* request.removeListener('send', listener);
* request.on('send', function(response) {
* customHandler.send(response);
* });
* @return [Function]
* @readonly
* @!attribute HTTP_DATA
* A request listener that reads data from the HTTP connection in order
* to build the response data.
* Handles the {AWS.Request~httpData 'httpData' Request event}.
...
function uploadPart(chunk, partNumber) { var self = this; var partParams = { Body: chunk, ContentLength: AWS.util.string.byteLength(chunk), PartNumber: partNumber }; var partInfo = {ETag: null, PartNumber: partNumber}; self.completeInfo[partNumber] = partInfo; var req = self.service.uploadPart(partParams); self.parts[partNumber] = req; req._lastUploadedBytes = 0; req._managedUpload = self; req.on('httpUploadProgress', self.progress); req.send(function(err, data) { delete self.parts[partParams.PartNumber]; self.activeParts--; if (!err && (!data || !data.ETag)) { var message = 'No access to ETag property on response.'; if (AWS.util.isBrowser()) { message += ' Check CORS configuration to expose ETag header.'; } err = AWS.util.error(new Error(message), { code: 'ETagMissing', retryable: false }); } if (err) return self.cleanup(err); partInfo.ETag = data.ETag; self.doneParts++; if (self.isDoneChunking && self.doneParts === self.numParts) { self.finishMultiPart(); } else { self.fillQueue.call(self); } }); }
n/a
function validateBody() { var self = this; self.body = self.service.config.params.Body; if (!self.body) throw new Error('params.Body is required'); if (typeof self.body === 'string') { self.body = new AWS.util.Buffer(self.body); } self.sliceFn = AWS.util.arraySliceFn(self.body); }
n/a
function addContentType(req) { var httpRequest = req.httpRequest; if (httpRequest.method === 'GET' || httpRequest.method === 'HEAD') { // Content-Type is not set in GET/HEAD requests delete httpRequest.headers['Content-Type']; return; } if (!httpRequest.headers['Content-Type']) { // always have a Content-Type httpRequest.headers['Content-Type'] = 'application/octet-stream'; } var contentType = httpRequest.headers['Content-Type']; if (AWS.util.isBrowser()) { if (typeof httpRequest.body === 'string' && !contentType.match(/;\s*charset=/)) { var charset = '; charset=UTF-8'; httpRequest.headers['Content-Type'] += charset; } else { var replaceFn = function(_, prefix, charsetName) { return prefix + charsetName.toUpperCase(); }; httpRequest.headers['Content-Type'] = contentType.replace(/(;\s*charset=)(.+)$/, replaceFn); } } }
n/a
function addExpect100Continue(req) { var len = req.httpRequest.headers['Content-Length']; if (AWS.util.isNode() && len >= 1024 * 1024) { req.httpRequest.headers['Expect'] = '100-continue'; } }
n/a
clearBucketRegionCache = function (buckets) { var bucketRegionCache = this.bucketRegionCache; if (!buckets) { buckets = Object.keys(bucketRegionCache); } else if (typeof buckets === 'string') { buckets = [buckets]; } for (var i = 0; i < buckets.length; i++) { delete bucketRegionCache[buckets[i]]; } return bucketRegionCache; }
n/a
function computeContentMd5(req) { if (req.service.willComputeChecksums(req)) { var md5 = AWS.util.crypto.md5(req.httpRequest.body, 'base64'); req.httpRequest.headers['Content-MD5'] = md5; } }
n/a
function computeSseCustomerKeyMd5(req) { var keys = { SSECustomerKey: 'x-amz-server-side-encryption-customer-key-MD5', CopySourceSSECustomerKey: 'x-amz-copy-source-server-side-encryption-customer-key-MD5' }; AWS.util.each(keys, function(key, header) { if (req.params[key]) { var value = AWS.util.crypto.md5(req.params[key], 'base64'); req.httpRequest.headers[header] = value; } }); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function correctBucketRegionFromCache(req) { var bucket = req.params.Bucket || null; if (bucket) { var service = req.service; var requestRegion = req.httpRequest.region; var cachedRegion = service.bucketRegionCache[bucket]; if (cachedRegion && cachedRegion !== requestRegion) { service.updateReqBucketRegion(req, cachedRegion); } } }
n/a
function createBucket(params, callback) { // When creating a bucket *outside* the classic region, the location // constraint must be set for the bucket and it must match the endpoint. // This chunk of code will set the location constraint param based // on the region (when possible), but it will not override a passed-in // location constraint. if (typeof params === 'function' || !params) { callback = callback || params; params = {}; } var hostname = this.endpoint.hostname; if (hostname !== this.api.globalEndpoint && !params.CreateBucketConfiguration) { params.CreateBucketConfiguration = { LocationConstraint: this.config.region }; } return this.makeRequest('createBucket', params, callback); }
n/a
function createPresignedPost(params, callback) { if (typeof params === 'function' && callback === undefined) { callback = params; params = null; } params = AWS.util.copy(params || {}); var boundParams = this.config.params || {}; var bucket = params.Bucket || boundParams.Bucket, self = this, config = this.config, endpoint = AWS.util.copy(this.endpoint); if (!config.s3BucketEndpoint) { endpoint.pathname = '/' + bucket; } function finalizePost() { return { url: AWS.util.urlFormat(endpoint), fields: self.preparePostFields( config.credentials, config.region, bucket, params.Fields, params.Conditions, params.Expires ) }; } if (callback) { config.getCredentials(function (err) { if (err) { callback(err); } callback(null, finalizePost()); }); } else { return finalizePost(); } }
n/a
function disableBodySigning(request) { var headers = request.httpRequest.headers; // Add the header to anything that isn't a presigned url, unless that presigned url had a body defined if (!Object.prototype.hasOwnProperty.call(headers, 'presigned-expires')) { headers['X-Amz-Content-Sha256'] = 'UNSIGNED-PAYLOAD'; } }
n/a
function dnsCompatibleBucketName(bucketName) { var b = bucketName; var domain = new RegExp(/^[a-z0-9][a-z0-9\.\-]{1,61}[a-z0-9]$/); var ipAddress = new RegExp(/(\d+\.){3}\d+/); var dots = new RegExp(/\.\./); return (b.match(domain) && !b.match(ipAddress) && !b.match(dots)) ? true : false; }
n/a
function extractData(resp) { var req = resp.request; if (req.operation === 'getBucketLocation') { var match = resp.httpResponse.body.toString().match(/>(.+)<\/Location/); delete resp.data['_']; if (match) { resp.data.LocationConstraint = match[1]; } else { resp.data.LocationConstraint = ''; } } var bucket = req.params.Bucket || null; if (req.operation === 'deleteBucket' && typeof bucket === 'string' && !resp.error) { req.service.clearBucketRegionCache(bucket); } else { var headers = resp.httpResponse.headers || {}; var region = headers['x-amz-bucket-region'] || null; if (!region && req.operation === 'createBucket' && !resp.error) { var createBucketConfiguration = req.params.CreateBucketConfiguration; if (!createBucketConfiguration) { region = 'us-east-1'; } else if (createBucketConfiguration.LocationConstraint === 'EU') { region = 'eu-west-1'; } else { region = createBucketConfiguration.LocationConstraint; } } if (region) { if (bucket && region !== req.service.bucketRegionCache[bucket]) { req.service.bucketRegionCache[bucket] = region; } } } req.service.extractRequestIds(resp); }
n/a
function extractError(resp) { var codes = { 304: 'NotModified', 403: 'Forbidden', 400: 'BadRequest', 404: 'NotFound' }; var req = resp.request; var code = resp.httpResponse.statusCode; var body = resp.httpResponse.body || ''; var headers = resp.httpResponse.headers || {}; var region = headers['x-amz-bucket-region'] || null; var bucket = req.params.Bucket || null; var bucketRegionCache = req.service.bucketRegionCache; if (region && bucket && region !== bucketRegionCache[bucket]) { bucketRegionCache[bucket] = region; } var cachedRegion; if (codes[code] && body.length === 0) { if (bucket && !region) { cachedRegion = bucketRegionCache[bucket] || null; if (cachedRegion !== req.httpRequest.region) { region = cachedRegion; } } resp.error = AWS.util.error(new Error(), { code: codes[code], message: null, region: region }); } else { var data = new AWS.XML.Parser().parse(body.toString()); if (data.Region && !region) { region = data.Region; if (bucket && region !== bucketRegionCache[bucket]) { bucketRegionCache[bucket] = region; } } else if (bucket && !region && !data.Region) { cachedRegion = bucketRegionCache[bucket] || null; if (cachedRegion !== req.httpRequest.region) { region = cachedRegion; } } resp.error = AWS.util.error(new Error(), { code: data.Code || code, message: data.Message || null, region: region }); } req.service.extractRequestIds(resp); }
n/a
function extractRequestIds(resp) { var extendedRequestId = resp.httpResponse.headers ? resp.httpResponse.headers['x-amz-id-2'] : null; var cfId = resp.httpResponse.headers ? resp.httpResponse.headers['x-amz-cf-id'] : null; resp.extendedRequestId = extendedRequestId; resp.cfId = cfId; if (resp.error) { resp.error.requestId = resp.requestId || null; resp.error.extendedRequestId = extendedRequestId; resp.error.cfId = cfId; } }
n/a
function getSignedUrl(operation, params, callback) { params = AWS.util.copy(params || {}); var expires = params.Expires || 900; delete params.Expires; // we can't validate this var request = this.makeRequest(operation, params); return request.presign(expires, callback); }
n/a
function getSignerClass(request) {
var defaultApiVersion = this.api.signatureVersion;
var userDefinedVersion = this._originalConfig ? this._originalConfig.signatureVersion : null;
var regionDefinedVersion = this.config.signatureVersion;
var isPresigned = request ? request.isPresigned() : false;
/*
1) User defined version specified:
a) always return user defined version
2) No user defined version specified:
a) default to lowest version the region supports
*/
if (userDefinedVersion) {
userDefinedVersion = userDefinedVersion === 'v2' ? 's3' : userDefinedVersion;
return AWS.Signers.RequestSigner.getVersion(userDefinedVersion);
}
if (regionDefinedVersion) {
defaultApiVersion = regionDefinedVersion;
}
return AWS.Signers.RequestSigner.getVersion(defaultApiVersion);
}
...
var validation = req.service.config.paramValidation;
new AWS.ParamValidator(validation).validate(rules, req.params);
});
addAsync('COMPUTE_SHA256', 'afterBuild', function COMPUTE_SHA256(req, done) {
req.haltHandlersOnError();
if (!req.service.api.signatureVersion) return done(); // none
if (req.service.getSignerClass(req) === AWS.Signers.V4) {
var body = req.httpRequest.body || '';
AWS.util.computeSha256(body, function(err, sha) {
if (err) {
done(err);
}
else {
req.httpRequest.headers['X-Amz-Content-Sha256'] = sha;
...
function isValidAccelerateOperation(operation) { var invalidOperations = [ 'createBucket', 'deleteBucket', 'listBuckets' ]; return invalidOperations.indexOf(operation) === -1; }
n/a
function noPresignedContentLength(request) { if (request.params.ContentLength !== undefined) { throw AWS.util.error(new Error(), {code: 'UnexpectedParameter', message: 'ContentLength is not supported in pre-signed URLs.'}); } }
n/a
function pathStyleBucketName(bucketName) { // user can force path style requests via the configuration if (this.config.s3ForcePathStyle) return true; if (this.config.s3BucketEndpoint) return false; if (this.dnsCompatibleBucketName(bucketName)) { return (this.config.sslEnabled && bucketName.match(/\./)) ? true : false; } else { return true; // not dns compatible names must always use path style } }
n/a
function populateURI(req) { var httpRequest = req.httpRequest; var b = req.params.Bucket; var service = req.service; var endpoint = httpRequest.endpoint; if (b) { if (!service.pathStyleBucketName(b)) { if (service.config.useAccelerateEndpoint && service.isValidAccelerateOperation(req.operation)) { if (service.config.useDualstack) { endpoint.hostname = b + '.s3-accelerate.dualstack.amazonaws.com'; } else { endpoint.hostname = b + '.s3-accelerate.amazonaws.com'; } } else if (!service.config.s3BucketEndpoint) { endpoint.hostname = b + '.' + endpoint.hostname; } var port = endpoint.port; if (port !== 80 && port !== 443) { endpoint.host = endpoint.hostname + ':' + endpoint.port; } else { endpoint.host = endpoint.hostname; } httpRequest.virtualHostedBucket = b; // needed for signing the request service.removeVirtualHostedBucketFromPath(req); } } }
n/a
function preparePostFields( credentials, region, bucket, fields, conditions, expiresInSeconds ) { var now = AWS.util.date.getDate(); if (!credentials || !region || !bucket) { throw new Error('Unable to create a POST object policy without a bucket,' + ' region, and credentials'); } fields = AWS.util.copy(fields || {}); conditions = (conditions || []).slice(0); expiresInSeconds = expiresInSeconds || 3600; var signingDate = AWS.util.date.iso8601(now).replace(/[:\-]|\.\d{3}/g, ''); var shortDate = signingDate.substr(0, 8); var scope = v4Credentials.createScope(shortDate, region, 's3'); var credential = credentials.accessKeyId + '/' + scope; fields['bucket'] = bucket; fields['X-Amz-Algorithm'] = 'AWS4-HMAC-SHA256'; fields['X-Amz-Credential'] = credential; fields['X-Amz-Date'] = signingDate; if (credentials.sessionToken) { fields['X-Amz-Security-Token'] = credentials.sessionToken; } for (var field in fields) { if (fields.hasOwnProperty(field)) { var condition = {}; condition[field] = fields[field]; conditions.push(condition); } } fields.Policy = this.preparePostPolicy( new Date(now.valueOf() + expiresInSeconds * 1000), conditions ); fields['X-Amz-Signature'] = AWS.util.crypto.hmac( v4Credentials.getSigningKey(credentials, shortDate, region, 's3', true), fields.Policy, 'hex' ); return fields; }
n/a
function preparePostPolicy(expiration, conditions) { return AWS.util.base64.encode(JSON.stringify({ expiration: AWS.util.date.iso8601(expiration), conditions: conditions })); }
n/a
function prepareSignedUrl(request) { request.addListener('validate', request.service.noPresignedContentLength); request.removeListener('build', request.service.addContentType); if (!request.params.Body) { // no Content-MD5/SHA-256 if body is not provided request.removeListener('build', request.service.computeContentMd5); } else { request.addListener('afterBuild', AWS.EventListeners.Core.COMPUTE_SHA256); } }
n/a
function removeVirtualHostedBucketFromPath(req) { var httpRequest = req.httpRequest; var bucket = httpRequest.virtualHostedBucket; if (bucket && httpRequest.path) { httpRequest.path = httpRequest.path.replace(new RegExp('/' + bucket), ''); if (httpRequest.path[0] !== '/') { httpRequest.path = '/' + httpRequest.path; } } }
n/a
function reqRegionForNetworkingError(resp, done) { if (!AWS.util.isBrowser()) { return done(); } var error = resp.error; var request = resp.request; var bucket = request.params.Bucket; if (!error || error.code !== 'NetworkingError' || !bucket || request.httpRequest.region === 'us-east-1') { return done(); } var service = request.service; var bucketRegionCache = service.bucketRegionCache; var cachedRegion = bucketRegionCache[bucket] || null; if (cachedRegion && cachedRegion !== request.httpRequest.region) { service.updateReqBucketRegion(request, cachedRegion); done(); } else if (!service.dnsCompatibleBucketName(bucket)) { service.updateReqBucketRegion(request, 'us-east-1'); if (bucketRegionCache[bucket] !== 'us-east-1') { bucketRegionCache[bucket] = 'us-east-1'; } done(); } else if (request.httpRequest.virtualHostedBucket) { var getRegionReq = service.listObjects({Bucket: bucket, MaxKeys: 0}); service.updateReqBucketRegion(getRegionReq, 'us-east-1'); getRegionReq._requestRegionForBucket = bucket; getRegionReq.send(function() { var region = service.bucketRegionCache[bucket] || null; if (region && region !== request.httpRequest.region) { service.updateReqBucketRegion(request, region); } done(); }); } else { // DNS-compatible path-style // (s3ForcePathStyle or bucket name with dot over https) // Cannot obtain region information for this case done(); } }
n/a
function requestBucketRegion(resp, done) { var error = resp.error; var req = resp.request; var bucket = req.params.Bucket || null; if (!error || !bucket || error.region || req.operation === 'listObjects' || (AWS.util.isNode() && req.operation === 'headBucket') || (error.statusCode === 400 && req.operation !== 'headObject') || regionRedirectErrorCodes.indexOf(error.code) === -1) { return done(); } var reqOperation = AWS.util.isNode() ? 'headBucket' : 'listObjects'; var reqParams = {Bucket: bucket}; if (reqOperation === 'listObjects') reqParams.MaxKeys = 0; var regionReq = req.service[reqOperation](reqParams); regionReq._requestRegionForBucket = bucket; regionReq.send(function() { var region = req.service.bucketRegionCache[bucket] || null; error.region = region; done(); }); }
n/a
function retryableError(error, request) { if (operationsWith200StatusCodeError[request.operation] && error.statusCode === 200) { return true; } else if (request._requestRegionForBucket && request.service.bucketRegionCache[request._requestRegionForBucket]) { return false; } else if (error && error.code === 'RequestTimeout') { return true; } else if (error && regionRedirectErrorCodes.indexOf(error.code) != -1 && error.region && error.region != request.httpRequest.region) { request.httpRequest.region = error.region; if (error.statusCode === 301) { request.service.updateReqBucketRegion(request); } return true; } else { var _super = AWS.Service.prototype.retryableError; return _super.call(this, error, request); } }
...
delete resp.httpResponse.buffers;
});
add('FINALIZE_ERROR', 'retry', function FINALIZE_ERROR(resp) {
if (resp.httpResponse.statusCode) {
resp.error.statusCode = resp.httpResponse.statusCode;
if (resp.error.retryable === undefined) {
resp.error.retryable = this.service.retryableError(resp.error, this);
}
}
});
add('INVALIDATE_CREDENTIALS', 'retry', function INVALIDATE_CREDENTIALS(resp) {
if (!resp.error) return;
switch (resp.error.code) {
...
function setupRequestListeners(request) { request.addListener('validate', this.validateScheme); request.addListener('validate', this.validateBucketEndpoint); request.addListener('validate', this.correctBucketRegionFromCache); request.addListener('build', this.addContentType); request.addListener('build', this.populateURI); request.addListener('build', this.computeContentMd5); request.addListener('build', this.computeSseCustomerKeyMd5); request.addListener('afterBuild', this.addExpect100Continue); request.removeListener('validate', AWS.EventListeners.Core.VALIDATE_REGION); request.addListener('extractError', this.extractError); request.onAsync('extractError', this.requestBucketRegion); request.addListener('extractData', this.extractData); request.addListener('extractData', AWS.util.hoistPayloadMember); request.addListener('beforePresign', this.prepareSignedUrl); if (AWS.util.isBrowser()) { request.onAsync('retry', this.reqRegionForNetworkingError); } if (this.shouldDisableBodySigning(request)) { request.removeListener('afterBuild', AWS.EventListeners.Core.COMPUTE_SHA256); request.addListener('afterBuild', this.disableBodySigning); } }
n/a
function shouldDisableBodySigning(request) { var signerClass = this.getSignerClass(); if (this.config.s3DisableBodySigning === true && signerClass === AWS.Signers.V4 && request.httpRequest.endpoint.protocol === 'https:') { return true; } return false; }
n/a
function successfulResponse(resp) { var req = resp.request; var httpResponse = resp.httpResponse; if (operationsWith200StatusCodeError[req.operation] && httpResponse.body.toString().match('<Error>')) { return false; } else { return httpResponse.statusCode < 300; } }
...
req.response.error = e;
}
done();
});
});
add('VALIDATE_RESPONSE', 'validateResponse', function VALIDATE_RESPONSE(resp) {
if (this.service.successfulResponse(resp, this)) {
resp.data = {};
resp.error = null;
} else {
resp.data = null;
resp.error = AWS.util.error(new Error(),
{code: 'UnknownError', message: 'An unknown error occurred.'});
}
...
function updateReqBucketRegion(request, region) { var httpRequest = request.httpRequest; if (typeof region === 'string' && region.length) { httpRequest.region = region; } if (!httpRequest.endpoint.host.match(/s3(?!-accelerate).*\.amazonaws\.com$/)) { return; } var service = request.service; var s3Config = service.config; var s3BucketEndpoint = s3Config.s3BucketEndpoint; if (s3BucketEndpoint) { delete s3Config.s3BucketEndpoint; } var newConfig = AWS.util.copy(s3Config); delete newConfig.endpoint; newConfig.region = httpRequest.region; httpRequest.endpoint = (new AWS.S3(newConfig)).endpoint; service.populateURI(request); s3Config.s3BucketEndpoint = s3BucketEndpoint; httpRequest.headers.Host = httpRequest.endpoint.host; if (request._asm.currentState === 'validate') { request.removeListener('build', service.populateURI); request.addListener('build', service.removeVirtualHostedBucketFromPath); } }
n/a
function upload(params, options, callback) { if (typeof options === 'function' && callback === undefined) { callback = options; options = null; } options = options || {}; options = AWS.util.merge(options || {}, {service: this, params: params}); var uploader = new AWS.S3.ManagedUpload(options); if (typeof callback === 'function') uploader.send(callback); return uploader; }
n/a
validateBucketEndpoint = function (req) { if (!req.params.Bucket && req.service.config.s3BucketEndpoint) { var msg = 'Cannot send requests to root API with `s3BucketEndpoint` set.'; throw AWS.util.error(new Error(), { code: 'ConfigError', message: msg }); } }
n/a
validateScheme = function (req) { var params = req.params, scheme = req.httpRequest.endpoint.protocol, sensitive = params.SSECustomerKey || params.CopySourceSSECustomerKey; if (sensitive && scheme !== 'https:') { var msg = 'Cannot send SSE keys over HTTP. Set \'sslEnabled\'' + 'to \'true\' in your configuration'; throw AWS.util.error(new Error(), { code: 'ConfigError', message: msg }); } }
n/a
function validateService() { var msg; var messages = []; // default to us-east-1 when no region is provided if (!this.config.region) this.config.region = 'us-east-1'; if (!this.config.endpoint && this.config.s3BucketEndpoint) { messages.push('An endpoint must be provided when configuring ' + '`s3BucketEndpoint` to true.'); } if (messages.length === 1) { msg = messages[0]; } else if (messages.length > 1) { msg = 'Multiple configuration errors:\n' + messages.join('\n'); } if (msg) { throw AWS.util.error(new Error(), {name: 'InvalidEndpoint', message: msg}); } }
n/a
function willComputeChecksums(req) { if (this.computableChecksumOperations[req.operation]) return true; if (!this.config.computeChecksums) return false; // TODO: compute checksums for Stream objects if (!AWS.util.Buffer.isBuffer(req.httpRequest.body) && typeof req.httpRequest.body !== 'string') { return false; } var rules = req.service.api.operations[req.operation].input.members; // Sha256 signing disabled, and not a presigned url if (req.service.shouldDisableBodySigning(req) && !Object.prototype.hasOwnProperty.call(req.httpRequest.headers, 'presigned-expires ')) { if (rules.ContentMD5 && !req.params.ContentMD5) { return true; } } // V4 signer uses SHA256 signatures so only compute MD5 if it is required if (req.service.getSignerClass(req) === AWS.Signers.V4) { if (rules.ContentMD5 && !rules.ContentMD5.required) return false; } if (rules.ContentMD5 && !req.params.ContentMD5) return true; }
n/a
function SAMLCredentials(params) { AWS.Credentials.call(this); this.expired = true; this.params = params; }
n/a
function Credentials() { // hide secretAccessKey from being displayed with util.inspect AWS.util.hideProperties(this, ['secretAccessKey']); this.expired = false; this.expireTime = null; if (arguments.length === 1 && typeof arguments[0] === 'object') { var creds = arguments[0].credentials || arguments[0]; this.accessKeyId = creds.accessKeyId; this.secretAccessKey = creds.secretAccessKey; this.sessionToken = creds.sessionToken; } else { this.accessKeyId = arguments[0]; this.secretAccessKey = arguments[1]; this.sessionToken = arguments[2]; } }
n/a
function SAMLCredentials(params) { AWS.Credentials.call(this); this.expired = true; this.params = params; }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
createClients = function () { this.service = this.service || new STS({params: this.params}); }
n/a
function refresh(callback) { var self = this; self.createClients(); if (!callback) callback = function(err) { if (err) throw err; }; self.service.assumeRoleWithSAML(function (err, data) { if (!err) { self.service.credentialsFrom(data, self); } callback(err); }); }
n/a
SES = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
SMS = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
SNS = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
SQS = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
function buildEndpoint(request) { var url = request.httpRequest.params.QueueUrl; if (url) { request.httpRequest.endpoint = new AWS.Endpoint(url); // signature version 4 requires the region name to be set, // sqs queue urls contain the region name var matches = request.httpRequest.endpoint.host.match(/^sqs\.(.+?)\./); if (matches) request.httpRequest.region = matches[1]; } }
n/a
function calculateChecksum(data) { return AWS.util.crypto.md5(data, 'hex'); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function isChecksumValid(checksum, data) { return this.calculateChecksum(data) === checksum; }
n/a
function setupRequestListeners(request) { request.addListener('build', this.buildEndpoint); if (request.service.config.computeChecksums) { if (request.operation === 'sendMessage') { request.addListener('extractData', this.verifySendMessageChecksum); } else if (request.operation === 'sendMessageBatch') { request.addListener('extractData', this.verifySendMessageBatchChecksum); } else if (request.operation === 'receiveMessage') { request.addListener('extractData', this.verifyReceiveMessageChecksum); } } }
n/a
function throwInvalidChecksumError(response, ids, message) { response.error = AWS.util.error(new Error(), { retryable: true, code: 'InvalidChecksum', messageIds: ids, message: response.request.operation + ' returned an invalid MD5 response. ' + message }); }
n/a
function verifyReceiveMessageChecksum(response) { if (!response.data) return; var service = this.service; var messageIds = []; AWS.util.arrayEach(response.data.Messages, function(message) { var md5 = message.MD5OfBody; var body = message.Body; if (!service.isChecksumValid(md5, body)) { messageIds.push(message.MessageId); } }); if (messageIds.length > 0) { service.throwInvalidChecksumError(response, messageIds, 'Invalid messages: ' + messageIds.join(', ')); } }
n/a
function verifySendMessageBatchChecksum(response) { if (!response.data) return; var service = this.service; var entries = {}; var errors = []; var messageIds = []; AWS.util.arrayEach(response.data.Successful, function (entry) { entries[entry.Id] = entry; }); AWS.util.arrayEach(this.params.Entries, function (entry) { if (entries[entry.Id]) { var md5 = entries[entry.Id].MD5OfMessageBody; var body = entry.MessageBody; if (!service.isChecksumValid(md5, body)) { errors.push(entry.Id); messageIds.push(entries[entry.Id].MessageId); } } }); if (errors.length > 0) { service.throwInvalidChecksumError(response, messageIds, 'Invalid messages: ' + errors.join(', ')); } }
n/a
function verifySendMessageChecksum(response) { if (!response.data) return; var md5 = response.data.MD5OfMessageBody; var body = this.params.MessageBody; var calculatedMd5 = this.service.calculateChecksum(body); if (calculatedMd5 !== md5) { var msg = 'Got "' + response.data.MD5OfMessageBody + '", expecting "' + calculatedMd5 + '".'; this.service.throwInvalidChecksumError(response, [response.data.MessageId], msg); } }
n/a
SSM = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
STS = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
function assumeRoleWithSAML(params, callback) { return this.makeUnauthenticatedRequest('assumeRoleWithSAML', params, callback); }
n/a
function assumeRoleWithWebIdentity(params, callback) { return this.makeUnauthenticatedRequest('assumeRoleWithWebIdentity', params, callback); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function credentialsFrom(data, credentials) { if (!data) return null; if (!credentials) credentials = new AWS.TemporaryCredentials(); credentials.expired = false; credentials.accessKeyId = data.Credentials.AccessKeyId; credentials.secretAccessKey = data.Credentials.SecretAccessKey; credentials.sessionToken = data.Credentials.SessionToken; credentials.expireTime = data.Credentials.Expiration; return credentials; }
n/a
SWF = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function SequentialExecutor() { this._events = {}; }
...
return expected === resp.error.code;
}
// if expected is not string, can be boolean indicating presence of error
return expected === !!resp.error;
}
},
listeners: new AWS.SequentialExecutor().addNamedListeners(function(add) {
add('RETRY_CHECK', 'retry', function(resp) {
var waiter = resp.request._waiter;
if (resp.error && resp.error.code === 'ResourceNotReady') {
resp.error.retryDelay = (waiter.config.delay || 0) * 1000;
}
});
...
function Object() { [native code] }
n/a
function on(eventName, listener) { if (this._events[eventName]) { this._events[eventName].push(listener); } else { this._events[eventName] = [listener]; } return this; }
...
/**
* @api private
*/
toGet: function toGet() {
if (this.service.api.protocol === 'query' ||
this.service.api.protocol === 'ec2') {
this.removeListener('build', this.buildAsGet);
this.addListener('build', this.buildAsGet);
}
return this;
},
/**
* @api private
*/
...
function addListeners(listeners) { var self = this; // extract listeners if parameter is an SequentialExecutor object if (listeners._events) listeners = listeners._events; AWS.util.each(listeners, function(event, callbacks) { if (typeof callbacks === 'function') callbacks = [callbacks]; AWS.util.arrayEach(callbacks, function(callback) { self.on(event, callback); }); }); return self; }
...
}
delete params.$waiter;
}
var request = this.service.makeRequest(this.config.operation, params);
request._waiter = this;
request.response.maxRetries = this.config.maxAttempts;
request.addListeners(this.listeners);
if (callback) request.send(callback);
return request;
},
setSuccess: function setSuccess(resp) {
resp.error = null;
...
function addNamedAsyncListener(name, eventName, callback) { callback._isAsync = true; return this.addNamedListener(name, eventName, callback); }
n/a
function addNamedListener(name, eventName, callback) { this[name] = callback; this.addListener(eventName, callback); return this; }
n/a
function addNamedListeners(callback) { var self = this; callback( function() { self.addNamedListener.apply(self, arguments); }, function() { self.addNamedAsyncListener.apply(self, arguments); } ); return this; }
...
* @return [Function]
* @readonly
*/
Core: {} /* doc hack */
};
AWS.EventListeners = {
Core: new SequentialExecutor().addNamedListeners(function(add, addAsync) {
addAsync('VALIDATE_CREDENTIALS', 'validate',
function VALIDATE_CREDENTIALS(req, done) {
if (!req.service.api.signatureVersion) return done(); // none
req.service.config.getCredentials(function(err) {
if (err) {
req.response.error = AWS.util.error(err,
{code: 'CredentialsError', message: 'Missing credentials in config'});
...
function callListeners(listeners, args, doneCallback, prevError) { var self = this; var error = prevError || null; function callNextListener(err) { if (err) { error = AWS.util.error(error || new Error(), err); if (self._haltHandlersOnError) { return doneCallback.call(self, error); } } self.callListeners(listeners, args, doneCallback, error); } while (listeners.length > 0) { var listener = listeners.shift(); if (listener._isAsync) { // asynchronous listener listener.apply(self, args.concat([callNextListener])); return; // stop here, callNextListener will continue } else { // synchronous listener try { listener.apply(self, args); } catch (err) { error = AWS.util.error(error || new Error(), err); } if (error && self._haltHandlersOnError) { doneCallback.call(self, error); return; } } } doneCallback.call(self, error); }
n/a
function SequentialExecutor() { this._events = {}; }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function emit(eventName, eventArgs, doneCallback) { if (!doneCallback) doneCallback = function() { }; var listeners = this.listeners(eventName); var count = listeners.length; this.callListeners(listeners, eventArgs, doneCallback); return count > 0; }
...
resp.error = null;
resp.data = null;
function callback(httpResp) {
resp.httpResponse.stream = httpResp;
httpResp.on('headers', function onHeaders(statusCode, headers, statusMessage) {
resp.request.emit(
'httpHeaders',
[statusCode, headers, resp, statusMessage]
);
if (!resp.httpResponse.streaming) {
if (AWS.HttpClient.streamsApiVersion === 2) { // streams2 API check
httpResp.on('readable', function onReadable() {
...
function listeners(eventName) { return this._events[eventName] ? this._events[eventName].slice(0) : []; }
n/a
function on(eventName, listener) { if (this._events[eventName]) { this._events[eventName].push(listener); } else { this._events[eventName] = [listener]; } return this; }
...
* @return [Function]
* @!attribute SEND
* A request listener that initiates the HTTP connection for a
* request being sent. Handles the {AWS.Request~send 'send' Request event}
* @example Replacing the HTTP handler
* var listener = AWS.EventListeners.Core.SEND;
* request.removeListener('send', listener);
* request.on('send', function(response) {
* customHandler.send(response);
* });
* @return [Function]
* @readonly
* @!attribute HTTP_DATA
* A request listener that reads data from the HTTP connection in order
* to build the response data.
...
function onAsync(eventName, listener) { listener._isAsync = true; return this.on(eventName, listener); }
n/a
function removeAllListeners(eventName) { if (eventName) { delete this._events[eventName]; } else { this._events = {}; } return this; }
...
* setTimeout(request.abort.bind(request), 1000);
*
* // prints "Error: RequestAbortedError Request aborted by user"
* @return [AWS.Request] the same request object, for chaining.
* @since v1.4.0
*/
abort: function abort() {
this.removeAllListeners('validateResponse');
this.removeAllListeners('extractError');
this.on('validateResponse', function addAbortedError(resp) {
resp.error = AWS.util.error(new Error('Request aborted by user'), {
code: 'RequestAbortedError', retryable: false
});
});
...
function removeListener(eventName, listener) { var listeners = this._events[eventName]; if (listeners) { var length = listeners.length; var position = -1; for (var i = 0; i < length; ++i) { if (listeners[i] === listener) { position = i; } } if (position > -1) { listeners.splice(position, 1); } } return this; }
...
/**
* @!attribute VALIDATE_CREDENTIALS
* A request listener that validates whether the request is being
* sent with credentials.
* Handles the {AWS.Request~validate 'validate' Request event}
* @example Sending a request without validating credentials
* var listener = AWS.EventListeners.Core.VALIDATE_CREDENTIALS;
* request.removeListener('validate', listener);
* @readonly
* @return [Function]
* @!attribute VALIDATE_REGION
* A request listener that validates whether the region is set
* for a request.
* Handles the {AWS.Request~validate 'validate' Request event}
* @example Sending a request without validating region configuration
...
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
function Object() { [native code] }
n/a
function addVersions(svc, versions) { if (!Array.isArray(versions)) versions = [versions]; svc.services = svc.services || {}; for (var i = 0; i < versions.length; i++) { if (svc.services[versions[i]] === undefined) { svc.services[versions[i]] = null; } } svc.apiVersions = Object.keys(svc.services).sort(); }
n/a
function defineMethods(svc) { AWS.util.each(svc.prototype.api.operations, function iterator(method) { if (svc.prototype[method]) return; var operation = svc.prototype.api.operations[method]; if (operation.authtype === 'none') { svc.prototype[method] = function (params, callback) { return this.makeUnauthenticatedRequest(method, params, callback); }; } else { svc.prototype[method] = function (params, callback) { return this.makeRequest(method, params, callback); }; } }); }
n/a
function defineService(serviceIdentifier, versions, features) { AWS.Service._serviceMap[serviceIdentifier] = true; if (!Array.isArray(versions)) { features = versions; versions = []; } var svc = inherit(AWS.Service, features || {}); if (typeof serviceIdentifier === 'string') { AWS.Service.addVersions(svc, versions); var identifier = svc.serviceIdentifier || serviceIdentifier; svc.serviceIdentifier = identifier; } else { // defineService called with an API svc.prototype.api = serviceIdentifier; AWS.Service.defineMethods(svc); } return svc; }
n/a
function defineServiceApi(superclass, version, apiConfig) { var svc = inherit(superclass, { serviceIdentifier: superclass.serviceIdentifier }); function setApi(api) { if (api.isApi) { svc.prototype.api = api; } else { svc.prototype.api = new Api(api); } } if (typeof version === 'string') { if (apiConfig) { setApi(apiConfig); } else { try { setApi(AWS.apiLoader(superclass.serviceIdentifier, version)); } catch (err) { throw AWS.util.error(err, { message: 'Could not find API configuration ' + superclass.serviceIdentifier + '-' + version }); } } if (!Object.prototype.hasOwnProperty.call(superclass.services, version)) { superclass.apiVersions = superclass.apiVersions.concat(version).sort(); } superclass.services[version] = svc; } else { setApi(version); } AWS.Service.defineMethods(svc); return svc; }
n/a
hasService = function (identifier) { return Object.prototype.hasOwnProperty.call(AWS.Service._serviceMap, identifier); }
...
* @see constructor
*/
update: function update(options, allowUnknownKeys) {
allowUnknownKeys = allowUnknownKeys || false;
options = this.extractCredentials(options);
AWS.util.each.call(this, options, function (key, value) {
if (allowUnknownKeys || Object.prototype.hasOwnProperty.call(this.keys, key) ||
AWS.Service.hasService(key)) {
this.set(key, value);
}
});
},
/**
* Loads configuration data from a JSON file into this config object.
...
function addAllRequestListeners(request) { var list = [AWS.events, AWS.EventListeners.Core, this.serviceInterface(), AWS.EventListeners.CorePost]; for (var i = 0; i < list.length; i++) { if (list[i]) request.addListeners(list[i]); } // disable parameter validation if (!this.config.paramValidation) { request.removeListener('validate', AWS.EventListeners.Core.VALIDATE_PARAMETERS); } if (this.config.logger) { // add logging events request.addListeners(AWS.EventListeners.Logger); } this.setupRequestListeners(request); // call prototype's customRequestHandler if (typeof this.constructor.prototype.customRequestHandler === 'function') { this.constructor.prototype.customRequestHandler(request); } // call instance's customRequestHandler if (Object.prototype.hasOwnProperty.call(this, 'customRequestHandler') && typeof this.customRequestHandler === 'function') { this.customRequestHandler(request); } }
n/a
function clockSkewError(error) { switch (error.code) { case 'RequestTimeTooSkewed': case 'RequestExpired': case 'InvalidSignatureException': case 'SignatureDoesNotMatch': case 'AuthFailure': case 'RequestInTheFuture': return true; default: return false; } }
...
resp.error.retryable = true;
}
}
});
add('CLOCK_SKEWED', 'retry', function CLOCK_SKEWED(resp) {
if (!resp.error) return;
if (this.service.clockSkewError(resp.error)
&& this.service.config.correctClockSkew
&& AWS.config.isClockSkewed) {
resp.error.retryable = true;
}
});
add('REDIRECT', 'retry', function REDIRECT(resp) {
...
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function customizeRequests(callback) { if (!callback) { this.customRequestHandler = null; } else if (typeof callback === 'function') { this.customRequestHandler = callback; } else { throw new Error('Invalid callback type \'' + typeof callback + '\' provided in customizeRequests'); } }
n/a
function endpointFromTemplate(endpoint) { if (typeof endpoint !== 'string') return endpoint; var e = endpoint; e = e.replace(/\{service\}/g, this.api.endpointPrefix); e = e.replace(/\{region\}/g, this.config.region); e = e.replace(/\{scheme\}/g, this.config.sslEnabled ? 'https' : 'http'); return e; }
n/a
function expiredCredentialsError(error) { // TODO : this only handles *one* of the expired credential codes return (error.code === 'ExpiredTokenException'); }
n/a
function getLatestServiceClass(version) { version = this.getLatestServiceVersion(version); if (this.constructor.services[version] === null) { AWS.Service.defineServiceApi(this.constructor, version); } return this.constructor.services[version]; }
n/a
function getLatestServiceVersion(version) { if (!this.constructor.services || this.constructor.services.length === 0) { throw new Error('No services defined on ' + this.constructor.serviceIdentifier); } if (!version) { version = 'latest'; } else if (AWS.util.isType(version, Date)) { version = AWS.util.date.iso8601(version).split('T')[0]; } if (Object.hasOwnProperty(this.constructor.services, version)) { return version; } var keys = Object.keys(this.constructor.services).sort(); var selectedVersion = null; for (var i = keys.length - 1; i >= 0; i--) { // versions that end in "*" are not available on disk and can be // skipped, so do not choose these as selectedVersions if (keys[i][keys[i].length - 1] !== '*') { selectedVersion = keys[i]; } if (keys[i].substr(0, 10) <= version) { return selectedVersion; } } throw new Error('Could not find ' + this.constructor.serviceIdentifier + ' API to satisfy version constraint `' + version + '\''); }
n/a
function getSignerClass() { var version; if (this.config.signatureVersion) { version = this.config.signatureVersion; } else { version = this.api.signatureVersion; } return AWS.Signers.RequestSigner.getVersion(version); }
...
var validation = req.service.config.paramValidation;
new AWS.ParamValidator(validation).validate(rules, req.params);
});
addAsync('COMPUTE_SHA256', 'afterBuild', function COMPUTE_SHA256(req, done) {
req.haltHandlersOnError();
if (!req.service.api.signatureVersion) return done(); // none
if (req.service.getSignerClass(req) === AWS.Signers.V4) {
var body = req.httpRequest.body || '';
AWS.util.computeSha256(body, function(err, sha) {
if (err) {
done(err);
}
else {
req.httpRequest.headers['X-Amz-Content-Sha256'] = sha;
...
function initialize(config) { var svcConfig = AWS.config[this.serviceIdentifier]; this.config = new AWS.Config(AWS.config); if (svcConfig) this.config.update(svcConfig, true); if (config) this.config.update(config, true); this.validateService(); if (!this.config.endpoint) regionConfig(this); this.config.endpoint = this.endpointFromTemplate(this.config.endpoint); this.setEndpoint(this.config.endpoint); }
n/a
function loadServiceClass(serviceConfig) { var config = serviceConfig; if (!AWS.util.isEmpty(this.api)) { return null; } else if (config.apiConfig) { return AWS.Service.defineServiceApi(this.constructor, config.apiConfig); } else if (!this.constructor.services) { return null; } else { config = new AWS.Config(AWS.config); config.update(serviceConfig, true); var version = config.apiVersions[this.constructor.serviceIdentifier]; version = version || config.apiVersion; return this.getLatestServiceClass(version); } }
n/a
function makeRequest(operation, params, callback) { if (typeof params === 'function') { callback = params; params = null; } params = params || {}; if (this.config.params) { // copy only toplevel bound params var rules = this.api.operations[operation]; if (rules) { params = AWS.util.copy(params); AWS.util.each(this.config.params, function(key, value) { if (rules.input.members[key]) { if (params[key] === undefined || params[key] === null) { params[key] = value; } } }); } } var request = new AWS.Request(this, operation, params); this.addAllRequestListeners(request); if (callback) request.send(callback); return request; }
...
}
if (typeof params.$waiter.maxAttempts === 'number') {
this.config.maxAttempts = params.$waiter.maxAttempts;
}
delete params.$waiter;
}
var request = this.service.makeRequest(this.config.operation, params);
request._waiter = this;
request.response.maxRetries = this.config.maxAttempts;
request.addListeners(this.listeners);
if (callback) request.send(callback);
return request;
},
...
function makeUnauthenticatedRequest(operation, params, callback) { if (typeof params === 'function') { callback = params; params = {}; } var request = this.makeRequest(operation, params).toUnauthenticated(); return callback ? request.send(callback) : request; }
n/a
function networkingError(error) { return error.code === 'NetworkingError'; }
n/a
function numRetries() { if (this.config.maxRetries !== undefined) { return this.config.maxRetries; } else { return this.defaultRetryCount; } }
...
this.request = request;
this.data = null;
this.error = null;
this.retryCount = 0;
this.redirectCount = 0;
this.httpResponse = new AWS.HttpResponse();
if (request) {
this.maxRetries = request.service.numRetries();
this.maxRedirects = request.service.config.maxRedirects;
}
},
/**
* Creates a new request for the next page of response data, calling the
* callback with the page data if a callback is provided.
...
function paginationConfig(operation, throwException) { var paginator = this.api.operations[operation].paginator; if (!paginator) { if (throwException) { var e = new Error(); throw AWS.util.error(e, 'No pagination configuration for ' + operation); } return null; } return paginator; }
...
*/
eachItem: function eachItem(callback) {
var self = this;
function wrappedCallback(err, data) {
if (err) return callback(err, null);
if (data === null) return callback(null, null);
var config = self.service.paginationConfig(self.operation);
var resultKey = config.resultKey;
if (Array.isArray(resultKey)) resultKey = resultKey[0];
var items = jmespath.search(data, resultKey);
var continueIteration = true;
AWS.util.arrayEach(items, function(item) {
continueIteration = callback(null, item);
if (continueIteration === false) {
...
function retryDelays(retryCount) { return AWS.util.calculateRetryDelay(retryCount, this.config.retryDelayOptions); }
...
});
add('RETRY_CHECK', 'retry', function RETRY_CHECK(resp) {
if (resp.error) {
if (resp.error.redirect && resp.redirectCount < resp.maxRedirects) {
resp.error.retryDelay = 0;
} else if (resp.retryCount < resp.maxRetries) {
resp.error.retryDelay = this.service.retryDelays(resp.retryCount) || 0;
}
}
});
addAsync('RESET_RETRY_STATE', 'afterRetry', function RESET_RETRY_STATE(resp, done) {
var delay, willRetry = false;
...
function retryableError(error) { if (this.networkingError(error)) return true; if (this.expiredCredentialsError(error)) return true; if (this.throttledError(error)) return true; if (error.statusCode >= 500) return true; return false; }
...
delete resp.httpResponse.buffers;
});
add('FINALIZE_ERROR', 'retry', function FINALIZE_ERROR(resp) {
if (resp.httpResponse.statusCode) {
resp.error.statusCode = resp.httpResponse.statusCode;
if (resp.error.retryable === undefined) {
resp.error.retryable = this.service.retryableError(resp.error, this);
}
}
});
add('INVALIDATE_CREDENTIALS', 'retry', function INVALIDATE_CREDENTIALS(resp) {
if (!resp.error) return;
switch (resp.error.code) {
...
function serviceInterface() { switch (this.api.protocol) { case 'ec2': return AWS.EventListeners.Query; case 'query': return AWS.EventListeners.Query; case 'json': return AWS.EventListeners.Json; case 'rest-json': return AWS.EventListeners.RestJson; case 'rest-xml': return AWS.EventListeners.RestXml; } if (this.api.protocol) { throw new Error('Invalid service `protocol\' ' + this.api.protocol + ' in API config'); } }
n/a
function setEndpoint(endpoint) { this.endpoint = new AWS.Endpoint(endpoint, this.config); }
n/a
function setupRequestListeners() { }
n/a
function successfulResponse(resp) { return resp.httpResponse.statusCode < 300; }
...
req.response.error = e;
}
done();
});
});
add('VALIDATE_RESPONSE', 'validateResponse', function VALIDATE_RESPONSE(resp) {
if (this.service.successfulResponse(resp, this)) {
resp.data = {};
resp.error = null;
} else {
resp.data = null;
resp.error = AWS.util.error(new Error(),
{code: 'UnknownError', message: 'An unknown error occurred.'});
}
...
function throttledError(error) { // this logic varies between services switch (error.code) { case 'ProvisionedThroughputExceededException': case 'Throttling': case 'ThrottlingException': case 'RequestLimitExceeded': case 'RequestThrottled': return true; default: return false; } }
n/a
function validateService() { }
n/a
function waitFor(state, params, callback) { var waiter = new AWS.ResourceWaiter(this, state); return waiter.wait(params, callback); }
n/a
ServiceCatalog = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function SharedIniFileCredentials(options) { AWS.Credentials.call(this); options = options || {}; this.filename = options.filename; this.profile = options.profile || process.env.AWS_PROFILE || 'default'; this.disableAssumeRole = !!options.disableAssumeRole; this.get(function() {}); }
...
// Setup default chain providers
// If this changes, please update documentation for
// AWS.CredentialProviderChain.defaultProviders in
// credentials/credential_provider_chain.js
AWS.CredentialProviderChain.defaultProviders = [
function () { return new AWS.EnvironmentCredentials('AWS'); },
function () { return new AWS.EnvironmentCredentials('AMAZON'); },
function () { return new AWS.SharedIniFileCredentials(); },
function () {
if (AWS.ECSCredentials.prototype.getECSRelativeUri() !== undefined) {
return new AWS.ECSCredentials();
}
return new AWS.EC2MetadataCredentials();
}
];
...
function Credentials() { // hide secretAccessKey from being displayed with util.inspect AWS.util.hideProperties(this, ['secretAccessKey']); this.expired = false; this.expireTime = null; if (arguments.length === 1 && typeof arguments[0] === 'object') { var creds = arguments[0].credentials || arguments[0]; this.accessKeyId = creds.accessKeyId; this.secretAccessKey = creds.secretAccessKey; this.sessionToken = creds.sessionToken; } else { this.accessKeyId = arguments[0]; this.secretAccessKey = arguments[1]; this.sessionToken = arguments[2]; } }
n/a
function SharedIniFileCredentials(options) { AWS.Credentials.call(this); options = options || {}; this.filename = options.filename; this.profile = options.profile || process.env.AWS_PROFILE || 'default'; this.disableAssumeRole = !!options.disableAssumeRole; this.get(function() {}); }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function loadDefaultFilename() { var env = process.env; var home = env.HOME || env.USERPROFILE || (env.HOMEPATH ? ((env.HOMEDRIVE || 'C:/') + env.HOMEPATH) : null); if (!home) { throw AWS.util.error( new Error('Cannot load credentials, HOME path not set'), { code: 'SharedIniFileCredentialsProviderFailure' } ); } this.filename = path.join(home, '.aws', 'credentials'); }
n/a
function loadRoleProfile(creds, roleProfile, callback) { if (this.disableAssumeRole) { throw AWS.util.error( new Error('Role assumption profiles are disabled. ' + 'Failed to load profile ' + this.profile + ' from ' + this.filename), { code: 'SharedIniFileCredentialsProviderFailure' } ); } var self = this; var roleArn = roleProfile['role_arn']; var roleSessionName = roleProfile['role_session_name']; var externalId = roleProfile['external_id']; var sourceProfileName = roleProfile['source_profile']; if (!sourceProfileName) { throw AWS.util.error( new Error('source_profile is not set in ' + this.filename + ' using profile ' + this.profile), { code: 'SharedIniFileCredentialsProviderFailure' } ); } var sourceProfile = creds[sourceProfileName]; if (typeof sourceProfile !== 'object') { throw AWS.util.error( new Error('source_profile ' + sourceProfileName + ' set in ' + this.filename + ' using profile ' + this.profile + ' does not exist'), { code: 'SharedIniFileCredentialsProviderFailure' } ); } this.roleArn = roleArn; var sourceCredentials = { accessKeyId: sourceProfile['aws_access_key_id'], secretAccessKey: sourceProfile['aws_secret_access_key'], sessionToken: sourceProfile['aws_session_token'] }; if (!sourceCredentials.accessKeyId || !sourceCredentials.secretAccessKey) { throw AWS.util.error( new Error('Credentials not set in source_profile ' + sourceProfileName + ' set in ' + this.filename + ' using profile ' + this.profile), { code: 'SharedIniFileCredentialsProviderFailure' } ); } var sts = new STS({ credentials: new AWS.Credentials(sourceCredentials) }); var roleParams = { RoleArn: roleArn, RoleSessionName: roleSessionName || 'aws-sdk-js-' + Date.now() }; if (externalId) { roleParams.ExternalId = externalId; } sts.assumeRole(roleParams, function (err, data) { if (err) { callback(err); return; } self.accessKeyId = data.Credentials.AccessKeyId; self.secretAccessKey = data.Credentials.SecretAccessKey; self.sessionToken = data.Credentials.SessionToken; self.expireTime = data.Credentials.Expiration; callback(); }); }
n/a
function refresh(callback) { if (!callback) callback = function(err) { if (err) throw err; }; try { if (!this.filename) this.loadDefaultFilename(); var creds = AWS.util.ini.parse(AWS.util.readFileSync(this.filename)); var profile = creds[this.profile]; if (typeof profile !== 'object') { throw AWS.util.error( new Error('Profile ' + this.profile + ' not found in ' + this.filename), { code: 'SharedIniFileCredentialsProviderFailure' } ); } if (profile['role_arn']) { this.loadRoleProfile(creds, profile, callback); return; } this.accessKeyId = profile['aws_access_key_id']; this.secretAccessKey = profile['aws_secret_access_key']; this.sessionToken = profile['aws_session_token']; if (!this.accessKeyId || !this.secretAccessKey) { throw AWS.util.error( new Error('Credentials not set in ' + this.filename + ' using profile ' + this.profile), { code: 'SharedIniFileCredentialsProviderFailure' } ); } this.expired = false; callback(); } catch (err) { callback(err); } }
n/a
Shield = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
Presign = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
* @api private
*/
presign: function presign(expires, callback) {
if (!callback && typeof expires === 'function') {
callback = expires;
expires = null;
}
return new AWS.Signers.Presign().sign(this.toGet(), expires, callback);
},
/**
* @api private
*/
isPresigned: function isPresigned() {
return Object.prototype.hasOwnProperty.call(this.httpRequest.headers, 'presigned-expires');
...
function RequestSigner(request) { this.request = request; }
n/a
S3 = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
V2 = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
V3 = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
V3Https = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function V4(request, serviceName, signatureCache) { AWS.Signers.RequestSigner.call(this, request); this.serviceName = serviceName; this.signatureCache = signatureCache; }
n/a
Presign = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
* @api private
*/
presign: function presign(expires, callback) {
if (!callback && typeof expires === 'function') {
callback = expires;
expires = null;
}
return new AWS.Signers.Presign().sign(this.toGet(), expires, callback);
},
/**
* @api private
*/
isPresigned: function isPresigned() {
return Object.prototype.hasOwnProperty.call(this.httpRequest.headers, 'presigned-expires');
...
function Object() { [native code] }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function sign(request, expireTime, callback) { request.httpRequest.headers[expiresHeader] = expireTime || 3600; request.on('build', signedUrlBuilder); request.on('sign', signedUrlSigner); request.removeListener('afterBuild', AWS.EventListeners.Core.SET_CONTENT_LENGTH); request.removeListener('afterBuild', AWS.EventListeners.Core.COMPUTE_SHA256); request.emit('beforePresign', [request]); if (callback) { request.build(function() { if (this.response.error) callback(this.response.error); else { callback(null, AWS.util.urlFormat(request.httpRequest.endpoint)); } }); } else { request.build(); if (request.response.error) throw request.response.error; return AWS.util.urlFormat(request.httpRequest.endpoint); } }
...
* @api private
*/
presign: function presign(expires, callback) {
if (!callback && typeof expires === 'function') {
callback = expires;
expires = null;
}
return new AWS.Signers.Presign().sign(this.toGet(), expires, callback);
},
/**
* @api private
*/
isPresigned: function isPresigned() {
return Object.prototype.hasOwnProperty.call(this.httpRequest.headers, 'presigned-expires');
...
function RequestSigner(request) { this.request = request; }
n/a
function Object() { [native code] }
n/a
function getVersion(version) { switch (version) { case 'v2': return AWS.Signers.V2; case 'v3': return AWS.Signers.V3; case 'v4': return AWS.Signers.V4; case 's3': return AWS.Signers.S3; case 'v3https': return AWS.Signers.V3Https; } throw new Error('Unknown signing version ' + version); }
n/a
function RequestSigner(request) { this.request = request; }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function getServiceClientId() { return this.serviceClientId; }
n/a
function setServiceClientId(id) { this.serviceClientId = id; }
...
try {
var date = AWS.util.date.getDate();
var SignerClass = service.getSignerClass(req);
var signer = new SignerClass(req.httpRequest,
service.api.signingName || service.api.endpointPrefix,
service.config.signatureCache);
signer.setServiceClientId(service._clientId);
// clear old authorization headers
delete req.httpRequest.headers['Authorization'];
delete req.httpRequest.headers['Date'];
delete req.httpRequest.headers['X-Amz-Date'];
// add new authorization
...
S3 = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function RequestSigner(request) { this.request = request; }
n/a
function addAuthorization(credentials, date) { if (!this.request.headers['presigned-expires']) { this.request.headers['X-Amz-Date'] = AWS.util.date.rfc822(date); } if (credentials.sessionToken) { // presigned URLs require this header to be lowercased this.request.headers['x-amz-security-token'] = credentials.sessionToken; } var signature = this.sign(credentials.secretAccessKey, this.stringToSign()); var auth = 'AWS ' + credentials.accessKeyId + ':' + signature; this.request.headers['Authorization'] = auth; }
...
// clear old authorization headers
delete req.httpRequest.headers['Authorization'];
delete req.httpRequest.headers['Date'];
delete req.httpRequest.headers['X-Amz-Date'];
// add new authorization
signer.addAuthorization(credentials, date);
req.signedAt = date;
} catch (e) {
req.response.error = e;
}
done();
});
});
...
function canonicalizedAmzHeaders() { var amzHeaders = []; AWS.util.each(this.request.headers, function (name) { if (name.match(/^x-amz-/i)) amzHeaders.push(name); }); amzHeaders.sort(function (a, b) { return a.toLowerCase() < b.toLowerCase() ? -1 : 1; }); var parts = []; AWS.util.arrayEach.call(this, amzHeaders, function (name) { parts.push(name.toLowerCase() + ':' + String(this.request.headers[name])); }); return parts.join('\n'); }
n/a
function canonicalizedResource() { var r = this.request; var parts = r.path.split('?'); var path = parts[0]; var querystring = parts[1]; var resource = ''; if (r.virtualHostedBucket) resource += '/' + r.virtualHostedBucket; resource += path; if (querystring) { // collect a list of sub resources and query params that need to be signed var resources = []; AWS.util.arrayEach.call(this, querystring.split('&'), function (param) { var name = param.split('=')[0]; var value = param.split('=')[1]; if (this.subResources[name] || this.responseHeaders[name]) { var subresource = { name: name }; if (value !== undefined) { if (this.subResources[name]) { subresource.value = value; } else { subresource.value = decodeURIComponent(value); } } resources.push(subresource); } }); resources.sort(function (a, b) { return a.name < b.name ? -1 : 1; }); if (resources.length) { querystring = []; AWS.util.arrayEach(resources, function (res) { if (res.value === undefined) { querystring.push(res.name); } else { querystring.push(res.name + '=' + res.value); } }); resource += '?' + querystring.join('&'); } } return resource; }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function sign(secret, string) { return AWS.util.crypto.hmac(secret, string, 'base64', 'sha1'); }
...
* @api private
*/
presign: function presign(expires, callback) {
if (!callback && typeof expires === 'function') {
callback = expires;
expires = null;
}
return new AWS.Signers.Presign().sign(this.toGet(), expires, callback);
},
/**
* @api private
*/
isPresigned: function isPresigned() {
return Object.prototype.hasOwnProperty.call(this.httpRequest.headers, 'presigned-expires');
...
function stringToSign() { var r = this.request; var parts = []; parts.push(r.method); parts.push(r.headers['Content-MD5'] || ''); parts.push(r.headers['Content-Type'] || ''); // 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(); if (headers) parts.push(headers); parts.push(this.canonicalizedResource()); return parts.join('\n'); }
n/a
V2 = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function RequestSigner(request) { this.request = request; }
n/a
function addAuthorization(credentials, date) { if (!date) date = AWS.util.date.getDate(); var r = this.request; r.params.Timestamp = AWS.util.date.iso8601(date); r.params.SignatureVersion = '2'; r.params.SignatureMethod = 'HmacSHA256'; r.params.AWSAccessKeyId = credentials.accessKeyId; if (credentials.sessionToken) { r.params.SecurityToken = credentials.sessionToken; } delete r.params.Signature; // delete old Signature for re-signing r.params.Signature = this.signature(credentials); r.body = AWS.util.queryParamsToString(r.params); r.headers['Content-Length'] = r.body.length; }
...
// clear old authorization headers
delete req.httpRequest.headers['Authorization'];
delete req.httpRequest.headers['Date'];
delete req.httpRequest.headers['X-Amz-Date'];
// add new authorization
signer.addAuthorization(credentials, date);
req.signedAt = date;
} catch (e) {
req.response.error = e;
}
done();
});
});
...
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function signature(credentials) { return AWS.util.crypto.hmac(credentials.secretAccessKey, this.stringToSign(), 'base64'); }
n/a
function stringToSign() { var parts = []; parts.push(this.request.method); parts.push(this.request.endpoint.host.toLowerCase()); parts.push(this.request.pathname()); parts.push(AWS.util.queryParamsToString(this.request.params)); return parts.join('\n'); }
n/a
V3 = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function RequestSigner(request) { this.request = request; }
n/a
function addAuthorization(credentials, date) { var datetime = AWS.util.date.rfc822(date); this.request.headers['X-Amz-Date'] = datetime; if (credentials.sessionToken) { this.request.headers['x-amz-security-token'] = credentials.sessionToken; } this.request.headers['X-Amzn-Authorization'] = this.authorization(credentials, datetime); }
...
// clear old authorization headers
delete req.httpRequest.headers['Authorization'];
delete req.httpRequest.headers['Date'];
delete req.httpRequest.headers['X-Amz-Date'];
// add new authorization
signer.addAuthorization(credentials, date);
req.signedAt = date;
} catch (e) {
req.response.error = e;
}
done();
});
});
...
function authorization(credentials) { return 'AWS3 ' + 'AWSAccessKeyId=' + credentials.accessKeyId + ',' + 'Algorithm=HmacSHA256,' + 'SignedHeaders=' + this.signedHeaders() + ',' + 'Signature=' + this.signature(credentials); }
n/a
function canonicalHeaders() { var headers = this.request.headers; var parts = []; AWS.util.arrayEach(this.headersToSign(), function iterator(h) { parts.push(h.toLowerCase().trim() + ':' + String(headers[h]).trim()); }); return parts.sort().join('\n') + '\n'; }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function headersToSign() { var headers = []; AWS.util.each(this.request.headers, function iterator(k) { if (k === 'Host' || k === 'Content-Encoding' || k.match(/^X-Amz/i)) { headers.push(k); } }); return headers; }
n/a
function signature(credentials) { return AWS.util.crypto.hmac(credentials.secretAccessKey, this.stringToSign(), 'base64'); }
n/a
function signedHeaders() { var headers = []; AWS.util.arrayEach(this.headersToSign(), function iterator(h) { headers.push(h.toLowerCase()); }); return headers.sort().join(';'); }
n/a
function stringToSign() { var parts = []; parts.push(this.request.method); parts.push('/'); parts.push(''); parts.push(this.canonicalHeaders()); parts.push(this.request.body); return AWS.util.crypto.sha256(parts.join('\n')); }
n/a
V3Https = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
__super__ = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function authorization(credentials) { return 'AWS3-HTTPS ' + 'AWSAccessKeyId=' + credentials.accessKeyId + ',' + 'Algorithm=HmacSHA256,' + 'Signature=' + this.signature(credentials); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function stringToSign() { return this.request.headers['X-Amz-Date']; }
n/a
function V4(request, serviceName, signatureCache) { AWS.Signers.RequestSigner.call(this, request); this.serviceName = serviceName; this.signatureCache = signatureCache; }
n/a
function RequestSigner(request) { this.request = request; }
n/a
function addAuthorization(credentials, date) { var datetime = AWS.util.date.iso8601(date).replace(/[:\-]|\.\d{3}/g, ''); if (this.isPresigned()) { this.updateForPresigned(credentials, datetime); } else { this.addHeaders(credentials, datetime); } this.request.headers['Authorization'] = this.authorization(credentials, datetime); }
...
// clear old authorization headers
delete req.httpRequest.headers['Authorization'];
delete req.httpRequest.headers['Date'];
delete req.httpRequest.headers['X-Amz-Date'];
// add new authorization
signer.addAuthorization(credentials, date);
req.signedAt = date;
} catch (e) {
req.response.error = e;
}
done();
});
});
...
function addHeaders(credentials, datetime) { this.request.headers['X-Amz-Date'] = datetime; if (credentials.sessionToken) { this.request.headers['x-amz-security-token'] = credentials.sessionToken; } }
n/a
function authorization(credentials, datetime) { var parts = []; var credString = this.credentialString(datetime); parts.push(this.algorithm + ' Credential=' + credentials.accessKeyId + '/' + credString); parts.push('SignedHeaders=' + this.signedHeaders()); parts.push('Signature=' + this.signature(credentials, datetime)); return parts.join(', '); }
n/a
function canonicalHeaderValues(values) { return values.replace(/\s+/g, ' ').replace(/^\s+|\s+$/g, ''); }
n/a
function canonicalHeaders() { var headers = []; AWS.util.each.call(this, this.request.headers, function (key, item) { headers.push([key, item]); }); headers.sort(function (a, b) { return a[0].toLowerCase() < b[0].toLowerCase() ? -1 : 1; }); var parts = []; AWS.util.arrayEach.call(this, headers, function (item) { var key = item[0].toLowerCase(); if (this.isSignableHeader(key)) { parts.push(key + ':' + this.canonicalHeaderValues(item[1].toString())); } }); return parts.join('\n'); }
n/a
function canonicalString() { var parts = [], pathname = this.request.pathname(); if (this.serviceName !== 's3') pathname = AWS.util.uriEscapePath(pathname); parts.push(this.request.method); parts.push(pathname); parts.push(this.request.search()); parts.push(this.canonicalHeaders() + '\n'); parts.push(this.signedHeaders()); parts.push(this.hexEncodedBodyHash()); return parts.join('\n'); }
n/a
function V4(request, serviceName, signatureCache) { AWS.Signers.RequestSigner.call(this, request); this.serviceName = serviceName; this.signatureCache = signatureCache; }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function credentialString(datetime) { return v4Credentials.createScope( datetime.substr(0, 8), this.request.region, this.serviceName ); }
n/a
function hexEncodedBodyHash() { if (this.isPresigned() && this.serviceName === 's3' && !this.request.body) { return 'UNSIGNED-PAYLOAD'; } else if (this.request.headers['X-Amz-Content-Sha256']) { return this.request.headers['X-Amz-Content-Sha256']; } else { return this.hexEncodedHash(this.request.body || ''); } }
n/a
function hash(string) { return AWS.util.crypto.sha256(string, 'hex'); }
n/a
function isPresigned() { return this.request.headers[expiresHeader] ? true : false; }
n/a
function isSignableHeader(key) { if (key.toLowerCase().indexOf('x-amz-') === 0) return true; return this.unsignableHeaders.indexOf(key) < 0; }
n/a
function signature(credentials, datetime) { var signingKey = v4Credentials.getSigningKey( credentials, datetime.substr(0, 8), this.request.region, this.serviceName, this.signatureCache ); return AWS.util.crypto.hmac(signingKey, this.stringToSign(datetime), 'hex'); }
n/a
function signedHeaders() { var keys = []; AWS.util.each.call(this, this.request.headers, function (key) { key = key.toLowerCase(); if (this.isSignableHeader(key)) keys.push(key); }); return keys.sort().join(';'); }
n/a
function stringToSign(datetime) { var parts = []; parts.push('AWS4-HMAC-SHA256'); parts.push(datetime); parts.push(this.credentialString(datetime)); parts.push(this.hexEncodedHash(this.canonicalString())); return parts.join('\n'); }
n/a
function updateForPresigned(credentials, datetime) { var credString = this.credentialString(datetime); var qs = { 'X-Amz-Date': datetime, 'X-Amz-Algorithm': this.algorithm, 'X-Amz-Credential': credentials.accessKeyId + '/' + credString, 'X-Amz-Expires': this.request.headers[expiresHeader], 'X-Amz-SignedHeaders': this.signedHeaders() }; if (credentials.sessionToken) { qs['X-Amz-Security-Token'] = credentials.sessionToken; } if (this.request.headers['Content-Type']) { qs['Content-Type'] = this.request.headers['Content-Type']; } if (this.request.headers['Content-MD5']) { qs['Content-MD5'] = this.request.headers['Content-MD5']; } if (this.request.headers['Cache-Control']) { qs['Cache-Control'] = this.request.headers['Cache-Control']; } // need to pull in any other X-Amz-* headers AWS.util.each.call(this, this.request.headers, function(key, value) { if (key === expiresHeader) return; if (this.isSignableHeader(key)) { var lowerKey = key.toLowerCase(); // Metadata should be normalized if (lowerKey.indexOf('x-amz-meta-') === 0) { qs[lowerKey] = value; } else if (lowerKey.indexOf('x-amz-') === 0) { qs[key] = value; } } }); var sep = this.request.path.indexOf('?') >= 0 ? '&' : '?'; this.request.path += sep + AWS.util.queryParamsToString(qs); }
n/a
SimpleDB = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
Snowball = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
StepFunctions = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
StorageGateway = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
Support = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function TemporaryCredentials(params, masterCredentials) { AWS.Credentials.call(this); this.loadMasterCredentials(masterCredentials); this.expired = true; this.params = params || {}; if (this.params.RoleArn) { this.params.RoleSessionName = this.params.RoleSessionName || 'temporary-credentials'; } }
n/a
function Credentials() { // hide secretAccessKey from being displayed with util.inspect AWS.util.hideProperties(this, ['secretAccessKey']); this.expired = false; this.expireTime = null; if (arguments.length === 1 && typeof arguments[0] === 'object') { var creds = arguments[0].credentials || arguments[0]; this.accessKeyId = creds.accessKeyId; this.secretAccessKey = creds.secretAccessKey; this.sessionToken = creds.sessionToken; } else { this.accessKeyId = arguments[0]; this.secretAccessKey = arguments[1]; this.sessionToken = arguments[2]; } }
n/a
function TemporaryCredentials(params, masterCredentials) { AWS.Credentials.call(this); this.loadMasterCredentials(masterCredentials); this.expired = true; this.params = params || {}; if (this.params.RoleArn) { this.params.RoleSessionName = this.params.RoleSessionName || 'temporary-credentials'; } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
createClients = function () { this.service = this.service || new STS({params: this.params}); }
n/a
function loadMasterCredentials(masterCredentials) { this.masterCredentials = masterCredentials || AWS.config.credentials; while (this.masterCredentials.masterCredentials) { this.masterCredentials = this.masterCredentials.masterCredentials; } if (typeof this.masterCredentials.get !== 'function') { this.masterCredentials = new AWS.Credentials(this.masterCredentials); } }
n/a
function refresh(callback) { var self = this; self.createClients(); if (!callback) callback = function(err) { if (err) throw err; }; self.masterCredentials.get(function() { self.service.config.credentials = self.masterCredentials; var operation = self.params.RoleArn ? self.service.assumeRole : self.service.getSessionToken; operation.call(self.service, function (err, data) { if (!err) { self.service.credentialsFrom(data, self); } callback(err); }); }); }
n/a
WAF = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
WAFRegional = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function WebIdentityCredentials(params, clientConfig) { AWS.Credentials.call(this); this.expired = true; this.params = params; this.params.RoleSessionName = this.params.RoleSessionName || 'web-identity'; this.data = null; this._clientConfig = AWS.util.copy(clientConfig || {}); }
n/a
function Credentials() { // hide secretAccessKey from being displayed with util.inspect AWS.util.hideProperties(this, ['secretAccessKey']); this.expired = false; this.expireTime = null; if (arguments.length === 1 && typeof arguments[0] === 'object') { var creds = arguments[0].credentials || arguments[0]; this.accessKeyId = creds.accessKeyId; this.secretAccessKey = creds.secretAccessKey; this.sessionToken = creds.sessionToken; } else { this.accessKeyId = arguments[0]; this.secretAccessKey = arguments[1]; this.sessionToken = arguments[2]; } }
n/a
function WebIdentityCredentials(params, clientConfig) { AWS.Credentials.call(this); this.expired = true; this.params = params; this.params.RoleSessionName = this.params.RoleSessionName || 'web-identity'; this.data = null; this._clientConfig = AWS.util.copy(clientConfig || {}); }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
createClients = function () { if (!this.service) { var stsConfig = AWS.util.merge({}, this._clientConfig); stsConfig.params = this.params; this.service = new STS(stsConfig); } }
n/a
function refresh(callback) { var self = this; self.createClients(); if (!callback) callback = function(err) { if (err) throw err; }; self.service.assumeRoleWithWebIdentity(function (err, data) { self.data = null; if (!err) { self.data = data; self.service.credentialsFrom(data, self); } callback(err); }); }
n/a
WorkDocs = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
WorkSpaces = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function XmlBuilder() { }
n/a
function DomXmlParser() { }
n/a
function XmlBuilder() { }
n/a
toXML = function (params, shape, rootElement, noEmpty) { var xml = builder.create(rootElement); applyNamespaces(xml, shape); serialize(xml, params, shape); return xml.children.length > 0 || noEmpty ? xml.root().toString() : ''; }
n/a
function NodeXmlParser() { }
n/a
parse = function (xml, shape) { shape = shape || {}; var result = null; var error = null; var parser = new xml2js.Parser(options); parser.parseString(xml, function (e, r) { error = e; result = r; }); if (result) { var data = parseXml(result, shape); if (result.ResponseMetadata) { data.ResponseMetadata = parseXml(result.ResponseMetadata[0], {}); } return data; } else if (error) { throw util.error(error, {code: 'XMLParserError', retryable: true}); } else { // empty xml document return parseXml({}, shape); } }
...
* @param path [String] the path relative to your process's current
* working directory to load configuration from.
* @return [AWS.Config] the same configuration object
*/
loadFromPath: function loadFromPath(path) {
this.clear();
var options = JSON.parse(AWS.util.readFileSync(path));
var fileSystemCreds = new AWS.FileSystemCredentials(path);
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
...
XRay = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
n/a
function Service(config) { if (!this.loadServiceClass) { throw AWS.util.error(new Error(), 'Service must be constructed with `new\' operator'); } var ServiceClass = this.loadServiceClass(config || {}); if (ServiceClass) { var originalConfig = AWS.util.copy(config); var svc = new ServiceClass(config); Object.defineProperty(svc, '_originalConfig', { get: function() { return originalConfig; }, enumerable: false, configurable: true }); svc._clientId = ++clientCount; return svc; } this.initialize(config); }
n/a
constructor = function () { if (klass !== Object) { return klass.apply(this, arguments); } }
...
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
this.constructor(options);
return this;
},
/**
* Clears configuration data on this object
*
...
function AcceptorStateMachine(states, state) { this.currentState = state || null; this.states = states || {}; }
n/a
function addState(name, acceptState, failState, fn) { if (typeof acceptState === 'function') { fn = acceptState; acceptState = null; failState = null; } else if (typeof failState === 'function') { fn = failState; failState = null; } if (!this.currentState) this.currentState = name; this.states[name] = { accept: acceptState, fail: failState, fn: fn }; return this; }
...
} else {
done(self.response.error);
}
});
};
this.addState('validate', 'build', 'error', transition);
this.addState('build', 'afterBuild', 'restart', transition);
this.addState('afterBuild', 'sign', 'restart', transition);
this.addState('sign', 'send', 'retry', transition);
this.addState('retry', 'afterRetry', 'afterRetry', transition);
this.addState('afterRetry', 'sign', 'error', transition);
this.addState('send', 'validateResponse', 'retry', transition);
this.addState('validateResponse', 'extractData', 'extractError', transition);
...
function runTo(finalState, done, bindObject, inputError) { if (typeof finalState === 'function') { inputError = bindObject; bindObject = done; done = finalState; finalState = null; } var self = this; var state = self.states[self.currentState]; state.fn.call(bindObject || self, inputError, function(err) { if (err) { if (state.fail) self.currentState = state.fail; else return done ? done.call(bindObject, err) : null; } else { if (state.accept) self.currentState = state.accept; else return done ? done.call(bindObject) : null; } if (self.currentState === finalState) { return done ? done.call(bindObject, err) : null; } self.runTo(finalState, done, bindObject, err); }); }
...
if (callback) {
// append to user agent
this.httpRequest.appendToUserAgent('callback');
this.on('complete', function (resp) {
callback.call(resp, resp.error, resp.data);
});
}
this.runTo();
return this.response;
},
/**
* @!method promise()
* Returns a 'thenable' promise.
...
function Buffer(arg, encodingOrOffset, length) { if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) { return new Buffer(arg, encodingOrOffset, length) } // Common case. if (typeof arg === 'number') { if (typeof encodingOrOffset === 'string') { throw new Error( 'If encoding is specified then the first argument must be a string' ) } return allocUnsafe(this, arg) } return from(this, arg, encodingOrOffset, length) }
...
});
add('HTTP_HEADERS', 'httpHeaders',
function HTTP_HEADERS(statusCode, headers, resp, statusMessage) {
resp.httpResponse.statusCode = statusCode;
resp.httpResponse.statusMessage = statusMessage;
resp.httpResponse.headers = headers;
resp.httpResponse.body = new AWS.util.Buffer('');
resp.httpResponse.buffers = [];
resp.httpResponse.numBytes = 0;
var dateHeader = headers.date || headers.Date;
if (dateHeader) {
var serverTime = Date.parse(dateHeader);
if (resp.request.service.config.correctClockSkew
&& AWS.util.isClockSkewed(serverTime)) {
...
function addPromises(constructors, PromiseDependency) { if (PromiseDependency === undefined && AWS && AWS.config) { PromiseDependency = AWS.config.getPromisesDependency(); } if (PromiseDependency === undefined && typeof Promise !== 'undefined') { PromiseDependency = Promise; } if (typeof PromiseDependency !== 'function') var deletePromises = true; if (!Array.isArray(constructors)) constructors = [constructors]; for (var ind = 0; ind < constructors.length; ind++) { var constructor = constructors[ind]; if (deletePromises) { if (constructor.deletePromisesFromClass) { constructor.deletePromisesFromClass(); } } else if (constructor.addPromisesToClass) { constructor.addPromisesToClass(PromiseDependency); } } }
...
PromisesDependency = dep;
// if null was passed in, we should try to use native promises
if (dep === null && typeof Promise === 'function') {
PromisesDependency = Promise;
}
var constructors = [AWS.Request, AWS.Credentials, AWS.CredentialProviderChain];
if (AWS.S3 && AWS.S3.ManagedUpload) constructors.push(AWS.S3.ManagedUpload);
AWS.util.addPromises(constructors, PromisesDependency);
},
/**
* Gets the promise dependency set by `AWS.config.setPromisesDependency`.
*/
getPromisesDependency: function getPromisesDependency() {
return PromisesDependency;
...
function applyClockOffset(serverTime) { if (serverTime) AWS.config.systemClockOffset = serverTime - new Date().getTime(); }
...
resp.httpResponse.buffers = [];
resp.httpResponse.numBytes = 0;
var dateHeader = headers.date || headers.Date;
if (dateHeader) {
var serverTime = Date.parse(dateHeader);
if (resp.request.service.config.correctClockSkew
&& AWS.util.isClockSkewed(serverTime)) {
AWS.util.applyClockOffset(serverTime);
}
}
});
add('HTTP_DATA', 'httpData', function HTTP_DATA(chunk, resp) {
if (chunk) {
if (AWS.util.isNode()) {
...
function arrayEach(array, iterFunction) { for (var idx in array) { if (Object.prototype.hasOwnProperty.call(array, idx)) { var ret = iterFunction.call(this, array[idx], parseInt(idx, 10)); if (ret === util.abort) break; } } }
...
if (data === null) return callback(null, null);
var config = self.service.paginationConfig(self.operation);
var resultKey = config.resultKey;
if (Array.isArray(resultKey)) resultKey = resultKey[0];
var items = jmespath.search(data, resultKey);
var continueIteration = true;
AWS.util.arrayEach(items, function(item) {
continueIteration = callback(null, item);
if (continueIteration === false) {
return AWS.util.abort;
}
});
return continueIteration;
}
...
function arraySliceFn(obj) { var fn = obj.slice || obj.webkitSlice || obj.mozSlice; return typeof fn === 'function' ? fn : null; }
n/a
function calculateRetryDelay(retryCount, retryDelayOptions) { if (!retryDelayOptions) retryDelayOptions = {}; var customBackoff = retryDelayOptions.customBackoff || null; if (typeof customBackoff === 'function') { return customBackoff(retryCount); } var base = typeof retryDelayOptions.base === 'number' ? retryDelayOptions.base : 100; var delay = Math.random() * (Math.pow(2, retryCount) * base); return delay; }
n/a
function computeSha256(body, done) { if (util.isNode()) { var Stream = util.stream.Stream; var fs = require('fs'); if (body instanceof Stream) { if (typeof body.path === 'string') { // assume file object var settings = {}; if (typeof body.start === 'number') { settings.start = body.start; } if (typeof body.end === 'number') { settings.end = body.end; } body = fs.createReadStream(body.path, settings); } else { // TODO support other stream types return done(new Error('Non-file stream objects are ' + 'not supported with SigV4')); } } } util.crypto.sha256(body, 'hex', function(err, sha) { if (err) done(err); else done(null, sha); }); }
...
});
addAsync('COMPUTE_SHA256', 'afterBuild', function COMPUTE_SHA256(req, done) {
req.haltHandlersOnError();
if (!req.service.api.signatureVersion) return done(); // none
if (req.service.getSignerClass(req) === AWS.Signers.V4) {
var body = req.httpRequest.body || '';
AWS.util.computeSha256(body, function(err, sha) {
if (err) {
done(err);
}
else {
req.httpRequest.headers['X-Amz-Content-Sha256'] = sha;
done();
}
...
function copy(object) { if (object === null || object === undefined) return object; var dupe = {}; // jshint forin:false for (var key in object) { dupe[key] = object[key]; } return dupe; }
...
* Extracts accessKeyId, secretAccessKey and sessionToken
* from a configuration hash.
*
* @api private
*/
extractCredentials: function extractCredentials(options) {
if (options.accessKeyId && options.secretAccessKey) {
options = AWS.util.copy(options);
options.credentials = new AWS.Credentials(options);
}
return options;
},
/**
* Sets the promise dependency the SDK will use wherever Promises are returned.
...
function each(object, iterFunction) { for (var key in object) { if (Object.prototype.hasOwnProperty.call(object, key)) { var ret = iterFunction.call(this, key, object[key]); if (ret === util.abort) break; } } }
...
['*', '*']
].map(function(item) {
return item[0] && item[1] ? item.join('/') : null;
});
}
function applyConfig(service, config) {
util.each(config, function(key, value) {
if (key === 'globalEndpoint') return;
if (service.config[key] === undefined || service.config[key] === null) {
service.config[key] = value;
}
});
}
...
function engine() { if (util.isBrowser() && typeof navigator !== 'undefined') { return navigator.userAgent; } else { var engine = process.platform + '/' + process.version; if (process.env.AWS_EXECUTION_ENV) { engine += ' exec-env/' + process.env.AWS_EXECUTION_ENV; } return engine; } }
n/a
function error(err, options) { var originalError = null; if (typeof err.message === 'string' && err.message !== '') { if (typeof options === 'string' || (options && options.message)) { originalError = util.copy(err); originalError.message = err.message; } } err.message = err.message || null; if (typeof options === 'string') { err.message = options; } else if (typeof options === 'object' && options !== null) { util.update(err, options); if (options.message) err.message = options.message; if (options.code || options.name) err.code = options.code || options.name; if (options.stack) err.stack = options.stack; } if (typeof Object.defineProperty === 'function') { Object.defineProperty(err, 'name', {writable: true, enumerable: false}); Object.defineProperty(err, 'message', {enumerable: true}); } err.name = options && options.name || err.name || err.code || 'Error'; err.time = new Date(); if (originalError) err.originalError = originalError; return err; }
...
var self = this;
function finish(err) {
callback(err, err ? null : self.credentials);
}
function credError(msg, err) {
return new AWS.util.error(err || new Error(), {
code: 'CredentialsError',
message: msg,
name: 'CredentialsError'
});
}
function getAsyncCredentials() {
...
function extractRequestId(resp) { var requestId = resp.httpResponse.headers['x-amz-request-id'] || resp.httpResponse.headers['x-amzn-requestid']; if (!requestId && resp.data && resp.data.ResponseMetadata) { requestId = resp.data.ResponseMetadata.RequestId; } if (requestId) { resp.requestId = requestId; } if (resp.error) { resp.error.requestId = requestId; } }
n/a
function handleRequestWithRetries(httpRequest, options, cb) { if (!options) options = {}; var http = AWS.HttpClient.getInstance(); var httpOptions = options.httpOptions || {}; var retryCount = 0; var errCallback = function(err) { var maxRetries = options.maxRetries || 0; if (err && err.code === 'TimeoutError') err.retryable = true; if (err && err.retryable && retryCount < maxRetries) { retryCount++; var delay = util.calculateRetryDelay(retryCount, options.retryDelayOptions); setTimeout(sendRequest, delay + (err.retryAfter || 0)); } else { cb(err); } }; var sendRequest = function() { var data = ''; http.handleRequest(httpRequest, httpOptions, function(httpResponse) { httpResponse.on('data', function(chunk) { data += chunk.toString(); }); httpResponse.on('end', function() { var statusCode = httpResponse.statusCode; if (statusCode < 300) { cb(null, data); } else { var retryAfter = parseInt(httpResponse.headers['retry-after'], 10) * 1000 || 0; var err = util.error(new Error(), { retryable: statusCode >= 500 || statusCode === 429 } ); if (retryAfter && err.retryable) err.retryAfter = retryAfter; errCallback(err); } }); }, errCallback); }; process.nextTick(sendRequest); }
n/a
function hideProperties(obj, props) { if (typeof Object.defineProperty !== 'function') return; util.arrayEach(props, function (key) { Object.defineProperty(obj, key, { enumerable: false, writable: true, configurable: true }); }); }
n/a
function hoistPayloadMember(resp) { var req = resp.request; var operation = req.operation; var output = req.service.api.operations[operation].output; if (output.payload) { var payloadMember = output.members[output.payload]; var responsePayload = resp.data[output.payload]; if (payloadMember.type === 'structure') { util.each(responsePayload, function(key, value) { util.property(resp.data, key, value, false); }); } } }
n/a
function inherit(klass, features) { var newObject = null; if (features === undefined) { features = klass; klass = Object; newObject = {}; } else { var ctor = function ConstructorWrapper() {}; ctor.prototype = klass.prototype; newObject = new ctor(); } // constructor not supplied, create pass-through ctor if (features.constructor === Object) { features.constructor = function() { if (klass !== Object) { return klass.apply(this, arguments); } }; } features.constructor.prototype = newObject; util.update(features.constructor.prototype, features); features.constructor.__super__ = klass; return features.constructor; }
...
* the API configuration). Possible values are: 'v2', 'v3', 'v4'.
*
* @!attribute signatureCache
* @return [Boolean] whether the signature to sign requests with (overriding
* the API configuration) is cached. Only applies to the signature version 'v4'.
* Defaults to `true`.
*/
AWS.Config = AWS.util.inherit({
/**
* @!endgroup
*/
/**
* Creates a new configuration object. This is the object that passes
* option data along to service requests, including credentials, security,
...
function isBrowser() { return process && process.browser; }
n/a
function isClockSkewed(serverTime) { if (serverTime) { util.property(AWS.config, 'isClockSkewed', Math.abs(new Date().getTime() - serverTime) >= 300000, false); return AWS.config.isClockSkewed; } }
...
resp.httpResponse.body = new AWS.util.Buffer('');
resp.httpResponse.buffers = [];
resp.httpResponse.numBytes = 0;
var dateHeader = headers.date || headers.Date;
if (dateHeader) {
var serverTime = Date.parse(dateHeader);
if (resp.request.service.config.correctClockSkew
&& AWS.util.isClockSkewed(serverTime)) {
AWS.util.applyClockOffset(serverTime);
}
}
});
add('HTTP_DATA', 'httpData', function HTTP_DATA(chunk, resp) {
if (chunk) {
...
function isDualstackAvailable(service) { if (!service) return false; var metadata = require('../apis/metadata.json'); if (typeof service !== 'string') service = service.serviceIdentifier; if (typeof service !== 'string' || !metadata.hasOwnProperty(service)) return false; return !!metadata[service].dualstackAvailable; }
...
if (Object.prototype.hasOwnProperty.call(regionConfig.rules, key)) {
var config = regionConfig.rules[key];
if (typeof config === 'string') {
config = regionConfig.patterns[config];
}
// set dualstack endpoint
if (service.config.useDualstack && util.isDualstackAvailable(service)) {
config = util.copy(config);
config.endpoint = '{service}.dualstack.{region}.amazonaws.com';
}
// set global endpoint
service.isGlobalEndpoint = !!config.globalEndpoint;
...
function isEmpty(obj) { for (var prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { return false; } } return true; }
n/a
function isNode() { return !util.isBrowser(); }
...
AWS.util.applyClockOffset(serverTime);
}
}
});
add('HTTP_DATA', 'httpData', function HTTP_DATA(chunk, resp) {
if (chunk) {
if (AWS.util.isNode()) {
resp.httpResponse.numBytes += chunk.length;
var total = resp.httpResponse.headers['content-length'];
var progress = { loaded: resp.httpResponse.numBytes, total: total };
resp.request.emit('httpDownloadProgress', [progress, resp]);
}
...
function isType(obj, type) { // handle cross-"frame" objects if (typeof type === 'function') type = util.typeName(type); return Object.prototype.toString.call(obj) === '[object ' + type + ']'; }
...
for (var i = 0; i < acceptedTypes.length; i++) {
if (typeof acceptedTypes[i] === 'string') {
if (typeof value === acceptedTypes[i]) return true;
} else if (acceptedTypes[i] instanceof RegExp) {
if ((value || '').toString().match(acceptedTypes[i])) return true;
} else {
if (value instanceof acceptedTypes[i]) return true;
if (AWS.util.isType(value, acceptedTypes[i])) return true;
if (!type && !foundInvalidType) acceptedTypes = acceptedTypes.slice();
acceptedTypes[i] = AWS.util.typeName(acceptedTypes[i]);
}
foundInvalidType = true;
}
var acceptedType = type;
...
function memoizedProperty(obj, name, get, enumerable) { var cachedValue = null; // build enumerable attribute for each value with lazy accessor. util.property(obj, name, function() { if (cachedValue === null) { cachedValue = get(); } return cachedValue; }, enumerable); }
n/a
function merge(obj1, obj2) { return util.update(util.copy(obj1), obj2); }
...
if (typeof defaultValue === 'function') {
this[property] = defaultValue.call(this);
} else {
this[property] = defaultValue;
}
} else if (property === 'httpOptions' && this[property]) {
// deep merge httpOptions
this[property] = AWS.util.merge(this[property], value);
} else {
this[property] = value;
}
},
/**
* All of the keys with their default values.
...
function mixin() { var klass = arguments[0]; for (var i = 1; i < arguments.length; i++) { // jshint forin:false for (var prop in arguments[i].prototype) { var fn = arguments[i].prototype[prop]; if (prop !== 'constructor') { klass.prototype[prop] = fn; } } } return klass; }
...
*/
AWS.Request.deletePromisesFromClass = function deletePromisesFromClass() {
delete this.prototype.promise;
};
AWS.util.addPromises(AWS.Request);
AWS.util.mixin(AWS.Request, AWS.SequentialExecutor);
...
function promisifyMethod(methodName, PromiseDependency) { return function promise() { var self = this; return new PromiseDependency(function(resolve, reject) { self[methodName](function(err, data) { if (err) { reject(err); } else { resolve(data); } }); }); }; }
n/a
function property(obj, name, value, enumerable, isValue) { var opts = { configurable: true, enumerable: enumerable !== undefined ? enumerable : true }; if (typeof value === 'function' && !isValue) { opts.get = value; } else { opts.value = value; opts.writable = true; } Object.defineProperty(obj, name, opts); }
n/a
function queryParamsToString(params) { var items = []; var escape = util.uriEscape; var sortedKeys = Object.keys(params).sort(); util.arrayEach(sortedKeys, function(name) { var value = params[name]; var ename = escape(name); var result = ename + '='; if (Array.isArray(value)) { var vals = []; util.arrayEach(value, function(item) { vals.push(escape(item)); }); result = ename + '=' + vals.sort().join('&' + ename + '='); } else if (value !== undefined && value !== null) { result = ename + '=' + escape(value); } items.push(result); }); return items.join('&'); }
n/a
function queryStringParse(qs) { return util.querystring.parse(qs); }
n/a
function readFileSync(path) { if (util.isBrowser()) return null; return require('fs').readFileSync(path, 'utf-8'); }
...
* @param path [String] the path relative to your process's current
* working directory to load configuration from.
* @return [AWS.Config] the same configuration object
*/
loadFromPath: function loadFromPath(path) {
this.clear();
var options = JSON.parse(AWS.util.readFileSync(path));
var fileSystemCreds = new AWS.FileSystemCredentials(path);
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
...
function typeName(type) { if (Object.prototype.hasOwnProperty.call(type, 'name')) return type.name; var str = type.toString(); var match = str.match(/^\s*function (.+)\(/); return match ? match[1] : str; }
...
if (typeof value === acceptedTypes[i]) return true;
} else if (acceptedTypes[i] instanceof RegExp) {
if ((value || '').toString().match(acceptedTypes[i])) return true;
} else {
if (value instanceof acceptedTypes[i]) return true;
if (AWS.util.isType(value, acceptedTypes[i])) return true;
if (!type && !foundInvalidType) acceptedTypes = acceptedTypes.slice();
acceptedTypes[i] = AWS.util.typeName(acceptedTypes[i]);
}
foundInvalidType = true;
}
var acceptedType = type;
if (!acceptedType) {
acceptedType = acceptedTypes.join(', ').replace(/,([^,]+)$/, ', or$1');
...
function update(obj1, obj2) { util.each(obj2, function iterator(key, item) { obj1[key] = item; }); return obj1; }
...
* @!group General Configuration Options
*
* @!attribute credentials
* @return [AWS.Credentials] the AWS credentials to sign requests with.
*
* @!attribute region
* @example Set the global region setting to us-west-2
* AWS.config.update({region: 'us-west-2'});
* @return [AWS.Credentials] The region to send service requests to.
* @see http://docs.amazonwebservices.com/general/latest/gr/rande.html
* A list of available endpoints for each AWS service
*
* @!attribute maxRetries
* @return [Integer] the maximum amount of retries to perform for a
* service request. By default this value is calculated by the specific
...
function uriEscape(string) { var output = encodeURIComponent(string); output = output.replace(/[^A-Za-z0-9_.~\-%]+/g, escape); // AWS percent-encodes some extra non-standard characters in a URI output = output.replace(/[*]/g, function(ch) { return '%' + ch.charCodeAt(0).toString(16).toUpperCase(); }); return output; }
n/a
function uriEscapePath(string) { var parts = []; util.arrayEach(string.split('/'), function (part) { parts.push(util.uriEscape(part)); }); return parts.join('/'); }
n/a
function urlFormat(url) { return util.url.format(url); }
n/a
function urlParse(url) { return util.url.parse(url); }
n/a
function userAgent() { var name = util.isBrowser() ? 'js' : 'nodejs'; var agent = 'aws-sdk-' + name + '/' + require('./core').VERSION; if (name === 'nodejs') agent += ' ' + util.engine(); return agent; }
n/a
function Buffer(arg, encodingOrOffset, length) { // Common case. if (typeof arg === 'number') { if (typeof encodingOrOffset === 'string') { throw new Error( 'If encoding is specified then the first argument must be a string' ); } return Buffer.allocUnsafe(arg); } return Buffer.from(arg, encodingOrOffset, length); }
...
});
add('HTTP_HEADERS', 'httpHeaders',
function HTTP_HEADERS(statusCode, headers, resp, statusMessage) {
resp.httpResponse.statusCode = statusCode;
resp.httpResponse.statusMessage = statusMessage;
resp.httpResponse.headers = headers;
resp.httpResponse.body = new AWS.util.Buffer('');
resp.httpResponse.buffers = [];
resp.httpResponse.numBytes = 0;
var dateHeader = headers.date || headers.Date;
if (dateHeader) {
var serverTime = Date.parse(dateHeader);
if (resp.request.service.config.correctClockSkew
&& AWS.util.isClockSkewed(serverTime)) {
...
alloc = function (size, fill, encoding) { assertSize(size); if (size > 0 && fill !== undefined) { // Since we are filling anyway, don't zero fill initially. // Only pay attention to encoding if it's a string. This // prevents accidentally sending in a number that would // be interpretted as a start offset. if (typeof encoding !== 'string') encoding = undefined; return createUnsafeBuffer(size).fill(fill, encoding); } return new FastBuffer(size); }
n/a
allocUnsafe = function (size) { assertSize(size); return allocate(size); }
n/a
allocUnsafeSlow = function (size) { assertSize(size); return createUnsafeBuffer(size); }
n/a
function byteLength(string, encoding) { if (typeof string !== 'string') { if (ArrayBuffer.isView(string) || isArrayBuffer(string) || isSharedArrayBuffer(string)) { return string.byteLength; } throw new TypeError('"string" must be a string, Buffer, or ArrayBuffer'); } var len = string.length; if (len === 0) return 0; // Use a for loop to avoid recursion var loweredCase = false; for (;;) { switch (encoding) { case 'ascii': case 'latin1': case 'binary': return len; case 'utf8': case 'utf-8': case undefined: return binding.byteLengthUtf8(string); case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': return len * 2; case 'hex': return len >>> 1; case 'base64': return base64ByteLength(string, len); default: // The C++ binding defaulted to UTF8, we should too. if (loweredCase) return binding.byteLengthUtf8(string); encoding = ('' + encoding).toLowerCase(); loweredCase = true; } } }
...
} else {
done();
}
});
add('SET_CONTENT_LENGTH', 'afterBuild', function SET_CONTENT_LENGTH(req) {
if (req.httpRequest.headers['Content-Length'] === undefined) {
var length = AWS.util.string.byteLength(req.httpRequest.body);
req.httpRequest.headers['Content-Length'] = length;
}
});
add('SET_HTTP_HOST', 'afterBuild', function SET_HTTP_HOST(req) {
req.httpRequest.headers['Host'] = req.httpRequest.endpoint.host;
});
...
function compare(a, b) { if (!(a instanceof Buffer) || !(b instanceof Buffer)) { throw new TypeError('Arguments must be Buffers'); } if (a === b) { return 0; } return binding.compare(a, b); }
n/a
concat = function (list, length) { var i; if (!Array.isArray(list)) throw new TypeError('"list" argument must be an Array of Buffers'); if (list.length === 0) return new FastBuffer(); if (length === undefined) { length = 0; for (i = 0; i < list.length; i++) length += list[i].length; } else { length = length >>> 0; } var buffer = Buffer.allocUnsafe(length); var pos = 0; for (i = 0; i < list.length; i++) { var buf = list[i]; if (!Buffer.isBuffer(buf)) throw new TypeError('"list" argument must be an Array of Buffers'); buf.copy(buffer, pos); pos += buf.length; } // Note: `length` is always equal to `buffer.length` at this point if (pos < length) { // Zero-fill the remaining bytes if the specified `length` was more than // the actual total length, i.e. if we have some remaining allocated bytes // there were not initialized. buffer.fill(0, pos, length); } return buffer; }
...
resp.httpResponse.buffers.push(new AWS.util.Buffer(chunk));
}
});
add('HTTP_DONE', 'httpDone', function HTTP_DONE(resp) {
// convert buffers array into single buffer
if (resp.httpResponse.buffers && resp.httpResponse.buffers.length > 0) {
var body = AWS.util.buffer.concat(resp.httpResponse.buffers);
resp.httpResponse.body = body;
}
delete resp.httpResponse.numBytes;
delete resp.httpResponse.buffers;
});
add('FINALIZE_ERROR', 'retry', function FINALIZE_ERROR(resp) {
...
from = function (value, encodingOrOffset, length) { if (typeof value === 'number') throw new TypeError('"value" argument must not be a number'); if (isArrayBuffer(value) || isSharedArrayBuffer(value)) return fromArrayBuffer(value, encodingOrOffset, length); if (typeof value === 'string') return fromString(value, encodingOrOffset); return fromObject(value); }
n/a
function isBuffer(b) { return b instanceof Buffer; }
...
validatePayload: function validatePayload(value, context) {
if (value === null || value === undefined) return;
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 = AWS.util.stream.Stream;
if (AWS.util.Buffer.isBuffer(value) || 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;
...
isEncoding = function (encoding) { return typeof encoding === 'string' && typeof internalUtil.normalizeEncoding(encoding) === 'string'; }
n/a
function asciiSlice() { [native code] }
n/a
function asciiWrite() { [native code] }
n/a
function base64Slice() { [native code] }
n/a
function base64Write() { [native code] }
n/a
function compare(target, start, end, thisStart, thisEnd) { if (!(target instanceof Buffer)) throw new TypeError('Argument must be a Buffer'); if (arguments.length === 1) return compare_(this, target); if (start === undefined) start = 0; else if (start < 0) throw new RangeError('out of range index'); else start >>>= 0; if (end === undefined) end = target.length; else if (end > target.length) throw new RangeError('out of range index'); else end >>>= 0; if (thisStart === undefined) thisStart = 0; else if (thisStart < 0) throw new RangeError('out of range index'); else thisStart >>>= 0; if (thisEnd === undefined) thisEnd = this.length; else if (thisEnd > this.length) throw new RangeError('out of range index'); else thisEnd >>>= 0; if (thisStart >= thisEnd) return (start >= end ? 0 : -1); else if (start >= end) return 1; return compareOffset(this, target, start, thisStart, end, thisEnd); }
n/a
function copy() { [native code] }
...
* Extracts accessKeyId, secretAccessKey and sessionToken
* from a configuration hash.
*
* @api private
*/
extractCredentials: function extractCredentials(options) {
if (options.accessKeyId && options.secretAccessKey) {
options = AWS.util.copy(options);
options.credentials = new AWS.Credentials(options);
}
return options;
},
/**
* Sets the promise dependency the SDK will use wherever Promises are returned.
...
function equals(b) { if (!(b instanceof Buffer)) throw new TypeError('Argument must be a Buffer'); if (this === b) return true; return binding.compare(this, b) === 0; }
n/a
function fill(val, start, end, encoding) { // Handle string cases: if (typeof val === 'string') { if (typeof start === 'string') { encoding = start; start = 0; end = this.length; } else if (typeof end === 'string') { encoding = end; end = this.length; } if (encoding !== undefined && typeof encoding !== 'string') { throw new TypeError('encoding must be a string'); } var normalizedEncoding = internalUtil.normalizeEncoding(encoding); if (normalizedEncoding === undefined) { throw new TypeError('Unknown encoding: ' + encoding); } if (val.length === 0) { // Previously, if val === '', the Buffer would not fill, // which is rather surprising. val = 0; } else if (val.length === 1) { var code = val.charCodeAt(0); if ((normalizedEncoding === 'utf8' && code < 128) || normalizedEncoding === 'latin1') { // Fast path: If `val` fits into a single byte, use that numeric value. val = code; } } } else if (typeof val === 'number') { val = val & 255; } // Invalid ranges are not set to a default, so can range check early. if (start < 0 || end > this.length) throw new RangeError('Out of range index'); if (end <= start) return this; start = start >>> 0; end = end === undefined ? this.length : end >>> 0; binding.fill(this, val, start, end, encoding); return this; }
n/a
function hexSlice() { [native code] }
n/a
function hexWrite() { [native code] }
n/a
function includes(val, byteOffset, encoding) { return this.indexOf(val, byteOffset, encoding) !== -1; }
n/a
function indexOf(val, byteOffset, encoding) { return bidirectionalIndexOf(this, val, byteOffset, encoding, true); }
...
}
}
},
validateEnum: function validateRange(shape, value, context) {
if (this.validation['enum'] && shape['enum'] !== undefined) {
// Fail if the string value is not present in the enum list
if (shape['enum'].indexOf(value) === -1) {
this.fail('EnumError', 'Found string value of ' + value + ', but '
+ 'expected ' + shape['enum'].join('|') + ' for ' + context);
}
}
},
validateType: function validateType(value, context, acceptedTypes, type) {
...
function inspect() { var str = ''; var max = exports.INSPECT_MAX_BYTES; str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim(); if (this.length > max) str += ' ... '; return `<${this.constructor.name} ${str}>`; }
...
if (!logger) return;
function buildMessage() {
var time = AWS.util.date.getDate().getTime();
var delta = (time - req.startTime.getTime()) / 1000;
var ansi = logger.isTTY ? true : false;
var status = resp.httpResponse.statusCode;
var params = require('util').inspect(req.params, true, null);
var message = '';
if (ansi) message += '\x1B[33m';
message += '[AWS ' + req.service.serviceIdentifier + ' ' + status;
message += ' ' + delta.toString() + 's ' + resp.retryCount + ' retries]';
if (ansi) message += '\x1B[0;1m';
message += ' ' + AWS.util.string.lowerFirst(req.operation);
...
function lastIndexOf(val, byteOffset, encoding) { return bidirectionalIndexOf(this, val, byteOffset, encoding, false); }
n/a
function latin1Slice() { [native code] }
n/a
function latin1Write() { [native code] }
n/a
function readDoubleBE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 8, this.length); return binding.readDoubleBE(this, offset); }
n/a
function readDoubleLE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 8, this.length); return binding.readDoubleLE(this, offset); }
n/a
function readFloatBE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return binding.readFloatBE(this, offset); }
n/a
function readFloatLE(offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return binding.readFloatLE(this, offset); }
n/a
readInt16BE = function (offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); var val = this[offset + 1] | (this[offset] << 8); return (val & 0x8000) ? val | 0xFFFF0000 : val; }
n/a
readInt16LE = function (offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); var val = this[offset] | (this[offset + 1] << 8); return (val & 0x8000) ? val | 0xFFFF0000 : val; }
n/a
readInt32BE = function (offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return (this[offset] << 24) | (this[offset + 1] << 16) | (this[offset + 2] << 8) | (this[offset + 3]); }
n/a
readInt32LE = function (offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return (this[offset]) | (this[offset + 1] << 8) | (this[offset + 2] << 16) | (this[offset + 3] << 24); }
n/a
readInt8 = function (offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 1, this.length); var val = this[offset]; return !(val & 0x80) ? val : (0xff - val + 1) * -1; }
n/a
readIntBE = function (offset, byteLength, noAssert) { offset = offset >>> 0; byteLength = byteLength >>> 0; if (!noAssert) checkOffset(offset, byteLength, this.length); var i = byteLength; var mul = 1; var val = this[offset + --i]; while (i > 0 && (mul *= 0x100)) val += this[offset + --i] * mul; mul *= 0x80; if (val >= mul) val -= Math.pow(2, 8 * byteLength); return val; }
n/a
readIntLE = function (offset, byteLength, noAssert) { offset = offset >>> 0; byteLength = byteLength >>> 0; if (!noAssert) checkOffset(offset, byteLength, this.length); var val = this[offset]; var mul = 1; var i = 0; while (++i < byteLength && (mul *= 0x100)) val += this[offset + i] * mul; mul *= 0x80; if (val >= mul) val -= Math.pow(2, 8 * byteLength); return val; }
n/a
readUInt16BE = function (offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); return (this[offset] << 8) | this[offset + 1]; }
n/a
readUInt16LE = function (offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 2, this.length); return this[offset] | (this[offset + 1] << 8); }
n/a
readUInt32BE = function (offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return (this[offset] * 0x1000000) + ((this[offset + 1] << 16) | (this[offset + 2] << 8) | this[offset + 3]); }
n/a
readUInt32LE = function (offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 4, this.length); return ((this[offset]) | (this[offset + 1] << 8) | (this[offset + 2] << 16)) + (this[offset + 3] * 0x1000000); }
n/a
readUInt8 = function (offset, noAssert) { offset = offset >>> 0; if (!noAssert) checkOffset(offset, 1, this.length); return this[offset]; }
n/a
readUIntBE = function (offset, byteLength, noAssert) { offset = offset >>> 0; byteLength = byteLength >>> 0; if (!noAssert) checkOffset(offset, byteLength, this.length); var val = this[offset + --byteLength]; var mul = 1; while (byteLength > 0 && (mul *= 0x100)) val += this[offset + --byteLength] * mul; return val; }
n/a
readUIntLE = function (offset, byteLength, noAssert) { offset = offset >>> 0; byteLength = byteLength >>> 0; if (!noAssert) checkOffset(offset, byteLength, this.length); var val = this[offset]; var mul = 1; var i = 0; while (++i < byteLength && (mul *= 0x100)) val += this[offset + i] * mul; return val; }
n/a
function slice(start, end) { const srcLength = this.length; start = adjustOffset(start, srcLength); end = end !== undefined ? adjustOffset(end, srcLength) : srcLength; const newLength = end > start ? end - start : 0; return new FastBuffer(this.buffer, this.byteOffset + start, newLength); }
...
if (typeof acceptedTypes[i] === 'string') {
if (typeof value === acceptedTypes[i]) return true;
} else if (acceptedTypes[i] instanceof RegExp) {
if ((value || '').toString().match(acceptedTypes[i])) return true;
} else {
if (value instanceof acceptedTypes[i]) return true;
if (AWS.util.isType(value, acceptedTypes[i])) return true;
if (!type && !foundInvalidType) acceptedTypes = acceptedTypes.slice();
acceptedTypes[i] = AWS.util.typeName(acceptedTypes[i]);
}
foundInvalidType = true;
}
var acceptedType = type;
if (!acceptedType) {
...
function swap16() { // For Buffer.length < 128, it's generally faster to // do the swap in javascript. For larger buffers, // dropping down to the native code is faster. const len = this.length; if (len % 2 !== 0) throw new RangeError('Buffer size must be a multiple of 16-bits'); if (len < 128) { for (var i = 0; i < len; i += 2) swap(this, i, i + 1); return this; } return swap16n(this); }
n/a
function swap32() { // For Buffer.length < 192, it's generally faster to // do the swap in javascript. For larger buffers, // dropping down to the native code is faster. const len = this.length; if (len % 4 !== 0) throw new RangeError('Buffer size must be a multiple of 32-bits'); if (len < 192) { for (var i = 0; i < len; i += 4) { swap(this, i, i + 3); swap(this, i + 1, i + 2); } return this; } return swap32n(this); }
n/a
function swap64() { // For Buffer.length < 192, it's generally faster to // do the swap in javascript. For larger buffers, // dropping down to the native code is faster. const len = this.length; if (len % 8 !== 0) throw new RangeError('Buffer size must be a multiple of 64-bits'); if (len < 192) { for (var i = 0; i < len; i += 8) { swap(this, i, i + 7); swap(this, i + 1, i + 6); swap(this, i + 2, i + 5); swap(this, i + 3, i + 4); } return this; } return swap64n(this); }
n/a
toJSON = function () { if (this.length) { const data = []; for (var i = 0; i < this.length; ++i) data[i] = this[i]; return { type: 'Buffer', data }; } else { return { type: 'Buffer', data: [] }; } }
n/a
toLocaleString = function (encoding, start, end) { let result; if (arguments.length === 0) { result = this.utf8Slice(0, this.length); } else { result = slowToString(this, encoding, start, end); } if (result === undefined) throw new Error('"toString()" failed'); return result; }
n/a
toString = function (encoding, start, end) { let result; if (arguments.length === 0) { result = this.utf8Slice(0, this.length); } else { result = slowToString(this, encoding, start, end); } if (result === undefined) throw new Error('"toString()" failed'); return result; }
...
var ansi = logger.isTTY ? true : false;
var status = resp.httpResponse.statusCode;
var params = require('util').inspect(req.params, true, null);
var message = '';
if (ansi) message += '\x1B[33m';
message += '[AWS ' + req.service.serviceIdentifier + ' ' + status;
message += ' ' + delta.toString() + 's ' + resp.retryCount +
x27; retries]';
if (ansi) message += '\x1B[0;1m';
message += ' ' + AWS.util.string.lowerFirst(req.operation);
message += '(' + params + ')';
if (ansi) message += '\x1B[0m';
return message;
}
...
function ucs2Slice() { [native code] }
n/a
function ucs2Write() { [native code] }
n/a
function utf8Slice() { [native code] }
n/a
function utf8Write() { [native code] }
n/a
write = function (string, offset, length, encoding) { // Buffer#write(string); if (offset === undefined) { encoding = 'utf8'; length = this.length; offset = 0; // Buffer#write(string, encoding) } else if (length === undefined && typeof offset === 'string') { encoding = offset; length = this.length; offset = 0; // Buffer#write(string, offset[, length][, encoding]) } else if (isFinite(offset)) { offset = offset >>> 0; if (isFinite(length)) { length = length >>> 0; if (encoding === undefined) encoding = 'utf8'; } else { encoding = length; length = undefined; } } else { // if someone is still calling the obsolete form of write(), tell them. // we don't want eg buf.write("foo", "utf8", 10) to silently turn into // buf.write("foo", "utf8"), so we can't ignore extra args throw new Error('Buffer.write(string, encoding, offset[, length]) ' + 'is no longer supported'); } var remaining = this.length - offset; if (length === undefined || length > remaining) length = remaining; if (string.length > 0 && (length < 0 || offset < 0)) throw new RangeError('Attempt to write outside buffer bounds'); if (!encoding) encoding = 'utf8'; var loweredCase = false; for (;;) { switch (encoding) { case 'hex': return this.hexWrite(string, offset, length); case 'utf8': case 'utf-8': return this.utf8Write(string, offset, length); case 'ascii': return this.asciiWrite(string, offset, length); case 'latin1': case 'binary': return this.latin1Write(string, offset, length); case 'base64': // Warning: maxLength not taken into account in base64Write return this.base64Write(string, offset, length); case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': return this.ucs2Write(string, offset, length); default: if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding); encoding = ('' + encoding).toLowerCase(); loweredCase = true; } } }
...
* * **xhrAsync** [Boolean] — Whether the SDK will send asynchronous
* HTTP requests. Used in the browser environment only. Set to false to
* send requests synchronously. Defaults to true (async on).
* * **xhrWithCredentials** [Boolean] — Sets the "withCredentials"
* property of an XMLHttpRequest object. Used in the browser environment
* only. Defaults to false.
* @!attribute logger
* @return [#write,#log] an object that responds to .write() (like a stream)
* or .log() (like the console object) in order to log information about
* requests
*
* @!attribute systemClockOffset
* @return [Number] an offset value in milliseconds to apply to all signing
* times. Use this to compensate for clock skew when your system may be
* out of sync with the service time. Note that this configuration option
...
function writeDoubleBE(val, offset, noAssert) { val = +val; offset = offset >>> 0; if (!noAssert) binding.writeDoubleBE(this, val, offset); else binding.writeDoubleBE(this, val, offset, true); return offset + 8; }
n/a
function writeDoubleLE(val, offset, noAssert) { val = +val; offset = offset >>> 0; if (!noAssert) binding.writeDoubleLE(this, val, offset); else binding.writeDoubleLE(this, val, offset, true); return offset + 8; }
n/a
function writeFloatBE(val, offset, noAssert) { val = +val; offset = offset >>> 0; if (!noAssert) binding.writeFloatBE(this, val, offset); else binding.writeFloatBE(this, val, offset, true); return offset + 4; }
n/a
function writeFloatLE(val, offset, noAssert) { val = +val; offset = offset >>> 0; if (!noAssert) binding.writeFloatLE(this, val, offset); else binding.writeFloatLE(this, val, offset, true); return offset + 4; }
n/a
writeInt16BE = function (value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000); this[offset] = (value >>> 8); this[offset + 1] = value; return offset + 2; }
n/a
writeInt16LE = function (value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000); this[offset] = value; this[offset + 1] = (value >>> 8); return offset + 2; }
n/a
writeInt32BE = function (value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000); this[offset] = (value >>> 24); this[offset + 1] = (value >>> 16); this[offset + 2] = (value >>> 8); this[offset + 3] = value; return offset + 4; }
n/a
writeInt32LE = function (value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000); this[offset] = value; this[offset + 1] = (value >>> 8); this[offset + 2] = (value >>> 16); this[offset + 3] = (value >>> 24); return offset + 4; }
n/a
writeInt8 = function (value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80); this[offset] = value; return offset + 1; }
n/a
writeIntBE = function (value, offset, byteLength, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) { checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength - 1) - 1, -Math.pow(2, 8 * byteLength - 1)); } var i = byteLength - 1; var mul = 1; var sub = 0; this[offset + i] = value; while (--i >= 0 && (mul *= 0x100)) { if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) sub = 1; this[offset + i] = ((value / mul) >> 0) - sub; } return offset + byteLength; }
n/a
writeIntLE = function (value, offset, byteLength, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) { checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength - 1) - 1, -Math.pow(2, 8 * byteLength - 1)); } var i = 0; var mul = 1; var sub = 0; this[offset] = value; while (++i < byteLength && (mul *= 0x100)) { if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) sub = 1; this[offset + i] = ((value / mul) >> 0) - sub; } return offset + byteLength; }
n/a
writeUInt16BE = function (value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0); this[offset] = (value >>> 8); this[offset + 1] = value; return offset + 2; }
n/a
writeUInt16LE = function (value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0); this[offset] = value; this[offset + 1] = (value >>> 8); return offset + 2; }
n/a
writeUInt32BE = function (value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0); this[offset] = (value >>> 24); this[offset + 1] = (value >>> 16); this[offset + 2] = (value >>> 8); this[offset + 3] = value; return offset + 4; }
n/a
writeUInt32LE = function (value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0); this[offset + 3] = (value >>> 24); this[offset + 2] = (value >>> 16); this[offset + 1] = (value >>> 8); this[offset] = value; return offset + 4; }
n/a
writeUInt8 = function (value, offset, noAssert) { value = +value; offset = offset >>> 0; if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0); this[offset] = value; return offset + 1; }
n/a
writeUIntBE = function (value, offset, byteLength, noAssert) { value = +value; offset = offset >>> 0; byteLength = byteLength >>> 0; if (!noAssert) { const maxBytes = Math.pow(2, 8 * byteLength) - 1; checkInt(this, value, offset, byteLength, maxBytes, 0); } var i = byteLength - 1; var mul = 1; this[offset + i] = value; while (--i >= 0 && (mul *= 0x100)) this[offset + i] = (value / mul) >>> 0; return offset + byteLength; }
n/a
writeUIntLE = function (value, offset, byteLength, noAssert) { value = +value; offset = offset >>> 0; byteLength = byteLength >>> 0; if (!noAssert) { const maxBytes = Math.pow(2, 8 * byteLength) - 1; checkInt(this, value, offset, byteLength, maxBytes, 0); } var mul = 1; var i = 0; this[offset] = value; while (++i < byteLength && (mul *= 0x100)) this[offset + i] = (value / mul) >>> 0; return offset + byteLength; }
n/a
function decode64(string) { if (typeof string === 'number') { throw util.error(new Error('Cannot base64 decode number ' + string)); } if (string === null || typeof string === 'undefined') { return string; } return (typeof util.Buffer.from === 'function' && util.Buffer.from !== Uint8Array.from) ? util.Buffer.from(string, 'base64') : new util.Buffer(string, 'base64'); }
n/a
function encode64(string) { if (typeof string === 'number') { throw util.error(new Error('Cannot base64 encode number ' + string)); } if (string === null || typeof string === 'undefined') { return string; } var buf = (typeof util.Buffer.from === 'function' && util.Buffer.from !== Uint8Array.from) ? util.Buffer.from(string) : new util .Buffer(string); return buf.toString('base64'); }
n/a
concat = function (buffers) { var length = 0, offset = 0, buffer = null, i; for (i = 0; i < buffers.length; i++) { length += buffers[i].length; } buffer = new util.Buffer(length); for (i = 0; i < buffers.length; i++) { buffers[i].copy(buffer, offset); offset += buffers[i].length; } return buffer; }
...
resp.httpResponse.buffers.push(new AWS.util.Buffer(chunk));
}
});
add('HTTP_DONE', 'httpDone', function HTTP_DONE(resp) {
// convert buffers array into single buffer
if (resp.httpResponse.buffers && resp.httpResponse.buffers.length > 0) {
var body = AWS.util.buffer.concat(resp.httpResponse.buffers);
resp.httpResponse.body = body;
}
delete resp.httpResponse.numBytes;
delete resp.httpResponse.buffers;
});
add('FINALIZE_ERROR', 'retry', function FINALIZE_ERROR(resp) {
...
function toStream(buffer) { if (!util.Buffer.isBuffer(buffer)) buffer = new util.Buffer(buffer); var readable = new (util.stream.Readable)(); var pos = 0; readable._read = function(size) { if (pos >= buffer.length) return readable.push(null); var end = pos + size; if (end > buffer.length) end = buffer.length; readable.push(buffer.slice(pos, end)); pos = end; }; return readable; }
n/a
function crc32(data) { var tbl = util.crypto.crc32Table; var crc = 0 ^ -1; if (typeof data === 'string') { data = new util.Buffer(data); } for (var i = 0; i < data.length; i++) { var code = data.readUInt8(i); crc = (crc >>> 8) ^ tbl[(crc ^ code) & 0xFF]; } return (crc ^ -1) >>> 0; }
n/a
function createHash(algorithm) { return util.crypto.lib.createHash(algorithm); }
n/a
hash = function (algorithm, data, digest, callback) { var hash = util.crypto.createHash(algorithm); if (!digest) { digest = 'binary'; } if (digest === 'buffer') { digest = undefined; } if (typeof data === 'string') data = new util.Buffer(data); var sliceFn = util.arraySliceFn(data); var isBuffer = util.Buffer.isBuffer(data); //Identifying objects with an ArrayBuffer as buffers if (util.isBrowser() && typeof ArrayBuffer !== 'undefined' && data && data.buffer instanceof ArrayBuffer) isBuffer = true; if (callback && typeof data === 'object' && typeof data.on === 'function' && !isBuffer) { data.on('data', function(chunk) { hash.update(chunk); }); data.on('error', function(err) { callback(err); }); data.on('end', function() { callback(null, hash.digest(digest)); }); } else if (callback && sliceFn && !isBuffer && typeof FileReader !== 'undefined') { // this might be a File/Blob var index = 0, size = 1024 * 512; var reader = new FileReader(); reader.onerror = function() { callback(new Error('Failed to read data.')); }; reader.onload = function() { var buf = new util.Buffer(new Uint8Array(reader.result)); hash.update(buf); index += buf.length; reader._continueReading(); }; reader._continueReading = function() { if (index >= data.size) { callback(null, hash.digest(digest)); return; } var back = index + size; if (back > data.size) back = data.size; reader.readAsArrayBuffer(sliceFn.call(data, index, back)); }; reader._continueReading(); } else { if (util.isBrowser() && typeof data === 'object' && !isBuffer) { data = new util.Buffer(new Uint8Array(data)); } var out = hash.update(data).digest(digest); if (callback) callback(null, out); return out; } }
n/a
function hmac(key, string, digest, fn) { if (!digest) digest = 'binary'; if (digest === 'buffer') { digest = undefined; } if (!fn) fn = 'sha256'; if (typeof string === 'string') string = new util.Buffer(string); return util.crypto.lib.createHmac(fn, key).update(string).digest(digest); }
n/a
function md5(data, digest, callback) { return util.crypto.hash('md5', data, digest, callback); }
n/a
function sha256(data, digest, callback) { return util.crypto.hash('sha256', data, digest, callback); }
n/a
function toHex(data) { var out = []; for (var i = 0; i < data.length; i++) { out.push(('0' + data.charCodeAt(i).toString(16)).substr(-2, 2)); } return out.join(''); }
n/a
function format(date, formatter) { if (!formatter) formatter = 'iso8601'; return util.date[formatter](util.date.from(date)); }
n/a
function format(date) { if (typeof date === 'number') { return new Date(date * 1000); // unix timestamp } else { return new Date(date); } }
n/a
function getDate() { if (!AWS) AWS = require('./core'); if (AWS.config.systemClockOffset) { // use offset when non-zero return new Date(new Date().getTime() + AWS.config.systemClockOffset); } else { return new Date(); } }
...
service.config.getCredentials(function (err, credentials) {
if (err) {
req.response.error = err;
return done();
}
try {
var date = AWS.util.date.getDate();
var SignerClass = service.getSignerClass(req);
var signer = new SignerClass(req.httpRequest,
service.api.signingName || service.api.endpointPrefix,
service.config.signatureCache);
signer.setServiceClientId(service._clientId);
// clear old authorization headers
...
function iso8601(date) { if (date === undefined) { date = util.date.getDate(); } return date.toISOString().replace(/\.\d{3}Z$/, 'Z'); }
n/a
function parseTimestamp(value) { if (typeof value === 'number') { // unix timestamp (number) return new Date(value * 1000); } else if (value.match(/^\d+$/)) { // unix timestamp return new Date(value * 1000); } else if (value.match(/^\d{4}/)) { // iso8601 return new Date(value); } else if (value.match(/^\w{3},/)) { // rfc822 return new Date(value); } else { throw util.error( new Error('unhandled timestamp format: ' + value), {code: 'TimestampParserError'}); } }
n/a
function rfc822(date) { if (date === undefined) { date = util.date.getDate(); } return date.toUTCString(); }
n/a
function unixTimestamp(date) { if (date === undefined) { date = util.date.getDate(); } return date.getTime() / 1000; }
n/a
function makeAsync(fn, expectedArgs) { if (expectedArgs && expectedArgs <= fn.length) { return fn; } return function() { var args = Array.prototype.slice.call(arguments, 0); var callback = args.pop(); var result = fn.apply(null, args); callback(result); }; }
...
*
* @see AWS.Request.eachItem
* @see AWS.Response.nextPage
* @since v1.4.0
*/
eachPage: function eachPage(callback) {
// Make all callbacks async-ish
callback = AWS.util.fn.makeAsync(callback, 3);
function wrappedCallback(response) {
callback.call(response, response.error, response.data, function (result) {
if (result === false) return;
if (response.hasNextPage()) {
response.nextPage().on('complete', wrappedCallback).send();
...
noop = function () {}
n/a
function string(ini) { var currentSection, map = {}; util.arrayEach(ini.split(/\r?\n/), function(line) { line = line.split(/(^|\s)[;#]/)[0]; // remove comments var section = line.match(/^\s*\[([^\[\]]+)\]\s*$/); if (section) { currentSection = section[1]; } else if (currentSection) { var item = line.match(/^\s*(.+?)\s*=\s*(.+?)\s*$/); if (item) { map[currentSection] = map[currentSection] || {}; map[currentSection][item[1]] = item[2]; } } }); return map; }
...
* @param path [String] the path relative to your process's current
* working directory to load configuration from.
* @return [AWS.Config] the same configuration object
*/
loadFromPath: function loadFromPath(path) {
this.clear();
var options = JSON.parse(AWS.util.readFileSync(path));
var fileSystemCreds = new AWS.FileSystemCredentials(path);
var chain = new AWS.CredentialProviderChain();
chain.providers.unshift(fileSystemCreds);
chain.resolve(function (err, creds) {
if (err) throw err;
else options.credentials = creds;
});
...
function byteLength(string) { if (string === null || string === undefined) return 0; if (typeof string === 'string') string = new util.Buffer(string); if (typeof string.byteLength === 'number') { return string.byteLength; } else if (typeof string.length === 'number') { return string.length; } else if (typeof string.size === 'number') { return string.size; } else if (typeof string.path === 'string') { return require('fs').lstatSync(string.path).size; } else { throw util.error(new Error('Cannot determine length of ' + string), { object: string }); } }
...
} else {
done();
}
});
add('SET_CONTENT_LENGTH', 'afterBuild', function SET_CONTENT_LENGTH(req) {
if (req.httpRequest.headers['Content-Length'] === undefined) {
var length = AWS.util.string.byteLength(req.httpRequest.body);
req.httpRequest.headers['Content-Length'] = length;
}
});
add('SET_HTTP_HOST', 'afterBuild', function SET_HTTP_HOST(req) {
req.httpRequest.headers['Host'] = req.httpRequest.endpoint.host;
});
...
function lowerFirst(string) { return string[0].toLowerCase() + string.substr(1); }
...
var params = require('util').inspect(req.params, true, null);
var message = '';
if (ansi) message += '\x1B[33m';
message += '[AWS ' + req.service.serviceIdentifier + ' ' + status;
message += ' ' + delta.toString() + 's ' + resp.retryCount + ' retries]';
if (ansi) message += '\x1B[0;1m';
message += ' ' + AWS.util.string.lowerFirst(req.operation);
message += '(' + params + ')';
if (ansi) message += '\x1B[0m';
return message;
}
var line = buildMessage();
if (typeof logger.log === 'function') {
...
function upperFirst(string) { return string[0].toUpperCase() + string.substr(1); }
n/a
function uuidV4() { return require('uuid').v4(); }
...
return;
}
// creates a copy of params so user's param object isn't mutated
var params = AWS.util.copy(req.params);
for (var i = 0, iLen = idempotentMembers.length; i < iLen; i++) {
if (!params[idempotentMembers[i]]) {
// add the member
params[idempotentMembers[i]] = AWS.util.uuid.v4();
}
}
req.params = params;
});
add('VALIDATE_PARAMETERS', 'validate', function VALIDATE_PARAMETERS(req) {
var rules = req.service.api.operations[req.operation].input;
...