UNPKG

mss-sdk

Version:
5 lines 240 kB
// AWS SDK for JavaScript v2.0.14 // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // License at https://sdk.amazonaws.com/js/BUNDLE_LICENSE.txt (function e(t,r,n){function i(a,o){if(!r[a]){if(!t[a]){var u=typeof require=="function"&&require;if(!o&&u)return u(a,!0);if(s)return s(a,!0);throw new Error("Cannot find module '"+a+"'")}var c=r[a]={exports:{}};t[a][0].call(c.exports,function(e){var r=t[a][1][e];return i(r?r:e)},c,c.exports,e,t,r,n)}return r[a].exports}var s=typeof require=="function"&&require;for(var a=0;a<n.length;a++)i(n[a]);return i})({1:[function(e,t,r){var n=e("./core");n.XML.Parser=e("./xml/browser_parser");e("./http/xhr");if(typeof window!=="undefined")window.AWS=n},{"./core":3,"./http/xhr":12,"./xml/browser_parser":44}],2:[function(e,t,r){var n=e("./core");e("./credentials");e("./credentials/credential_provider_chain");n.Config=n.util.inherit({constructor:function i(e){if(e===undefined)e={};e=this.extractCredentials(e);n.util.each.call(this,this.keys,function(t,r){this.set(t,e[t],r)})},update:function s(e,t){t=t||false;e=this.extractCredentials(e);n.util.each.call(this,e,function(e,r){if(t||this.keys.hasOwnProperty(e))this[e]=r})},getCredentials:function a(e){var t=this;function r(r){e(r,r?null:t.credentials)}function i(e,t){return new n.util.error(t||new Error,{code:"CredentialsError",message:e})}function s(){t.credentials.get(function(e){if(e){var n="Could not load credentials from "+t.credentials.constructor.name;e=i(n,e)}r(e)})}function a(){var e=null;if(!t.credentials.accessKeyId||!t.credentials.secretAccessKey){e=i("Missing credentials")}r(e)}if(t.credentials){if(typeof t.credentials.get==="function"){s()}else{a()}}else if(t.credentialProvider){t.credentialProvider.resolve(function(e,n){if(e){e=i("Could not load credentials from any providers",e)}t.credentials=n;r(e)})}else{r(i("No credentials to load"))}},loadFromPath:function o(e){this.clear();var t=JSON.parse(n.util.readFileSync(e));var r=new n.FileSystemCredentials(e);var i=new n.CredentialProviderChain;i.providers.unshift(r);i.resolve(function(e,r){if(e)throw e;else t.credentials=r});this.constructor(t);return this},clear:function u(){n.util.each.call(this,this.keys,function(e){delete this[e]});this.set("credentials",undefined);this.set("credentialProvider",undefined)},set:function c(e,t,r){if(t===undefined){if(r===undefined){r=this.keys[e]}if(typeof r==="function"){this[e]=r.call(this)}else{this[e]=r}}else{this[e]=t}},keys:{credentials:null,credentialProvider:null,region:null,logger:null,apiVersions:{},apiVersion:null,endpoint:undefined,httpOptions:{},maxRetries:undefined,maxRedirects:10,paramValidation:true,sslEnabled:true,s3ForcePathStyle:false,computeChecksums:true,convertResponseTypes:true,dynamoDbCrc32:true,signatureVersion:null},extractCredentials:function f(e){if(e.accessKeyId&&e.secretAccessKey){e=n.util.copy(e);e.credentials=new n.Credentials(e)}return e}});n.config=new n.Config},{"./core":3,"./credentials":4,"./credentials/credential_provider_chain":6}],3:[function(e,t,r){var n={util:e("./util")};var i={};i.toString();t.exports=n;n.util.update(n,{VERSION:"2.0.14",Signers:{},Protocol:{Json:e("./protocol/json"),Query:e("./protocol/query"),Rest:e("./protocol/rest"),RestJson:e("./protocol/rest_json"),RestXml:e("./protocol/rest_xml")},XML:{Builder:e("./xml/builder"),Parser:null},JSON:{Builder:e("./json/builder"),Parser:e("./json/parser")},Model:{Api:e("./model/api"),Operation:e("./model/operation"),Shape:e("./model/shape"),Paginator:e("./model/paginator"),ResourceWaiter:e("./model/resource_waiter")},util:e("./util")});e("./service");e("./credentials");e("./credentials/credential_provider_chain");e("./credentials/temporary_credentials");e("./credentials/web_identity_credentials");e("./credentials/cognito_identity_credentials");e("./credentials/saml_credentials");e("./config");e("./http");e("./sequential_executor");e("./event_listeners");e("./request");e("./response");e("./resource_waiter");e("./signers/request_signer");e("./param_validator");n.events=new n.SequentialExecutor},{"./config":2,"./credentials":4,"./credentials/cognito_identity_credentials":5,"./credentials/credential_provider_chain":6,"./credentials/saml_credentials":7,"./credentials/temporary_credentials":8,"./credentials/web_identity_credentials":9,"./event_listeners":10,"./http":11,"./json/builder":13,"./json/parser":14,"./model/api":15,"./model/operation":17,"./model/paginator":18,"./model/resource_waiter":19,"./model/shape":20,"./param_validator":21,"./protocol/json":22,"./protocol/query":23,"./protocol/rest":24,"./protocol/rest_json":25,"./protocol/rest_xml":26,"./request":30,"./resource_waiter":31,"./response":32,"./sequential_executor":33,"./service":34,"./signers/request_signer":36,"./util":43,"./xml/builder":45}],4:[function(e,t,r){var n=e("./core");n.Credentials=n.util.inherit({constructor:function i(){n.util.hideProperties(this,["secretAccessKey"]);this.expired=false;this.expireTime=null;if(arguments.length===1&&typeof arguments[0]==="object"){var e=arguments[0].credentials||arguments[0];this.accessKeyId=e.accessKeyId;this.secretAccessKey=e.secretAccessKey;this.sessionToken=e.sessionToken}else{this.accessKeyId=arguments[0];this.secretAccessKey=arguments[1];this.sessionToken=arguments[2]}},expiryWindow:15,needsRefresh:function s(){var e=n.util.date.getDate().getTime();var t=new Date(e+this.expiryWindow*1e3);if(this.expireTime&&t>this.expireTime){return true}else{return this.expired||!this.accessKeyId||!this.secretAccessKey}},get:function a(e){var t=this;if(this.needsRefresh()){this.refresh(function(r){if(!r)t.expired=false;if(e)e(r)})}else if(e){e()}},refresh:function o(e){this.expired=false;e()}})},{"./core":3}],5:[function(e,t,r){var n=e("../core");n.CognitoIdentityCredentials=n.util.inherit(n.Credentials,{localStorageKey:{id:"aws.cognito.identity-id",providers:"aws.cognito.identity-providers"},constructor:function i(e){n.Credentials.call(this);this.expired=true;this.webIdentityCredentials=new n.WebIdentityCredentials(e);this.cognito=new n.CognitoIdentity({params:e});this.sts=new n.STS;this.params=e;this.data=null;this.identityId=null;this.loadCachedId()},refresh:function s(e){var t=this;t.data=null;t.identityId=null;t.getId(function(r){if(!r){t.cognito.getOpenIdToken(function(r,n){if(!r){t.cacheId(n);t.params.WebIdentityToken=n.Token;t.webIdentityCredentials.refresh(function(r){if(!r){t.data=t.webIdentityCredentials.data;t.sts.credentialsFrom(t.data,t)}e(r)})}else{e(r)}})}else{e(r)}})},getId:function a(e){var t=this;if(typeof t.params.IdentityId==="string")return e();t.cognito.getId(function(r,n){if(!r&&n.IdentityId){t.params.IdentityId=n.IdentityId}e(r,n)})},loadCachedId:function o(){var e=this;if(n.util.isBrowser()&&!e.params.IdentityId){var t=window.localStorage;var r=t[e.localStorageKey.id];if(r&&e.params.Logins){var i=Object.keys(e.params.Logins);var s=(t[e.localStorageKey.providers]||"").split(",");var a=s.filter(function(e){return i.indexOf(e)!==-1});if(a.length!==0){e.params.IdentityId=r}}else if(r){e.params.IdentityId=r}}},cacheId:function u(e){this.identityId=e.IdentityId;this.params.IdentityId=this.identityId;if(n.util.isBrowser()){var t=window.localStorage;t[this.localStorageKey.id]=e.IdentityId;if(this.params.Logins){t[this.localStorageKey.providers]=Object.keys(this.params.Logins).join(",")}}}})},{"../core":3}],6:[function(e,t,r){var n=e("../core");n.CredentialProviderChain=n.util.inherit(n.Credentials,{constructor:function i(e){if(e){this.providers=e}else{this.providers=n.CredentialProviderChain.defaultProviders.slice(0)}},resolve:function s(e){if(this.providers.length===0){e(new Error("No providers"));return this}var t=0;var r=this.providers.slice(0);function n(i,s){if(!i&&s||t===r.length){e(i,s);return}var a=r[t++];if(typeof a==="function"){s=a.call()}else{s=a}if(s.get){s.get(function(e){n(e,e?null:s)})}else{n(null,s)}}n();return this}});n.CredentialProviderChain.defaultProviders=[]},{"../core":3}],7:[function(e,t,r){var n=e("../core");n.SAMLCredentials=n.util.inherit(n.Credentials,{constructor:function i(e){n.Credentials.call(this);this.expired=true;this.params=e;this.service=new n.STS({params:this.params})},refresh:function s(e){var t=this;if(!e)e=function(e){if(e)throw e};t.service.assumeRoleWithSAML(function(r,n){if(!r){t.service.credentialsFrom(n,t)}e(r)})}})},{"../core":3}],8:[function(e,t,r){var n=e("../core");n.TemporaryCredentials=n.util.inherit(n.Credentials,{constructor:function i(e){n.Credentials.call(this);this.loadMasterCredentials();this.expired=true;this.params=e||{};if(this.params.RoleArn){this.params.RoleSessionName=this.params.RoleSessionName||"temporary-credentials"}this.service=new n.STS({params:this.params})},refresh:function s(e){var t=this;if(!e)e=function(e){if(e)throw e};t.service.config.credentials=t.masterCredentials;var r=t.params.RoleArn?t.service.assumeRole:t.service.getSessionToken;r.call(t.service,function(r,n){if(!r){t.service.credentialsFrom(n,t)}e(r)})},loadMasterCredentials:function a(){this.masterCredentials=n.config.credentials;while(this.masterCredentials.masterCredentials){this.masterCredentials=this.masterCredentials.masterCredentials}}})},{"../core":3}],9:[function(e,t,r){var n=e("../core");n.WebIdentityCredentials=n.util.inherit(n.Credentials,{constructor:function i(e){n.Credentials.call(this);this.expired=true;this.params=e;this.params.RoleSessionName=this.params.RoleSessionName||"web-identity";this.service=new n.STS({params:this.params});this.data=null},refresh:function s(e){var t=this;if(!e)e=function(e){if(e)throw e};t.service.assumeRoleWithWebIdentity(function(r,n){t.data=null;if(!r){t.data=n;t.service.credentialsFrom(n,t)}e(r)})}})},{"../core":3}],10:[function(e,t,r){var n=e("./core");var i=e("./sequential_executor");n.EventListeners={Core:{}};n.EventListeners={Core:(new i).addNamedListeners(function(e,t){t("VALIDATE_CREDENTIALS","validate",function r(e,t){if(!e.service.api.signatureVersion)return t();e.service.config.getCredentials(function(r){if(r){e.response.error=n.util.error(r,{code:"CredentialsError",message:"Missing credentials in config"})}t()})});e("VALIDATE_REGION","validate",function i(e){if(!e.service.config.region&&!e.service.isGlobalEndpoint){e.response.error=n.util.error(new Error,{code:"ConfigError",message:"Missing region in config"})}});e("VALIDATE_PARAMETERS","validate",function s(e){var t=e.service.api.operations[e.operation].input;(new n.ParamValidator).validate(t,e.params)});e("SET_CONTENT_LENGTH","afterBuild",function a(e){if(e.httpRequest.headers["Content-Length"]===undefined){var t=n.util.string.byteLength(e.httpRequest.body);e.httpRequest.headers["Content-Length"]=t}});e("SET_HTTP_HOST","afterBuild",function o(e){e.httpRequest.headers["Host"]=e.httpRequest.endpoint.host});e("RESTART","restart",function u(e){var t=this.response.error;if(!t||!t.retryable)return;if(this.response.retryCount<this.service.config.maxRetries){this.response.retryCount++}else{this.response.error=null}});t("SIGN","sign",function c(e,t){if(!e.service.api.signatureVersion)return t();e.service.config.getCredentials(function(r,i){if(r){e.response.error=r;return t()}try{var s=n.util.date.getDate();var a=e.service.getSignerClass(e);var o=new a(e.httpRequest,e.service.api.signingName||e.service.api.endpointPrefix);delete e.httpRequest.headers["Authorization"];delete e.httpRequest.headers["Date"];delete e.httpRequest.headers["X-Amz-Date"];o.addAuthorization(i,s);e.signedAt=s}catch(u){e.response.error=u}t()})});e("VALIDATE_RESPONSE","validateResponse",function f(e){if(this.service.successfulResponse(e,this)){e.data={};e.error=null}else{e.data=null;e.error=n.util.error(new Error,{code:"UnknownError",message:"An unknown error occurred."})}});t("SEND","send",function l(e,t){e.httpResponse._abortCallback=t;e.error=null;e.data=null;function r(r){e.httpResponse.stream=r;r.on("headers",function i(t,s){e.request.emit("httpHeaders",[t,s,e]);if(!e.request.httpRequest._streaming){if(n.HttpClient.streamsApiVersion===2){r.on("readable",function a(){var t=r.read();if(t!==null){e.request.emit("httpData",[t,e])}})}else{r.on("data",function o(t){e.request.emit("httpData",[t,e])})}}});r.on("end",function s(){e.request.emit("httpDone");t()})}function i(t){t.on("sendProgress",function r(t){e.request.emit("httpUploadProgress",[t,e])});t.on("receiveProgress",function n(t){e.request.emit("httpDownloadProgress",[t,e])})}function s(r){e.error=n.util.error(r,{code:"NetworkingError",region:e.request.httpRequest.region,hostname:e.request.httpRequest.endpoint.hostname,retryable:true});e.request.emit("httpError",[e.error,e],function(){t()})}function a(){var t=n.HttpClient.getInstance();var a=e.request.service.config.httpOptions||{};var o=t.handleRequest(e.request.httpRequest,a,r,s);i(o)}var o=(n.util.date.getDate()-this.signedAt)/1e3;if(o>=60*10){this.emit("sign",[this],function(e){if(e)t(e);else a()})}else{a()}});e("HTTP_HEADERS","httpHeaders",function h(e,t,r){r.httpResponse.statusCode=e;r.httpResponse.headers=t;r.httpResponse.body=new n.util.Buffer("");r.httpResponse.buffers=[];r.httpResponse.numBytes=0});e("HTTP_DATA","httpData",function p(e,t){if(e){if(n.util.isNode()){t.httpResponse.numBytes+=e.length;var r=t.httpResponse.headers["content-length"];var i={loaded:t.httpResponse.numBytes,total:r};t.request.emit("httpDownloadProgress",[i,t])}t.httpResponse.buffers.push(new n.util.Buffer(e))}});e("HTTP_DONE","httpDone",function d(e){if(e.httpResponse.buffers&&e.httpResponse.buffers.length>0){var t=n.util.buffer.concat(e.httpResponse.buffers);e.httpResponse.body=t}delete e.httpResponse.numBytes;delete e.httpResponse.buffers});e("FINALIZE_ERROR","retry",function v(e){if(e.httpResponse.statusCode){e.error.statusCode=e.httpResponse.statusCode;if(e.error.retryable===undefined){e.error.retryable=this.service.retryableError(e.error,this)}}});e("INVALIDATE_CREDENTIALS","retry",function m(e){if(!e.error)return;switch(e.error.code){case"RequestExpired":case"ExpiredTokenException":case"ExpiredToken":e.error.retryable=true;e.request.service.config.credentials.expired=true}});e("REDIRECT","retry",function g(e){if(e.error&&e.error.statusCode>=300&&e.error.statusCode<400&&e.httpResponse.headers["location"]){this.httpRequest.endpoint=new n.Endpoint(e.httpResponse.headers["location"]);e.error.redirect=true;e.error.retryable=true}});e("RETRY_CHECK","retry",function y(e){if(e.error){if(e.error.redirect&&e.redirectCount<e.maxRedirects){e.error.retryDelay=0}else if(e.error.retryable&&e.retryCount<e.maxRetries){var t=this.service.retryDelays();e.error.retryDelay=t[e.retryCount]||0}}});t("RESET_RETRY_STATE","afterRetry",function b(e,t){var r,n=false;if(e.error){r=e.error.retryDelay||0;if(e.error.retryable&&e.retryCount<e.maxRetries){e.retryCount++;n=true}else if(e.error.redirect&&e.redirectCount<e.maxRedirects){e.redirectCount++;n=true}}if(n){e.error=null;setTimeout(t,r)}else{t()}})}),CorePost:(new i).addNamedListeners(function(e){e("EXTRACT_REQUEST_ID","extractData",function t(e){e.requestId=e.httpResponse.headers["x-amz-request-id"]||e.httpResponse.headers["x-amzn-requestid"];if(!e.requestId&&e.data&&e.data.ResponseMetadata){e.requestId=e.data.ResponseMetadata.RequestId}})}),Logger:(new i).addNamedListeners(function(t){t("LOG_REQUEST","complete",function r(t){var r=t.request;var i=r.service.config.logger;if(!i)return;function s(){var s=n.util.date.getDate().getTime();var a=(s-r.startTime.getTime())/1e3;var o=i.isTTY?true:false;var u=t.httpResponse.statusCode;var c=e("util").inspect(r.params,true,true);var f="";if(o)f+="";f+="[AWS "+r.service.serviceIdentifier+" "+u;f+=" "+a.toString()+"s "+t.retryCount+" retries]";if(o)f+="";f+=" "+n.util.string.lowerFirst(r.operation);f+="("+c+")";if(o)f+="";return f}var a=s();if(typeof i.log==="function"){i.log(a)}else if(typeof i.write==="function"){i.write(a+"\n")}})}),Json:(new i).addNamedListeners(function(t){var r=e("./protocol/json");t("BUILD","build",r.buildRequest);t("EXTRACT_DATA","extractData",r.extractData);t("EXTRACT_ERROR","extractError",r.extractError)}),Rest:(new i).addNamedListeners(function(t){var r=e("./protocol/rest");t("BUILD","build",r.buildRequest);t("EXTRACT_DATA","extractData",r.extractData);t("EXTRACT_ERROR","extractError",r.extractError)}),RestJson:(new i).addNamedListeners(function(t){var r=e("./protocol/rest_json");t("BUILD","build",r.buildRequest);t("EXTRACT_DATA","extractData",r.extractData);t("EXTRACT_ERROR","extractError",r.extractError)}),RestXml:(new i).addNamedListeners(function(t){var r=e("./protocol/rest_xml");t("BUILD","build",r.buildRequest);t("EXTRACT_DATA","extractData",r.extractData);t("EXTRACT_ERROR","extractError",r.extractError)}),Query:(new i).addNamedListeners(function(t){var r=e("./protocol/query");t("BUILD","build",r.buildRequest);t("EXTRACT_DATA","extractData",r.extractData);t("EXTRACT_ERROR","extractError",r.extractError)})}},{"./core":3,"./protocol/json":22,"./protocol/query":23,"./protocol/rest":24,"./protocol/rest_json":25,"./protocol/rest_xml":26,"./sequential_executor":33,util:64}],11:[function(e,t,r){var n=e("./core");var i=n.util.inherit;n.Endpoint=i({constructor:function s(e,t){n.util.hideProperties(this,["slashes","auth","hash","search","query"]);if(typeof e==="undefined"||e===null){throw new Error("Invalid endpoint: "+e)}else if(typeof e!=="string"){return n.util.copy(e)}if(!e.match(/^http/)){var r=t&&t.sslEnabled!==undefined?t.sslEnabled:n.config.sslEnabled;e=(r?"https":"http")+"://"+e}n.util.update(this,n.util.urlParse(e));if(this.port){this.port=parseInt(this.port,10)}else{this.port=this.protocol==="https:"?443:80}}});n.HttpRequest=i({constructor:function a(e,t){e=new n.Endpoint(e);this.method="POST";this.path=e.path||"/";this.headers={};this.body="";this.endpoint=e;this.region=t;this.setUserAgent()},setUserAgent:function o(){var e=n.util.isBrowser()?"X-Amz-":"";this.headers[e+"User-Agent"]=n.util.userAgent()},pathname:function u(){return this.path.split("?",1)[0]},search:function c(){return this.path.split("?",2)[1]||""}});n.HttpResponse=i({constructor:function f(){this.statusCode=undefined;this.headers={};this.body=undefined}});n.HttpClient=i({});n.HttpClient.getInstance=function l(){if(this.singleton===undefined){this.singleton=new this}return this.singleton}},{"./core":3}],12:[function(e,t,r){var n=e("../core");var i=e("events").EventEmitter;e("../http");n.XHRClient=n.util.inherit({handleRequest:function s(e,t,r,a){var o=this;var u=e.endpoint;var c=new i;var f=u.protocol+"//"+u.hostname;if(u.port!==80&&u.port!==443){f+=":"+u.port}f+=e.path;var l=new XMLHttpRequest,h=false;e.stream=l;if(t.timeout){l.timeout=t.timeout}if(t.xhrWithCredentials){l.withCredentials=true}l.addEventListener("readystatechange",function(){try{if(l.status===0)return}catch(e){return}if(this.readyState>=this.HEADERS_RECEIVED&&!h){try{l.responseType="arraybuffer"}catch(e){}c.statusCode=l.status;c.headers=o.parseHeaders(l.getAllResponseHeaders());c.emit("headers",c.statusCode,c.headers);h=true}if(this.readyState===this.DONE){o.finishRequest(l,c)}},false);l.upload.addEventListener("progress",function(e){c.emit("sendProgress",e)});l.addEventListener("progress",function(e){c.emit("receiveProgress",e)},false);l.addEventListener("timeout",function(){a(n.util.error(new Error("Timeout"),{code:"TimeoutError"}))},false);l.addEventListener("error",function(){a(n.util.error(new Error("Network Failure"),{code:"NetworkingError"}))},false);r(c);l.open(e.method,f,t.xhrAsync!==false);n.util.each(e.headers,function(e,t){if(e!=="Content-Length"&&e!=="User-Agent"&&e!=="Host"){l.setRequestHeader(e,t)}});if(e.body&&typeof e.body.buffer==="object"){l.send(e.body.buffer)}else{l.send(e.body)}return c},parseHeaders:function a(e){var t={};n.util.arrayEach(e.split(/\r?\n/),function(e){var r=e.split(":",1)[0];var n=e.substring(r.length+2);if(r.length>0)t[r]=n});return t},finishRequest:function o(e,t){var r;if(e.responseType==="arraybuffer"&&e.response){var i=e.response;r=new n.util.Buffer(i.byteLength);var s=new Uint8Array(i);for(var a=0;a<r.length;++a){r[a]=s[a]}}try{if(!r&&typeof e.responseText==="string"){r=new n.util.Buffer(e.responseText)}}catch(o){}if(r)t.emit("data",r);t.emit("end")}});n.HttpClient.prototype=n.XHRClient.prototype;n.HttpClient.streamsApiVersion=1},{"../core":3,"../http":11,events:55}],13:[function(e,t,r){var n=e("../util");function i(){}i.prototype.build=function(e,t){return JSON.stringify(s(e,t))};function s(e,t){if(!t||e===undefined||e===null)return undefined;switch(t.type){case"structure":return a(e,t);case"map":return u(e,t);case"list":return o(e,t);default:return c(e,t)}}function a(e,t){var r={};n.each(e,function(e,n){var i=t.members[e];if(i){if(i.location!=="body")return;var a=s(n,i);if(a!==undefined)r[e]=a}});return r}function o(e,t){var r=[];n.arrayEach(e,function(e){var n=s(e,t.member);if(n!==undefined)r.push(n)});return r}function u(e,t){var r={};n.each(e,function(e,n){var i=s(n,t.value);if(i!==undefined)r[e]=i});return r}function c(e,t){return t.toWireFormat(e)}t.exports=i},{"../util":43}],14:[function(e,t,r){var n=e("../util");function i(){}i.prototype.parse=function(e,t){return s(JSON.parse(e),t)};function s(e,t){if(!t||e===undefined||e===null)return undefined;switch(t.type){case"structure":return a(e,t);case"map":return u(e,t);case"list":return o(e,t);default:return c(e,t)}}function a(e,t){var r={};n.each(e,function(e,n){var i=t.members[e];if(i){var a=s(n,i);if(a!==undefined)r[e]=a}});return r}function o(e,t){var r=[];n.arrayEach(e,function(e){var n=s(e,t.member);if(n!==undefined)r.push(n)});return r}function u(e,t){var r={};n.each(e,function(e,n){var i=s(n,t.value);if(i!==undefined)r[e]=i});return r}function c(e,t){return t.toType(e)}t.exports=i},{"../util":43}],15:[function(e,t,r){var n=e("./collection");var i=e("./operation");var s=e("./shape");var a=e("./paginator");var o=e("./resource_waiter");var u=e("../util");var c=u.property;var f=u.memoizedProperty;function l(e,t){e=e||{};t=t||{};t.api=this;e.metadata=e.metadata||{};c(this,"isApi",true,false);c(this,"apiVersion",e.metadata.apiVersion);c(this,"endpointPrefix",e.metadata.endpointPrefix);c(this,"signingName",e.metadata.signingName);c(this,"globalEndpoint",e.metadata.globalEndpoint);c(this,"signatureVersion",e.metadata.signatureVersion);c(this,"jsonVersion",e.metadata.jsonVersion);c(this,"targetPrefix",e.metadata.targetPrefix);c(this,"protocol",e.metadata.protocol);c(this,"timestampFormat",e.metadata.timestampFormat);c(this,"xmlNamespaceUri",e.metadata.xmlNamespace);c(this,"abbreviation",e.metadata.serviceAbbreviation);c(this,"fullName",e.metadata.serviceFullName);f(this,"className",function(){var t=e.metadata.serviceAbbreviation||e.metadata.serviceFullName;if(!t)return null;t=t.replace(/^Amazon|AWS\s*|\(.*|\s+|\W+/g,"");if(t==="ElasticLoadBalancing")t="ELB";return t});c(this,"operations",new n(e.operations,t,function(e,r){return new i(e,r,t)},u.string.lowerFirst));c(this,"shapes",new n(e.shapes,t,function(e,r){return s.create(r,t)}));c(this,"paginators",new n(e.paginators,t,function(e,r){return new a(e,r,t)}));c(this,"waiters",new n(e.waiters,t,function(e,r){return new o(e,r,t)},u.string.lowerFirst));if(t.documentation){c(this,"documentation",e.documentation);c(this,"documentationUrl",e.documentationUrl)}}t.exports=l},{"../util":43,"./collection":16,"./operation":17,"./paginator":18,"./resource_waiter":19,"./shape":20}],16:[function(e,t,r){var n=e("../util").memoizedProperty;function i(e,t,r,i){i=i||String;var s=this;for(var a in e){if(e.hasOwnProperty(a)){(function(t){n(s,i(t),function(){return r(t,e[t])})})(a)}}}t.exports=i},{"../util":43}],17:[function(e,t,r){var n=e("./shape");var i=e("../util");var s=i.property;var a=i.memoizedProperty;function o(e,t,r){r=r||{};s(this,"name",e);s(this,"api",r.api,false);t.http=t.http||{};s(this,"httpMethod",t.http.method||"POST");s(this,"httpPath",t.http.requestUri||"/");a(this,"input",function(){if(!t.input){return new n.create({type:"structure"},r)}return n.create(t.input,r)});a(this,"output",function(){if(!t.output){return new n.create({type:"structure"},r)}return n.create(t.output,r)});a(this,"errors",function(){var e=[];if(!t.errors)return null;for(var i=0;i<t.errors.length;i++){e.push(n.create(t.errors[i],r))}return e});a(this,"paginator",function(){return r.api.paginators[e]});if(r.documentation){s(this,"documentation",t.documentation);s(this,"documentationUrl",t.documentationUrl)}}t.exports=o},{"../util":43,"./shape":20}],18:[function(e,t,r){var n=e("../util").property;function i(e,t){n(this,"inputToken",t.input_token);n(this,"limitKey",t.limit_key);n(this,"moreResults",t.more_results);n(this,"outputToken",t.output_token);n(this,"resultKey",t.result_key)}t.exports=i},{"../util":43}],19:[function(e,t,r){var n=e("../util");var i=n.property;function s(e,t,r){r=r||{};function s(){i(this,"name",e);i(this,"api",r.api,false);if(t.operation){i(this,"operation",n.string.lowerFirst(t.operation))}var s=this,a={ignoreErrors:"ignore_errors",successType:"success_type",successValue:"success_value",successPath:"success_path",acceptorType:"acceptor_type",acceptorValue:"acceptor_value",acceptorPath:"acceptor_path",failureType:"failure_type",failureValue:"failure_value",failurePath:"success_path",interval:"interval",maxAttempts:"max_attempts"};Object.keys(a).forEach(function(e){var r=t[a[e]];if(r)i(s,e,r)})}if(r.api){var a=null;if(t["extends"]){a=r.api.waiters[t["extends"]]}else if(e!=="__default__"){a=r.api.waiters["__default__"]}if(a)s.prototype=a}return new s}t.exports=s},{"../util":43}],20:[function(e,t,r){var n=e("./collection");var i=e("../util");function s(e,t,r){if(r!==null&&r!==undefined){i.property.apply(this,arguments)}}function a(e,t){if(!e.constructor.prototype[t]){i.memoizedProperty.apply(this,arguments)}}function o(e,t,r){t=t||{};s(this,"shape",e.shape);s(this,"api",t.api,false);s(this,"type",e.type);s(this,"location",e.location||"body");s(this,"name",this.name||e.xmlName||e.locationName||r);s(this,"isStreaming",e.streaming||false);s(this,"isComposite",e.isComposite||false);s(this,"isShape",true,false);if(t.documentation){s(this,"documentation",e.documentation);s(this,"documentationUrl",e.documentationUrl)}if(e.xmlAttribute){s(this,"isXmlAttribute",e.xmlAttribute||false)}s(this,"defaultValue",null);this.toWireFormat=function(e){if(e===null||e===undefined)return"";return e};this.toType=function(e){return e}}o.normalizedTypes={character:"string","double":"float","long":"integer","short":"integer",biginteger:"integer",bigdecimal:"float",blob:"binary"};o.types={structure:c,list:f,map:l,"boolean":y,timestamp:h,"float":d,integer:v,string:p,base64:g,binary:m};o.resolve=function b(e,t){if(e.shape){var r=t.api.shapes[e.shape];if(!r){throw new Error("Cannot find shape reference: "+e.shape)}return r}else{return null}};o.create=function w(e,t,r){if(e.isShape)return e;var n=o.resolve(e,t);if(n){var i=Object.keys(e);if(!t.documentation){i=i.filter(function(e){return!e.match(/documentation/)})}if(i===["shape"]){return n}var s=function(){n.constructor.call(this,e,t,r)};s.prototype=n;return new s}else{if(!e.type){if(e.members)e.type="structure";else if(e.member)e.type="list";else if(e.key)e.type="map";else e.type="string"}var a=e.type;if(o.normalizedTypes[e.type]){e.type=o.normalizedTypes[e.type]}if(o.types[e.type]){return new o.types[e.type](e,t,r)}else{throw new Error("Unrecognized shape type: "+a)}}};function u(e){o.apply(this,arguments);s(this,"isComposite",true);if(e.flattened){s(this,"flattened",e.flattened||false)}}function c(e,t){var r=null,i=!this.isShape;u.apply(this,arguments);if(i){s(this,"defaultValue",function(){return{}});s(this,"members",{});s(this,"memberNames",[]);s(this,"required",[]);s(this,"isRequired",function(e){return false})}if(e.members){s(this,"members",new n(e.members,t,function(e,r){return o.create(r,t,e)}));a(this,"memberNames",function(){return e.xmlOrder||Object.keys(e.members)})}if(e.required){s(this,"required",e.required);s(this,"isRequired",function(t){if(!r){r={};for(var n=0;n<e.required.length;n++){r[e.required[n]]=true}}return r[t]},false,true)}s(this,"resultWrapper",e.resultWrapper||null);if(e.payload){s(this,"payload",e.payload)}if(typeof e.xmlNamespace==="string"){s(this,"xmlNamespaceUri",e.xmlNamespace)}else if(typeof e.xmlNamespace==="object"){s(this,"xmlNamespacePrefix",e.xmlNamespace.prefix);s(this,"xmlNamespaceUri",e.xmlNamespace.uri)}}function f(e,t){var r=this,n=!this.isShape;u.apply(this,arguments);if(n){s(this,"defaultValue",function(){return[]})}if(e.member){a(this,"member",function(){return o.create(e.member,t)})}if(this.flattened){var i=this.name;a(this,"name",function(){return r.member.name||i})}}function l(e,t){var r=!this.isShape;u.apply(this,arguments);if(r){s(this,"defaultValue",function(){return{}});s(this,"key",o.create({type:"string"},t));s(this,"value",o.create({type:"string"},t))}if(e.key){a(this,"key",function(){return o.create(e.key,t)})}if(e.value){a(this,"value",function(){return o.create(e.value,t)})}}function h(e){var t=this;o.apply(this,arguments);if(e.timestampFormat){s(this,"timestampFormat",e.timestampFormat)}else if(this.api){s(this,"timestampFormat",this.api.timestampFormat)}this.toType=function(e){if(e===null||e===undefined)return null;if(typeof e.toUTCString==="function")return e;return typeof e==="string"||typeof e==="number"?i.date.parseTimestamp(e):null};this.toWireFormat=function(e){return i.date.format(e,t.timestampFormat)}}function p(){o.apply(this,arguments)}function d(){o.apply(this,arguments);this.toType=function(e){if(e===null||e===undefined)return null;return parseFloat(e)};this.toWireFormat=this.toType}function v(){o.apply(this,arguments);this.toType=function(e){if(e===null||e===undefined)return null;return parseInt(e,10)};this.toWireFormat=this.toType}function m(){o.apply(this,arguments);this.toType=i.base64.decode;this.toWireFormat=i.base64.encode}function g(){m.apply(this,arguments)}function y(){o.apply(this,arguments);this.toType=function(e){if(typeof e==="boolean")return e;if(e===null||e===undefined)return null;return e==="true"}}o.shapes={StructureShape:c,ListShape:f,MapShape:l,StringShape:p,BooleanShape:y,Base64Shape:g};t.exports=o},{"../util":43,"./collection":16}],21:[function(e,t,r){var n=e("./core");n.ParamValidator=n.util.inherit({validate:function i(e,t,r){return this.validateMember(e,t||{},r||"params")},validateStructure:function s(e,t,r){this.validateType(r,t,["object"],"structure");for(var n=0;e.required&&n<e.required.length;n++){var i=e.required[n];var s=t[i];if(s===undefined||s===null){this.fail("MissingRequiredParameter","Missing required key '"+i+"' in "+r)}}for(i in t){if(!t.hasOwnProperty(i))continue;var a=t[i],o=e.members[i];if(o!==undefined){var u=[r,i].join(".");this.validateMember(o,a,u)}else{this.fail("UnexpectedParameter","Unexpected key '"+i+"' found in "+r)}}return true},validateMember:function a(e,t,r){switch(e.type){case"structure":return this.validateStructure(e,t,r);case"list":return this.validateList(e,t,r);case"map":return this.validateMap(e,t,r);default:return this.validateScalar(e,t,r)}},validateList:function o(e,t,r){this.validateType(r,t,[Array]);for(var n=0;n<t.length;n++){this.validateMember(e.member,t[n],r+"["+n+"]")}},validateMap:function u(e,t,r){this.validateType(r,t,["object"],"map");for(var n in t){if(!t.hasOwnProperty(n))continue;this.validateMember(e.value,t[n],r+"['"+n+"']")}},validateScalar:function c(e,t,r){switch(e.type){case null:case undefined:case"string":return this.validateType(r,t,["string"]);case"base64":case"binary":return this.validatePayload(r,t);case"integer":case"float":return this.validateNumber(r,t);case"boolean":return this.validateType(r,t,["boolean"]);case"timestamp":return this.validateType(r,t,[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 "+e.type+" for "+r)}},fail:function f(e,t){throw n.util.error(new Error(t),{code:e})},validateType:function l(e,t,r,i){if(t===null||t===undefined)return;var s=false;for(var a=0;a<r.length;a++){if(typeof r[a]==="string"){if(typeof t===r[a])return}else if(r[a]instanceof RegExp){if((t||"").toString().match(r[a]))return}else{if(t instanceof r[a])return;if(n.util.isType(t,r[a]))return; if(!i&&!s)r=r.slice();r[a]=n.util.typeName(r[a])}s=true}var o=i;if(!o){o=r.join(", ").replace(/,([^,]+)$/,", or$1")}var u=o.match(/^[aeiou]/i)?"n":"";this.fail("InvalidParameterType","Expected "+e+" to be a"+u+" "+o)},validateNumber:function h(e,t){if(t===null||t===undefined)return;if(typeof t==="string"){var r=parseFloat(t);if(r.toString()===t)t=r}this.validateType(e,t,["number"])},validatePayload:function p(e,t){if(t===null||t===undefined)return;if(typeof t==="string")return;if(t&&typeof t.byteLength==="number")return;if(n.util.isNode()){var r=n.util.nodeRequire("stream").Stream;if(n.util.Buffer.isBuffer(t)||t instanceof r)return}var i=["Buffer","Stream","File","Blob","ArrayBuffer","DataView"];if(t){for(var s=0;s<i.length;s++){if(n.util.isType(t,i[s]))return;if(n.util.typeName(t.constructor)===i[s])return}}this.fail("InvalidParameterType","Expected "+e+" to be a "+"string, Buffer, Stream, Blob, or typed array object")}})},{"./core":3}],22:[function(e,t,r){var n=e("../util");var i=e("../json/builder");var s=e("../json/parser");function a(e){var t=e.httpRequest;var r=e.service.api;var n=r.targetPrefix+"."+r.operations[e.operation].name;var s=r.jsonVersion||"1.0";var a=r.operations[e.operation].input;var o=new i;if(s===1)s="1.0";t.body=o.build(e.params||{},a);t.headers["Content-Type"]="application/x-amz-json-"+s;t.headers["X-Amz-Target"]=n}function o(e){var t={};var r=e.httpResponse;if(r.body.length>0){var i=JSON.parse(r.body.toString());if(i.__type||i.code){t.code=(i.__type||i.code).split("#").pop()}else{t.code="UnknownError"}if(t.code==="RequestEntityTooLarge"){t.message="Request body must be less than 1 MB"}else{t.message=i.message||i.Message||null}}else{t.code=r.statusCode;t.message=null}e.error=n.error(new Error,t)}function u(e){var t=e.httpResponse.body.toString()||"{}";if(e.request.service.config.convertResponseTypes===false){e.data=JSON.parse(t)}else{var r=e.request.service.api.operations[e.request.operation];var n=r.output||{};var i=new s;e.data=i.parse(t,n)}}t.exports={buildRequest:a,extractError:o,extractData:u}},{"../json/builder":13,"../json/parser":14,"../util":43}],23:[function(e,t,r){var n=e("../core");var i=e("../util");var s=e("../query/query_param_serializer");var a=e("../model/shape");function o(e){var t=e.service.api.operations[e.operation];var r=e.httpRequest;r.headers["Content-Type"]="application/x-www-form-urlencoded; charset=utf-8";r.params={Version:e.service.api.apiVersion,Action:t.name};var n=new s;n.serialize(e.params,t.input,function(e,t){r.params[e]=t});r.body=i.queryParamsToString(r.params)}function u(e){var t,r=e.httpResponse.body.toString();if(r.match("<UnknownOperationException")){t={Code:"UnknownOperation",Message:"Unknown operation "+e.request.operation}}else{t=(new n.XML.Parser).parse(r)}if(t.Errors)t=t.Errors;if(t.Error)t=t.Error;if(t.Code){e.error=i.error(new Error,{code:t.Code,message:t.Message})}else{e.error=i.error(new Error,{code:e.httpResponse.statusCode,message:null})}}function c(e){var t=e.request;var r=t.service.api.operations[t.operation];var s=r.output||{};var o=s;if(o.resultWrapper){var u=a.create({type:"structure"});u.members[o.resultWrapper]=s;u.memberNames=[o.resultWrapper];i.property(s,"name",s.resultWrapper);s=u}var c=new n.XML.Parser;var f=c.parse(e.httpResponse.body.toString(),s);if(o.resultWrapper){if(f[o.resultWrapper]){i.update(f,f[o.resultWrapper]);delete f[o.resultWrapper]}}e.data=f}t.exports={buildRequest:o,extractError:u,extractData:c}},{"../core":3,"../model/shape":20,"../query/query_param_serializer":27,"../util":43}],24:[function(e,t,r){var n=e("../util");function i(e){e.httpRequest.method=e.service.api.operations[e.operation].httpMethod}function s(e){var t=e.service.api.operations[e.operation];var r=t.input;var i=[e.httpRequest.endpoint.path,t.httpPath].join("/");i=i.replace(/\/+/g,"/");var s=e.service.escapePathParam||a;var u=e.service.escapeQuerystringParam||o;var c={},f=false;n.each(r.members,function(t,r){var n=e.params[t];if(n===null||n===undefined)return;if(r.location==="uri"){i=i.replace("{"+r.name+"}",s(n))}else if(r.location==="querystring"){f=true;c[r.name]=u(n)}});if(f){i+=i.indexOf("?")>=0?"&":"?";var l=[];n.arrayEach(Object.keys(c).sort(),function(e){l.push(o(e)+"="+c[e])});i+=l.join("&")}e.httpRequest.path=i}function a(e){return n.uriEscape(String(e))}function o(e){return n.uriEscape(String(e))}function u(e){var t=e.service.api.operations[e.operation];n.each(t.input.members,function(t,r){var i=e.params[t];if(i===null||i===undefined)return;if(r.location==="headers"&&r.type==="map"){n.each(i,function(t,n){e.httpRequest.headers[r.name+t]=n})}else if(r.location==="header"){i=r.toWireFormat(i).toString();e.httpRequest.headers[r.name]=i}})}function c(e){i(e);s(e);u(e)}function f(){}function l(e){var t=e.request;var r={};var i=e.httpResponse;var s=t.service.api.operations[t.operation];var a=s.output;var o={};n.each(i.headers,function(e,t){o[e.toLowerCase()]=t});n.each(a.members,function(e,t){var s=(t.name||e).toLowerCase();if(t.location==="headers"&&t.type==="map"){r[e]={};n.each(i.headers,function(n,i){var s=n.match(new RegExp("^"+t.name+"(.+)","i"));if(s!==null){r[e][s[1]]=i}})}else if(t.location==="header"){if(o[s]!==undefined){r[e]=o[s]}}else if(t.location==="status"){r[e]=parseInt(i.statusCode,10)}});e.data=r}t.exports={buildRequest:c,extractError:f,extractData:l}},{"../util":43}],25:[function(e,t,r){var n=e("../util");var i=e("./rest");var s=e("./json");var a=e("../json/builder");function o(e){var t=new a;var r=e.service.api.operations[e.operation].input;if(r.payload){var n={};var i=r.members[r.payload];n=e.params[r.payload];if(n===undefined)return;if(i.type==="structure"){e.httpRequest.body=t.build(n,i)}else{e.httpRequest.body=n}}else{e.httpRequest.body=t.build(e.params,r)}}function u(e){i.buildRequest(e);if(["GET","HEAD"].indexOf(e.httpRequest.method)<0){o(e)}}function c(e){s.extractError(e)}function f(e){i.extractData(e);var t=e.request;var r=t.service.api.operations[t.operation].output||{};if(r.payload){var a=r.members[r.payload];if(a.isStreaming){e.data[r.payload]=e.httpResponse.body}else if(a.type==="structure"){s.extractData(e)}else{e.data[r.payload]=e.httpResponse.body.toString()}}else{var o=e.data;s.extractData(e);e.data=n.merge(o,e.data)}}t.exports={buildRequest:u,extractError:c,extractData:f}},{"../json/builder":13,"../util":43,"./json":22,"./rest":24}],26:[function(e,t,r){var n=e("../core");var i=e("../util");var s=e("./rest");function a(e){var t=e.service.api.operations[e.operation].input;var r=new n.XML.Builder;var s=e.params;var a=t.payload;if(a){var o=t.members[a];s=s[a];if(s===undefined)return;if(o.type==="structure"){var u=o.name;e.httpRequest.body=r.toXML(s,o,u)}else{e.httpRequest.body=s}}else{e.httpRequest.body=r.toXML(s,t,t.shape||i.string.upperFirst(e.operation)+"Request")}}function o(e){s.buildRequest(e);if(["GET","HEAD"].indexOf(e.httpRequest.method)<0){a(e)}}function u(e){s.extractError(e);var t=(new n.XML.Parser).parse(e.httpResponse.body.toString());if(t.Errors)t=t.Errors;if(t.Error)t=t.Error;if(t.Code){e.error=i.error(new Error,{code:t.Code,message:t.Message})}else{e.error=i.error(new Error,{code:e.httpResponse.statusCode,message:null})}}function c(e){s.extractData(e);var t;var r=e.request;var a=e.httpResponse.body;var o=r.service.api.operations[r.operation];var u=o.output;var c=u.payload;if(c){var f=u.members[c];if(f.isStreaming){e.data[c]=a}else if(f.type==="structure"){t=new n.XML.Parser;i.update(e.data,t.parse(a.toString(),f))}else{e.data[c]=a.toString()}}else if(a.length>0){t=new n.XML.Parser;var l=t.parse(a.toString(),u);i.update(e.data,l)}}t.exports={buildRequest:o,extractError:u,extractData:c}},{"../core":3,"../util":43,"./rest":24}],27:[function(e,t,r){var n=e("../util");function i(){}i.prototype.serialize=function(e,t,r){s("",e,t,r)};function s(e,t,r,i){n.each(r.members,function(r,n){var s=t[r];if(s===null||s===undefined)return;var a=e?e+"."+n.name:n.name;u(a,s,n,i)})}function a(e,t,r,i){var s=1;n.each(t,function(t,n){var a=r.flattened?".":".entry.";var o=a+s++ +".";var c=o+(r.key.name||"key");var f=o+(r.value.name||"value");u(e+c,t,r.key,i);u(e+f,n,r.value,i)})}function o(e,t,r,i){var s=r.member||{};if(t.length===0){i.call(this,e,null);return}n.arrayEach(t,function(t,n){var a="."+(n+1);if(r.flattened){if(s.name){var o=e.split(".");o.pop();o.push(s.name);e=o.join(".")}}else{a=".member"+a}u(e+a,t,s,i)})}function u(e,t,r,n){if(t===null||t===undefined)return;if(r.type==="structure"){s(e,t,r,n)}else if(r.type==="list"){o(e,t,r,n)}else if(r.type==="map"){a(e,t,r,n)}else{n(e,r.toWireFormat(t).toString())}}t.exports=i},{"../util":43}],28:[function(e,t,r){var n=e("./util");var i=e("./region_config.json");function s(e){var t=e.serviceIdentifier||"";var r=e.config.region||"";var s={};i.forEach(function(i){(i.regions||[]).forEach(function(a){if(r.match(new RegExp("^"+a.replace("*",".*")+"$"))){(i.serviceConfigs||[]).forEach(function(r){(r.services||[]).forEach(function(i){if(t.match(new RegExp("^"+i.replace("*",".*")+"$"))){n.update(s,r.config);e.isGlobalEndpoint=!!r.globalEndpoint}})})}})});n.each(s,function(t,r){if(e.config[t]===undefined||e.config[t]===null){e.config[t]=r}})}t.exports=s},{"./region_config.json":29,"./util":43}],29:[function(e,t,r){t.exports=[{regions:["*"],serviceConfigs:[{services:["*"],config:{endpoint:"{service}.{region}.amazonaws.com"}},{services:["cloudfront","iam","importexport","sts"],config:{endpoint:"{service}.amazonaws.com"},globalEndpoint:true},{services:["s3"],config:{endpoint:"{service}-{region}.amazonaws.com"}},{services:["route53"],config:{endpoint:"https://{service}.amazonaws.com"},globalEndpoint:true}]},{regions:["us-east-1"],serviceConfigs:[{services:["s3","simpledb"],config:{endpoint:"{service}.amazonaws.com"}}]},{regions:["cn-*"],serviceConfigs:[{services:["*"],config:{endpoint:"{service}.{region}.amazonaws.com.cn",signatureVersion:"v4"}}]}]},{}],30:[function(e,t,r){(function(t){var r=e("./core");var n=e("./state_machine");var i=r.util.inherit;var s={success:1,error:1,complete:1};function a(e){return s.hasOwnProperty(e._asm.currentState)}var o=new n;o.setupStates=function(){var e=function(e,t){try{var n=this;n.emit(n._asm.currentState,function(){var r=n.response.error;if(r&&r!==e&&a(n)){throw r}t(r)})}catch(i){if(i!==e&&a(n)){r.SequentialExecutor.prototype.unhandledErrorCallback.call(this,i);t()}else{t(i)}}};this.addState("validate","build","error",e);this.addState("build","afterBuild","restart",e);this.addState("afterBuild","sign","restart",e);this.addState("sign","send","retry",e);this.addState("retry","afterRetry","afterRetry",e);this.addState("afterRetry","sign","error",e);this.addState("send","validateResponse","retry",e);this.addState("validateResponse","extractData","extractError",e);this.addState("extractError","extractData","retry",e);this.addState("extractData","success","retry",e);this.addState("restart","build","error",e);this.addState("success","complete","complete",e);this.addState("error","complete","complete",e);this.addState("complete",null,null,e)};o.setupStates();r.Request=i({constructor:function u(e,t,i){var s=e.endpoint;var a=e.config.region;if(e.isGlobalEndpoint)a="us-east-1";this.service=e;this.operation=t;this.params=i||{};this.httpRequest=new r.HttpRequest(s,a);this.startTime=r.util.date.getDate();this.response=new r.Response(this);this._asm=new n(o.states,"validate");r.SequentialExecutor.call(this);this.emit=this.emitEvent},send:function c(e){if(e){this.on("complete",function(t){e.call(t,t.error,t.data)})}this.runTo();return this.response},build:function f(e){return this.runTo("send",e)},runTo:function l(e,t){this._asm.runTo(e,t,this);return this},abort:function h(){this.removeAllListeners("validateResponse");this.removeAllListeners("extractError");this.on("validateResponse",function e(t){t.error=r.util.error(new Error("Request aborted by user"),{code:"RequestAbortedError",retryable:false})});if(this.httpRequest.stream){this.httpRequest.stream.abort();if(this.httpRequest._abortCallback){this.httpRequest._abortCallback()}else{this.removeAllListeners("send")}}return this},eachPage:function p(e){e=r.util.fn.makeAsync(e,3);function t(n){e.call(n,n.error,n.data,function(i){if(i===false)return;if(n.hasNextPage()){n.nextPage().on("complete",t).send()}else{e.call(n,null,null,r.util.fn.noop)}})}this.on("complete",t).send()},eachItem:function d(e){function t(t,n){if(t)return e(t,null);if(n===null)return e(null,null);var i=this.request.service.paginationConfig(this.request.operation);var s=i.resultKey;if(Array.isArray(s))s=s[0];var a=r.util.jamespath.query(s,n);r.util.arrayEach(a,function(t){r.util.arrayEach(t,function(t){e(null,t)})})}this.eachPage(t)},isPageable:function v(){return this.service.paginationConfig(this.operation)?true:false},createReadStream:function m(){var e=r.util.nodeRequire("stream");var n=this;var i=null;var s=false;if(r.HttpClient.streamsApiVersion===2){i=new e.Readable;i._read=function(){}}else{i=new e.Stream;i.readable=true}i.sent=false;i.on("newListener",function(e){if(!i.sent&&(e==="data"||e==="readable")){if(e==="data")s=true;i.sent=true;t.nextTick(function(){n.send(function(){})})}});this.on("httpHeaders",function a(e,t,o){if(e<300){this.httpRequest._streaming=true;n.removeListener("httpData",r.EventListeners.Core.HTTP_DATA);n.removeListener("httpError",r.EventListeners.Core.HTTP_ERROR);n.on("httpError",function c(e,t){t.error=e;t.error.retryable=false});var u=o.httpResponse.stream;if(s){u.on("data",function(e){i.emit("data",e)});u.on("end",function(){i.emit("end")})}else{u.on("readable",function(){var e;do{e=u.read();if(e!==null)i.push(e)}while(e!==null);i.read(0)});u.on("end",function(){i.push(null)})}u.on("error",function(e){i.emit("error",e)})}});this.on("error",function(e){i.emit("error",e)});return i},emitEvent:function g(e,t,n){if(typeof t==="function"){n=t;t=null}if(!n)n=this.unhandledErrorCallback;if(!t)t=this.eventParameters(e,this.response);var i=r.SequentialExecutor.prototype.emit;i.call(this,e,t,function(e){if(e)this.response.error=e;n.call(this,e)})},eventParameters:function y(e){switch(e){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]}},presign:function b(e,t){if(!t&&typeof e==="function"){t=e;e=null}return(new r.Signers.Presign).sign(this.toGet(),e,t)},toUnauthenticated:function w(){this.removeListener("validate",r.EventListeners.Core.VALIDATE_CREDENTIALS);this.removeListener("sign",r.EventListeners.Core.SIGN);return this.toGet()},toGet:function E(){if(this.service.api.protocol==="query"){this.removeListener("build",this.buildAsGet);this.addListener("build",this.buildAsGet)}return this},buildAsGet:function S(e){e.httpRequest.method="GET";e.httpRequest.path=e.service.endpoint.path+"?"+e.httpRequest.body;e.httpRequest.body="";delete e.httpRequest.headers["Content-Length"];delete e.httpRequest.headers["Content-Type"]}});r.util.mixin(r.Request,r.SequentialExecutor)}).call(this,e("FWaASH"))},{"./core":3,"./state_machine":42,FWaASH:57}],31:[function(e,t,r){var n=e("./core");var i=n.util.inherit;n.ResourceWaiter=i({constructor:function s(e,t){this.service=e;this.state=t;if(typeof this.state==="object"){n.util.each.call(this,this.state,function(e,t){this.state=e;this.expectedValue=t})}this.loadWaiterConfig(this.state);if(!this.expectedValue){this.expectedValue=this.config.successValue}},service:null,state:null,expectedValue:null,config:null,waitDone:false,Listeners:{retry:(new n.SequentialExecutor).addNamedListeners(function(e){e("RETRY_CHECK","retry",function(e){var t=e.request._waiter;if(e.error&&e.error.code==="ResourceNotReady"){e.error.retryDelay=t.config.interval*1e3}})}),output:(new n.SequentialExecutor).addNamedListeners(function(e){e("CHECK_OUT_ERROR","extractError",function t(e){if(e.error){e.request._waiter.setError(e,true)}});e("CHECK_OUTPUT","extractData",function r(e){var t=e.request._waiter;var r=t.checkSuccess(e);if(!r){t.setError(e,r===null?false:true)}else{e.error=null}})}),error:(new n.SequentialExecutor).addNamedListeners(function(e){e("CHECK_ERROR","extractError",function t(e){var t=e.request._waiter;var r=t.checkError(e);if(!r){t.setError(e,r===null?false:true)}else{e.error=null;e.request.removeAllListeners("extractData")}});e("CHECK_ERR_OUTPUT","extractData",function r(e){e.request._waiter.setError(e,true)})})},wait:function a(e,t){if(typeof e==="function"){t=e;e=undefined}var r=this.service.makeRequest(this.config.operation,e);var n=this.Listeners[this.config.successType];r._waiter=this;r.response.maxRetries=this.config.maxAttempts;r.addListeners(this.Listeners.retry);if(n)r.addListeners(n);if(t)r.send(t);return r},setError:function o(e,t){e.data=null;e.error=n.util.error(e.error||new Error,{code:"ResourceNotReady",message:"Resource is not in the state "+this.state,retryable:t})},checkSuccess:function u(e){if(!this.config.successPath){return e.httpResponse.statusCode<300}var t=n.util.jamespath.find(this.config.successPath,e.data);if(this.config.failureValue&&this.config.failureValue.indexOf(t)>=0){return null}if(this.expectedValue){return t===this.expectedValue}else{return t?true:false}},checkError:function c(e){var t=this.config.successValue;if(typeof t==="number"){return e.httpResponse.statusCode===t}else{return e.error&&e.error.code===t}},loadWaiterConfig:function f(e,t){if(!this.service.api.waiters[e]){if(t)return;throw new n.util.error(new Error,{code:"StateNotFoundError",message:"State "+e+" not found."})}this.config=this.service.api.waiters[e];var r=this.config;(function(){r.successType=r.successType||r.acceptorType;r.successPath=r.successPath||r.acceptorPath;r.successValue=r.successValue||r.acceptorValue;r.failureType=r.failureType||r.acceptorType;r.failurePath=r.failurePath||r.acceptorPath;r.failureValue=r.